diff --git a/build/PolySonic.js b/build/PolySonic.js index 6edf988..22020c0 100644 --- a/build/PolySonic.js +++ b/build/PolySonic.js @@ -13,12 +13,13 @@ this.mixinMethod(b,a,c.instance.mdv,"bind"),b},mixinMethod:function(a,b,c,d){var if(j.length=this._childPlayers.length?(d=window.document.timeline.play(e),this._childPlayers.push(d),d.playbackRate=this.playbackRate,this.paused&&d.pause()):d=this._childPlayers[b],e.player=this.source.player,d.startTime!=this.startTime+a&&(null===this.startTime?(d.currentTime=this.source.player.currentTime-a,d._startTime=null):d.startTime=this.startTime+a,d._updateChildren()),-1==this.playbackRate&&this.currentTime=0&&this.metaArray.splice(c,1)},get list(){return this.metaArray},byId:function(a){return this.metaData[a]}})}(),Polymer("core-iconset",{src:"",width:0,icons:"",iconSize:24,offsetX:0,offsetY:0,type:"iconset",created:function(){this.iconMap={},this.iconNames=[],this.themes={}},ready:function(){this.src&&this.ownerDocument!==document&&(this.src=this.resolvePath(this.src,this.ownerDocument.baseURI)),this["super"](),this.updateThemes()},iconsChanged:function(){var a=this.offsetX,b=this.offsetY;this.icons&&this.icons.split(/\s+/g).forEach(function(c,d){this.iconNames.push(c),this.iconMap[c]={offsetX:a,offsetY:b},a+this.iconSize=b?c.initialOpacity:Math.max(0,c.initialOpacity-d*c.opacityDecayVelocity)}function c(a,c,d){var e=a/1e3,f=.3*e,g=b(a,c,d);return Math.max(0,Math.min(f,g))}function d(a,c,d){var e=b(a.tDown,a.tUp,d);return.01>e&&c>=Math.min(a.maxRadius,l)}function e(a,c,d){var e=b(a.tDown,a.tUp,d);return e>=d.initialOpacity&&c>=Math.min(a.maxRadius,l)}function f(a,b,c,d,e,f){void 0!==f&&(a.bg.style.opacity=f),a.wave.style.opacity=e;var g=d/(a.containerSize/2),h=b-a.containerWidth/2,i=c-a.containerHeight/2;a.wc.style.webkitTransform="translate3d("+h+"px,"+i+"px,0)",a.wc.style.transform="translate3d("+h+"px,"+i+"px,0)",a.wave.style.webkitTransform="scale("+g+","+g+")",a.wave.style.transform="scale3d("+g+","+g+",1)"}function g(a){var b=window.getComputedStyle(a),c=b.color,d=document.createElement("div");d.style.backgroundColor=c,d.classList.add("wave");var e=document.createElement("div");e.classList.add("wave-container"),e.appendChild(d);var f=a.$.waves;f.appendChild(e),a.$.bg.style.backgroundColor=c;var g={bg:a.$.bg,wc:e,wave:d,waveColor:c,maxRadius:0,isMouseDown:!1,mouseDownStart:0,mouseUpStart:0,tDown:0,tUp:0};return g}function h(a,b){if(a.waves){var c=a.waves.indexOf(b);a.waves.splice(c,1),b.wc.remove()}}function i(a,b){var c=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return"undefined"==typeof b&&(b=1),c?"rgba("+c[1]+", "+c[2]+", "+c[3]+", "+b+")":"rgba(255, 255, 255, "+b+")"}function j(a,b){return Math.sqrt(m(a.x-b.x,2)+m(a.y-b.y,2))}function k(a,b){var c=j(a,{x:0,y:0}),d=j(a,{x:b.w,y:0}),e=j(a,{x:0,y:b.h}),f=j(a,{x:b.w,y:b.h});return Math.max(c,d,e,f)}var l=150,m=Math.pow,n=Date.now;window.performance&&performance.now&&(n=performance.now.bind(performance)),Polymer("paper-ripple",{initialOpacity:.25,opacityDecayVelocity:.8,backgroundFill:!0,pixelDensity:2,eventDelegates:{down:"downAction",up:"upAction"},ready:function(){this.waves=[]},downAction:function(a){var b=g(this);this.cancelled=!1,b.isMouseDown=!0,b.tDown=0,b.tUp=0,b.mouseUpStart=0,b.mouseDownStart=n();var c=this.getBoundingClientRect(),d=c.width,e=c.height,f=a.x-c.left,h=a.y-c.top;b.startPosition={x:f,y:h},this.classList.contains("recenteringTouch")&&(b.endPosition={x:d/2,y:e/2},b.slideDistance=j(b.startPosition,b.endPosition)),b.containerSize=Math.max(d,e),b.containerWidth=d,b.containerHeight=e,b.maxRadius=k(b.startPosition,{w:d,h:e}),b.wc.style.top=(b.containerHeight-b.containerSize)/2+"px",b.wc.style.left=(b.containerWidth-b.containerSize)/2+"px",b.wc.style.width=b.containerSize+"px",b.wc.style.height=b.containerSize+"px",this.waves.push(b),this._loop||(this._loop=this.animate.bind(this,{width:d,height:e}),requestAnimationFrame(this._loop))},upAction:function(){for(var a=0;a0&&(r.tDown=n()-r.mouseDownStart),r.mouseUpStart>0&&(r.tUp=n()-r.mouseUpStart);var s=r.tUp,t=r.tDown;l=Math.max(l,t),m=Math.max(m,s);{var u=a(t,s,p),v=b(t,s,p);i(r.waveColor,v)}o=r.waveColor;var w=r.startPosition.x,x=r.startPosition.y;if(r.endPosition){var y=Math.min(1,u/r.containerSize*2/Math.sqrt(2));w+=y*(r.endPosition.x-r.startPosition.x),x+=y*(r.endPosition.y-r.startPosition.y)}var z=null;if(this.backgroundFill){var A=c(t,s,p);z=i(r.waveColor,A)}f(r,w,x,u,v,A);var B=e(r,u,p),C=d(r,u,p),D=!C||B,E=r.mouseUpStart?!C:!B;j=j||E,(!D||this.cancelled)&&k.push(r)}j&&requestAnimationFrame(this._loop);for(var q=0;q=0},setItemSelected:function(a,b){if(void 0!==a&&null!==a){if(b)this.selection.push(a);else{var c=this.selection.indexOf(a);c>=0&&this.selection.splice(c,1)}this.fire("core-select",{isSelected:b,item:a})}},select:function(a){this.multi?this.toggle(a):this.getSelection()!==a&&(this.setItemSelected(this.getSelection(),!1),this.setItemSelected(a,!0))},toggle:function(a){this.setItemSelected(a,!this.isSelected(a))}}),Polymer("core-selector",{selected:null,multi:!1,valueattr:"name",selectedClass:"core-selected",selectedProperty:"",selectedAttribute:"active",selectedItem:null,selectedModel:null,selectedIndex:-1,excludedLocalNames:"",target:null,itemsSelector:"",activateEvent:"tap",notap:!1,defaultExcludedLocalNames:"template",observe:{"selected multi":"selectedChanged"},ready:function(){this.activateListener=this.activateHandler.bind(this),this.itemFilter=this.filterItem.bind(this),this.excludedLocalNamesChanged(),this.observer=new MutationObserver(this.updateSelected.bind(this)),this.target||(this.target=this)},get items(){if(!this.target)return[];var a=this.target!==this?this.itemsSelector?this.target.querySelectorAll(this.itemsSelector):this.target.children:this.$.items.getDistributedNodes();return Array.prototype.filter.call(a,this.itemFilter)},filterItem:function(a){return!this._excludedNames[a.localName]},excludedLocalNamesChanged:function(){this._excludedNames={};var a=this.defaultExcludedLocalNames;this.excludedLocalNames&&(a+=" "+this.excludedLocalNames),a.split(/\s+/g).forEach(function(a){this._excludedNames[a]=1},this)},targetChanged:function(a){a&&(this.removeListener(a),this.observer.disconnect(),this.clearSelection()),this.target&&(this.addListener(this.target),this.observer.observe(this.target,{childList:!0}),this.updateSelected())},addListener:function(a){Polymer.addEventListener(a,this.activateEvent,this.activateListener)},removeListener:function(a){Polymer.removeEventListener(a,this.activateEvent,this.activateListener)},get selection(){return this.$.selection.getSelection()},selectedChanged:function(){1===arguments.length?this.processSplices(arguments[0]):this.updateSelected()},updateSelected:function(){this.validateSelected(),this.multi?(this.clearSelection(this.selected),this.selected&&this.selected.forEach(function(a){this.setValueSelected(a,!0)},this)):this.valueToSelection(this.selected)},validateSelected:function(){if(this.multi&&!Array.isArray(this.selected)&&null!=this.selected)this.selected=[this.selected];else if(!this.multi&&Array.isArray(this.selected)){var a=this.selected[0];this.clearSelection([a]),this.selected=a}},processSplices:function(a){for(var b,c=0;b=a[c];c++){for(var d=0;d=0){var c=this.items[b],d=this.valueForNode(c)||b;this.multi?this.selected?this.addRemoveSelected(d):this.selected=[d]:this.selected=d,this.asyncFire("core-activate",{item:c})}}},addRemoveSelected:function(a){var b=this.selected.indexOf(a);b>=0?this.selected.splice(b,1):this.selected.push(a)},findDistributedTarget:function(a,b){for(;a&&a!=this;){var c=Array.prototype.indexOf.call(b,a);if(c>=0)return c;a=a.parentNode}},selectIndex:function(a){var b=this.items[a];return b?(this.selected=this.valueForNode(b)||a,b):void 0},selectPrevious:function(a){var b=a&&!this.selectedIndex?this.items.length-1:this.selectedIndex-1;return this.selectIndex(b)},selectNext:function(a){var b=a&&this.selectedIndex>=this.items.length-1?0:this.selectedIndex+1;return this.selectIndex(b)}}),function(){window.CoreStyle=window.CoreStyle||{g:{},list:{},refMap:{}},Polymer("core-style",{publish:{ref:""},g:CoreStyle.g,refMap:CoreStyle.refMap,list:CoreStyle.list,ready:function(){this.id?this.provide():(this.registerRef(this.ref),window.ShadowDOMPolyfill||this.require())},attached:function(){!this.id&&window.ShadowDOMPolyfill&&this.require()},provide:function(){this.register(),this.textContent?this._completeProvide():this.async(this._completeProvide)},register:function(){var a=this.list[this.id];a?(Array.isArray(a)||(this.list[this.id]=[a]),this.list[this.id].push(this)):this.list[this.id]=this},_completeProvide:function(){this.createShadowRoot(),this.domObserver=new MutationObserver(this.domModified.bind(this)).observe(this.shadowRoot,{subtree:!0,characterData:!0,childList:!0}),this.provideContent()},provideContent:function(){this.ensureTemplate(),this.shadowRoot.textContent="",this.shadowRoot.appendChild(this.instanceTemplate(this.template)),this.cssText=this.shadowRoot.textContent},ensureTemplate:function(){if(!this.template&&(this.template=this.querySelector("template:not([repeat]):not([bind])"),!this.template)){this.template=document.createElement("template");for(var a=this.firstChild;a;)this.template.content.appendChild(a.cloneNode(!0)),a=a.nextSibling}},domModified:function(){this.cssText=this.shadowRoot.textContent,this.notify()},notify:function(){var a=this.refMap[this.id];if(a)for(var b,c=0;b=a[c];c++)b.require()},registerRef:function(a){this.refMap[this.ref]=this.refMap[this.ref]||[],this.refMap[this.ref].push(this)},applyRef:function(a){this.ref=a,this.registerRef(this.ref),this.require()},require:function(){var a=this.cssTextForRef(this.ref);if(a){if(this.ensureStyleElement(),this.styleElement._cssText===a)return;this.styleElement._cssText=a,window.ShadowDOMPolyfill&&(this.styleElement.textContent=a,a=WebComponents.ShadowCSS.shimStyle(this.styleElement,this.getScopeSelector())),this.styleElement.textContent=a}},cssTextForRef:function(a){var b=this.byId(a),c="";if(b)if(Array.isArray(b)){for(var d,e=[],f=0,g=b.length;g>f&&(d=b[f]);f++)e.push(d.cssText);c=e.join("\n\n")}else c=b.cssText;return b&&!c&&console.warn("No styles provided for ref:",a),c},byId:function(a){return this.list[a]},ensureStyleElement:function(){this.styleElement||(this.styleElement=window.ShadowDOMPolyfill?this.makeShimStyle():this.makeRootStyle()),this.styleElement||console.warn(this.localName,"could not setup style.")},makeRootStyle:function(){var a=document.createElement("style");return this.appendChild(a),a},makeShimStyle:function(){var a=this.findHost(this);if(a){var b=a.localName,c=document.querySelector("style["+b+"="+this.ref+"]");return c||(c=document.createElement("style"),c.setAttribute(b,this.ref),document.head.appendChild(c)),c}},getScopeSelector:function(){if(!this._scopeSelector){var a="",b=this.findHost(this);if(b){var c=b.hasAttribute("is"),d=c?b.getAttribute("is"):b.localName;a=WebComponents.ShadowCSS.makeScopeSelector(d,c)}this._scopeSelector=a}return this._scopeSelector},findHost:function(a){for(;a.parentNode;)a=a.parentNode;return a.host||wrap(document.documentElement)},cycle:function(a,b){function c(a){return Math.abs((Number(a)-b)%255)}if(a.match("#")){var d=this.hexToRgb(a);if(!d)return a;a="rgb("+d.r+","+d.b+","+d.g+")"}return a.replace(/rgb\(([^,]*),([^,]*),([^,]*)\)/,function(a,b,d,e){return"rgb("+c(b)+","+c(d)+", "+c(e)+")"})},hexToRgb:function(a){var b=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);return b?{r:parseInt(b[1],16),g:parseInt(b[2],16),b:parseInt(b[3],16)}:null}})}(),Polymer("core-transition",{type:"transition",go:function(a,b){this.complete(a)},setup:function(a){},teardown:function(a){},complete:function(a){this.fire("core-transitionend",null,a)},listenOnce:function(a,b,c,d){var e=this,f=function(){c.apply(e,d),a.removeEventListener(b,f,!1)};a.addEventListener(b,f,!1)}}),function(){var a=CoreStyle.g.transitions=CoreStyle.g.transitions||{};a.duration="500ms",a.heroDelay="50ms",a.scaleDelay="500ms",a.cascadeFadeDuration="250ms",Polymer("core-transition-pages",{publish:{scopeClass:"",activeClass:"",transitionProperty:""},completed:!1,prepare:function(a,b){this.boundCompleteFn=this.complete.bind(this,a),this.scopeClass&&a.classList.add(this.scopeClass)},go:function(a,b){this.completed=!1,this.activeClass&&a.classList.add(this.activeClass),a.addEventListener("transitionend",this.boundCompleteFn,!1)},setup:function(a){a._pageTransitionStyles||(a._pageTransitionStyles={});var b=this.calcStyleName();a._pageTransitionStyles[b]||(this.installStyleInScope(a,b),a._pageTransitionStyles[b]=!0)},calcStyleName:function(){return this.id||this.localName},installStyleInScope:function(a,b){a.shadowRoot||(a.createShadowRoot().innerHTML="");var c=a.shadowRoot,d=document.createElement("core-style"); -c.insertBefore(d,c.firstChild),d.applyRef(b)},complete:function(a,b){"box-shadow"===b.propertyName||this.transitionProperty&&-1===b.propertyName.indexOf(this.transitionProperty)||(this.completed=!0,this.fire("core-transitionend",this,a))},ensureComplete:function(a){a.removeEventListener("transitionend",this.boundCompleteFn,!1),this.scopeClass&&a.classList.remove(this.scopeClass),this.activeClass&&a.classList.remove(this.activeClass)}})}(),function(){function a(b,c){var d,e,f,g,h=b.firstElementChild;for(e=[],f=b.shadowRoot;f;)e.push(f),f=f.olderShadowRoot;for(g=e.length-1;g>=0;g--)if(d=e[g].querySelector(c))return d;for(;h;){if(d=a(h,c))return d;h=h.nextElementSibling}return null}function b(a,c,d){var e,f,g,h,i,j=a.firstElementChild;for(g=[],f=a.shadowRoot;f;)g.push(f),f=f.olderShadowRoot;for(h=g.length-1;h>=0;h--)for(e=g[h].querySelectorAll(c),i=0;i0?"&":"?")+f);var g=this.isBodyMethod(d)?a.body||f:null;return b.open(d,c,e),a.responseType&&(b.responseType=a.responseType),a.withCredentials&&(b.withCredentials=!0),this.makeReadyStateHandler(b,a.callback),this.setRequestHeaders(b,a.headers),b.send(g),e||b.onreadystatechange(b),b},toQueryString:function(a){var b=[];for(var c in a){var d=a[c];c=encodeURIComponent(c),b.push(null==d?c:c+"="+encodeURIComponent(d))}return b.join("&")},isBodyMethod:function(a){return this.bodyMethods[(a||"").toUpperCase()]},bodyMethods:{POST:1,PUT:1,PATCH:1,DELETE:1},makeReadyStateHandler:function(a,b){a.onreadystatechange=function(){4==a.readyState&&b&&b.call(null,a.response,a)}},setRequestHeaders:function(a,b){if(b)for(var c in b)a.setRequestHeader(c,b[c])}}),Polymer("core-ajax",{url:"",handleAs:"",auto:!1,params:"",response:null,error:null,loading:!1,progress:null,method:"",headers:null,body:null,contentType:"application/x-www-form-urlencoded",withCredentials:!1,xhrArgs:null,created:function(){this.progress={}},ready:function(){this.xhr=document.createElement("core-xhr")},receive:function(a,b){this.isSuccess(b)?this.processResponse(b):this.processError(b),this.complete(b)},isSuccess:function(a){var b=a.status||0;return b>=200&&300>b},processResponse:function(a){var b=this.evalResponse(a);a===this.activeRequest&&(this.response=b),this.fire("core-response",{response:b,xhr:a})},processError:function(a){var b=this.evalResponse(a),c={statusCode:a.status,response:b};a===this.activeRequest&&(this.error=c),this.fire("core-error",{response:c,xhr:a})},processProgress:function(a,b){if(b===this.activeRequest){var c={lengthComputable:a.lengthComputable,loaded:a.loaded,total:a.total};this.progress=c}},complete:function(a){a===this.activeRequest&&(this.loading=!1),this.fire("core-complete",{response:a.status,xhr:a})},evalResponse:function(a){return this[(this.handleAs||"text")+"Handler"](a)},xmlHandler:function(a){return a.responseXML},textHandler:function(a){return a.responseText},jsonHandler:function(a){var b=a.responseText;try{return JSON.parse(b)}catch(c){return console.warn("core-ajax caught an exception trying to parse response as JSON:"),console.warn("url:",this.url),console.warn(c),b}},documentHandler:function(a){return a.response},blobHandler:function(a){return a.response},arraybufferHandler:function(a){return a.response},urlChanged:function(){if(!this.handleAs){var a=String(this.url).split(".").pop();switch(a){case"json":this.handleAs="json"}}this.autoGo()},paramsChanged:function(){this.autoGo()},bodyChanged:function(){this.autoGo()},autoChanged:function(){this.autoGo()},autoGo:function(){this.auto&&(this.goJob=this.job(this.goJob,this.go,0))},getParams:function(a){return a=this.params||a,a&&"string"==typeof a&&(a=JSON.parse(a)),a},go:function(){var a=this.xhrArgs||{};a.body=this.body||a.body,a.params=this.getParams(a.params),a.headers=this.headers||a.headers||{},a.headers&&"string"==typeof a.headers&&(a.headers=JSON.parse(a.headers));var b=Object.keys(a.headers).some(function(a){return"content-type"===a.toLowerCase()});if(a.body instanceof FormData?delete a.headers["Content-Type"]:!b&&this.contentType&&(a.headers["Content-Type"]=this.contentType),("arraybuffer"===this.handleAs||"blob"===this.handleAs||"document"===this.handleAs)&&(a.responseType=this.handleAs),a.withCredentials=this.withCredentials,a.callback=this.receive.bind(this),a.url=this.url,a.method=this.method,this.response=this.error=this.progress=null,this.activeRequest=a.url&&this.xhr.request(a),this.activeRequest){this.loading=!0;var c=this.activeRequest;"onprogress"in c?this.activeRequest.addEventListener("progress",function(a){this.processProgress(a,c)}.bind(this),!1):this.progress={lengthComputable:!1}}return this.activeRequest},abort:function(){this.activeRequest&&(this.activeRequest.abort(),this.activeRequest=null,this.progress={},this.loading=!1)}}),Polymer("core-item",{}),function(){function a(a,b){return b&&"Infinity"===a?Number.POSITIVE_INFINITY:Number(a)}Polymer("core-animation",{publish:{target:{value:null,reflect:!0},keyframes:{value:null,reflect:!0},customEffect:{value:null,reflect:!0},composite:{value:"replace",reflect:!0},duration:{value:"auto",reflect:!0},fill:{value:"auto",reflect:!0},easing:{value:"linear",reflect:!0},delay:{value:0,reflect:!0},endDelay:{value:0,reflect:!0},iterations:{value:1,reflect:!0},iterationStart:{value:0,reflect:!0},iterationComposite:{value:"replace",reflect:!0},direction:{value:"normal",reflect:!0},playbackRate:{value:1,reflect:!0},autoplay:{value:!1,reflect:!0}},animation:!1,observe:{target:"apply",keyframes:"apply",customEffect:"apply",composite:"apply",duration:"apply",fill:"apply",easing:"apply",iterations:"apply",iterationStart:"apply",iterationComposite:"apply",delay:"apply",endDelay:"apply",direction:"apply",playbackRate:"apply",autoplay:"apply"},ready:function(){this.apply()},play:function(){return this.apply(),this.animation&&!this.autoplay?(this.player=document.timeline.play(this.animation),this.player.onfinish=this.animationFinishHandler.bind(this),this.player):void 0},cancel:function(){this.player&&this.player.cancel()},finish:function(){this.player&&this.player.finish()},pause:function(){this.player&&this.player.pause()},hasTarget:function(){return null!==this.target},apply:function(){return this.animation=this.makeAnimation(),this.autoplay&&this.animation&&this.play(),this.animation},makeSingleAnimation:function(a){return a.classList.add("core-animation-target"),new Animation(a,this.animationEffect,this.timingProps)},makeAnimation:function(){if(!this.target)return null;var a;if(Array.isArray(this.target)){var b=[];this.target.forEach(function(a){b.push(this.makeSingleAnimation(a))}.bind(this)),a=new AnimationGroup(b)}else a=this.makeSingleAnimation(this.target);return a},animationChanged:function(){this.fire("core-animation-change",this)},targetChanged:function(a){a&&a.classList.remove("core-animation-target")},get timingProps(){var b={},c={delay:{isNumber:!0},endDelay:{isNumber:!0},fill:{},iterationStart:{isNumber:!0},iterations:{isNumber:!0,allowInfinity:!0},duration:{isNumber:!0},playbackRate:{isNumber:!0},direction:{},easing:{}};for(t in c)if(null!==this[t]){var d=c[t].property||t;b[d]=c[t].isNumber&&"auto"!==this[t]?a(this[t],c[t].allowInfinity):this[t]}return b},get animationEffect(){var a,b=[];if(this.keyframes)b=this.keyframes;else if(!this.customEffect){var c=this.querySelectorAll("core-animation-keyframe");0===c.length&&this.shadowRoot&&(c=this.shadowRoot.querySelectorAll("core-animation-keyframe")),Array.prototype.forEach.call(c,function(a){b.push(a.properties)})}return a=this.customEffect?this.customEffect:b},animationFinishHandler:function(){this.fire("core-animation-finish")}})}(),Polymer("core-animation-keyframe",{publish:{offset:{value:null,reflect:!0}},get properties(){var a={},b=this.querySelectorAll("core-animation-prop");return Array.prototype.forEach.call(b,function(b){a[b.name]=b.value}),null!==this.offset&&(a.offset=this.offset),a}}),Polymer("core-animation-prop",{publish:{name:{value:"",reflect:!0},value:{value:"",reflect:!0}}}),Polymer("album-art",{moreLikeThis:chrome.i18n.getMessage("moreLikeThis"),backButton:chrome.i18n.getMessage("backButton"),playTrackLabel:chrome.i18n.getMessage("playTrack"),moreOptionsLabel:chrome.i18n.getMessage("moreOptionsLabel"),closeLabel:chrome.i18n.getMessage("closeLabel"),add2PlayQueue:chrome.i18n.getMessage("add2PlayQueue"),favoriteAlbum:chrome.i18n.getMessage("favoriteAlbum"),downloadButton:chrome.i18n.getMessage("downloadButton"),albumTracklist:chrome.i18n.getMessage("albumTracklist"),imgURL:"",defaultImgURL:"../../../images/default-cover-art.png",width:"250px",height:"250px",albumSize:0,ready:function(){"use strict";this.page=this.page||"cover",this.artist=this.artist||"Artist Name",this.album=this.album||"Album Title",this.app=document.getElementById("tmpl"),this.audio=document.getElementById("audio"),this.playerArt=document.getElementById("coverArt"),this.app.colorThiefAlbum=this.app.colorThiefAlbum||"#db4437",this.app.colorThiefAlbumOff=this.app.colorThiefAlbumOff||"white"},setImage:function(a,b){"use strict";var c=window.URL.createObjectURL(a.target.result);this.showArt(c),this.isLoading=!1,this.imgURL=c,b&&b(c)},mouseIn:function(a,b,c){c.setZ(2)},mouseOut:function(a,b,c){c.setZ(1)},showArt:function(a){"use strict";this.$.card.style.backgroundImage="url('"+a+"')",this.$.topper.style.backgroundImage="url('"+a+"')",this.imgURL=a},slideUp:function(){"use strict";this.page="info"},closeSlide:function(){"use strict";this.page="cover"},doDialog:function(){"use strict";this.async(function(){this.app.dataLoading=!1,this.app.tracker.sendAppView("Album Details"),this.app.colorThiefEnabled&&this.playlist[0].palette&&(this.app.colorThiefAlbum=this.playlist[0].palette[0],this.app.colorThiefAlbumOff=this.playlist[0].palette[1]),this.closeSlide(),this.$.detailsDialog.open(),this.app.$.fab.state="mid",this.app.$.fab.ident=this.id})},closeDialog:function(){"use strict";this.app.tracker.sendAppView("Album Wall"),this.$.detailsDialog.close(),this.app.$.fab.state="off"},defaultPlayerImage:function(){"use strict";this.app.$.coverArt.style.backgroundImage="url('../../images/default-cover-art.png')"},add2Playlist:function(){"use strict";this.app.playlist=this.app.playlist.concat(this.playlist),this.app.dataLoading=!1,this.audio.paused&&(this.app.playing=0,this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.playlist[0].id}),this.imgURL,this.playlist[0].id),this.app.getImageForPlayer(this.imgURL,function(){this.app.setFabColor(this.playlist[0])}.bind(this))),this.app.doToast(chrome.i18n.getMessage("added2Queue"))},doAlbumDownload:function(a,b,c){"use strict";var d=new DownloadManager,e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.doQuery(function(){this.app.$.downloads.appendChild(d),this.app.isDownloading=!0,e.cancel(),d.downloadAlbum({id:this.albumID,artist:this.artist,album:this.album,size:this.albumSize},function(){console.log("Download Finished: "+this.artist+" - "+this.album)}.bind(this))}.bind(this))},doTrackDownload:function(a,b,c){"use strict";var d=new DownloadManager,e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.doQuery(function(){this.app.$.downloads.appendChild(d),this.app.isDownloading=!0,e.cancel(),d.downloadTrack(c.attributes.ident.value,function(){console.log("Track Download Finished")}.bind(this))}.bind(this))},playTrack:function(a,b,c){"use strict";this.app.setFabColor(this.playlist[0]),this.$.detailsDialog.close(),this.playerArt.style.backgroundImage="url('"+this.imgURL+"')",this.app.playlist=[{artist:c.attributes.artist.value,title:c.attributes.trackTitle.value,cover:this.imgURL,duration:c.attributes.duration.value,id:c.attributes.ident.value}],this.app.playing=0,this.app.playAudio(c.attributes.artist.value,c.attributes.trackTitle.value,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:c.attributes.ident.value}),this.imgURL,c.attributes.ident.value),this.app.$.fab.state="off"},addSingle2Playlist:function(a,b,c){"use strict";var d={id:c.attributes.ident.value,artist:c.attributes.artist.value,title:c.attributes.trackTitle.value,duration:c.attributes.duration.value,cover:this.imgURL};this.app.playlist.push(d),this.audio.paused&&(this.app.setFabColor(this.playlist[0]),this.app.playAudio(c.attributes.artist.value,c.attributes.trackTitle.value,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:c.attributes.ident.value}),this.imgURL,c.attributes.ident.value),this.app.playing=0,this.imgURL?this.playerArt.style.backgroundImage="url('"+this.imgURL+"')":this.playerArt.style.backgroundImage="url('../../images/default-cover-art.png')"),this.app.doToast(chrome.i18n.getMessage("added2Queue"))},playAlbum:function(){"use strict";this.app.dataLoading=!1,this.$.detailsDialog.close(),this.app.setFabColor(this.playlist[0]),this.app.getImageForPlayer(this.imgURL,function(){this.app.playlist=this.playlist,this.app.playing=0,this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.playlist[0].id}),this.imgURL,this.playlist[0].id)}.bind(this))},addFavorite:function(a,b,c){"use strict";var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.doXhr(this.app.buildUrl("star",{albumId:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(this.isFavorite=!0,d.cancel())}.bind(this))},removeFavorite:function(a,b,c){"use strict";var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.doXhr(this.app.buildUrl("unstar",{albumId:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(this.isFavorite=!1,d.cancel())}.bind(this))},paletteChanged:function(){"use strict";if(this.palette)for(var a=this.playlist.length,b=0;a>b;b++)this.playlist[b].palette=this.palette},getPalette:function(a){"use strict";this.app.getDbItem("al-"+this.item+"-palette",function(b){this.palette=b.target.result,this.async(a)}.bind(this))},doPlayback:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.playAlbum.bind(this))}.bind(this))},doDetails:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.doDialog.bind(this))}.bind(this))},doAdd2Playlist:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.add2Playlist.bind(this))}.bind(this))},processJSON:function(a){"use strict";this.playlist.length=0,this.albumID=this.trackResponse["subsonic-response"].album.song[0].parent;var b=this.trackResponse["subsonic-response"].album.song;b.sort(function(a,b){var c=a.discNumber||0,d=b.discNumber||0,e=a.track||0,f=b.track||0;return c===d?e-f:c-d}),this.async(function(){for(var c=b.length,d=0;c>d;d++){var e=Math.floor(b[d].duration/60),f=Math.floor(b[d].duration-60*e),g=e+":"+("0"+f).slice(-2),h={id:b[d].id,artist:b[d].artist,title:b[d].title,duration:g,cover:this.imgURL,palette:this.palette,disk:b[d].diskNumber,track:b[d].track};this.albumSize=this.albumSize+b[d].size,this.playlist.push(h),d===c-1&&this.async(a)}})},doQuery:function(a){"use strict";this.async(function(){this.app.getDbItem(this.item,function(b){b.target.result?(this.trackResponse=b.target.result,this.processJSON(a)):this.app.doXhr(this.app.buildUrl("getAlbum",{id:this.item}),"json",function(b){this.trackResponse=b.target.response,this.processJSON(a),this.app.putInDb(this.trackResponse,this.item,function(){console.log("JSON Data Added to indexedDB "+this.item)}.bind(this))}.bind(this))}.bind(this))})},itemChanged:function(){"use strict";this.async(function(){if(this.item){var a="al-"+this.item;this.showArt(this.defaultImgURL),this.playlist=[],this.isLoading=!0,this.async(function(){this.app.getDbItem(a,function(b){b.target.result?this.setImage(b):this.app.getImageFile(this.app.buildUrl("getCoverArt",{size:550,id:a}),a,function(b){this.setImage(b,function(b){this.app.colorThiefHandler(b,a)}.bind(this))}.bind(this))}.bind(this))})}})},setRating:function(a,b,c){"use strict";var d=parseInt(c.attributes.star.value,10),e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.app.doXhr(this.app.buildUrl("setRating",{id:this.item,rating:d}),"json",function(a){var b=a.target.response["subsonic-response"];e.cancel(),"ok"===b.status&&(this.rating=d)}.bind(this))},moreLikeCallback:function(){this.app.$.audio.paused&&this.app.getImageForPlayer(this.app.playlist[0].cover,function(){this.app.playing=0,this.app.setFabColor(this.app.playlist[0]),this.app.playAudio(this.app.playlist[0].artist,this.app.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.app.playlist[0].id}),this.app.playlist[0].cover,this.app.playlist[0].id),this.app.dataLoading=!1}.bind(this))},moreLike:function(a,b,c){"use strict";var d=c.attributes.ident.value;this.$.detailsDialog.close(),this.app.$.fab.state="off",this.app.dataLoading=!0,this.app.doXhr(this.app.buildUrl("getSimilarSongs",{count:50,id:d}),"json",function(a){var b=a.target.response["subsonic-response"].similarSongs.song;if(b){this.app.$.audio.pause(),this.app.playlist.length=0;for(var c=b.length,d=0;c>d;d++){var e=Math.floor(b[d].duration/60),f={id:b[d].id,artist:b[d].artist,title:b[d].title,duration:e+":"+("0"+Math.floor(b[d].duration-60*e)).slice(-2)},g="al-"+b[d].albumId;this.app.getDbItem(g,function(a){a.target.result?(f.cover=window.URL.createObjectURL(a.target.result),this.app.getDbItem(g+"-palette",function(a){f.palette=a.target.result,this.app.playlist.push(f),this.moreLikeCallback()}.bind(this))):this.app.getImageFile(this.app.buildUrl("getCoverArt",{size:550,id:g}),g,function(a){f.cover=window.URL.createObjectURL(a.target.result),this.app.colorThiefHandler(imgURL,g,function(a){f.palette=a,this.app.playlist.push(f),this.moreLikeCallback()}.bind(this))}.bind(this))}.bind(this))}}else this.app.dataLoading=!1,this.app.doToast(chrome.i18n.getMessage("noResults"))}.bind(this))}}),Polymer("paper-spinner",{eventDelegates:{animationend:"reset",webkitAnimationEnd:"reset"},publish:{active:{value:!1,reflect:!0},alt:{value:"loading",reflect:!0}},ready:function(){this.hasAttribute("aria-label")?this.alt=this.getAttribute("aria-label"):this.setAttribute("aria-label",this.alt),this.active||this.setAttribute("aria-hidden","true")},activeChanged:function(){this.active?(this.$.spinnerContainer.classList.remove("cooldown"),this.$.spinnerContainer.classList.add("active"),this.removeAttribute("aria-hidden")):(this.$.spinnerContainer.classList.add("cooldown"),this.setAttribute("aria-hidden","true"))},altChanged:function(){""===this.alt?this.setAttribute("aria-hidden","true"):this.removeAttribute("aria-hidden"),this.setAttribute("aria-label",this.alt)},reset:function(){this.$.spinnerContainer.classList.remove("active","cooldown")}}),function(){function a(a){var b="";if(a){var c=a.toLowerCase();1==c.length?l.test(c)&&(b=c):b="multiply"==c?"*":c}return b}function b(a){var b="";return a&&(b=m.test(a)?j[a]:a.toLowerCase()),b}function c(a){var b="";return Number(a)&&(b=a>=65&&90>=a?String.fromCharCode(32+a):a>=112&&123>=a?"f"+(a-112):a>=48&&57>=a?String(48-a):a>=96&&105>=a?String(96-a):k[a]),b}function d(d){var e=a(d.key)||b(d.keyIdentifier)||c(d.keyCode)||a(d.detail.key)||"";return{shift:d.shiftKey,ctrl:d.ctrlKey,meta:d.metaKey,alt:d.altKey,key:e}}function e(a){var b=a.split("+"),c=Object.create(null);return b.forEach(function(a){"shift"==a?c.shift=!0:"ctrl"==a?c.ctrl=!0:"alt"==a?c.alt=!0:c.key=a}),c}function f(a,b){return Boolean(a.alt)==Boolean(b.alt)&&Boolean(a.ctrl)==Boolean(b.ctrl)&&Boolean(a.shift)==Boolean(b.shift)&&a.key===b.key}function g(a){for(var b,c=d(a),e=0;ed&&(b=c[d]);d++)this.moveInsertedElements(b),this.cacheDomLocation(b),b.parentNode.removeChild(b),a.__contents.push(b);this.cacheDomLocation(a),this.updateEventController(a);var f=this.makeHost();f.shadowRoot.appendChild(a),a.__host=f}},makeHost:function(){var a=document.createElement("overlay-host");return a.createShadowRoot(),this.appendChild(a),a},moveInsertedElements:function(a){var b=a.getDistributedNodes(),c=a.parentNode;a.__contents=[];for(var d,e=0,f=b.length;f>e&&(d=b[e]);e++)this.cacheDomLocation(d),this.updateEventController(d),a.__contents.push(d),c.appendChild(d)},updateEventController:function(a){a.eventController=this.element.findController(a)},removeElement:function(a){a.eventController=null,this.replaceElement(a);var b=a.__host;b&&b.parentNode.removeChild(b)},replaceElement:function(a){if(a.__contents){for(var b,c=0,d=a.__contents;b=d[c];c++)this.replaceElement(b);a.__contents=null}if(a.__parentNode){var e=a.__nextElementSibling&&a.__nextElementSibling===a.__parentNode?a.__nextElementSibling:null;a.__parentNode.insertBefore(a,e)}},cacheDomLocation:function(a){a.__nextElementSibling=a.nextElementSibling,a.__parentNode=a.parentNode}})}(),function(){function a(a){var b=f();j.push(a);var d=f();b>=d&&c(a,b)}function b(a){var b=j.indexOf(a);b>=0&&(j.splice(b,1),d(a,""))}function c(a,b){d(a.target,b+2)}function d(a,b){a.style.zIndex=b}function e(){return j[j.length-1]}function f(){var a,b=e();if(b){var c=window.getComputedStyle(b.target).zIndex;isNaN(c)||(a=Number(c))}return a||k}function g(){var a=e();a&&!a.transitioning&&a.applyFocus()}function h(a){if(a.opened)l.push(a);else{var b=l.indexOf(a);b>=0&&l.splice(b,1)}}function i(){return l}Polymer("core-overlay",Polymer.mixin({publish:{target:null,sizingTarget:null,opened:!1,backdrop:!1,layered:!1,autoCloseDisabled:!1,autoFocusDisabled:!1,closeAttribute:"core-overlay-toggle",closeSelector:"",transition:"core-transition-fade"},captureEventName:"tap",targetListeners:{tap:"tapHandler",keydown:"keydownHandler","core-transitionend":"transitionend"},attached:function(){this.resizerAttachedHandler()},detached:function(){this.resizerDetachedHandler()},resizerShouldNotify:function(){return this.opened},registerCallback:function(a){this.layer=document.createElement("core-overlay-layer"),this.keyHelper=document.createElement("core-key-helper"),this.meta=document.createElement("core-transition"),this.scrim=document.createElement("div"),this.scrim.className="core-overlay-backdrop"},ready:function(){this.target=this.target||this,Polymer.flush()},toggle:function(){this.opened=!this.opened},open:function(){this.opened=!0},close:function(){this.opened=!1},domReady:function(){this.ensureTargetSetup()},targetChanged:function(a){if(this.target&&(this.target.tabIndex<0&&(this.target.tabIndex=-1),this.addElementListenerList(this.target,this.targetListeners),this.target.style.display="none",this.target.__overlaySetup=!1),a){this.removeElementListenerList(a,this.targetListeners);var b=this.getTransition();b?b.teardown(a):(a.style.position="",a.style.outline=""),a.style.display=""}},transitionChanged:function(a){this.target&&(a&&this.getTransition(a).teardown(this.target),this.target.__overlaySetup=!1)},ensureTargetSetup:function(){if(this.target&&!this.target.__overlaySetup){this.sizingTarget||(this.sizingTarget=this.target),this.target.__overlaySetup=!0,this.target.style.display="";var a=this.getTransition();a&&a.setup(this.target);var b=this.target.style,c=getComputedStyle(this.target);"static"===c.position&&(b.position="fixed"),b.outline="none",b.display="none"}},openedChanged:function(){this.transitioning=!0,this.ensureTargetSetup(),this.prepareRenderOpened(),this.async(function(){this.target.style.display="",this.target.offsetWidth,this.renderOpened()}),this.fire("core-overlay-open",this.opened)},prepareRenderOpened:function(){this.opened&&a(this),this.prepareBackdrop(),this.async(function(){this.autoCloseDisabled||this.enableElementListener(this.opened,document,this.captureEventName,"captureHandler",!0)}),this.enableElementListener(this.opened,window,"resize","resizeHandler"), -this.opened&&(this.target.offsetHeight,this.discoverDimensions(),this.preparePositioning(),this.positionTarget(),this.updateTargetDimensions(),this.finishPositioning(),this.layered&&(this.layer.addElement(this.target),this.layer.opened=this.opened))},renderOpened:function(){this.notifyResize();var a=this.getTransition();a?a.go(this.target,{opened:this.opened}):this.transitionend(),this.renderBackdropOpened()},transitionend:function(a){a&&a.target!==this.target||(this.transitioning=!1,this.opened||(this.resetTargetDimensions(),this.target.style.display="none",this.completeBackdrop(),b(this),this.layered&&(e()||(this.layer.opened=this.opened),this.layer.removeElement(this.target))),this.fire("core-overlay-"+(this.opened?"open":"close")+"-completed"),this.applyFocus())},prepareBackdrop:function(){this.backdrop&&this.opened&&(this.scrim.parentNode||(document.body.appendChild(this.scrim),this.scrim.style.zIndex=f()-1),h(this))},renderBackdropOpened:function(){this.backdrop&&i().length<2&&this.scrim.classList.toggle("core-opened",this.opened)},completeBackdrop:function(){this.backdrop&&(h(this),0===i().length&&this.scrim.parentNode.removeChild(this.scrim))},preparePositioning:function(){this.target.style.transition=this.target.style.webkitTransition="none",this.target.style.transform=this.target.style.webkitTransform="none",this.target.style.display=""},discoverDimensions:function(){if(!this.dimensions){var a=getComputedStyle(this.target),b=getComputedStyle(this.sizingTarget);this.dimensions={position:{v:"auto"!==a.top?"top":"auto"!==a.bottom?"bottom":null,h:"auto"!==a.left?"left":"auto"!==a.right?"right":null,css:a.position},size:{v:"none"!==b.maxHeight,h:"none"!==b.maxWidth},margin:{top:parseInt(a.marginTop)||0,right:parseInt(a.marginRight)||0,bottom:parseInt(a.marginBottom)||0,left:parseInt(a.marginLeft)||0}}}},finishPositioning:function(a){this.target.style.display="none",this.target.style.transform=this.target.style.webkitTransform="",this.target.offsetWidth,this.target.style.transition=this.target.style.webkitTransition=""},getTransition:function(a){return this.meta.byId(a||this.transition)},getFocusNode:function(){return this.target.querySelector("[autofocus]")||this.target},applyFocus:function(){var a=this.getFocusNode();this.opened?this.autoFocusDisabled||a.focus():(a.blur(),e()==this?console.warn("Current core-overlay is attempting to focus itself as next! (bug)"):g())},positionTarget:function(){this.fire("core-overlay-position",{target:this.target,sizingTarget:this.sizingTarget,opened:this.opened}),this.dimensions.position.v||(this.target.style.top="0px"),this.dimensions.position.h||(this.target.style.left="0px")},updateTargetDimensions:function(){this.sizeTarget(),this.repositionTarget()},sizeTarget:function(){this.sizingTarget.style.boxSizing="border-box";var a=this.dimensions,b=this.target.getBoundingClientRect();a.size.v||this.sizeDimension(b,a.position.v,"top","bottom","Height"),a.size.h||this.sizeDimension(b,a.position.h,"left","right","Width")},sizeDimension:function(a,b,c,d,e){var f=this.dimensions,g=b===d,h=g?c:d,i=window["inner"+e],j=f.margin[h]+(g?i-a[d]:a[c]),k="offset"+e,l=this.target[k]-this.sizingTarget[k];this.sizingTarget.style["max"+e]=i-j-l+"px"},repositionTarget:function(){if("fixed"===this.dimensions.position.css){if(!this.dimensions.position.v){var a=(window.innerHeight-this.target.offsetHeight)/2;a-=this.dimensions.margin.top,this.target.style.top=a+"px"}if(!this.dimensions.position.h){var b=(window.innerWidth-this.target.offsetWidth)/2;b-=this.dimensions.margin.left,this.target.style.left=b+"px"}}},resetTargetDimensions:function(){this.dimensions&&this.dimensions.size.v||(this.sizingTarget.style.maxHeight="",this.target.style.top=""),this.dimensions&&this.dimensions.size.h||(this.sizingTarget.style.maxWidth="",this.target.style.left=""),this.dimensions=null},tapHandler:function(a){a.target&&this.closeSelector&&a.target.matches(this.closeSelector)||this.closeAttribute&&a.target.hasAttribute(this.closeAttribute)?this.toggle():this.autoCloseJob&&(this.autoCloseJob.stop(),this.autoCloseJob=null)},captureHandler:function(a){this.autoCloseDisabled||e()!=this||(this.autoCloseJob=this.job(this.autoCloseJob,function(){this.close()}))},keydownHandler:function(a){this.autoCloseDisabled||a.keyCode!=this.keyHelper.ESCAPE_KEY||(this.close(),a.stopPropagation())},resizeHandler:function(){this.updateTargetDimensions()},addElementListenerList:function(a,b){for(var c in b)this.addElementListener(a,c,b[c])},removeElementListenerList:function(a,b){for(var c in b)this.removeElementListener(a,c,b[c])},enableElementListener:function(a,b,c,d,e){a?this.addElementListener(b,c,d,e):this.removeElementListener(b,c,d,e)},addElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.addEventListener(a,b,e,d)},removeElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.removeEventListener(a,b,e,d)},_makeBoundListener:function(a){var b=this,c=this[a];if(c){var d="_bound"+a;return this[d]||(this[d]=function(a){c.call(b,a)}),this[d]}}},Polymer.CoreResizer));var j=[],k=10,l=[]}(),Polymer("core-transition-css",{baseClass:"core-transition",openedClass:"core-opened",closedClass:"core-closed",completeEventName:"transitionend",publish:{transitionType:null},registerCallback:function(a){this.transitionStyle=a.templateContent().firstElementChild},fetchTemplate:function(){return null},go:function(a,b){void 0!==b.opened&&this.transitionOpened(a,b.opened)},setup:function(a){a._hasTransitionStyle||(a.shadowRoot||(a.createShadowRoot().innerHTML=""),this.installScopeStyle(this.transitionStyle,"transition",a.shadowRoot),a._hasTransitionStyle=!0),a.classList.add(this.baseClass),this.transitionType&&a.classList.add(this.baseClass+"-"+this.transitionType)},teardown:function(a){a.classList.remove(this.baseClass),this.transitionType&&a.classList.remove(this.baseClass+"-"+this.transitionType)},transitionOpened:function(a,b){this.listenOnce(a,this.completeEventName,function(){b||a.classList.remove(this.closedClass),this.complete(a)}),a.classList.toggle(this.openedClass,b),a.classList.toggle(this.closedClass,!b)}}),function(){var a;Polymer("paper-toast",{text:"",duration:3e3,opened:!1,responsiveWidth:"480px",swipeDisabled:!1,autoCloseDisabled:!1,narrowMode:!1,eventDelegates:{trackstart:"trackStart",track:"track",trackend:"trackEnd",transitionend:"transitionEnd"},narrowModeChanged:function(){this.classList.toggle("fit-bottom",this.narrowMode),this.opened&&this.$.overlay.resizeHandler()},openedChanged:function(){this.opened?this.dismissJob=this.job(this.dismissJob,this.dismiss,this.duration):(this.dismissJob&&this.dismissJob.stop(),this.dismiss())},toggle:function(){this.opened=!this.opened},show:function(){a&&a.dismiss(),a=this,this.opened=!0},dismiss:function(){this.dragging?this.shouldDismiss=!0:(this.opened=!1,a===this&&(a=null))},trackStart:function(a){this.swipeDisabled||(a.preventTap(),this.vertical=a.yDirection,this.w=this.offsetWidth,this.h=this.offsetHeight,this.dragging=!0,this.classList.add("dragging"))},track:function(a){if(this.dragging){var b=this.style;if(this.vertical){var c=a.dy;b.opacity=(this.h-Math.abs(c))/this.h,b.transform=b.webkitTransform="translate3d(0, "+c+"px, 0)"}else{var d=a.dx;b.opacity=(this.w-Math.abs(d))/this.w,b.transform=b.webkitTransform="translate3d("+d+"px, 0, 0)"}}},trackEnd:function(a){if(this.dragging){this.classList.remove("dragging"),this.style.opacity="",this.style.transform=this.style.webkitTransform="";var b=this.classList;this.vertical?(b.toggle("fade-out-down",1===a.yDirection&&a.dy>0),b.toggle("fade-out-up",-1===a.yDirection&&a.dy<0)):(b.toggle("fade-out-right",1===a.xDirection&&a.dx>0),b.toggle("fade-out-left",-1===a.xDirection&&a.dx<0)),this.dragging=!1}},transitionEnd:function(){var a=this.classList;a.contains("fade-out-right")||a.contains("fade-out-left")||a.contains("fade-out-down")||a.contains("fade-out-up")?(this.dismiss(),a.remove("fade-out-right","fade-out-left","fade-out-down","fade-out-up")):this.shouldDismiss&&this.dismiss(),this.shouldDismiss=!1}})}(),Polymer("core-menu"),Polymer("core-collapse",Polymer.mixin({target:null,horizontal:!1,opened:!1,duration:.33,fixedSize:!1,allowOverflow:!1,created:function(){this.transitionEndListener=this.transitionEnd.bind(this)},ready:function(){this.target=this.target||this},domReady:function(){this.async(function(){this.afterInitialUpdate=!0})},attached:function(){this.resizerAttachedHandler()},detached:function(){this.target&&this.removeListeners(this.target),this.resizableDetachedHandler()},targetChanged:function(a){a&&this.removeListeners(a),this.target&&(this.isTargetReady=!!this.target,this.classList.toggle("core-collapse-closed",this.target!==this),this.toggleOpenedStyle(!1),this.horizontalChanged(),this.addListeners(this.target),this.toggleClosedClass(!0),this.update())},addListeners:function(a){a.addEventListener("transitionend",this.transitionEndListener)},removeListeners:function(a){a.removeEventListener("transitionend",this.transitionEndListener)},horizontalChanged:function(){this.dimension=this.horizontal?"width":"height"},openedChanged:function(){this.update(),this.fire("core-collapse-open",this.opened)},toggle:function(){this.opened=!this.opened},setTransitionDuration:function(a){var b=this.target.style;b.transition=a?this.dimension+" "+a+"s":null,0===a&&this.async("transitionEnd")},transitionEnd:function(){this.opened&&!this.fixedSize&&this.updateSize("auto",null),this.setTransitionDuration(null),this.toggleOpenedStyle(this.opened),this.toggleClosedClass(!this.opened),this.asyncFire("core-resize",null,this.target),this.notifyResize()},toggleClosedClass:function(a){this.hasClosedClass=a,this.target.classList.toggle("core-collapse-closed",a)},toggleOpenedStyle:function(a){this.target.style.overflow=this.allowOverflow&&a?"":"hidden"},updateSize:function(a,b,c){this.setTransitionDuration(b),this.calcSize();var d=this.target.style,e=d[this.dimension]===a;d[this.dimension]=a,c&&e&&this.transitionEnd()},update:function(){this.target&&(this.isTargetReady||this.targetChanged(),this.horizontalChanged(),this[this.opened?"show":"hide"](),this.notifyResize())},calcSize:function(){return this.target.getBoundingClientRect()[this.dimension]+"px"},getComputedSize:function(){return getComputedStyle(this.target)[this.dimension]},show:function(){if(this.toggleClosedClass(!1),!this.afterInitialUpdate)return void this.transitionEnd();if(!this.fixedSize){this.updateSize("auto",null);var a=this.calcSize();if("0px"==a)return void this.transitionEnd();this.updateSize(0,null)}this.async(function(){this.updateSize(this.size||a,this.duration,!0)})},hide:function(){this.toggleOpenedStyle(!1),(!this.hasClosedClass||this.fixedSize)&&(this.fixedSize?this.size=this.getComputedSize():this.updateSize(this.calcSize(),null),this.async(function(){this.updateSize(0,this.duration)}))}},Polymer.CoreResizer)),Polymer("core-submenu",{publish:{active:{value:!1,reflect:!0}},opened:!1,get items(){return this.$.submenu.items},hasItems:function(){return!!this.items.length},unselectAllItems:function(){this.$.submenu.selected=null,this.$.submenu.clearSelection()},activeChanged:function(){this.hasItems()&&(this.opened=this.active),this.active||this.unselectAllItems()},toggle:function(){this.opened=!this.opened},activate:function(){this.hasItems()&&this.active&&(this.toggle(),this.unselectAllItems())}}),Polymer("core-scroll-threshold",{publish:{scrollTarget:null,orient:"v",upperThreshold:null,lowerThreshold:null,upperTriggered:!1,lowerTriggered:!1},observe:{"upperThreshold lowerThreshold scrollTarget orient":"setup"},ready:function(){this._boundScrollHandler=this.checkThreshold.bind(this)},detached:function(){this._scrollTarget&&this._scrollTarget.removeEventListener("scroll",this._boundScrollHandler)},setup:function(){var a=this.scrollTarget||this;this._scrollTarget&&this._scrollTarget!=a&&this._scrollTarget.removeEventListener("scroll",this._boundScrollHandler),a&&(this._scrollTarget=a,this._scrollTarget.addEventListener("scroll",this._boundScrollHandler)),this.style.overflow=a==this?"auto":null,this.scrollPosition="v"==this.orient?"scrollTop":"scrollLeft",this.sizeExtent="v"==this.orient?"offsetHeight":"offsetWidth",this.scrollExtent="v"==this.orient?"scrollHeight":"scrollWidth",this.upperThreshold||(this.upperTriggered=!1),this.lowerThreshold||(this.lowerTriggered=!1)},checkThreshold:function(a){var b=this._scrollTarget[this.scrollPosition];if(this.upperTriggered||null===this.upperThreshold||bd;d++)for(var e=b[d].episode.length,f=0;e>f;f++)b[d].episode[f].podcastRole=this.app.activeUser.podcastRole,f===e-1&&d===c-1&&(this.podcast=b,this.async(this.responseCallback));else if(a.artists&&a.artists.index)this.artist=a.artists.index,this.async(this.responseCallback);else if(a.searchResult3&&a.searchResult3.album)for(var g=a.searchResult3.album,c=a.searchResult3.album.length,h=[],d=0;c>d;d++)this.containsObject(g[d],h)||h.push(g[d]),d===c-1&&(this.wall=h,this.async(this.responseCallback));else this.app.pageLimit=!0;this.isLoading||this.wall[0]||(this.app.dataLoading=!1)}})},artistDetails:function(a,b,c){"use strict";var d=document.getElementById("aDetails");this.app.dataLoading=!0,d.artistId=c.attributes.ident.value,d.queryData()},doAjax:function(){"use strict";this.$.ajax.url=this.app.buildUrl(this.request,this.post),this.$.ajax.go()},getPodcast:function(){"use strict";this.showing="podcast",this.clearData(function(){this.app.pageLimit=!1,this.request="getPodcasts",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},getStarred:function(){"use strict";this.showing=this.listMode,this.clearData(function(){this.app.pageLimit=!1,"ID3"===this.queryMethod?this.request="getStarred2":this.request="getStarred",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},getArtist:function(){"use strict";this.clearData(function(){this.app.pageLimit=!1,this.request="getArtists",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.showing="artists",this.doAjax()}.bind(this))},sortChanged:function(){"use strict";this.showing=this.listMode,this.clearData(function(){this.app.pageLimit=!1,"ID3"===this.queryMethod?this.request="getAlbumList2":this.request="getAlbumList",this.post.type=this.sort,this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},resizeLists:function(){"use strict";this.$.cover.updateSize(),this.$.podcast.updateSize(),this.$.artists.updateSize()},errorChanged:function(){"use strict";this.error&&(console.error(this.error),this.app.doToast(chrome.i18n.getMessage("connectionError")))},loadMore:function(){"use strict";this.$.threshold.clearLower(),this.isLoading||"getStarred2"===this.request||"getPodcasts"===this.request||"getArtists"===this.request||this.app.pageLimit||0!==this.app.page||(this.isLoading=!0,this.post.offset=parseInt(this.post.offset,10)+parseInt(this.post.size,10),this.async(function(){this.doAjax()}))},querySizeChanged:function(){"use strict";this.post.size=this.querySize},listModeChanged:function(){"use strict";this.async(function(){this.listMode&&"getArtists"!==this.request&&"getPodcasts"!==this.request&&("cover"===this.listMode?this.showing="cover":this.showing="list",this.app.dataLoading=!1)})},getPaletteFromDb:function(a,b){"use strict";this.app.getDbItem(a+"-palette",function(a){b(a.target.result)}.bind(this))},doPlay:function(a,b){"use strict";this.app.playlist=[a],this.app.playing=0,this.app.playAudio("",a.title,b,a.cover,a.id),this.app.dataLoading=!1},mouseIn:function(a,b,c){c.setZ(2)},mouseOut:function(a,b,c){c.setZ(1)},playPodcast:function(a,b,c){"use strict";this.app.dataLoading=!0;var d,e,f=this.app.buildUrl("getCoverArt",{id:c.attributes.cover.value}),g=this.app.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:c.attributes.streamId.value});c.attributes.cover.value?this.app.getDbItem(c.attributes.cover.value,function(a){if(a.target.result){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d,function(){this.getPaletteFromDb(c.attributes.cover.value,function(a){e.palette=a,this.app.setFabColor(e),this.doPlay(e,g)}.bind(this))}.bind(this))}else this.app.getImageFile(f,c.attributes.cover.value,function(a){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d,function(){this.app.colorThiefHandler(d,c.attributes.cover.value,function(a){e.palette=a,this.app.setFabColor(e),this.doPlay(e,g)}.bind(this))}.bind(this))}.bind(this))}.bind(this)):(d="../../../images/default-cover-art.png",e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d),this.doPlay(e,g),this.app.page=1)},add2Playlist:function(a,b,c){"use strict";var d,e,f=this.app.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:c.attributes.streamId.value});this.app.dataLoading=!0,c.attributes.cover.value?this.app.getDbItem(c.attributes.cover.value,function(a){a.target.result?(d=window.URL.createObjectURL(a.target.result),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.getPaletteFromDb(c.attributes.cover.value,function(a){e.palette=a,this.audio.paused?this.app.getImageForPlayer(d,function(){this.app.setFabColor(e),this.doPlay(e,f),this.app.dataLoading=!1,this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this)):(this.app.dataLoading=!1,this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue")))}.bind(this))):this.app.getImageFile(this.app.buldUrl("getCoverArt",{id:c.attributes.cover.value}),c.attributes.cover.value,function(a){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.colorThiefHandler(d,c.attributes.cover.value,function(a){e.palette=a}),this.audio.paused?this.app.getImageForPlayer(d,function(){this.app.dataLoading=!1,this.app.setFabColor(e),this.doPlay(e,f),this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this)):(this.app.dataLoading=!1,this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue")))}.bind(this))}.bind(this)):(d="../../../images/default-cover-art.png",this.audio.paused?(e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d),this.doPlay(e,f)):(e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue"))))},showingChanged:function(){"use strict";var a=document.getElementById("fab");"podcast"===this.showing?a.state="podcast":a.state="off"},topOfPage:function(){"use strict";this.scrollTarget.scrollTop=0},deleteDialog:function(a,b,c){"use strict";this.app.delID=c.attributes.ident.value,this.app.$.confirmDelete.open()},deleteChannel:function(a){"use strict";this.app.doXhr(this.app.buildUrl("deletePodcastChannel",{id:a}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax()}.bind(this))}.bind(this))},refreshContent:function(){"use strict";0!==this.post.offset&&(this.post.offset=0),this.clearData(function(){this.doAjax()}.bind(this))},downloadEpisode:function(a,b,c){"use strict";this.app.doXhr(this.app.buildUrl("downloadPodcastEpisode",{id:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax(),this.app.doToast(chrome.i18n.getMessage("downloadPodcast"))}.bind(this))}.bind(this))},episodeDialog:function(a,b,c){"use strict";this.app.delID=c.attributes.ident.value,this.app.$.episodeConfirm.open()},deleteEpisode:function(a){"use strict";this.app.doXhr(this.app.buildUrl("deletePodcastEpisode",{id:a}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax()}.bind(this))}.bind(this))},toggleCollapse:function(a,b,c){"use strict";var d="#"+c.attributes.ident.value;this.$.all.querySelector(d).toggle()},playSomething:function(a,b){"use strict";var c=this.$.all.querySelector("#"+a);c.playAlbum(),b()},findIndexByKeyValue:function(a,b,c){"use strict";for(var d=a.length,e=0;d>e;e+=1)if(a[e][b]===c)return e;return null},jumpToLetter:function(a){"use strict";this.$.artists.scrollToItem(this.findIndexByKeyValue(this.artist,"name",a))},containsObject:function(a,b){"use strict";for(var c=b.length,d=0;c>d;d+=1)if(b[d].id===a.id)return!0;return!1}}),function(){Polymer("core-toolbar",{justify:"",middleJustify:"",bottomJustify:"",justifyChanged:function(a){this.updateBarJustify(this.$.topBar,this.justify,a)},middleJustifyChanged:function(a){this.updateBarJustify(this.$.middleBar,this.middleJustify,a)},bottomJustifyChanged:function(a){this.updateBarJustify(this.$.bottomBar,this.bottomJustify,a)},updateBarJustify:function(a,b,c){c&&a.removeAttribute(this.toLayoutAttrName(c)),b&&a.setAttribute(this.toLayoutAttrName(b),"")},toLayoutAttrName:function(a){return"between"===a?"justified":a+"-justified"}})}(),Polymer("core-header-panel",{publish:{mode:{value:"",reflect:!0},tallClass:"tall",shadow:!1},animateDuration:200,modeConfigs:{shadowMode:{waterfall:1,"waterfall-tall":1},noShadow:{seamed:1,cover:1,scroll:1},tallMode:{"waterfall-tall":1},outerScroll:{scroll:1}},ready:function(){this.scrollHandler=this.scroll.bind(this),this.addListener()},detached:function(){this.removeListener(this.mode)},addListener:function(){this.scroller.addEventListener("scroll",this.scrollHandler)},removeListener:function(a){var b=this.getScrollerForMode(a);b.removeEventListener("scroll",this.scrollHandler)},domReady:function(){this.async("scroll")},modeChanged:function(a){var b=this.modeConfigs,c=this.header;c&&(b.tallMode[a]&&!b.tallMode[this.mode]?(c.classList.remove(this.tallClass),this.async(function(){c.classList.remove("animate")},null,this.animateDuration)):c.classList.toggle("animate",b.tallMode[this.mode])),b&&(b.outerScroll[this.mode]||b.outerScroll[a])&&(this.removeListener(a),this.addListener()),this.scroll()},get header(){return this.$.headerContent.getDistributedNodes()[0]},getScrollerForMode:function(a){return this.modeConfigs.outerScroll[a]?this.$.outerContainer:this.$.mainContainer},get scroller(){return this.getScrollerForMode(this.mode)},scroll:function(){var a=this.modeConfigs,b=this.$.mainContainer,c=this.header,d=b.scrollTop,e=0===d;this.$.dropShadow.classList.toggle("hidden",!this.shadow&&(e&&a.shadowMode[this.mode]||a.noShadow[this.mode])),c&&a.tallMode[this.mode]&&c.classList.toggle(this.tallClass,e||c.classList.contains(this.tallClass)&&b.scrollHeight=this.offsetWidth-this.edgeSwipeSensitivity:a.pageX<=this.edgeSwipeSensitivity)},trackStart:function(a){this.swipeAllowed()&&(this.dragging=!0,this.isMainSelected()&&(this.dragging=this.peeking||this.isEdgeTouch(a)),this.dragging&&(this.width=this.$.drawer.offsetWidth,this.transition=!1,a.preventTap()))},translateXForDeltaX:function(a){var b=this.isMainSelected();return this.rightDrawer?Math.max(0,b?this.width+a:a):Math.min(0,b?a-this.width:a)},trackx:function(a){if(this.dragging){if(this.peeking){if(Math.abs(a.dx)<=this.edgeSwipeSensitivity)return;this.peeking=!1}this.moveDrawer(this.translateXForDeltaX(a.dx))}},trackEnd:function(a){this.dragging&&(this.dragging=!1,this.transition=!0,this.moveDrawer(null),this.rightDrawer?this.selected=a.xDirection>0?"main":"drawer":this.selected=a.xDirection>0?"drawer":"main")},transformForTranslateX:function(a){return null===a?"":this.hasWillChange?"translateX("+a+"px)":"translate3d("+a+"px, 0, 0)"},moveDrawer:function(a){var b=this.$.drawer.style;this.hasTransform?b.transform=this.transformForTranslateX(a):b.webkitTransform=this.transformForTranslateX(a)}}),Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(a){return(this.clampValue(a)-this.min)/(this.max-this.min)},clampValue:function(a){return Math.min(this.max,Math.max(this.min,this.calcStep(a)))},calcStep:function(a){return this.step?Math.round(a/this.step)/(1/this.step):a},validateValue:function(){var a=this.clampValue(this.value);return this.value=this.oldValue=isNaN(a)?this.oldValue:a,this.value!==a},update:function(){this.validateValue(),this.ratio=100*this.calcRatio(this.value)}}),Polymer("paper-progress",{secondaryProgress:0,indeterminate:!1,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this["super"](),this.secondaryProgress=this.clampValue(this.secondaryProgress),this.secondaryRatio=100*this.calcRatio(this.secondaryProgress), -this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(a,b){var c="scaleX("+b/100+")";a.style.transform=a.style.webkitTransform=c},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}}),Polymer("core-input",{publish:{committedValue:"",preventInvalidInput:!1},previousValidInput:"",eventDelegates:{input:"inputAction",change:"changeAction"},ready:function(){this.disabledHandler(),this.placeholderHandler()},attributeChanged:function(a,b){this[a+"Handler"]&&this[a+"Handler"](b)},disabledHandler:function(){this.disabled?this.setAttribute("aria-disabled",""):this.removeAttribute("aria-disabled")},placeholderHandler:function(){this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label")},commit:function(){this.committedValue=this.value},changeAction:function(){this.commit()},inputAction:function(a){this.preventInvalidInput&&(a.target.validity.valid?this.previousValidInput=a.target.value:a.target.value=this.previousValidInput)}}),function(){var a=CoreStyle.g.paperInput=CoreStyle.g.paperInput||{};a.labelColor="#757575",a.focusedColor="#4059a9",a.invalidColor="#d34336",Polymer("paper-input-decorator",{publish:{label:"",floatingLabel:!1,disabled:{value:!1,reflect:!0},labelVisible:null,isInvalid:!1,autoValidate:!1,error:"",focused:{value:!1,reflect:!0}},computed:{floatingLabelVisible:"floatingLabel && !_labelVisible",_labelVisible:"(labelVisible === true || labelVisible === false) ? labelVisible : _autoLabelVisible"},ready:function(){Polymer.addEventListener(this,"focus",this.focusAction.bind(this),!0),Polymer.addEventListener(this,"blur",this.blurAction.bind(this),!0)},attached:function(){this.input=this.querySelector("input,textarea"),this.mo=new MutationObserver(function(){this.input=this.querySelector("input,textarea")}.bind(this)),this.mo.observe(this,{childList:!0})},detached:function(){this.mo.disconnect(),this.mo=null},prepareLabelTransform:function(){var a=this.$.floatedLabelText.getBoundingClientRect(),b=this.$.labelText.getBoundingClientRect();if(0!==a.width){var c=a.height/b.height;this.$.labelText.cachedTransform="scale3d("+a.width/b.width+","+c+",1) translate3d(0,"+(a.top-b.top)/c+"px,0)"}},animateFloatingLabel:function(){return!this.floatingLabel||this.labelAnimated?!1:(this.$.labelText.cachedTransform||this.prepareLabelTransform(),this.$.labelText.cachedTransform?(this.labelAnimated=!0,this.async(function(){this.transitionEndAction()},null,250),this._labelVisible?(this.$.labelText.style.webkitTransform||this.$.labelText.style.transform||(this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform,this.$.labelText.style.transform=this.$.labelText.cachedTransform,this.$.labelText.offsetTop),this.$.labelText.style.webkitTransform="",this.$.labelText.style.transform=""):(this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform,this.$.labelText.style.transform=this.$.labelText.cachedTransform,this.input.placeholder=""),!0):!1)},animateUnderline:function(a){if(this.focused){var b=this.$.underline.getBoundingClientRect(),c=a.x-b.left;this.$.focusedUnderline.style.mozTransformOrigin=c+"px",this.$.focusedUnderline.style.webkitTransformOrigin=c+"px ",this.$.focusedUnderline.style.transformOriginX=c+"px",this.underlineAnimated=!0}},validate:function(){return this.input?(this.isInvalid=!this.input.validity.valid,this.input.validity.valid):!0},_labelVisibleChanged:function(a){void 0!==a&&(this.animateFloatingLabel()||this.updateInputLabel(this.input,this.label))},labelVisibleChanged:function(){"true"===this.labelVisible?this.labelVisible=!0:"false"===this.labelVisible&&(this.labelVisible=!1)},labelChanged:function(){this.input&&this.updateInputLabel(this.input,this.label)},isInvalidChanged:function(){this.classList.toggle("invalid",this.isInvalid)},focusedChanged:function(){this.updateLabelVisibility(this.input&&this.input.value),this.lastEvent&&(this.animateUnderline(this.lastEvent),this.lastEvent=null),this.underlineVisible=this.focused},inputChanged:function(a){this.input&&(this.updateLabelVisibility(this.input.value),this.updateInputLabel(this.input,this.label),this.autoValidate&&this.validate()),a&&this.updateInputLabel(a,"")},focusAction:function(){this.focused=!0},blurAction:function(){this.focused=!1},updateLabelVisibility:function(a){var b=null!==a&&void 0!==a?String(a):a;this._autoLabelVisible=!this.focused&&!b||!this.floatingLabel&&!b},updateInputLabel:function(a,b){this._labelVisible?this.input.placeholder=this.label:this.input.placeholder="",b?a.setAttribute("aria-label",b):a.removeAttribute("aria-label")},inputAction:function(){this.updateLabelVisibility(this.input.value),this.autoValidate&&this.validate()},downAction:function(a){return a.target!==this.input&&this.focused?void a.preventDefault():void(this.lastEvent=a)},tapAction:function(a){this.disabled||this.focused||this.input&&(this.input.focus(),a.preventDefault())},transitionEndAction:function(){this.underlineAnimated=!1,this.labelAnimated=!1,this._labelVisible&&(this.input.placeholder=this.label)},charCounterErrorAction:function(a){this.isInvalid=a.detail.hasError,this.$.errorIcon.hidden=a.detail.hideErrorIcon}})}(),Polymer("paper-input",{publish:{label:"",floatingLabel:!1,disabled:{value:!1,reflect:!0},value:"",committedValue:""},focus:function(){this.$.input.focus()},valueChanged:function(){this.$.decorator.updateLabelVisibility(this.value)},changeAction:function(a){this.fire("change",null,this)}}),Polymer("paper-slider",{snaps:!1,pin:!1,disabled:!1,secondaryProgress:0,editable:!1,maxMarkers:100,dragging:!1,observe:{"step snaps":"update"},ready:function(){this.update()},update:function(){this.positionKnob(this.calcRatio(this.value)),this.updateMarkers()},minChanged:function(){this.update(),this.setAttribute("aria-valuemin",this.min)},maxChanged:function(){this.update(),this.setAttribute("aria-valuemax",this.max)},valueChanged:function(){this.update(),this.setAttribute("aria-valuenow",this.value),this.fire("core-change")},disabledChanged:function(){this.disabled?this.removeAttribute("tabindex"):this.tabIndex=0},immediateValueChanged:function(){this.dragging||(this.value=this.immediateValue),this.editable&&(this.$.input.value=this.immediateValue),this.fire("immediate-value-change")},expandKnob:function(){this.expand=!0},resetKnob:function(){this.expandJob&&this.expandJob.stop(),this.expand=!1},positionKnob:function(a){this.immediateValue=this.calcStep(this.calcKnobPosition(a))||0,this._ratio=this.snaps?this.calcRatio(this.immediateValue):a,this.$.sliderKnob.style.left=100*this._ratio+"%"},inputChange:function(){this.value=this.$.input.value,this.fire("change")},calcKnobPosition:function(a){return(this.max-this.min)*a+this.min},trackStart:function(a){this._w=this.$.sliderBar.offsetWidth,this._x=this._ratio*this._w,this._startx=this._x||0,this._minx=-this._startx,this._maxx=this._w-this._startx,this.$.sliderKnob.classList.add("dragging"),this.dragging=!0,a.preventTap()},trackx:function(a){var b=Math.min(this._maxx,Math.max(this._minx,a.dx));this._x=this._startx+b,this.immediateValue=this.calcStep(this.calcKnobPosition(this._x/this._w))||0;var c=this.$.sliderKnob.style;c.transform=c.webkitTransform="translate3d("+(this.snaps?this.calcRatio(this.immediateValue)*this._w-this._startx:b)+"px, 0, 0)"},trackEnd:function(){var a=this.$.sliderKnob.style;a.transform=a.webkitTransform="",this.$.sliderKnob.classList.remove("dragging"),this.dragging=!1,this.resetKnob(),this.value=this.immediateValue,this.fire("change")},knobdown:function(a){a.preventDefault(),this.expandKnob()},bardown:function(a){a.preventDefault(),this.transiting=!0,this._w=this.$.sliderBar.offsetWidth;var b=this.$.sliderBar.getBoundingClientRect(),c=(a.x-b.left)/this._w;this.positionKnob(c),this.expandJob=this.job(this.expandJob,this.expandKnob,60),this.asyncFire("change")},knobTransitionEnd:function(a){a.target===this.$.sliderKnob&&(this.transiting=!1)},updateMarkers:function(){this.markers=[];var a=(this.max-this.min)/this.step;if(this.snaps||!(a>this.maxMarkers))for(var b=0;a>b;b++)this.markers.push("")},increment:function(){this.value=this.clampValue(this.value+this.step)},decrement:function(){this.value=this.clampValue(this.value-this.step)},incrementKey:function(a,b){"end"===b.key?this.value=this.max:this.increment(),this.fire("change")},decrementKey:function(a,b){"home"===b.key?this.value=this.min:this.decrement(),this.fire("change")}}),Polymer("paper-dialog-base",{publish:{heading:"",transition:"",layered:!0},ready:function(){this["super"](),this.sizingTarget=this.$.scroller},headingChanged:function(a){var b=this.getAttribute("aria-label");b&&b!==a||this.setAttribute("aria-label",this.heading)},openAction:function(){this.$.scroller.scrollTop&&(this.$.scroller.scrollTop=0)}}),Polymer("paper-dialog"),Polymer("paper-action-dialog",{publish:{closeSelector:"[affirmative],[dismissive]"}}),Polymer("core-dropdown-base",{publish:{opened:!1},eventDelegates:{tap:"toggleOverlay"},overlayListeners:{"core-overlay-open":"openAction"},get dropdown(){if(!this._dropdown){this._dropdown=this.querySelector(".dropdown");for(var a in this.overlayListeners)this.addElementListener(this._dropdown,a,this.overlayListeners[a])}return this._dropdown},attached:function(){this.dropdown},addElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.addEventListener(a,b,e,d)},removeElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.removeEventListener(a,b,e,d)},_makeBoundListener:function(a){var b=this,c=this[a];if(c){var d="_bound"+a;return this[d]||(this[d]=function(a){c.call(b,a)}),this[d]}},openedChanged:function(){if(!this.disabled){var a=this.dropdown;a&&(a.opened=this.opened)}},openAction:function(a){this.opened=!!a.detail},toggleOverlay:function(a){this.dropdown.contains(a.target)||this.disabled||(this.opened=!this.opened)}}),Polymer("paper-menu-button",{overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction"},activateAction:function(){this.opened=!1}}),function(){function a(a){var b;return((b=document.documentElement)||(b=document.body.parentNode))&&"number"==typeof b[a]?b:document.body}function b(){var b,c,d=a("clientWidth"),e=document.body;return"number"==typeof document.clientWidth?{w:document.clientWidth,h:document.clientHeight}:d===e||(b=Math.max(d.clientWidth,e.clientWidth))>self.innerWidth||(c=Math.max(d.clientHeight,e.clientHeight))>self.innerHeight?{w:e.clientWidth,h:e.clientHeight}:{w:b,h:c}}Polymer("core-dropdown",{publish:{relatedTarget:null,halign:"left",valign:"top"},measure:function(){var a=this.target,b=a.style.position;a.style.position="fixed",a.style.left="0px",a.style.top="0px";var c=a.getBoundingClientRect();return a.style.position=b,a.style.left=null,a.style.top=null,c},resetTargetDimensions:function(){var a=this.dimensions,b=this.target.style;a.position.h_by===this.localName&&(b[a.position.h]=null,a.position.h_by=null),a.position.v_by===this.localName&&(b[a.position.v]=null,a.position.v_by=null);var b=this.sizingTarget.style;b.width=null,b.height=null,this["super"]()},positionTarget:function(){if(!this.relatedTarget&&(this.relatedTarget=this.target.parentElement||this.target.parentNode&&this.target.parentNode.host,!this.relatedTarget))return void this["super"]();var a=this.sizingTarget,b=this.measure();a.style.width=Math.ceil(b.width)+"px",a.style.height=Math.ceil(b.height)+"px",this.layered?this.positionLayeredTarget():this.positionNestedTarget()},positionLayeredTarget:function(){var a=this.target,c=this.relatedTarget.getBoundingClientRect(),d=this.dimensions,e=d.margin,f=b();d.position.h||("right"===this.halign?(a.style.right=f.w-c.right-e.right+"px",d.position.h="right"):(a.style.left=c.left-e.left+"px",d.position.h="left"),d.position.h_by=this.localName),d.position.v||("bottom"===this.valign?(a.style.bottom=f.h-c.bottom-e.bottom+"px",d.position.v="bottom"):(a.style.top=c.top-e.top+"px",d.position.v="top"),d.position.v_by=this.localName),(d.position.h_by||d.position.v_by)&&(a.style.position="fixed")},positionNestedTarget:function(){var a=this.target,b=this.relatedTarget,c=a.offsetParent,d=b.offsetParent;window.ShadowDOMPolyfill&&(c=wrap(c),d=wrap(d)),c!==d&&c!==b&&console.warn("core-dropdown-overlay: dropdown's offsetParent must be the relatedTarget or the relatedTarget's offsetParent!");var e=this.dimensions,f=e.margin,g=c===b;e.position.h||("right"===this.halign?(a.style.right=(g?0:c.offsetWidth-b.offsetLeft-b.offsetWidth)-f.right+"px",e.position.h="right"):(a.style.left=(g?0:b.offsetLeft)-f.left+"px",e.position.h="left"),e.position.h_by=this.localName),e.position.v||("bottom"===this.valign?(a.style.bottom=(g?0:c.offsetHeight-b.offsetTop-b.offsetHeight)-f.bottom+"px",e.position.v="bottom"):(a.style.top=(g?0:b.offsetTop)-f.top+"px",e.position.v="top"),e.position.v_by=this.localName)}})}(),Polymer("paper-dropdown-transition",{publish:{duration:500},setup:function(a){this["super"](arguments);var b={top:"0%",left:"0%",bottom:"100%",right:"100%"},c=a.$.background;c.style.webkitTransformOrigin=b[a.halign]+" "+b[a.valign],c.style.transformOrigin=b[a.halign]+" "+b[a.valign]},transitionOpened:function(a,b){if(this["super"](arguments),b){this.player&&this.player.cancel();var c=Number(a.getAttribute("duration"))||this.duration,d=[],e=a.getBoundingClientRect(),f=a.$.ripple,g=.2;d.push(new Animation(f,[{opacity:.9,transform:"scale(0)"},{opacity:.9,transform:"scale(1)"}],{duration:c*g})),d.push(new Animation(a.$.background,[{opacity:0,transform:"scale(0)"},{opacity:0,transform:"scale(0)"}],{duration:0,delay:0,fill:"forwards"}));var h=a.$.background,i=40/e.width,j=40/e.height;d.push(new Animation(h,[{opacity:.9,transform:"scale("+i+","+j+")"},{opacity:1,transform:"scale("+Math.max(i,.95)+","+Math.max(j,.5)+")"},{opacity:1,transform:"scale(1, 1)"}],{delay:c*g,duration:c*(1-g),fill:"forwards"}));var k=a.querySelector(".menu");if(k){var l=k.items||k.children.array(),m=g+(1-g)/2,n=c*(1-m)/l.length,o="bottom"===this.valign;l.forEach(function(a,b){d.push(new Animation(a,[{opacity:0},{opacity:1}],{delay:c*m+n*(o?l.length-1-b:b),duration:n,fill:"both"}))}.bind(this)),d.push(new Animation(a.$.scroller,[{opacity:1},{opacity:1}],{delay:c*m,duration:n*l.length,fill:"both"}))}else d.push(new Animation(a.$.scroller,[{opacity:0},{opacity:1}],{delay:c*(g+(1-g)/2),duration:.5*c,fill:"both"}));var p=new AnimationGroup(d,{easing:"cubic-bezier(0.4, 0, 0.2, 1)"});this.player=document.timeline.play(p),this.player.onfinish=function(){this.fire("core-transitionend",this,a)}.bind(this)}else this.fire("core-transitionend",this,a)}}),Polymer("paper-dropdown",{publish:{transition:"paper-dropdown-transition"},ready:function(){this["super"](),this.sizingTarget=this.$.scroller}}),function(){var a={publish:{label:"Select an item",openedIcon:"arrow-drop-up",closedIcon:"arrow-drop-down"},selectedItemLabel:"",overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction","core-select":"selectAction"},activateAction:function(a){this.opened=!1},selectAction:function(a){var b=a.detail;b.isSelected?(this.$.label.classList.add("selectedItem"),this.selectedItemLabel=b.item.label||b.item.textContent):(this.$.label.classList.remove("selectedItem"),this.selectedItemLabel="")}};Polymer.mixin2(a,Polymer.CoreFocusable),Polymer("paper-dropdown-menu",a)}(),function(){function a(a){return a.id||(a.id="core-label-"+b++),a.id}var b=0;Polymer("core-label",{publish:{"for":{reflect:!0,value:""}},eventDelegates:{tap:"tapHandler"},created:function(){a(this),this._forElement=null},ready:function(){this["for"]||(this._forElement=this.querySelector("[for]"),this._tie())},tapHandler:function(a){this._forElement&&a.target!==this._forElement&&(this._forElement.focus(),this._forElement.click(),this.fire("tap",null,this._forElement))},_tie:function(){this._forElement&&this._forElement.setAttribute("aria-labelledby",this.id)},_findScope:function(){for(var a=this.parentNode;a&&a.parentNode;)a=a.parentNode;return a},forChanged:function(a,b){this._forElement&&this._forElement.removeAttribute("aria-labelledby");var c=this._findScope();c&&(this._forElement=c.querySelector(b),this._forElement&&this._tie())}})}(),Polymer("volume-slider",{created:function(){this.volume=this.volume||100},volumeChanged:function(){var a=document.getElementById("audio");a.volume=this.volume/100,chrome.storage.sync.set({volume:this.volume})}}),Polymer("subsonic-login",{timer:0,ready:function(){"use strict";this.post=[],this.app=document.getElementById("tmpl"),this.urlError=chrome.i18n.getMessage("urlError"),this.urlLabel=chrome.i18n.getMessage("urlLabel"),this.usernameError=chrome.i18n.getMessage("usernameError"),this.usernameLabel=chrome.i18n.getMessage("usernameLabel"),this.passwordLabel=chrome.i18n.getMessage("passwordLabel"),this.showPass=chrome.i18n.getMessage("showPass"),this.hideThePass=chrome.i18n.getMessage("hidePass"),this.submitButton=chrome.i18n.getMessage("submitButton")},submit:function(){"use strict";if(this.invalid1&&this.invalid2&&void 0===this.post.version)this.app.doToast("URL, Username & Version Required");else if(this.invalid1)this.app.doToast("URL Required");else if(this.invalid2)this.app.doToast("Username Required");else if(!this.invalid1&&!this.invalid2&&!this.invalid3){var a=this.post.url.substr(-1);"/"===a&&(this.post.url=this.post.url.substring(0,this.post.url.length-1)),this.$.ajax.go()}},hidePass:function(a,b,c){"use strict";var d=this.$.password.type,e=this.$.showPass,f=this.timer;"text"===d?(this.$.password.type="password",e.innerHTML=this.showPass,f&&(clearTimeout(f),f=0)):(this.$.password.type="text",e.innerHTML=this.hideThePass,f=setTimeout(function(){this.$.password.type="password",e.innerHTML=this.showPass,f=0}.bind(this),15e3))},responseChanged:function(){"use strict";var a=document.getElementById("wall");this.response&&("ok"===this.response["subsonic-response"].status?(chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass}),this.app.url=this.post.url,this.app.user=this.post.user,this.app.pass=this.post.pass,this.app.userDetails(),this.app.version=this.response["subsonic-response"].version,this.app.doToast("Loading Data"),this.app.tracker.sendEvent("API Version",this.response["subsonic-response"].version),this.app.$.firstRun.close(),this.app.doXhr(this.url+"/rest/getMusicFolders.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic","json",function(a){this.app.mediaFolders=a.target.response["subsonic-response"].musicFolders.musicFolder,a.target.response["subsonic-response"].musicFolders.musicFolder[1]||(this.app.$.sortBox.style.display="none")}.bind(this)),setTimeout(function(){a.doAjax()},100)):(console.log(this.response),this.app.doToast(this.response["subsonic-response"].error.message)))},errorChanged:function(){"use strict";0===this.error.statusCode&&this.app.doToast(chrome.i18n.getMessage("connectionError"))},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version}}),Polymer("paper-radio-button",{publish:{checked:{value:!1,reflect:!0},label:"",toggles:!1,disabled:{value:!1,reflect:!0}},eventDelegates:{tap:"tap"},tap:function(){if(!this.disabled){var a=this.checked;this.toggle(),this.checked!==a&&this.fire("change")}},toggle:function(){this.checked=!this.toggles||!this.checked},checkedChanged:function(){this.setAttribute("aria-checked",this.checked?"true":"false"),this.fire("core-change")},labelChanged:function(){this.setAttribute("aria-label",this.label)}}),Polymer("paper-toggle-button",{checked:!1,disabled:!1,eventDelegates:{down:"downAction",up:"upAction",tap:"tap",trackstart:"trackStart",trackx:"trackx",trackend:"trackEnd"},downAction:function(a){var b=this.$.ink.getBoundingClientRect();this.$.ink.downAction({x:b.left+b.width/2,y:b.top+b.height/2})},upAction:function(a){this.$.ink.upAction()},tap:function(){this.disabled||(this.checked=!this.checked,this.fire("change"))},trackStart:function(a){this.disabled||(this._w=this.$.toggleBar.offsetWidth/2,a.preventTap())},trackx:function(a){this._x=Math.min(this._w,Math.max(0,this.checked?this._w+a.dx:a.dx)),this.$.toggleButton.classList.add("dragging");var b=this.$.toggleButton.style;b.webkitTransform=b.transform="translate3d("+this._x+"px,0,0)"},trackEnd:function(){var a=this.$.toggleButton.style;a.transform=a.webkitTransform="",this.$.toggleButton.classList.remove("dragging");var b=this.checked;this.checked=Math.abs(this._x)>this._w/2,this.checked!==b&&this.fire("change")},checkedChanged:function(){this.setAttribute("aria-pressed",Boolean(this.checked)),this.fire("core-change")}}),Polymer("settings-menu",{post:{},manifest:chrome.runtime.getManifest(),urlError:chrome.i18n.getMessage("urlError"),urlLabel:chrome.i18n.getMessage("urlLabel"),usernameError:chrome.i18n.getMessage("usernameError"),usernameLabel:chrome.i18n.getMessage("usernameLabel"),passwordLabel:chrome.i18n.getMessage("passwordLabel"),showPass:chrome.i18n.getMessage("showPass"),hideThePass:chrome.i18n.getMessage("hidePass"),submitButton:chrome.i18n.getMessage("submitButton"),bitrateLabel:chrome.i18n.getMessage("bitrateLabel"),cacheDetails:chrome.i18n.getMessage("cacheDetails"),clearCacheLabel:chrome.i18n.getMessage("clearCacheLabel"),clearSettingsLabel:chrome.i18n.getMessage("clearSettingsLabel"),appName:chrome.i18n.getMessage("appName"),licenseInfoLink:chrome.i18n.getMessage("licenseInfoLink"),showLicenseLabel:chrome.i18n.getMessage("showLicenseLabel"),speeds:[96,128,192,256,320],timer:0,created:function(){this.elementReady=!1},domReady:function(){this.app=document.getElementById("tmpl"),this.wall=document.getElementById("wall"),this.outputVersion(this.manifest),setTimeout(function(){this.elementReady=!0}.bind(this),500)},outputVersion:function(a){this.polysonicVersion=a.version,console.log("App version: "+this.polysonicVersion)},validate:function(a){"use strict";var b=this.$.validate.querySelectorAll("paper-input-decorator");Array.prototype.forEach.call(b,function(a){a.isInvalid=!a.querySelector("input").validity.valid}),a()},submit:function(){"use strict";this.validate(function(){var a=this.$.input1.classList.contains("invalid"),b=this.$.input2.classList.contains("invalid"),c=this.$.input3.classList.contains("invalid");if(a&&b&&void 0===this.post.version?this.app.doToast("URL, Username & Version Required"):a?this.app.doToast("URL Required"):b?this.app.doToast("Username Required"):void 0===this.version&&this.app.doToast("Version Required"),!a&&!b&&!c&&void 0!==this.post.version&&void 0!==this.post.bitRate){var d=this.post.url.substr(-1);"/"===d&&(this.post.url=this.post.url.substring(0,this.post.url.length-1)),this.$.ajax.go(),this.wall.clearData(function(){this.wall.doAjax()}.bind(this))}}.bind(this))},hidePass:function(a,b,c){"use strict";var d=this.$.password.type,e=this.$.showPass,f=this.timer;"text"===d?(this.$.password.type="password",e.innerHTML=this.showPass,f&&(clearTimeout(f),f=0)):(this.$.password.type="text",e.innerHTML=this.hideThePass,f=setTimeout(function(){this.$.password.type="password",e.innerHTML=this.showPass,f=0}.bind(this),15e3))},methodSelect:function(){this.async(function(){chrome.storage.sync.set({queryMethod:this.post.queryMethod}),this.app.queryMethod=this.post.queryMethod,console.log("Query Method: "+this.post.queryMethod)})},doClearCache:function(){this.clearCache(function(){this.app.$.recommendReloadDialog.open()}.bind(this))},clearCache:function(a){var b=indexedDB.deleteDatabase("albumInfo");b.onsuccess=function(){console.log("Deleted database successfully"),this.app.createObjectStore(),this.app.calculateStorageSize()}.bind(this),b.onerror=function(){console.log("Error deleting database"),this.app.calculateStorageSize()}.bind(this),b.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked"),this.app.calculateStorageSize()}.bind(this),a()},clearSettings:function(){chrome.storage.sync.clear(),this.app.url="",this.app.user="",this.app.pass="",this.app.version="",this.app.bitRate="",this.app.querySize="",this.post=[],this.clearCache(function(){this.app.$.reloadAppDialog.open()}.bind(this))},responseChanged:function(){"use strict";if(this.response)if("ok"===this.response["subsonic-response"].status){if(this.post.url!==this.url){var a=indexedDB.deleteDatabase("albumInfo");a.onsuccess=function(){console.log("Deleted database successfully"),this.app.createObjectStore()},a.onerror=function(){console.log("Error deleting database")},a.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked")}}chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass,version:this.response["subsonic-response"].version,bitRate:this.post.bitRate,querySize:this.post.querySize,queryMethod:this.post.queryMethod}),this.app.url=this.post.url,this.app.user=this.post.user,this.app.pass=this.post.pass,this.app.version=this.response["subsonic-response"].version,this.app.bitRate=this.post.bitRate,this.app.querySize=this.post.querySize,this.app.queryMethod=this.post.queryMethod,this.app.doToast("Settings Saved")}else this.app.doToast("failed"===this.response["subsonic-response"].status?this.response["subsonic-response"].error.message:"Error Connecting to Server. Check Settings")},bitRateSelect:function(){chrome.storage.sync.set({bitRate:this.post.bitRate}),this.app.bitRate=this.post.bitRate,console.log("Bitrate: "+this.post.bitRate)},querySelect:function(){chrome.storage.sync.set({querySize:this.post.querySize}),this.app.querySize=this.post.querySize,console.log("Query Size: "+this.post.querySize)},errorChanged:function(){"use strict";0===this.error.statusCode&&this.app.doToast(chrome.i18n.getMessage("connectionError"))},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version},bitRateChanged:function(){this.post.bitRate=this.bitRate},querySizeChanged:function(){this.post.querySize=this.querySize},queryMethodChanged:function(){this.post.queryMethod=this.queryMethod},showQuota:function(){this.app.calculateStorageSize(),this.$.quota.toggle()},linkGo:function(a,b,c){var d=c.attributes.link.value;window.open(d,"_blank")},analisticsToggle:function(){chrome.storage.sync.set({analistics:this.app.analisticsEnabled})},getLicense:function(a,b,c){var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.getLicense(function(){d.cancel()})}}),Polymer("paper-fab",{publish:{src:"",icon:"",mini:!1,raised:!0,recenteringTouch:!0,fill:!1},iconChanged:function(a){var b=this.getAttribute("aria-label");b&&b!==a||this.setAttribute("aria-label",this.icon)}}),Polymer("animated-fab",{created:function(){this.state=this.state||"off",this.page=this.page||0,this.timer=0},domReady:function(){this.app=document.getElementById("tmpl"),this.bottomPos=16,this.ready=!0},pageChanged:function(){var a;1===this.page?(a="Player",this.state="top"):0===this.page?(a="Album Wall",this.state="off"):2===this.page?(a="Settings",this.state="off"):3===this.page?(a="Artist Details",this.state="off"):this.state="off",0===this.page&&"podcast"===this.showing&&(this.state="podcast"),document.getElementById("tmpl").tracker.sendAppView(a)},playingChanged:function(){this.playing&&document.getElementById("tmpl").playThis()},isNowPlayingChanged:function(a,b){a?(this.bottomPos=105,clearTimeout(this.timer),this.timer=0):this.ready&&this.app&&(this.app.playlist[0]?this.timer=setTimeout(function(){this.bottomPos=16}.bind(this),12e4):this.bottomPos=16)}}),function(){var a=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),b=a&&a[1]>=8;Polymer("core-list",Polymer.mixin({publish:{data:null,groups:null,scrollTarget:null,selectionEnabled:!0,multi:!1,selection:null,grid:!1,width:null,height:200,runwayFactor:4},eventDelegates:{tap:"tapHandler","core-resize":"updateSize"},_scrollTop:0,observe:{"isAttached data grid width template scrollTarget":"initialize","multi selectionEnabled":"_resetSelection"},ready:function(){this._boundScrollHandler=this.scrollHandler.bind(this),this._boundPositionItems=this._positionItems.bind(this),this._oldMulti=this.multi,this._oldSelectionEnabled=this.selectionEnabled,this._virtualStart=0,this._virtualCount=0,this._physicalStart=0,this._physicalOffset=0,this._physicalSize=0,this._physicalSizes=[],this._physicalAverage=0,this._itemSizes=[],this._dividerSizes=[],this._repositionedItems=[],this._aboveSize=0,this._nestedGroups=!1,this._groupStart=0,this._groupStartIndex=0},attached:function(){this.isAttached=!0,this.template=this.querySelector("template"),this.template.bindingDelegate||(this.template.bindingDelegate=this.element.syntax),this.resizableAttachedHandler()},detached:function(){this.isAttached=!1,this._target&&this._target.removeEventListener("scroll",this._boundScrollHandler),this.resizableDetachedHandler()},updateSize:function(){this._positionPending||this._needItemInit||(this._resetIndex(this._getFirstVisibleIndex()||0),this.initialize())},_resetSelection:function(){this._oldMulti!=this.multi&&!this.multi||this._oldSelectionEnabled!=this.selectionEnabled&&!this.selectionEnabled?(this._clearSelection(),this.refresh()):this.selection=this.$.selection.getSelection(),this._oldMulti=this.multi,this._oldSelectionEnabled=this.selectionEnabled},_adjustVirtualIndex:function(a,b){if(0!==this._targetSize){for(var c=0,d=0;d=this._virtualStart)break;var i=Math.max(g.addedCount-g.removed.length,h-this._virtualStart);if(c+=i,this._physicalStart+=i,this._virtualStart+=i,this._grouped){if(b)f=g.index;else{var j=this.groupForVirtualIndex(g.index);e=j.group,f=j.groupIndex}e==this._groupStart&&f0;){var b=this.getGroupLen()-this._groupStartIndex-1;a>b?(a-=b+1,this._groupStart++,this._groupStartIndex=0):(this._groupStartIndex+=a,a=0)}for(;0>a;)-a>this._groupStartIndex?(a+=this._groupStartIndex,this._groupStart--,this._groupStartIndex=this.getGroupLen()):(this._groupStartIndex+=a,a=this.getGroupLen())}this.grid&&(a=this._grouped?this._groupStartIndex%this._rowFactor:this._virtualStart%this._rowFactor,a&&this.changeStartIndex(-a))},getRowCount:function(a){if(this.grid){if(this._grouped){if(0>a){if(this._groupStartIndex>0)return-Math.min(this._rowFactor,this._groupStartIndex);var b=this.getGroupLen(this._groupStart-1);return-Math.min(this._rowFactor,b%this._rowFactor||this._rowFactor)}return Math.min(this._rowFactor,this.getGroupLen()-this._groupStartIndex)}return a*this._rowFactor}return a},_virtualToPhysical:function(a){var b=(a-this._physicalStart)%this._physicalCount;return 0>b?this._physicalCount+b:b},groupForVirtualIndex:function(a){if(this._grouped){var b;for(b=0;ba)break;a-=c}return{group:b,groupIndex:a}}return{}},virtualIndexForGroup:function(a,b){for(b=b?Math.min(b,this.getGroupLen(a)):0,a--;a>=0;)b+=this.getGroupLen(a--);return b},dataForIndex:function(a,b,c){if(this.data){if(!this._nestedGroups)return this.data[a];if(ad?-1:d>0?1:0,Math.abs(d)>Math.max(this._physicalSize,this._targetSize))b=Math.round(d/this._physicalAverage*this._rowFactor),b=Math.max(b,-this._virtualStart),b=Math.min(b,this._virtualCount-this._virtualStart-1),this._physicalOffset+=Math.max(d,-this._physicalOffset),this.changeStartIndex(b);else{var e=this._aboveSize+this._physicalOffset,f=.3*Math.max((this._physicalSize-this._targetSize,this._physicalSize));this._upperBound=e+f,this._lowerBound=e+this._physicalSize-this._targetSize-f;var g=this._dir>0?this._upperBound:this._lowerBound;if(this._dir>0&&this._scrollTop>g||this._dir<0&&this._scrollTop0&&(this._dir<0&&this._virtualStart>0||this._dir>0&&this._virtualStart0?this._virtualStart:this._virtualStart+this._physicalCount-1),j=this._physicalSizes[i];h-=j;var k=this.getRowCount(this._dir);this._dir>0&&(this._physicalOffset+=j),this.changeStartIndex(k),this._dir<0&&this._repositionedItems.push(this._virtualStart)}}}this._updateItems(!d)&&(Observer.hasObjectObserve?this.async(this._boundPositionItems):(Platform.flush(),Platform.endOfMicrotask(this._boundPositionItems)))},_updateItems:function(a){var b,c,d,e=!1,f=this._groupStart,g=this._groupStartIndex;for(b=0;b=this.getGroupLen(f)&&(g=0,f++);return e},_positionItems:function(){var a,b,c,d;if(this.updateMetrics(),this._dir<0){for(;this._repositionedItems.length;)b=this._repositionedItems.pop(),c=this._virtualToPhysical(b),this._physicalOffset-=this._physicalSizes[c];this._scrollTop+this._targetSize=this._rowFactor&&(f=0,h+=i),g=this._rowMargin+f*this.width):h+=i;this._scrollTop>=0&&this._updateViewportHeight()},_updateViewportHeight:function(){var a=Math.max(this._virtualCount-this._virtualStart-this._physicalCount,0);a=Math.ceil(a/this._rowFactor);var b=this._physicalOffset+this._physicalSize+a*this._physicalAverage;this._viewportSize!=b&&(this._viewportSize=b,this.$.viewport.style.height=this._viewportSize+"px",this.syncScroller())},_updateScrollPosition:function(a){var b=0===this._virtualStart?this._physicalOffset:Math.min(a+this._physicalOffset,0);b&&(this.adjustPositionAllowed&&(this._scrollTop=this.setScrollTop(a-b)),this._physicalOffset-=b)},tapHandler:function(a){var b=a.target,c=a.path;this.selectionEnabled&&b!==this&&requestAnimationFrame(function(){var a=window.ShadowDOMPolyfill?wrap(document.activeElement):this.shadowRoot.activeElement;if((!a||a==this||a.parentElement==this||document.activeElement==document.body)&&"input"!=c[0].localName&&"button"!=c[0].localName&&"select"!=c[0].localName){var d=b.templateInstance&&b.templateInstance.model;if(d){var e=this.dataForIndex(d.index,d.groupIndex,d.groupItemIndex),f=this._physicalItems[d.physicalIndex];this.$.selection.select(this.multi||e!=this.selection?e:null),this.asyncFire("core-activate",{data:e,item:f})}}}.bind(this))},selectedHandler:function(a,b){this.selection=this.$.selection.getSelection();var c=this.indexesForData(b.item);this._selectedData.set(b.item,b.isSelected),c.physical>=0&&c.virtual>=0&&this.refresh()},selectItem:function(a){if(this.selectionEnabled){var b=this.data[a];b&&this.$.selection.select(b)}},setItemSelected:function(a,b){var c=this.data[a];c&&this.$.selection.setItemSelected(c,b)},indexesForData:function(a){var b=-1,c=0;if(this._nestedGroups)for(var d=0;db)){b+=c;break}c+=this.data[d].length}else b=this.data.indexOf(a);var e=this.virtualToPhysicalIndex(b);return{virtual:b,physical:e}},virtualToPhysicalIndex:function(a){for(var b=0,c=this._physicalData.length;c>b;b++)if(this._physicalData[b].index===a)return b;return-1},clearSelection:function(){this._clearSelection(),this.refresh()},_clearSelection:function(){this._selectedData=new WeakMap,this.$.selection.clear(),this.selection=this.$.selection.getSelection()},_getFirstVisibleIndex:function(){for(var a=0;a=this._scrollTop-this._aboveSize)return b}},_resetIndex:function(a){a=Math.min(a,this._virtualCount-1),a=Math.max(a,0),this.changeStartIndex(a-this._virtualStart),this._scrollTop=this.setScrollTop(this._aboveSize+a/this._rowFactor*this._physicalAverage),this._physicalOffset=this._scrollTop-this._aboveSize,this._dir=0},scrollToItem:function(a){this.scrollToGroupItem(null,a)},scrollToGroup:function(a){this.scrollToGroupItem(a,0)},scrollToGroupItem:function(a,b){null!=a&&(b=this.virtualIndexForGroup(a,b)),this._resetIndex(b),this.refresh()}},Polymer.CoreResizable))}(),Polymer("artist-details",{created:function(){this.data=[]},domReady:function(){this.app=document.getElementById("tmpl"),this.scrollTarget=this.app.appScroller()},queryData:function(){this.data.length=0,this.async(function(){this.app.doXhr(this.app.buildUrl("getArtist",{id:this.artistId}),"json",function(a){for(var b=a.target.response["subsonic-response"].artist.album,c=b.length,d=0;c>d;d++)this.data.push(b[d]),d===c-1&&(this.app.page=3,this.app.dataLoading=!1)}.bind(this))})},playSomething:function(a,b){var c=this.$.all.querySelector("#"+a);console.log(c),c.$.detailsDialog.close(),c.doPlayback(),this.async(b)}}),Polymer("download-manager",{downloads:[],app:document.querySelector("#tmpl"),removeDownloadLabel:chrome.i18n.getMessage("removeDownloadLabel"),saveFileLabel:chrome.i18n.getMessage("saveFileLabel"),pauseDownload:chrome.i18n.getMessage("abortDownload"),hasSaved:!1,removeThis:function(a,b,c){this.parentNode.removeChild(this),this.async(function(){0===this.app.$.downloads.childElementCount&&(this.app.isDownloading=!1)},null,100)},formatBytes:function(a){return 1024>a?a+" Bytes":1048576>a?(a/1024).toFixed(2)+" KB":1073741824>a?(a/1048576).toFixed(2)+" MB":(a/1073741824).toFixed(2)+" GB"},doXhr:function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.responseType=b,d.onload=c,d.onerror=this.errorHandler,d.onprogress=this.xhrProgress.bind(this),d.send(),this.request=d},xhrProgress:function(a){this.progress=Math.floor(a.loaded/this.downloadSize*100);var b=new Date,c=b.getTime(),d=8*a.loaded,e=(c-this.start)/1e3,f=Math.round(d/e),g=(f/1024).toFixed(2),h=(g/1024).toFixed(2);1>h?this.rate=g+" Kbps":this.rate=h+" Mbps",this.output=this.formatBytes(a.loaded)+" of "+this.downloadSizeReadable+" Downloaded"},progressChanged:function(){this.progress&&100===this.progress&&this.app.doToast(chrome.i18n.getMessage("downloadFinished"))},errorHandler:function(a){console.error(a)},waitForIO:function(a,b){var c=Date.now(),d=function(){return a.readyState===a.WRITING&&Date.now()-c<4e3?void setTimeout(d,100):void(a.readyState===a.WRITING?(console.error("Write operation taking too long, aborting! (current writer readyState is "+a.readyState+")"),a.abort()):b())};setTimeout(d,100)},writeFileEntry:function(a,b,c){a.createWriter(function(a){a.onerror=this.errorHandler,a.onwriteend=c,a.truncate(b.size),this.waitForIO(a,function(){a.seek(0),a.write(b)})}.bind(this),this.errorHandler)},downloadTrack:function(a,b){var c=this.app.buildUrl("download",{id:a}),d=this.app.buildUrl("getSong",{id:a});this.doXhr(d,"json",function(a){var d=a.target.response["subsonic-response"].song;this.fileName=d.artist+" - "+d.title+"."+d.suffix,this.downloadSize=d.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize),this.app.doToast(chrome.i18n.getMessage("downloadStarted")),b(),this.isDownloading=!0;var e=new Date;this.start=e.getTime(),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1}.bind(this))}.bind(this))},downloadAlbum:function(a,b){var c=this.app.buildUrl("download",{id:a.id});this.fileName=a.artist+" - "+a.album+".zip",this.isDownloading=!0,this.downloadSize=a.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize);var d=new Date;this.start=d.getTime(),this.app.doToast(chrome.i18n.getMessage("downloadStarted")),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1,this.progress=100,b()}.bind(this))},downloadSinglePodcast:function(a,b){var c=this.app.buildUrl("download",{id:a.id});this.app.doNotify(this.app.downloadStarted),this.fileName=a.title.replace(":","")+"."+a.suffix,this.isDownloading=!0,this.downloadSize=a.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize);var d=new Date;this.start=d.getTime(),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1,this.progress=100,b()}.bind(this))},doSave:function(){this.output="Saving.. "+this.downloadSizeReadable;var a={type:"saveFile",suggestedName:this.fileName};chrome.fileSystem.chooseEntry(a,function(a){a?this.writeFileEntry(a,this.blob,function(){this.output="File Saved "+this.downloadSizeReadable,this.hasSaved=!0}.bind(this)):console.error("Error Downloading",e)}.bind(this))},abortDownload:function(){this.request.abort(),this.removeThis()}}),Polymer("mini-player",{ready:function(){"use strict";this.timer=0},domReady:function(){"use strict";this.app=document.getElementById("tmpl"),this.label=chrome.i18n.getMessage("nowPlayingTitle")},setPlaying:function(a){"use strict";this.img=a.cover,this.artist=a.artist,this.track=a.title},waitingToPlayChanged:function(){"use strict";this.waitingToPlay?this.$.spinner.hidden=!1:this.$.spinner.hidden=!0},isNowPlayingChanged:function(a,b){"use strict";a?(this.page=1,clearTimeout(this.timer),this.timer=0):this.app&&(this.app.playlist[0]?this.timer=setTimeout(function(){this.page=0}.bind(this),12e4):this.page=0),this.app&&(this.app.$.audio.paused?this.$.playButton.icon="av:play-arrow":this.$.playButton.icon="av:pause")},toPlayer:function(){"use strict";this.app.nowPlaying()},playPause:function(){"use strict";this.app.$.audio.paused?this.$.playButton.icon="av:pause":this.$.playButton.icon="av:play-arrow",this.app.playPause()},openPlaylist:function(){"use strict";this.app.showPlaylist("bottom")},progressClick:function(a,b){"use strict";var c=this.app.$.audio,d=this.progress/100;c.currentTime=c.duration-(c.duration-c.duration*d)}}),function(){"use strict";function a(a){return 1024>a?a+" Bytes":1048576>a?(a/1024).toFixed(2)+" KB":1073741824>a?(a/1048576).toFixed(2)+" MB":(a/1073741824).toFixed(2)+" GB"}function b(){f.$.audio.paused&&(f.doShufflePlayback(),f.dataLoading=!1,f.closePlaylists())}function c(a){"ok"===a.target.response["subsonic-response"].status?(f.doToast(chrome.i18n.getMessage("playlistCreated")),f.$.createPlaylist.close(),f.savingPlaylist=!1):(f.doToast(chrome.i18n.getMessage("playlistError")),f.savingPlaylist=!1)}function d(a){var b=[];for(var c in a)c=encodeURIComponent(c),b.push(null===a[c]?c:c+"="+encodeURIComponent(a[c]));return b.join("&")}function e(a){for(var b="",c="ABCD/EFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",d=0;a>d;d++)b+=c.charAt(Math.floor(Math.random()*c.length));return b}var f=document.querySelector("#tmpl");f.addEventListener("template-bound",function(){f.sizePlayer(),chrome.storage.sync.get(function(a){void 0===a.url&&f.$.firstRun.open(),f.url=a.url,f.user=a.user,f.pass=a.pass,f.listMode="cover",f.bitRate=a.bitRate||320,f.shuffleSettings.size=f.shuffleSettings.size||"50",f.version="1.11.0",f.querySize=40,f.volume=a.volume||100,f.queryMethod=a.queryMethod||"ID3",f.colorThiefEnabled=!0,f.dataLoading=!1,f.params={u:f.user,v:f.version,c:"PolySonic",f:"json"},f.url&&f.user&&f.pass&&f.version&&f.doXhr(f.buildUrl("ping",""),"json",function(b){200===b.target.status?(f.version=b.target.response["subsonic-response"].version,"ok"===b.target.response["subsonic-response"].status?(f.userDetails(),console.log("Connected to Subconic loading data"),f.doXhr(f.buildUrl("getMusicFolders",""),"json",function(b){f.mediaFolders=b.target.response["subsonic-response"].musicFolders.musicFolder,f.folder=a.mediaFolder||0,b.target.response["subsonic-response"].musicFolders.musicFolder[1]||(f.$.sortBox.style.display="none"),f.tracker.sendAppView("Album Wall")})):(f.tracker.sendEvent("Connection Error",b.target.response["subsonic-response"].error.meessage),f.$.firstRun.toggle(),f.doToast(b.target.response["subsonic-response"].error.meessage))):(f.tracker.sendEvent("Connection Error",b.target.response["subsonic-response"].error.meessage),f.$.firstRun.toggle(),f.doToast(b.target.response["subsonic-response"].error.meessage))})});var a=f.$.audio;f.appScroller().onscroll=f.scrollCallback,a.onwaiting=f.playerProgress,a.onprogress=f.buffering,a.ontimeupdate=f.playerProgress,a.onended=f.nextTrack,a.onerror=function(a){f.page=0,console.error("audio playback error ",a),f.doToast("Audio Playback Error"),f.tracker.sendEvent("Audio Playback Error",a.target)},f.service=analytics.getService("PolySonic"),f.tracker=this.service.getTracker("UA-50154238-6")}),f.shuffleSettings={},f.appName=chrome.i18n.getMessage("appName"),f.appDesc=chrome.i18n.getMessage("appDesc"),f.folderSelector=chrome.i18n.getMessage("folderSelector"),f.shuffleButton=chrome.i18n.getMessage("shuffleButton"),f.artistButton=chrome.i18n.getMessage("artistButton"),f.podcastButton=chrome.i18n.getMessage("podcastButton"),f.favoritesButton=chrome.i18n.getMessage("favoritesButton"),f.searchButton=chrome.i18n.getMessage("searchButton"),f.settingsButton=chrome.i18n.getMessage("settingsButton"),f.nowPlayingLabel=chrome.i18n.getMessage("nowPlayingLabel"),f.folderSelectorLabel=chrome.i18n.getMessage("folderSelectorLabel"),f.clearQueue=chrome.i18n.getMessage("clearQueue"),f.volumeLabel=chrome.i18n.getMessage("volumeLabel"),f.analistics=chrome.i18n.getMessage("analistics"),f.accept=chrome.i18n.getMessage("accept"),f.decline=chrome.i18n.getMessage("decline"),f.shuffleOptionsLabel=chrome.i18n.getMessage("shuffleOptionsLabel"),f.optional=chrome.i18n.getMessage("optional"),f.artistLabel=chrome.i18n.getMessage("artistLabel"),f.albumLabel=chrome.i18n.getMessage("albumLabel"),f.genreLabel=chrome.i18n.getMessage("genreLabel"),f.songReturn=chrome.i18n.getMessage("songReturn"),f.playButton=chrome.i18n.getMessage("playButton"),f.yearError=chrome.i18n.getMessage("yearError"),f.releasedAfter=chrome.i18n.getMessage("releasedAfter"),f.releasedBefore=chrome.i18n.getMessage("releasedBefore"),f.submitButton=chrome.i18n.getMessage("submitButton"),f.deleteConfirm=chrome.i18n.getMessage("deleteConfirm"),f.noResults=chrome.i18n.getMessage("noResults"),f.urlError=chrome.i18n.getMessage("urlError"),f.podcastSubmissionLabel=chrome.i18n.getMessage("podcastSubmissionLabel"),f.diskUsed=chrome.i18n.getMessage("diskused"),f.diskRemaining=chrome.i18n.getMessage("diskRemaining"),f.playlistsButton=chrome.i18n.getMessage("playlistsButton"),f.createPlaylistLabel=chrome.i18n.getMessage("createPlaylistLabel"),f.playlistLabel=chrome.i18n.getMessage("playlistLabel"),f.reloadAppLabel=chrome.i18n.getMessage("reloadApp"),f.settingsDeleted=chrome.i18n.getMessage("settingsDeleted"),f.recommendReload=chrome.i18n.getMessage("recommendReload"),f.jumpToLabel=chrome.i18n.getMessage("jumpToLabel"),f.closeLabel=chrome.i18n.getMessage("closeLabel"),f.moreOptionsLabel=chrome.i18n.getMessage("moreOptionsLabel"),f.refreshPodcastLabel=chrome.i18n.getMessage("refreshPodcast"),f.registeredEmail=chrome.i18n.getMessage("registeredEmail"),f.licenseKey=chrome.i18n.getMessage("licenseKey"),f.keyDate=chrome.i18n.getMessage("keyDate"),f.validLicense=chrome.i18n.getMessage("validLicense"),f.invalidLicense=chrome.i18n.getMessage("invalidLicense"),f.adjustVolumeLabel=chrome.i18n.getMessage("adjustVolumeLabel"),f.showDownloads=chrome.i18n.getMessage("showDownloads"),f.shuffleSizes=[20,40,50,75,100,200],f.sortTypes=[{sort:"newest",name:chrome.i18n.getMessage("newButton")},{sort:"alphabeticalByArtist",name:chrome.i18n.getMessage("byArtistButton")},{sort:"alphabeticalByName",name:chrome.i18n.getMessage("titleButton")},{sort:"frequent",name:chrome.i18n.getMessage("frequentButton")},{sort:"recent",name:chrome.i18n.getMessage("recentButton")}],f.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,f.IDBTransaction=window.IDBTransaction||window.webkitIDBTransaction||window.OIDBTransaction||window.msIDBTransaction,f.dbVersion=1,f.request=f.indexedDB.open("albumInfo",f.dbVersion),f.request.onerror=function(){console.log("Error creating/accessing IndexedDB database")},f.request.onsuccess=function(){if(console.log("Success creating/accessing IndexedDB database"),f.db=f.request.result,f.db.setVersion&&f.db.version!==f.dbVersion){var a=f.db.setVersion(this.dbVersion);a.onsuccess=function(){f.createObjectStore(this.db)}}},f.request.onupgradeneeded=function(a){f.createObjectStore(a.target.result)},f.createObjectStore=function(a){console.log("Creating objectStore"),a.createObjectStore("albumInfo")},f.dbErrorHandler=function(a){console.error(a)},f.getImageFile=function(a,b,c){f.doXhr(a,"blob",function(a){f.putInDb(new Blob([a.target.response],{type:"image/jpeg"}),b,c),console.log("Image Added to indexedDB "+b)})},f.putInDb=function(a,b,c){var d=f.db.transaction(["albumInfo"],"readwrite");b&&(d.objectStore("albumInfo").put(a,b),d.objectStore("albumInfo").get(b).onsuccess=c)},f.calculateStorageSize=function(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(b,c){f.storageQuota=f.diskUsed+": "+a(b)+", "+f.diskRemaining+": "+a(c)},function(a){console.log("Error",a)})},f.getDbItem=function(a,b){if(a){var c=f.db.transaction(["albumInfo"],"readwrite"),d=c.objectStore("albumInfo").get(a);d.onsuccess=b,d.onerror=f.dbErrorHandler}},f.doXhr=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.responseType=b,d.onload=c,d.onerror=function(d){f.dataLoading=!1,f.doToast(chrome.i18n.getMessage("connectionError")),f.async(function(){f.doToast(chrome.i18n.getMessage("reconnecting")),f.doXhr(a,b,c)},null,15e3)},d.send()},f.playlist=[],f.page=f.page||0,f.pageLimit=!1,f.reloadApp=function(){chrome.runtime.reload()},f.minimize=function(){chrome.app.window.current().minimize()},f.openDownloads=function(){f.$.downloadDialog.open()},f.closeDownloads=function(){f.$.downloadDialog.close()},f.closeDrawer=function(a){f.dataLoading=!0,f.$.panel.closeDrawer(),a&&f.async(a,null,500)},f.openPanel=function(){f.$.panel.openDrawer()},f.appScroller=function(){return f.$.headerPanel.scroller},f.doToast=function(a){var b=f.$.toast;b.text=a,b.show()},f.scrollCallback=function(){var a=f.$.fab,b=f.$.wall,c=f.appScroller();0===f.page&&"off"!==a.state&&c.scrollTopf.position&&"podcast"!==b.showing?a.state="bottom":3===f.page&&"off"!==a.state&&c.scrollTopf.position&&(a.state="bottom"),f.position=c.scrollTop},f.close=function(){f.checkUnsavedDownloads(function(){window.close()},function(){this.$.unsavedDownloads.open()}.bind(this))},f.checkUnsavedDownloads=function(a,b){if(0!==this.$.downloads.childElementCount)for(var c=this.$.downloads.querySelectorAll("download-manager"),d=c.length,e=0,f=0;d>f;f++)c[f].hasSaved||(e+=1),f===d-1&&0===e?a():b();else a()},f.closeAnyway=function(){window.close()},f.getColor=function(a){var b=new ColorThief;return b.getPalette(a,4)},f.getContrast50=function(a){return parseInt(a,16)>8388607.5?"black":"white"},f.componentToHex=function(a){var b=a.toString(16);return 1===b.length?"0"+b:b},f.rgbToHex=function(a,b,c){return f.componentToHex(a)+f.componentToHex(b)+f.componentToHex(c)},f.colorThiefHandler=function(a,b,c){var d=new Image;d.src=a,d.onload=function(){var a=f.getColor(d),e=[],g=a[1][0],h=a[1][1],i=a[1][2],j=f.rgbToHex(g,h,i);e[0]="rgb("+g+","+h+","+i+");",e[1]=f.getContrast50(j),e[2]="rgba("+g+","+h+","+i+",0.4);","white"!==e[1]?e[3]="#444444":e[3]="#c8c8c8",f.putInDb(e,b+"-palette",function(){c&&c(e),console.log("Color palette saved "+b)})}},f.playAudio=function(a,b,c,d,e){for(var g=document.querySelectorAll("mini-player"),h=g.length,i=0;h>i;i++)g[i].setPlaying({artist:a,title:b,cover:d});var j=f.$.audio,k=f.$.playNotify;""===a?(f.currentPlaying=b,k.title=b):(f.currentPlaying=a+" - "+b,k.title=a+" - "+b),f.activeUser.scrobblingEnabled&&f.doXhr(f.buildUrl("scrobble",{id:e,time:(new Date).getTime()}),"json",function(a){"failed"===a.target.response["subsonic-response"].status&&(console.log("Last FM submission: "+a.target.response["subsonic-response"].status),f.tracker.sendEvent("Last FM submission","Failed"))}),j.src=c,k.icon=d,j.play(),k.show(),f.tracker.sendEvent("Audio","Playing")},f.playNext=function(a){f.playlist[a]?f.playing=a:(f.$.audio.pause(),f.clearPlaylist())},f.nextTrack=function(){f.playNext(f.playing+1)},f.lastTrack=function(){f.playNext(f.playing-1)},f.playThis=function(){f.async(function(){f.setFabColor(this.playlist[this.playing]);var a;a=""===f.playlist[f.playing].artist?f.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:f.playlist[this.playing].id}):f.buildUrl("stream",{maxBitRate:f.bitRate,id:f.playlist[f.playing].id}),f.playAudio(f.playlist[f.playing].artist,f.playlist[f.playing].title,a,f.playlist[f.playing].cover,f.playlist[f.playing].id),f.playlist[f.playing].cover?f.getImageForPlayer(f.playlist[f.playing].cover):f.defaultPlayImage()})},f.playPause=function(){var a=f.$.audio;a.paused?a.play():a.pause()},f.playPlaylist=function(a,c,d){f.dataLoading=!0,f.playlist=null,f.playlist=[],f.$.audio.pause(),f.doXhr(f.buildUrl("getPlaylist",{id:d.attributes.ident.value}),"json",function(a){for(var c=a.target.response["subsonic-response"].playlist.entry,d=c.length,e=0;d>e;e++){var g=Math.floor(c[e].duration/60),h={id:c[e].id,artist:c[e].artist,title:c[e].title,duration:g+":"+("0"+Math.floor(c[e].duration-60*g)).slice(-2),cover:"al-"+c[e].albumId};f.fixCoverArtForShuffle(h,b)}})},f.shufflePlay=function(){f.dataLoading=!0,f.shuffleLoading=!0,f.playlist=null,f.playlist=[],f.startYearInvalid||f.endYearInvalid?(f.shuffleLoading=!1,f.doToast(chrome.i18n.getMessage("invalidEntry"))):(f.$.audio.pause(),f.doXhr(f.buildUrl("getRandomSongs",f.shuffleSettings),"json",function(a){var c=a.target.response["subsonic-response"].randomSongs.song,d=c.length;if(c)for(var e=0;d>e;e++){var g=Math.floor(c[e].duration/60),h={id:c[e].id,artist:c[e].artist,title:c[e].title,duration:g+":"+("0"+Math.floor(c[e].duration-60*g)).slice(-2),cover:"al-"+c[e].albumId};f.fixCoverArtForShuffle(h,b)}else f.doToast(chrome.i18n.getMessage("noMatch")),f.shuffleLoading=!1}))},f.doShufflePlayback=function(){f.$.audio.paused&&(f.playing=0,f.playAudio(f.playlist[0].artist,f.playlist[0].title,f.buildUrl("stream",{maxBitRate:f.bitRate,id:f.playlist[0].id}),f.playlist[0].cover,f.playlist[0].id),f.getImageForPlayer(f.playlist[0].cover,function(){f.setFabColor(f.playlist[0]),f.$.shuffleOptions.close(),f.shuffleLoading=!1}))},f.clearPlaylist=function(){f.$.audio.pause(),f.$.playlistDialog.close(),f.page=0,f.playlist=null,f.playlist=[]},f.toggleVolume=function(){f.$.volumeDialog.open()},f.closeVolume=function(){f.$.volumeDialog.close()},f.volUp=function(){f.volume<100&&(f.volume=f.volume+2)},f.volDown=function(){f.volume>0&&(f.volume=f.volume-2)},f.getImageForPlayer=function(a,b){f.$.coverArt.style.backgroundImage="url('"+a+"')",f.$.playNotify.icon=a,b&&f.async(b)},f.defaultPlayImage=function(){f.$.coverArt.style.backgroundImage="url('images/default-cover-art.png')",f.$.playNotify.icon="images/default-cover-art.png"},f.buffering=function(a){var b=a.srcElement;b.duration?f.buffer=Math.floor(b.buffered.end(0)/b.duration*100):f.buffer=0,b=null},f.playerProgress=function(a){var b=a.srcElement;a&&("waiting"===a.type?f.waitingToPlay=!0:"timeupdate"===a.type&&(f.waitingToPlay=!1)),f.currentMins=Math.floor(b.currentTime/60),f.currentSecs=Math.floor(b.currentTime-60*f.currentMins),f.totalMins=Math.floor(b.duration/60),f.totalSecs=Math.floor(b.duration-60*f.totalMins),b.paused?f.$.avIcon.icon="av:play-arrow":(f.$.avIcon.icon="av:pause",b.duration?(f.playTime=f.currentMins+":"+("0"+f.currentSecs).slice(-2)+" / "+f.totalMins+":"+("0"+f.totalSecs).slice(-2),f.progress=Math.floor(b.currentTime/b.duration*100)):(f.playTime=f.currentMins+":"+("0"+f.currentSecs).slice(-2)+" / ?:??",f.progress=0)),b.paused?f.isNowPlaying=!1:f.isNowPlaying=!0,b=null},f.showApp=function(){var a=document.getElementById("loader"),b=document.getElementById("box");a.classList.contains("hide")||(a.classList.add("hide"),b.classList.add("hide"),b.classList.add("hide"),f.askAnalistics()); +c.insertBefore(d,c.firstChild),d.applyRef(b)},complete:function(a,b){"box-shadow"===b.propertyName||this.transitionProperty&&-1===b.propertyName.indexOf(this.transitionProperty)||(this.completed=!0,this.fire("core-transitionend",this,a))},ensureComplete:function(a){a.removeEventListener("transitionend",this.boundCompleteFn,!1),this.scopeClass&&a.classList.remove(this.scopeClass),this.activeClass&&a.classList.remove(this.activeClass)}})}(),function(){function a(b,c){var d,e,f,g,h=b.firstElementChild;for(e=[],f=b.shadowRoot;f;)e.push(f),f=f.olderShadowRoot;for(g=e.length-1;g>=0;g--)if(d=e[g].querySelector(c))return d;for(;h;){if(d=a(h,c))return d;h=h.nextElementSibling}return null}function b(a,c,d){var e,f,g,h,i,j=a.firstElementChild;for(g=[],f=a.shadowRoot;f;)g.push(f),f=f.olderShadowRoot;for(h=g.length-1;h>=0;h--)for(e=g[h].querySelectorAll(c),i=0;i0?"&":"?")+f);var g=this.isBodyMethod(d)?a.body||f:null;return b.open(d,c,e),a.responseType&&(b.responseType=a.responseType),a.withCredentials&&(b.withCredentials=!0),this.makeReadyStateHandler(b,a.callback),this.setRequestHeaders(b,a.headers),b.send(g),e||b.onreadystatechange(b),b},toQueryString:function(a){var b=[];for(var c in a){var d=a[c];c=encodeURIComponent(c),b.push(null==d?c:c+"="+encodeURIComponent(d))}return b.join("&")},isBodyMethod:function(a){return this.bodyMethods[(a||"").toUpperCase()]},bodyMethods:{POST:1,PUT:1,PATCH:1,DELETE:1},makeReadyStateHandler:function(a,b){a.onreadystatechange=function(){4==a.readyState&&b&&b.call(null,a.response,a)}},setRequestHeaders:function(a,b){if(b)for(var c in b)a.setRequestHeader(c,b[c])}}),Polymer("core-ajax",{url:"",handleAs:"",auto:!1,params:"",response:null,error:null,loading:!1,progress:null,method:"",headers:null,body:null,contentType:"application/x-www-form-urlencoded",withCredentials:!1,xhrArgs:null,created:function(){this.progress={}},ready:function(){this.xhr=document.createElement("core-xhr")},receive:function(a,b){this.isSuccess(b)?this.processResponse(b):this.processError(b),this.complete(b)},isSuccess:function(a){var b=a.status||0;return b>=200&&300>b},processResponse:function(a){var b=this.evalResponse(a);a===this.activeRequest&&(this.response=b),this.fire("core-response",{response:b,xhr:a})},processError:function(a){var b=this.evalResponse(a),c={statusCode:a.status,response:b};a===this.activeRequest&&(this.error=c),this.fire("core-error",{response:c,xhr:a})},processProgress:function(a,b){if(b===this.activeRequest){var c={lengthComputable:a.lengthComputable,loaded:a.loaded,total:a.total};this.progress=c}},complete:function(a){a===this.activeRequest&&(this.loading=!1),this.fire("core-complete",{response:a.status,xhr:a})},evalResponse:function(a){return this[(this.handleAs||"text")+"Handler"](a)},xmlHandler:function(a){return a.responseXML},textHandler:function(a){return a.responseText},jsonHandler:function(a){var b=a.responseText;try{return JSON.parse(b)}catch(c){return console.warn("core-ajax caught an exception trying to parse response as JSON:"),console.warn("url:",this.url),console.warn(c),b}},documentHandler:function(a){return a.response},blobHandler:function(a){return a.response},arraybufferHandler:function(a){return a.response},urlChanged:function(){if(!this.handleAs){var a=String(this.url).split(".").pop();switch(a){case"json":this.handleAs="json"}}this.autoGo()},paramsChanged:function(){this.autoGo()},bodyChanged:function(){this.autoGo()},autoChanged:function(){this.autoGo()},autoGo:function(){this.auto&&(this.goJob=this.job(this.goJob,this.go,0))},getParams:function(a){return a=this.params||a,a&&"string"==typeof a&&(a=JSON.parse(a)),a},go:function(){var a=this.xhrArgs||{};a.body=this.body||a.body,a.params=this.getParams(a.params),a.headers=this.headers||a.headers||{},a.headers&&"string"==typeof a.headers&&(a.headers=JSON.parse(a.headers));var b=Object.keys(a.headers).some(function(a){return"content-type"===a.toLowerCase()});if(a.body instanceof FormData?delete a.headers["Content-Type"]:!b&&this.contentType&&(a.headers["Content-Type"]=this.contentType),("arraybuffer"===this.handleAs||"blob"===this.handleAs||"document"===this.handleAs)&&(a.responseType=this.handleAs),a.withCredentials=this.withCredentials,a.callback=this.receive.bind(this),a.url=this.url,a.method=this.method,this.response=this.error=this.progress=null,this.activeRequest=a.url&&this.xhr.request(a),this.activeRequest){this.loading=!0;var c=this.activeRequest;"onprogress"in c?this.activeRequest.addEventListener("progress",function(a){this.processProgress(a,c)}.bind(this),!1):this.progress={lengthComputable:!1}}return this.activeRequest},abort:function(){this.activeRequest&&(this.activeRequest.abort(),this.activeRequest=null,this.progress={},this.loading=!1)}}),Polymer("core-item",{}),function(){function a(a,b){return b&&"Infinity"===a?Number.POSITIVE_INFINITY:Number(a)}Polymer("core-animation",{publish:{target:{value:null,reflect:!0},keyframes:{value:null,reflect:!0},customEffect:{value:null,reflect:!0},composite:{value:"replace",reflect:!0},duration:{value:"auto",reflect:!0},fill:{value:"auto",reflect:!0},easing:{value:"linear",reflect:!0},delay:{value:0,reflect:!0},endDelay:{value:0,reflect:!0},iterations:{value:1,reflect:!0},iterationStart:{value:0,reflect:!0},iterationComposite:{value:"replace",reflect:!0},direction:{value:"normal",reflect:!0},playbackRate:{value:1,reflect:!0},autoplay:{value:!1,reflect:!0}},animation:!1,observe:{target:"apply",keyframes:"apply",customEffect:"apply",composite:"apply",duration:"apply",fill:"apply",easing:"apply",iterations:"apply",iterationStart:"apply",iterationComposite:"apply",delay:"apply",endDelay:"apply",direction:"apply",playbackRate:"apply",autoplay:"apply"},ready:function(){this.apply()},play:function(){return this.apply(),this.animation&&!this.autoplay?(this.player=document.timeline.play(this.animation),this.player.onfinish=this.animationFinishHandler.bind(this),this.player):void 0},cancel:function(){this.player&&this.player.cancel()},finish:function(){this.player&&this.player.finish()},pause:function(){this.player&&this.player.pause()},hasTarget:function(){return null!==this.target},apply:function(){return this.animation=this.makeAnimation(),this.autoplay&&this.animation&&this.play(),this.animation},makeSingleAnimation:function(a){return a.classList.add("core-animation-target"),new Animation(a,this.animationEffect,this.timingProps)},makeAnimation:function(){if(!this.target)return null;var a;if(Array.isArray(this.target)){var b=[];this.target.forEach(function(a){b.push(this.makeSingleAnimation(a))}.bind(this)),a=new AnimationGroup(b)}else a=this.makeSingleAnimation(this.target);return a},animationChanged:function(){this.fire("core-animation-change",this)},targetChanged:function(a){a&&a.classList.remove("core-animation-target")},get timingProps(){var b={},c={delay:{isNumber:!0},endDelay:{isNumber:!0},fill:{},iterationStart:{isNumber:!0},iterations:{isNumber:!0,allowInfinity:!0},duration:{isNumber:!0},playbackRate:{isNumber:!0},direction:{},easing:{}};for(t in c)if(null!==this[t]){var d=c[t].property||t;b[d]=c[t].isNumber&&"auto"!==this[t]?a(this[t],c[t].allowInfinity):this[t]}return b},get animationEffect(){var a,b=[];if(this.keyframes)b=this.keyframes;else if(!this.customEffect){var c=this.querySelectorAll("core-animation-keyframe");0===c.length&&this.shadowRoot&&(c=this.shadowRoot.querySelectorAll("core-animation-keyframe")),Array.prototype.forEach.call(c,function(a){b.push(a.properties)})}return a=this.customEffect?this.customEffect:b},animationFinishHandler:function(){this.fire("core-animation-finish")}})}(),Polymer("core-animation-keyframe",{publish:{offset:{value:null,reflect:!0}},get properties(){var a={},b=this.querySelectorAll("core-animation-prop");return Array.prototype.forEach.call(b,function(b){a[b.name]=b.value}),null!==this.offset&&(a.offset=this.offset),a}}),Polymer("core-animation-prop",{publish:{name:{value:"",reflect:!0},value:{value:"",reflect:!0}}}),Polymer("album-art",{moreLikeThis:chrome.i18n.getMessage("moreLikeThis"),backButton:chrome.i18n.getMessage("backButton"),playTrackLabel:chrome.i18n.getMessage("playTrack"),moreOptionsLabel:chrome.i18n.getMessage("moreOptionsLabel"),closeLabel:chrome.i18n.getMessage("closeLabel"),add2PlayQueue:chrome.i18n.getMessage("add2PlayQueue"),favoriteAlbum:chrome.i18n.getMessage("favoriteAlbum"),downloadButton:chrome.i18n.getMessage("downloadButton"),albumTracklist:chrome.i18n.getMessage("albumTracklist"),imgURL:"",defaultImgURL:"../../../images/default-cover-art.png",width:"250px",height:"250px",albumSize:0,ready:function(){"use strict";this.page=this.page||"cover",this.artist=this.artist||"Artist Name",this.album=this.album||"Album Title",this.app=document.getElementById("tmpl"),this.audio=document.getElementById("audio"),this.playerArt=document.getElementById("coverArt"),this.app.colorThiefAlbum=this.app.colorThiefAlbum||"#db4437",this.app.colorThiefAlbumOff=this.app.colorThiefAlbumOff||"white"},setImage:function(a,b){"use strict";var c=window.URL.createObjectURL(a.target.result);this.showArt(c),this.isLoading=!1,this.imgURL=c,b&&b(c)},mouseIn:function(a,b,c){c.setZ(2)},mouseOut:function(a,b,c){c.setZ(1)},showArt:function(a){"use strict";this.$.card.style.backgroundImage="url('"+a+"')",this.$.topper.style.backgroundImage="url('"+a+"')",this.imgURL=a},slideUp:function(){"use strict";this.page="info"},closeSlide:function(){"use strict";this.page="cover"},doDialog:function(){"use strict";this.async(function(){this.app.dataLoading=!1,this.app.tracker.sendAppView("Album Details"),this.app.colorThiefEnabled&&this.playlist[0].palette&&(this.app.colorThiefAlbum=this.playlist[0].palette[0],this.app.colorThiefAlbumOff=this.playlist[0].palette[1]),this.closeSlide(),this.$.detailsDialog.open(),this.app.$.fab.state="mid",this.app.$.fab.ident=this.id})},closeDialog:function(){"use strict";this.app.tracker.sendAppView("Album Wall"),this.$.detailsDialog.close(),this.app.$.fab.state="off"},defaultPlayerImage:function(){"use strict";this.app.$.coverArt.style.backgroundImage="url('../../images/default-cover-art.png')"},add2Playlist:function(){"use strict";this.app.playlist=this.app.playlist.concat(this.playlist),this.app.dataLoading=!1,this.audio.paused&&(this.app.playing=0,this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.playlist[0].id}),this.imgURL,this.playlist[0].id),this.app.getImageForPlayer(this.imgURL,function(){this.app.setFabColor(this.playlist[0])}.bind(this))),this.app.doToast(chrome.i18n.getMessage("added2Queue"))},doAlbumDownload:function(a,b,c){"use strict";var d=new DownloadManager,e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.doQuery(function(){this.app.$.downloads.appendChild(d),this.app.isDownloading=!0,e.cancel(),d.downloadAlbum({id:this.albumID,artist:this.artist,album:this.album,size:this.albumSize},function(){console.log("Download Finished: "+this.artist+" - "+this.album)}.bind(this))}.bind(this))},doTrackDownload:function(a,b,c){"use strict";var d=new DownloadManager,e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.doQuery(function(){this.app.$.downloads.appendChild(d),this.app.isDownloading=!0,e.cancel(),d.downloadTrack(c.attributes.ident.value,function(){console.log("Track Download Finished")}.bind(this))}.bind(this))},playTrack:function(a,b,c){"use strict";this.app.setFabColor(this.playlist[0]),this.$.detailsDialog.close(),this.playerArt.style.backgroundImage="url('"+this.imgURL+"')",this.app.playlist=[{artist:c.attributes.artist.value,title:c.attributes.trackTitle.value,cover:this.imgURL,duration:c.attributes.duration.value,id:c.attributes.ident.value}],this.app.playing=0,this.app.playAudio(c.attributes.artist.value,c.attributes.trackTitle.value,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:c.attributes.ident.value}),this.imgURL,c.attributes.ident.value),this.app.$.fab.state="off"},addSingle2Playlist:function(a,b,c){"use strict";this.app.playlist.push({id:c.attributes.ident.value,artist:c.attributes.artist.value,title:c.attributes.trackTitle.value,duration:c.attributes.duration.value,cover:this.imgURL}),this.audio.paused&&(this.app.setFabColor(this.playlist[0]),this.app.playAudio(c.attributes.artist.value,c.attributes.trackTitle.value,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:c.attributes.ident.value}),this.imgURL,c.attributes.ident.value),this.app.playing=0,this.imgURL?this.playerArt.style.backgroundImage="url('"+this.imgURL+"')":this.playerArt.style.backgroundImage="url('../../images/default-cover-art.png')"),this.app.doToast(chrome.i18n.getMessage("added2Queue"))},playAlbum:function(){"use strict";this.app.dataLoading=!1,this.$.detailsDialog.close(),this.app.setFabColor(this.playlist[0]),this.app.getImageForPlayer(this.imgURL,function(){this.app.playlist=this.playlist,this.app.playing=0,this.app.playAudio(this.playlist[0].artist,this.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.playlist[0].id}),this.imgURL,this.playlist[0].id)}.bind(this))},addFavorite:function(a,b,c){"use strict";var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.doXhr(this.app.buildUrl("star",{albumId:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(this.isFavorite=!0,d.cancel())}.bind(this))},removeFavorite:function(a,b,c){"use strict";var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.doXhr(this.app.buildUrl("unstar",{albumId:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(this.isFavorite=!1,d.cancel())}.bind(this))},paletteChanged:function(){"use strict";var a=this.playlist.length;if(this.palette&&0!==a)for(var b=0;a>b;b++)this.playlist[b].palette=this.palette},getPalette:function(a){"use strict";this.app.getDbItem("al-"+this.item+"-palette",function(b){this.palette=b.target.result,this.async(a)}.bind(this))},doPlayback:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.playAlbum.bind(this))}.bind(this))},doDetails:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.doDialog.bind(this))}.bind(this))},doAdd2Playlist:function(){"use strict";this.app.dataLoading=!0,this.getPalette(function(){this.doQuery(this.add2Playlist.bind(this))}.bind(this))},processJSON:function(a){"use strict";this.playlist.length=0,this.albumID=this.trackResponse["subsonic-response"].album.song[0].parent;var b=this.trackResponse["subsonic-response"].album.song;b.sort(function(a,b){var c=a.discNumber||0,d=b.discNumber||0,e=a.track||0,f=b.track||0;return c===d?e-f:c-d});for(var c=b.length,d=0;c>d;d++){var e=Math.floor(b[d].duration/60),f=Math.floor(b[d].duration-60*e),g=e+":"+("0"+f).slice(-2);this.albumSize=this.albumSize+b[d].size,this.playlist.push({id:b[d].id,artist:b[d].artist,title:b[d].title,duration:g,cover:this.imgURL,palette:this.palette,disk:b[d].diskNumber,track:b[d].track}),d===c-1&&this.async(a)}},doQuery:function(a){"use strict";this.async(function(){this.app.getDbItem(this.item,function(b){b.target.result?(this.trackResponse=b.target.result,this.processJSON(a)):this.app.doXhr(this.app.buildUrl("getAlbum",{id:this.item}),"json",function(b){this.trackResponse=b.target.response,this.processJSON(a),this.app.putInDb(this.trackResponse,this.item,function(){console.log("JSON Data Added to indexedDB "+this.item)}.bind(this))}.bind(this))}.bind(this))})},itemChanged:function(){"use strict";this.async(function(){if(this.item&&!this.app.scrolling){var a="al-"+this.item;this.showArt(this.defaultImgURL),this.playlist=[],this.isLoading=!0,this.async(function(){this.app.getDbItem(a,function(b){b.target.result?this.setImage(b):this.app.getImageFile(this.app.buildUrl("getCoverArt",{size:550,id:a}),a,function(b){this.setImage(b,function(b){this.app.colorThiefHandler(b,a)}.bind(this))}.bind(this))}.bind(this))})}else this.async(this.itemChanged,null,10)})},setRating:function(a,b,c){"use strict";var d=parseInt(c.attributes.star.value,10),e=new CoreAnimation;e.duration=1e3,e.iterations="Infinity",e.keyframes=[{opacity:1},{opacity:0}],e.target=c,e.play(),this.app.doXhr(this.app.buildUrl("setRating",{id:this.item,rating:d}),"json",function(a){var b=a.target.response["subsonic-response"];e.cancel(),"ok"===b.status&&(this.rating=d)}.bind(this))},moreLikeCallback:function(){this.app.$.audio.paused&&this.app.getImageForPlayer(this.app.playlist[0].cover,function(){this.app.playing=0,this.app.setFabColor(this.app.playlist[0]),this.app.playAudio(this.app.playlist[0].artist,this.app.playlist[0].title,this.app.buildUrl("stream",{maxBitRate:this.app.bitRate,id:this.app.playlist[0].id}),this.app.playlist[0].cover,this.app.playlist[0].id),this.app.dataLoading=!1}.bind(this))},moreLike:function(a,b,c){"use strict";var d=c.attributes.ident.value;this.$.detailsDialog.close(),this.app.$.fab.state="off",this.app.dataLoading=!0,this.app.doXhr(this.app.buildUrl("getSimilarSongs",{count:50,id:d}),"json",function(a){var b=a.target.response["subsonic-response"].similarSongs.song;if(b){this.app.$.audio.pause(),this.app.playlist.length=0;for(var c=b.length,d=0;c>d;d++){var e=Math.floor(b[d].duration/60),f={id:b[d].id,artist:b[d].artist,title:b[d].title,duration:e+":"+("0"+Math.floor(b[d].duration-60*e)).slice(-2)},g="al-"+b[d].albumId;this.app.getDbItem(g,function(a){a.target.result?(f.cover=window.URL.createObjectURL(a.target.result),this.app.getDbItem(g+"-palette",function(a){f.palette=a.target.result,this.app.playlist.push(f),this.moreLikeCallback()}.bind(this))):this.app.getImageFile(this.app.buildUrl("getCoverArt",{size:550,id:g}),g,function(a){f.cover=window.URL.createObjectURL(a.target.result),this.app.colorThiefHandler(imgURL,g,function(a){f.palette=a,this.app.playlist.push(f),this.moreLikeCallback()}.bind(this))}.bind(this))}.bind(this))}}else this.app.dataLoading=!1,this.app.doToast(chrome.i18n.getMessage("noResults"))}.bind(this))}}),Polymer("paper-spinner",{eventDelegates:{animationend:"reset",webkitAnimationEnd:"reset"},publish:{active:{value:!1,reflect:!0},alt:{value:"loading",reflect:!0}},ready:function(){this.hasAttribute("aria-label")?this.alt=this.getAttribute("aria-label"):this.setAttribute("aria-label",this.alt),this.active||this.setAttribute("aria-hidden","true")},activeChanged:function(){this.active?(this.$.spinnerContainer.classList.remove("cooldown"),this.$.spinnerContainer.classList.add("active"),this.removeAttribute("aria-hidden")):(this.$.spinnerContainer.classList.add("cooldown"),this.setAttribute("aria-hidden","true"))},altChanged:function(){""===this.alt?this.setAttribute("aria-hidden","true"):this.removeAttribute("aria-hidden"),this.setAttribute("aria-label",this.alt)},reset:function(){this.$.spinnerContainer.classList.remove("active","cooldown")}}),function(){function a(a){var b="";if(a){var c=a.toLowerCase();1==c.length?l.test(c)&&(b=c):b="multiply"==c?"*":c}return b}function b(a){var b="";return a&&(b=m.test(a)?j[a]:a.toLowerCase()),b}function c(a){var b="";return Number(a)&&(b=a>=65&&90>=a?String.fromCharCode(32+a):a>=112&&123>=a?"f"+(a-112):a>=48&&57>=a?String(48-a):a>=96&&105>=a?String(96-a):k[a]),b}function d(d){var e=a(d.key)||b(d.keyIdentifier)||c(d.keyCode)||a(d.detail.key)||"";return{shift:d.shiftKey,ctrl:d.ctrlKey,meta:d.metaKey,alt:d.altKey,key:e}}function e(a){var b=a.split("+"),c=Object.create(null);return b.forEach(function(a){"shift"==a?c.shift=!0:"ctrl"==a?c.ctrl=!0:"alt"==a?c.alt=!0:c.key=a}),c}function f(a,b){return Boolean(a.alt)==Boolean(b.alt)&&Boolean(a.ctrl)==Boolean(b.ctrl)&&Boolean(a.shift)==Boolean(b.shift)&&a.key===b.key}function g(a){for(var b,c=d(a),e=0;ed&&(b=c[d]);d++)this.moveInsertedElements(b),this.cacheDomLocation(b),b.parentNode.removeChild(b),a.__contents.push(b);this.cacheDomLocation(a),this.updateEventController(a);var f=this.makeHost();f.shadowRoot.appendChild(a),a.__host=f}},makeHost:function(){var a=document.createElement("overlay-host");return a.createShadowRoot(),this.appendChild(a),a},moveInsertedElements:function(a){var b=a.getDistributedNodes(),c=a.parentNode;a.__contents=[];for(var d,e=0,f=b.length;f>e&&(d=b[e]);e++)this.cacheDomLocation(d),this.updateEventController(d),a.__contents.push(d),c.appendChild(d)},updateEventController:function(a){a.eventController=this.element.findController(a)},removeElement:function(a){a.eventController=null,this.replaceElement(a);var b=a.__host;b&&b.parentNode.removeChild(b)},replaceElement:function(a){if(a.__contents){for(var b,c=0,d=a.__contents;b=d[c];c++)this.replaceElement(b);a.__contents=null}if(a.__parentNode){var e=a.__nextElementSibling&&a.__nextElementSibling===a.__parentNode?a.__nextElementSibling:null;a.__parentNode.insertBefore(a,e)}},cacheDomLocation:function(a){a.__nextElementSibling=a.nextElementSibling,a.__parentNode=a.parentNode}})}(),function(){function a(a){var b=f();j.push(a);var d=f();b>=d&&c(a,b)}function b(a){var b=j.indexOf(a);b>=0&&(j.splice(b,1),d(a,""))}function c(a,b){d(a.target,b+2)}function d(a,b){a.style.zIndex=b}function e(){return j[j.length-1]}function f(){var a,b=e();if(b){var c=window.getComputedStyle(b.target).zIndex;isNaN(c)||(a=Number(c))}return a||k}function g(){var a=e();a&&!a.transitioning&&a.applyFocus()}function h(a){if(a.opened)l.push(a);else{var b=l.indexOf(a);b>=0&&l.splice(b,1)}}function i(){return l}Polymer("core-overlay",Polymer.mixin({publish:{target:null,sizingTarget:null,opened:!1,backdrop:!1,layered:!1,autoCloseDisabled:!1,autoFocusDisabled:!1,closeAttribute:"core-overlay-toggle",closeSelector:"",transition:"core-transition-fade"},captureEventName:"tap",targetListeners:{tap:"tapHandler",keydown:"keydownHandler","core-transitionend":"transitionend"},attached:function(){this.resizerAttachedHandler()},detached:function(){this.resizerDetachedHandler()},resizerShouldNotify:function(){return this.opened},registerCallback:function(a){this.layer=document.createElement("core-overlay-layer"),this.keyHelper=document.createElement("core-key-helper"),this.meta=document.createElement("core-transition"),this.scrim=document.createElement("div"),this.scrim.className="core-overlay-backdrop"},ready:function(){this.target=this.target||this,Polymer.flush()},toggle:function(){this.opened=!this.opened},open:function(){this.opened=!0},close:function(){this.opened=!1},domReady:function(){this.ensureTargetSetup()},targetChanged:function(a){if(this.target&&(this.target.tabIndex<0&&(this.target.tabIndex=-1),this.addElementListenerList(this.target,this.targetListeners),this.target.style.display="none",this.target.__overlaySetup=!1),a){this.removeElementListenerList(a,this.targetListeners);var b=this.getTransition();b?b.teardown(a):(a.style.position="",a.style.outline=""),a.style.display=""}},transitionChanged:function(a){this.target&&(a&&this.getTransition(a).teardown(this.target),this.target.__overlaySetup=!1)},ensureTargetSetup:function(){if(this.target&&!this.target.__overlaySetup){this.sizingTarget||(this.sizingTarget=this.target),this.target.__overlaySetup=!0,this.target.style.display="";var a=this.getTransition();a&&a.setup(this.target);var b=this.target.style,c=getComputedStyle(this.target);"static"===c.position&&(b.position="fixed"),b.outline="none",b.display="none"}},openedChanged:function(){this.transitioning=!0,this.ensureTargetSetup(),this.prepareRenderOpened(),this.async(function(){this.target.style.display="",this.target.offsetWidth,this.renderOpened()}),this.fire("core-overlay-open",this.opened)},prepareRenderOpened:function(){this.opened&&a(this),this.prepareBackdrop(),this.async(function(){this.autoCloseDisabled||this.enableElementListener(this.opened,document,this.captureEventName,"captureHandler",!0); -},f.sizePlayer=function(){var a=window.innerHeight-256+"px",b=window.innerWidth+"px",c=f.$.coverArt;c.style.width=b,c.style.height=a,c.style.backgroundSize=b},f.askAnalistics=function(){chrome.storage.sync.get(function(a){f.service.getConfig().addCallback(function(b){void 0===a.analistics?f.$.analistics.open():(b.setTrackingPermitted(a.analistics),f.analisticsEnabled=a.analistics),f.allowAnalistics=function(){f.analisticsEnabled=!0,b.setTrackingPermitted(!0),chrome.storage.sync.set({analistics:!0})},f.disAllowAnalistics=function(){f.analisticsEnabled=!1,b.setTrackingPermitted(!1),chrome.storage.sync.set({analistics:!1})}})})},f.jumpTo=function(a,b,c){f.$.wall.jumpToLetter(c.attributes.it.value)},f.setFolder=function(a,b,c){f.folder=parseInt(c.attributes.i.value,10),chrome.storage.sync.set({mediaFolder:f.folder})},f.fixCoverArtForShuffle=function(a,b){var c=a.cover;f.getDbItem(c,function(d){if(d.target.result){var e=window.URL.createObjectURL(d.target.result);a.cover=e,f.getDbItem(c+"-palette",function(c){a.palette=c.target.result,f.playlist.push(a),f.async(b)})}else f.getImageFile(f.buildUrl("getCoverArt",{id:c}),c,function(d){var e=window.URL.createObjectURL(d.target.result);a.cover=e,f.colorThiefHandler(e,c,function(c){a.palette=c,f.playlist.push(a),f.async(b)})})})},f.setFabColor=function(a){f.colorThiefEnabled&&a.palette&&(f.colorThiefFab=a.palette[0],f.colorThiefFabOff=a.palette[1],f.colorThiefBuffered=a.palette[2],f.colorThiefProgBg=a.palette[3])},f.progressClick=function(a){var b=a.x/window.innerWidth;f.$.progress.value=100*b,f.$.audio.currentTime=audio.duration-(audio.duration-audio.duration*b)},f.savePlayQueue=function(){f.$.playlistDialog.close(),f.$.createPlaylist.open(),f.defaultName=(new Date).toGMTString()},f.savePlayQueue2Playlist=function(){var a=f.buildUrl("createPlaylist",{name:f.defaultName}),b=f.playlist.length;f.savingPlaylist=!0;for(var d=0;b>d;d++)a=a+"&songId="+f.playlist[d].id,d===b-1&&f.doXhr(a,"json",c)},f.closePlaylistSaver=function(){f.$.createPlaylist.close()},f.doAction=function(a,b,c){var d=f.appScroller(),e=f.$.wall,g=new CoreAnimation;g.duration=1e3,g.iterations="Infinity",g.keyframes=[{opacity:1},{opacity:0}],g.target=c,0===f.page&&0!==d.scrollTop&&"podcast"!==e.showing&&"bottom"===f.$.fab.state&&(d.scrollTop=0),0===f.page&&"podcast"===e.showing&&f.$.addPodcast.open(),1===f.page&&f.showPlaylist(),0===f.page&&"mid"===f.$.fab.state&&(g.play(),f.$.wall.playSomething(c.ident,function(){g.cancel(),f.$.fab.state="bottom"})),3===f.page&&(g.play(),f.$.aDetails.playSomething(c.ident,function(){g.cancel(),f.$.fab.state="bottom"}))},f.doSearch=function(){f.searchQuery?f.async(function(){f.closeDrawer(function(){f.async(function(){f.doXhr(f.buildUrl("search3",{query:encodeURIComponent(f.searchQuery)}),"json",function(a){if(f.dataLoading=!0,"ok"===a.target.response["subsonic-response"].status){f.searchQuery="";var b=a.target.response;b["subsonic-response"].searchResult3.album?f.async(function(){f.$.wall.clearData(function(){f.$.wall.response=b,f.showing=f.listMode})}):(f.dataLoading=!1,f.doToast(chrome.i18n.getMessage("noResults")))}})})})}):f.doToast(chrome.i18n.getMessage("noSearch"))},f.showPlaylist=function(a){a?f.$.playlistDialog.transition="core-transition-bottom":f.$.playlistDialog.transition="core-transition-top",f.async(function(){f.$.playlistDialog.toggle()})},f.closePlaylist=function(){f.async(function(){f.$.playlistDialog.close()})},f.openPlaylists=function(){f.closeDrawer(function(){f.dataLoading=!1,f.playlistsLoading=!0,f.doXhr(f.buildUrl("getPlaylists",""),"json",function(a){f.playlistsLoading=!1,f.playlists=a.target.response["subsonic-response"].playlists.playlist,f.async(function(){f.$.playlistsDialog.open()})})})},f.closePlaylists=function(){f.async(function(){f.$.playlistsDialog.close()})},f.reallyDelete=function(a,b,c){f.delID=c.attributes.ident.value,f.async(function(){f.$.playlistsDialog.close(),f.$.playlistConfirm.open()})},f.deletePlaylist=function(a,b,c){f.doXhr(f.buildUrl("deletePlaylist",{id:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status?(f.playlistsLoading=!0,f.doXhr(f.buildUrl("getPlaylists",""),"json",function(a){f.playlistsLoading=!1,f.playlists=a.target.response["subsonic-response"].playlists.playlist,f.async(function(){f.$.playlistsDialog.open()})})):f.doToast(chrome.i18n.getMessage("deleteError"))})},f.closeShuffleOptions=function(){f.async(function(){f.$.shuffleOptions.close()})},f.shuffleOptions=function(){f.closeDrawer(function(){f.doXhr(f.buildUrl("getGenres",""),"json",function(a){f.genres=a.target.response["subsonic-response"].genres.genre,f.dataLoading=!1,f.async(function(){f.$.shuffleOptions.open()})})})},f.closePodcastDialog=function(){f.async(function(){f.$.addPodcast.close()})},f.toggleWall=function(){f.dataLoading=!0;var a=f.$.wall;"cover"===a.listMode?(a.listMode="list",chrome.storage.sync.set({listMode:"list"})):(a.listMode="cover",chrome.storage.sync.set({listMode:"cover"})),f.tracker.sendEvent("ListMode Changed",a.listMode)},f.back2List=function(){f.async(function(){f.page=0})},f.nowPlaying=function(){f.async(function(){f.page=1})},f.selectAction=function(a,b,c){var d=f.$.wall;f.closeDrawer(function(){d.sort===c.attributes.i.value&&(f.pageLimit=!1,"ID3"===f.queryMethod?d.request="getAlbumList2":d.request="getAlbumList",d.post.type=c.attributes.i.value,d.refreshContent(),d.showing=f.listMode,d.$.threshold.clearLower()),d.sort=c.attributes.i.value})},f.getPodcast=function(){f.closeDrawer(function(){f.$.wall.getPodcast()})},f.getStarred=function(){f.closeDrawer(function(){f.$.wall.getStarred()})},f.getArtist=function(){f.closeDrawer(function(){f.$.wall.getArtist()})},f.gotoSettings=function(){f.async(function(){f.$.panel.closeDrawer(),f.page=2})},f.refreshPodcast=function(a,b,c){var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),f.doXhr(f.buildUrl("refreshPodcasts",""),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(d.cancel(),f.$.wall.refreshContent(),f.doToast(chrome.i18n.getMessage("podcastCheck")))})},f.addChannel=function(){f.castURL||f.doToast(f.urlError),f.invalidURL||(f.addingChannel=!0,f.doXhr(f.buildUrl("createPodcastChannel",{url:encodeURIComponent(f.castURL)}),"json",function(a){"ok"===a.target.response["subsonic-response"].status?(f.addingChannel=!1,f.$.addPodcast.close(),f.$.wall.refreshContent(),f.doToast(chrome.i18n.getMessage("channelAdded")),f.castURL=""):f.doToast(chrome.i18n.getMessage("podcastError"))}))},f.doDelete=function(a,b,c){f.$.wall.deleteChannel(c.attributes.ident.value)},f.deleteEpisode=function(a,b,c){f.$.wall.deleteEpisode(c.attributes.ident.value)},f.getLicense=function(a){f.doXhr(f.buildUrl("getLicense",""),"json",function(b){var c=b.target.response["subsonic-response"];if("ok"===c.status){f.serverLicense=c.license;var d=new Date(f.serverLicense.date),e=Math.floor(d.getFullYear()+1),g=new Date(d.setFullYear(e)),h=new Date,i=6e4,j=60*i,k=24*j,l=Math.ceil((g.getTime()-h.getTime())/k),m=Math.ceil((g.getTime()-h.getTime())/j);l>0?f.serverLicense.daysLeft=l+" days":f.serverLicense.daysLeft=m+"hours",f.$.licenseDialog.open(),f.async(a)}})},f.licenseDialogClose=function(){f.$.licenseDialog.close()},f.userDetails=function(){f.async(function(){f.doXhr(f.buildUrl("getUser",{username:f.user}),"json",function(a){var b=a.target.response["subsonic-response"];"ok"===b.status?f.activeUser=b.user:console.error("Error getting User details")})})},String.prototype.hexEncode=function(){for(var a,b="",c=0;ca?-1:a>b?1:0},u=Array.prototype,v=u.indexOf?function(a,b,c){return u.indexOf.call(a,b,c)}:function(a,b,c){if(c=null==c?0:0>c?Math.max(0,a.length+c):c,h(a))return h(b)&&1==b.length?a.indexOf(b,c):-1;for(;cf;f++)f in e&&b.call(c,e[f],f,a)},x=u.some?function(a,b,c){return u.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=h(a)?a.split(""):a,f=0;d>f;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1},y=u.every?function(a,b,c){return u.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=h(a)?a.split(""):a,f=0;d>f;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0},z=function(a){var b;a:{b=ed;for(var c=a.length,d=h(a)?a.split(""):a,e=0;c>e;e++)if(e in d&&b.call(void 0,d[e],e,a)){b=e;break a}b=-1}return 0>b?null:h(a)?a.charAt(b):a[b]},A=function(a,b){var c,d=v(a,b);return(c=d>=0)&&u.splice.call(a,d,1),c},B=function(a){return u.concat.apply(u,arguments)},C=function(a,b,c){return 2>=arguments.length?u.slice.call(a,b):u.slice.call(a,b,c)},D="StopIteration"in c?c.StopIteration:Error("StopIteration"),E=function(){};E.prototype.next=function(){throw D},E.prototype.vc=function(){return this};var F=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)},G=function(a){var b,c=[],d=0;for(b in a)c[d++]=a[b];return c},H=function(a){var b,c=[],d=0;for(b in a)c[d++]=b;return c},I=function(a,b){var c;a:{for(c in a)if(b.call(void 0,a[c],c,a))break a;c=void 0}return c&&a[c]},J="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),K=function(a,b){for(var c,d,e=1;e1){if(c%2)throw Error("Uneven number of arguments");for(var d=0;c>d;d+=2)this.set(arguments[d],arguments[d+1])}else a&&this.ia(a)};L.prototype.t=function(){M(this);for(var a=[],b=0;b2*this.h&&M(this),!0):!1};var M=function(a){if(a.h!=a.b.length){for(var b=0,c=0;b=c.length)throw D;var g=c[b++];return a?g:d[g]}},g};var N,O,P=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},Q={id:"hitType",name:"t",valueType:"text",maxLength:void 0,defaultValue:void 0},R={id:"sessionControl",name:"sc",valueType:"text",maxLength:void 0,defaultValue:void 0},S={id:"description",name:"cd",valueType:"text",maxLength:2048,defaultValue:void 0},T={id:"eventCategory",name:"ec",valueType:"text",maxLength:150,defaultValue:void 0},U={id:"eventAction",name:"ea",valueType:"text",maxLength:500,defaultValue:void 0},V={id:"eventLabel",name:"el",valueType:"text",maxLength:500,defaultValue:void 0},W={id:"eventValue",name:"ev",valueType:"integer",maxLength:void 0,defaultValue:void 0},X={pd:Q,Qc:{id:"anonymizeIp",name:"aip",valueType:"boolean",maxLength:void 0,defaultValue:void 0},Ad:{id:"queueTime",name:"qt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Wc:{id:"cacheBuster",name:"z",valueType:"text",maxLength:void 0,defaultValue:void 0},Gd:R,Wd:{id:"userId",name:"uid",valueType:"text",maxLength:void 0,defaultValue:void 0},xd:{id:"nonInteraction",name:"ni",valueType:"boolean",maxLength:void 0,defaultValue:void 0},fd:S,Pd:{id:"title",name:"dt",valueType:"text",maxLength:1500,defaultValue:void 0},Sc:{id:"appId",name:"aid",valueType:"text",maxLength:150,defaultValue:void 0},Tc:{id:"appInstallerId",name:"aiid",valueType:"text",maxLength:150,defaultValue:void 0},jd:T,hd:U,kd:V,ld:W,Id:{id:"socialNetwork",name:"sn",valueType:"text",maxLength:50,defaultValue:void 0},Hd:{id:"socialAction",name:"sa",valueType:"text",maxLength:50,defaultValue:void 0},Jd:{id:"socialTarget",name:"st",valueType:"text",maxLength:2048,defaultValue:void 0},Sd:{id:"transactionId",name:"ti",valueType:"text",maxLength:500,defaultValue:void 0},Rd:{id:"transactionAffiliation",name:"ta",valueType:"text",maxLength:500,defaultValue:void 0},Td:{id:"transactionRevenue",name:"tr",valueType:"currency",maxLength:void 0,defaultValue:void 0},Ud:{id:"transactionShipping",name:"ts",valueType:"currency",maxLength:void 0,defaultValue:void 0},Vd:{id:"transactionTax",name:"tt",valueType:"currency",maxLength:void 0,defaultValue:void 0},dd:{id:"currencyCode",name:"cu",valueType:"text",maxLength:10,defaultValue:void 0},td:{id:"itemPrice",name:"ip",valueType:"currency",maxLength:void 0,defaultValue:void 0},ud:{id:"itemQuantity",name:"iq",valueType:"integer",maxLength:void 0,defaultValue:void 0},rd:{id:"itemCode",name:"ic",valueType:"text",maxLength:500,defaultValue:void 0},sd:{id:"itemName",name:"in",valueType:"text",maxLength:500,defaultValue:void 0},qd:{id:"itemCategory",name:"iv",valueType:"text",maxLength:500,defaultValue:void 0},bd:{id:"campaignSource",name:"cs",valueType:"text",maxLength:100,defaultValue:void 0},$c:{id:"campaignMedium",name:"cm",valueType:"text",maxLength:50,defaultValue:void 0},ad:{id:"campaignName",name:"cn",valueType:"text",maxLength:100,defaultValue:void 0},Zc:{id:"campaignKeyword",name:"ck",valueType:"text",maxLength:500,defaultValue:void 0},Xc:{id:"campaignContent",name:"cc",valueType:"text",maxLength:500,defaultValue:void 0},Yc:{id:"campaignId",name:"ci",valueType:"text",maxLength:100,defaultValue:void 0},od:{id:"gclid",name:"gclid",valueType:"text",maxLength:void 0,defaultValue:void 0},ed:{id:"dclid",name:"dclid",valueType:"text",maxLength:void 0,defaultValue:void 0},zd:{id:"pageLoadTime",name:"plt",valueType:"integer",maxLength:void 0,defaultValue:void 0},gd:{id:"dnsTime",name:"dns",valueType:"integer",maxLength:void 0,defaultValue:void 0},Kd:{id:"tcpConnectTime",name:"tcp",valueType:"integer",maxLength:void 0,defaultValue:void 0},Fd:{id:"serverResponseTime",name:"srt",valueType:"integer",maxLength:void 0,defaultValue:void 0},yd:{id:"pageDownloadTime",name:"pdt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Bd:{id:"redirectResponseTime",name:"rrt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Ld:{id:"timingCategory",name:"utc",valueType:"text",maxLength:150,defaultValue:void 0},Od:{id:"timingVar",name:"utv",valueType:"text",maxLength:500,defaultValue:void 0},Nd:{id:"timingValue",name:"utt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Md:{id:"timingLabel",name:"utl",valueType:"text",maxLength:500,defaultValue:void 0},md:{id:"exDescription",name:"exd",valueType:"text",maxLength:150,defaultValue:void 0},nd:{id:"exFatal",name:"exf",valueType:"boolean",maxLength:void 0,defaultValue:"1"}},Y=function(a){if(1>a||a>200)throw Error("Expected dimension index range 1-200, but was : "+a);return{id:"dimension"+a,name:"cd"+a,valueType:"text",maxLength:150,defaultValue:void 0}},Z=function(a){if(1>a||a>200)throw Error("Expected metric index range 1-200, but was : "+a);return{id:"metric"+a,name:"cm"+a,valueType:"integer",maxLength:void 0,defaultValue:void 0}},$=function(a){return 1>a?"0":3>a?"1-2":(a=Math.floor(Math.log(a-1)/Math.log(2)),Math.pow(2,a)+1+"-"+Math.pow(2,a+1))},_=function(a,b){for(var c=0,d=a.length-1,e=0;d>=c;){var f=Math.floor((c+d)/2),e=a[f];if(e>=b){if(d=0==f?0:a[f-1],b>d)return(d+1).toString()+"-"+e.toString();d=f-1}else if(b>e){if(f>=a.length-1)return(a[a.length-1]+1).toString()+"+";c=f+1}}return"<= 0"},aa=function(){this.ab=[]},ba=function(){return new aa};a=aa.prototype,a.when=function(a){return this.ab.push(a),this},a.zb=function(a){var b=arguments;return this.when(function(a){return 0<=v(b,a.Gb())}),this},a.Oc=function(a,b){var c=C(arguments,1);return this.when(function(b){return b=b.T().get(a),0<=v(c,b)}),this},a.xb=function(a,b){if(k(this.e))throw Error("Filter has already been set.");return this.e=k(b)?n(a,b):a,this},a.Ca=function(){if(0==this.ab.length)throw Error("Must specify at least one predicate using #when or a helper method.");if(!k(this.e))throw Error("Must specify a delegate filter using #applyFilter.");return n(function(a){y(this.ab,function(b){return b(a)})&&this.e(a)},this)};var ca=function(){this.Ab=!1,this.Bb="",this.qb=!1,this.za=null};ca.prototype.wc=function(a){return this.Ab=!0,this.Bb=a||" - ",this},ca.prototype.Nc=function(){return this.qb=!0,this},ca.prototype.Ec=function(){return da(this,$)},ca.prototype.Fc=function(a){return da(this,o(_,a))};var da=function(a,b){if(null!=a.za)throw Error("LabelerBuilder: Only one labeling strategy may be used.");return a.za=n(function(a){var c=a.T().get(W),d=a.T().get(V);i(c)&&(c=b(c),null!=d&&this.Ab&&(c=d+this.Bb+c),a.T().set(V,c))},a),a};ca.prototype.Ca=function(){if(null==this.za)throw Error("LabelerBuilder: a labeling strategy must be specified prior to calling build().");return ba().zb("event").xb(n(function(a){this.za(a),this.qb&&a.T().remove(W)},this)).Ca()};var ea=function(a,b){var c=Array.prototype.slice.call(arguments),d=c.shift();if("undefined"==typeof d)throw Error("[goog.string.format] Template required");return d.replace(/%([0\-\ \+]*)(\d+)?(\.(\d+))?([%sfdiu])/g,function(a,b,d,e,f,g,h,i){if("%"==g)return"%";var j=c.shift();if("undefined"==typeof j)throw Error("[goog.string.format] Not enough arguments");return arguments[0]=j,fa[g].apply(null,arguments)})},fa={s:function(a,b,c){return isNaN(c)||""==c||a.length>=c?a:a=-1a?"-":0<=b.indexOf("+")?"+":0<=b.indexOf(" ")?" ":"",a>=0&&(d=f+d),isNaN(c)||d.length>=c?d:(d=isNaN(e)?Math.abs(a).toString():Math.abs(a).toFixed(e),a=c-d.length-f.length,d=0<=b.indexOf("-",0)?f+d+Array(a+1).join(" "):f+Array(a+1).join(0<=b.indexOf("0",0)?"0":" ")+d)},d:function(a,b,c,d,e,f,g,h){return fa.f(parseInt(a,10),b,c,d,0,f,g,h)}};fa.i=fa.d,fa.u=fa.d;var ga=function(a){if("function"==typeof a.t)return a.t();if(h(a))return a.split("");if(g(a)){for(var b=[],c=a.length,d=0;c>d;d++)b.push(a[d]);return b}return G(a)},ha=function(a,b){if("function"==typeof a.forEach)a.forEach(b,void 0);else if(g(a)||h(a))w(a,b,void 0);else{var c;if("function"==typeof a.F)c=a.F();else if("function"!=typeof a.t)if(g(a)||h(a)){c=[];for(var d=a.length,e=0;d>e;e++)c.push(e)}else c=H(a);else c=void 0;for(var d=ga(a),e=d.length,f=0;e>f;f++)b.call(void 0,d[f],c&&c[f],a)}},ia=function(a){this.B=new L;for(var b=arguments,c=0;cparseFloat(b))?String(a):b)}(),za={},Aa=function(a){var b;if(!(b=za[a])){b=0;for(var c=String(ya).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(c.length,d.length),f=0;0==b&&e>f;f++){var g=c[f]||"",h=d[f]||"",i=RegExp("(\\d*)(\\D*)","g"),j=RegExp("(\\d*)(\\D*)","g");do{var k=i.exec(g)||["","",""],l=j.exec(h)||["","",""];if(0==k[0].length&&0==l[0].length)break;b=t(0==k[1].length?0:parseInt(k[1],10),0==l[1].length?0:parseInt(l[1],10))||t(0==k[2].length,0==l[2].length)||t(k[2],l[2])}while(0==b)}b=za[a]=b>=0}return b},Ba=c.document,Ca=Ba&&ua?xa()||("CSS1Compat"==Ba.compatMode?parseInt(ya,10):5):void 0,Da=!ua||ua&&Ca>=9,Ea=ua&&!Aa("9"),Fa=!wa||Aa("528"),Ga=va&&Aa("1.9b")||ua&&Aa("8")||ta&&Aa("9.5")||wa&&Aa("528"),Ha=va&&!Aa("8")||ua&&!Aa("9"),Ia=function(a,b){if(na.call(this,a?a.type:""),this.relatedTarget=this.currentTarget=this.target=null,this.charCode=this.keyCode=this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.Db=this.state=null,a){var c=this.type=a.type;this.target=a.target||a.srcElement,this.currentTarget=b;var d=a.relatedTarget;if(d){if(va){var e;a:{try{oa(d.nodeName),e=!0;break a}catch(f){}e=!1}e||(d=null)}}else"mouseover"==c?d=a.fromElement:"mouseout"==c&&(d=a.toElement);this.relatedTarget=d,this.offsetX=wa||void 0!==a.offsetX?a.offsetX:a.layerX,this.offsetY=wa||void 0!==a.offsetY?a.offsetY:a.layerY,this.clientX=void 0!==a.clientX?a.clientX:a.pageX,this.clientY=void 0!==a.clientY?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0,this.button=a.button,this.keyCode=a.keyCode||0,this.charCode=a.charCode||("keypress"==c?a.keyCode:0),this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.state=a.state,this.Db=a,a.defaultPrevented&&this.preventDefault()}};r(Ia,na),Ia.prototype.preventDefault=function(){Ia.L.preventDefault.call(this);var a=this.Db;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,Ea)try{(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)&&(a.keyCode=-1)}catch(b){}},Ia.prototype.l=function(){};var Ja="closure_listenable_"+(1e6*Math.random()|0),Ka=function(a){return!(!a||!a[Ja])},La=0,Ma=function(a,b,c,d,e){this.O=a,this.proxy=null,this.src=b,this.type=c,this.pa=!!d,this.sa=e,this.key=++La,this.removed=this.qa=!1},Na=function(a){a.removed=!0,a.O=null,a.proxy=null,a.src=null,a.sa=null},Oa=function(a){this.src=a,this.j={},this.Z=0};Oa.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.j[f],a||(a=this.j[f]=[],this.Z++);var g=Qa(a,b,d,e);return g>-1?(b=a[g],c||(b.qa=!1)):(b=new Ma(b,this.src,f,!!d,e),b.qa=c,a.push(b)),b},Oa.prototype.remove=function(a,b,c,d){if(a=a.toString(),!(a in this.j))return!1;var e=this.j[a];return b=Qa(e,b,c,d),b>-1?(Na(e[b]),u.splice.call(e,b,1),0==e.length&&(delete this.j[a],this.Z--),!0):!1};var Pa=function(a,b){var c=b.type;if(!(c in a.j))return!1;var d=A(a.j[c],b);return d&&(Na(b),0==a.j[c].length&&(delete a.j[c],a.Z--)),d};Oa.prototype.removeAll=function(a){a=a&&a.toString();var b,c=0;for(b in this.j)if(!a||b==a){for(var d=this.j[b],e=0;e-1?a[e]:null};var Qa=function(a,b,c,d){for(var e=0;ee.keyCode||void 0!=e.returnValue)){a:{var g=!1;if(0==e.keyCode)try{e.keyCode=-1;break a}catch(h){g=!0}(g||void 0==e.returnValue)&&(e.returnValue=!0)}for(e=[],g=d.currentTarget;g;g=g.parentNode)e.push(g);for(var g=a.type,i=e.length-1;!d.U&&i>=0;i--)d.currentTarget=e[i],f&=_a(e[i],g,!0,d);for(i=0;!d.U&&i>>0),eb=function(a){return j(a)?a:(a[db]||(a[db]=function(b){return a.handleEvent(b)}),a[db])},fb=function(){ma.call(this),this.A=new Oa(this),this.kc=this,this.Qa=null};r(fb,ma),fb.prototype[Ja]=!0,a=fb.prototype,a.addEventListener=function(a,b,c,d){Ua(this,a,b,c,d)},a.removeEventListener=function(a,b,c,d){Ya(this,a,b,c,d)},a.dispatchEvent=function(a){var b,c=this.Qa;if(c){b=[];for(var d=1;c;c=c.Qa)b.push(c),++d}if(c=this.kc,d=a.type||a,h(a))a=new na(a,c);else if(a instanceof na)a.target=a.target||c;else{var e=a;a=new na(d,c),K(a,e)}var f,e=!0;if(b)for(var g=b.length-1;!a.U&&g>=0;g--)f=a.currentTarget=b[g],e=gb(f,d,!0,a)&&e;if(a.U||(f=a.currentTarget=c,e=gb(f,d,!0,a)&&e,a.U||(e=gb(f,d,!1,a)&&e)),b)for(g=0;!a.U&&g=0&&e>1));g++);f>=0&&(0==c.m&&1==e?ub(c,b):(e=c.n.splice(f,1)[0],Ab(c),e.Ma(b)))}}else xb(a,3,b)},vb=function(a,b){a.n&&a.n.length||2!=a.m&&3!=a.m||zb(a),a.n||(a.n=[]),a.n.push(b)},wb=function(a,b,c,d){var e={wa:null,jb:null,Ma:null};return e.wa=new tb(function(a,f){e.jb=b?function(c){try{var e=b.call(d,c);a(e)}catch(g){f(g)}}:a,e.Ma=c?function(b){try{var e=c.call(d,b);void 0===e&&b instanceof Db?f(b):a(e)}catch(g){f(g)}}:f}),e.wa.o=a,vb(a,e),e.wa};tb.prototype.vb=function(a){this.m=0,xb(this,2,a)},tb.prototype.wb=function(a){this.m=0,xb(this,3,a)};var xb=function(a,b,c){if(0==a.m){if(a==c)b=3,c=new TypeError("Promise cannot resolve to itself");else{if(sb(c))return a.m=1,void c.then(a.vb,a.wb,a);if(k(c))try{var d=c.then;if(j(d))return void yb(a,c,d)}catch(e){b=3,c=e}}a.v=c,a.m=b,zb(a),3!=b||c instanceof Db||Bb(a,c)}},yb=function(a,b,c){a.m=1;var d=!1,e=function(b){d||(d=!0,a.vb(b))},f=function(b){d||(d=!0,a.wb(b))};try{c.call(b,e,f)}catch(g){f(g)}},zb=function(a){a.La||(a.La=!0,lb(a.uc,a))};tb.prototype.uc=function(){for(;this.n&&this.n.length;){var a=this.n;this.n=[];for(var b=0;b=b.Ia&&b.cancel())}this.hb?this.hb.call(this.gb,this):this.Ka=!0,this.C||this.w(new Ob)}},Eb.prototype.ib=function(a,b){this.Ja=!1,Fb(this,a,b)};var Fb=function(a,b,c){a.C=!0,a.v=c,a.W=!b,Kb(a)},Gb=function(a){if(a.C){if(!a.Ka)throw new Nb;a.Ka=!1}};Eb.prototype.G=function(a){Gb(this),Fb(this,!0,a)},Eb.prototype.w=function(a){Gb(this),Fb(this,!1,a)},Eb.prototype.J=function(a,b){return Hb(this,a,null,b)};var Hb=function(a,b,c,d){return a.ja.push([b,c,d]),a.C&&Kb(a),a};Eb.prototype.then=function(a,b,c){var d,e,f=new tb(function(a,b){d=a,e=b});return Hb(this,d,function(a){a instanceof Ob?f.cancel():e(a)}),f.then(a,b,c)},rb(Eb);var Ib=function(a){var b=new Eb;return Hb(a,b.G,b.w,b),b},Jb=function(a){return x(a.ja,function(a){return j(a[1])})},Kb=function(a){if(a.ka&&a.C&&Jb(a)){var b=a.ka,d=Qb[b];d&&(c.clearTimeout(d.ma),delete Qb[b]),a.ka=0}a.o&&(a.o.Ia--,delete a.o);for(var b=a.v,e=d=!1;a.ja.length&&!a.Ja;){var f=a.ja.shift(),g=f[0],h=f[1],f=f[2];if(g=a.W?h:g)try{var i=g.call(f||a.gb,b);void 0!==i&&(a.W=a.W&&(i==b||i instanceof Error),a.v=b=i),sb(b)&&(e=!0,a.Ja=!0)}catch(j){b=j,a.W=!0,Jb(a)||(d=!0)}}a.v=b,e&&(i=n(a.ib,a,!0),e=n(a.ib,a,!1),b instanceof Eb?(Hb(b,i,e),b.Lb=!0):b.then(i,e)),d&&(b=new Pb(b),Qb[b.ma]=b,a.ka=b.ma)},Lb=function(a){var b=new Eb;return b.G(a),b},Mb=function(){var a=Kc,b=new Eb;return b.w(a),b},Nb=function(){s.call(this)};r(Nb,s),Nb.prototype.message="Deferred has already fired",Nb.prototype.name="AlreadyCalledError";var Ob=function(){s.call(this)};r(Ob,s),Ob.prototype.message="Deferred was canceled",Ob.prototype.name="CanceledError";var Pb=function(a){this.ma=c.setTimeout(n(this.pc,this),0),this.ga=a};Pb.prototype.pc=function(){throw delete Qb[this.ma],this.ga};var Qb={},Rb=function(a){this.$a=[],this.e=a};Rb.prototype.S=function(a){if(!j(a))throw Error("Invalid filter. Must be a function.");this.$a.push(a)},Rb.prototype.send=function(a,b){for(var c=new Sb(a,b),d=0;d=9||va&&Aa("1.9.1"),ua&&Aa("9");var Ub={id:"apiVersion",name:"v",valueType:"text",maxLength:void 0,defaultValue:void 0},Vb={id:"appName",name:"an",valueType:"text",maxLength:100,defaultValue:void 0},Wb={id:"appVersion",name:"av",valueType:"text",maxLength:100,defaultValue:void 0},Xb={id:"clientId",name:"cid",valueType:"text",maxLength:void 0,defaultValue:void 0},Yb={id:"language",name:"ul",valueType:"text",maxLength:20,defaultValue:void 0},Zb={id:"libVersion",name:"_v",valueType:"text",maxLength:void 0,defaultValue:void 0},$b={id:"sampleRateOverride",name:"usro",valueType:"integer",maxLength:void 0,defaultValue:void 0},_b={id:"screenColors",name:"sd",valueType:"text",maxLength:20,defaultValue:void 0},ac={id:"screenResolution",name:"sr",valueType:"text",maxLength:20,defaultValue:void 0},bc={id:"trackingId",name:"tid",valueType:"text",maxLength:void 0,defaultValue:void 0},cc={id:"viewportSize",name:"vp",valueType:"text",maxLength:20,defaultValue:void 0},dc={Rc:Ub,Uc:Vb,Vc:Wb,cd:Xb,vd:Yb,wd:Zb,Cd:$b,Dd:_b,Ed:ac,Qd:bc,Xd:cc},ec=function(a){if(!h(a))return a;var b=fc(a,X);if(k(b))return b;if(b=fc(a,dc),k(b))return b;if(b=/^dimension(\d+)$/.exec(a),null!==b)return Y(parseInt(b[1],10));if(b=/^metric(\d+)$/.exec(a),null!==b)return Z(parseInt(b[1],10));throw Error(a+" is not a valid parameter name.")},fc=function(a,b){var c=I(b,function(b){return b.id==a&&"metric"!=a&&"dimension"!=a});return k(c)?c:null},gc=function(a,b){this.Zb=b,this.q=b.Sa(),this.sb=new ia,this.Ya=!1};a=gc.prototype,a.set=function(a,b){var c=ec(a);this.sb.set(c,b)},a.S=function(a){this.Zb.S(a)},a.send=function(a,b){if(a instanceof ka)return a.send(this);var c=this.sb.clone();return b instanceof ia?c.ia(b):k(b)&&F(b,function(a,b){null!=a&&c.set(ec(b),a)},this),this.Ya&&(this.Ya=!1,c.set(R,"start")),this.q.send(a,c)},a.Gc=function(a){var b={description:a};return this.set(S,a),this.send("appview",b)},a.Hc=function(a,b,c,d){return this.send("event",{eventCategory:a,eventAction:b,eventLabel:c,eventValue:d})},a.Jc=function(a,b,c){return this.send("social",{socialNetwork:a,socialAction:b,socialTarget:c})},a.Ic=function(a,b){return this.send("exception",{exDescription:a,exFatal:b})},a.Cb=function(a,b,c,d,e){return this.send("timing",{timingCategory:a,timingVar:b,timingLabel:d,timingValue:c,sampleRateOverride:e})},a.Ac=function(){this.Ya=!0},a.Mc=function(a,b,c,d){return new hc(this,a,b,c,d)};var hc=function(a,b,c,d,e){this.yb=a,this.bc=b,this.ec=c,this.cc=d,this.V=e,this.dc=p()};hc.prototype.send=function(){var a=this.yb.Cb(this.bc,this.ec,p()-this.dc,this.cc,this.V);return this.yb=null,a};var ic=function(a,b,c,d,e){this.ic=a,this.fc=b,this.gc=c,this.k=d,this.hc=e};ic.prototype.Cc=function(a){var b=new gc(0,this.hc.create());return b.set(Zb,this.ic),b.set(Ub,1),b.set(Vb,this.fc),b.set(Wb,this.gc),b.set(bc,a),a=window.navigator.language,b.set(Yb,a),a=screen.colorDepth+"-bit",b.set(_b,a),a=[screen.width,screen.height].join("x"),b.set(ac,a),a=window.document,a="CSS1Compat"==a.compatMode?a.documentElement:a.body,a=new Tb(a.clientWidth,a.clientHeight),a=[a.width,a.height].join("x"),b.set(cc,a),b},ic.prototype.Bc=function(){return Ib(this.k.ha)};var jc=function(a){this.sc=a};jc.prototype.send=function(a,b){return this.sc.push({Ub:a,Vb:b}),Lb()};var kc=function(a,b,c){this.k=a,this.ra=[],this.M={enabled:new jc(this.ra),disabled:c},this.q=this.M.enabled,Hb(Ib(this.k.ha),o(this.Pb,b),this.Ob,this)};kc.prototype.Pb=function(a){this.M.enabled=a(),lc(this),w(this.ra,function(a){this.send(a.Ub,a.Vb)},this),this.ra=null,rc(this.k,n(this.Xb,this))},kc.prototype.Ob=function(){this.q=this.M.enabled=this.M.disabled,this.ra=null},kc.prototype.send=function(a,b){return this.q.send(a,b)};var lc=function(a){a.q=a.k.va()?a.M.enabled:a.M.disabled};kc.prototype.Xb=function(a){switch(a){case"analytics.tracking-permitted":lc(this)}};var mc=function(a,b,c,d,e,f){for(Eb.call(this,e,f),this.Na=a,this.Oa=[],this.lb=!!b,this.Nb=!!c,this.Mb=!!d,b=this.mb=0;bb;b++)switch(a[b]){case"x":a[b]=Math.floor(16*Math.random()).toString(16);break;case"y":a[b]=(Math.floor(4*Math.random())+8).toString(16)}a=a.join(""),this.H.set("analytics.user-id",a)}this.la=a},a)};oc.prototype.Kc=function(a){this.V=a};var uc=function(a){w(a.nb,function(a){a("analytics.tracking-permitted")})},vc=function(a){fb.call(this),this.Wa=a,this.H=chrome.storage.local,chrome.storage.onChanged.addListener(n(this.nc,this))};r(vc,fb),vc.prototype.nc=function(a){wc(this,a)&&this.dispatchEvent("a")};var wc=function(a,b){return x(H(b),function(a){return 0==a.lastIndexOf(this.Wa,0)},a)};vc.prototype.get=function(a){var b=new Eb,c=this.Wa+"."+a;return this.H.get(c,function(a){var d=chrome.runtime.lastError;d?b.w(d):b.G(a[c])}),b},vc.prototype.set=function(a,b){var c=new Eb,d={};return d[this.Wa+"."+a]=b,this.H.set(d,function(){var a=chrome.runtime.lastError;a?c.w(a):c.G()}),c};var xc=function(){};xc.Yb=function(){return xc.Ib?xc.Ib:xc.Ib=new xc},xc.prototype.send=function(){return Lb()};var yc=function(a,b){this.Xa=[];var c=n(function(){return this.Aa=new Rb(b.Sa()),w(this.Xa,function(a){this.Aa.S(a)},this),this.Xa=null,this.Aa},this);this.q=new kc(a,c,xc.Yb())};yc.prototype.Sa=function(){return this.q},yc.prototype.S=function(a){this.Aa?this.Aa.S(a):this.Xa.push(a)};var zc=function(a,b){this.k=a,this.mc=b};zc.prototype.create=function(){return new yc(this.k,this.mc)};var Ac=function(a,b){fb.call(this),this.ya=a||1,this.R=b||c,this.Ra=n(this.lc,this),this.Ta=p()};r(Ac,fb),a=Ac.prototype,a.enabled=!1,a.g=null,a.lc=function(){if(this.enabled){var a=p()-this.Ta;a>0&&a<.8*this.ya?this.g=this.R.setTimeout(this.Ra,this.ya-a):(this.g&&(this.R.clearTimeout(this.g),this.g=null),this.dispatchEvent("tick"),this.enabled&&(this.g=this.R.setTimeout(this.Ra,this.ya),this.Ta=p()))}},a.start=function(){this.enabled=!0,this.g||(this.g=this.R.setTimeout(this.Ra,this.ya),this.Ta=p())},a.stop=function(){this.enabled=!1,this.g&&(this.R.clearTimeout(this.g),this.g=null)},a.l=function(){Ac.L.l.call(this),this.stop(),delete this.R};var Bc=function(a,b,d){if(j(a))d&&(a=n(a,d));else{if(!a||"function"!=typeof a.handleEvent)throw Error("Invalid listener argument");a=n(a.handleEvent,a)}return b>2147483647?-1:c.setTimeout(a,b||0)},Cc=function(a){ma.call(this),this.Ua=a,this.b={}};r(Cc,ma);var Dc=[];Cc.prototype.listen=function(a,b,c,d){f(b)||(b&&(Dc[0]=b.toString()),b=Dc);for(var e=0;eb.maxLength&&a.set(b,c.substring(0,b.maxLength))})},Jc=function(a){ja(a,function(b,c){void 0!==b.defaultValue&&c==b.defaultValue&&a.remove(b)})},Kc={status:"device-offline",Ba:void 0},Lc={status:"rate-limited",Ba:void 0},Mc={status:"sampled-out",Ba:void 0},Nc={status:"sent",Ba:void 0},Oc=function(a,b){this.Wb=a,this.e=b};Oc.prototype.send=function(a,b){var c;c=this.Wb;var d=c.pb(),e=Math.floor((d-c.ob)*c.Sb);return e>0&&(c.$=Math.min(c.$+e,c.Tb),c.ob=d),1>c.$?c=!1:(c.$-=1,c=!0),c||"item"==a||"transaction"==a?this.e.send(a,b):Lb(Lc)};var Pc=function(){this.$=60,this.Tb=500,this.Sb=5e-4,this.pb=function(){return(new Date).getTime()},this.ob=this.pb()},Qc=function(a,b){this.k=a,this.e=b};Qc.prototype.send=function(a,b){var c,d=b.get(Xb),d=parseInt(d.split("-")[1],16);return"timing"!=a?c=this.k.V:((c=b.get($b))&&b.remove($b),c||(c=this.k.V)),655.36*c>d?this.e.send(a,b):Lb(Mc)};var Rc=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/,Sc=wa,Tc=function(a,b){if(Sc){Sc=!1;var d=c.location;if(d){var e=d.href;if(e&&(e=(e=Tc(3,e))?decodeURI(e):e)&&e!=d.hostname)throw Sc=!0,Error()}}return b.match(Rc)[a]||null},Uc=function(){};Uc.prototype.Eb=null;var Vc,Wc=function(a){var b;return(b=a.Eb)||(b={},Zc(a)&&(b[0]=!0,b[1]=!0),b=a.Eb=b),b},Xc=function(){};r(Xc,Uc);var Yc=function(a){return(a=Zc(a))?new ActiveXObject(a):new XMLHttpRequest},Zc=function(a){if(!a.Hb&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c=0?(e=b[c].substring(0,d),f=b[c].substring(d+1)):e=b[c],e=decodeURIComponent(e.replace(/\+/g," ")),e=nd(a,e),a.add(e,f?decodeURIComponent(f.replace(/\+/g," ")):"")}};a=ld.prototype,a.c=null,a.h=null,a.add=function(a,b){md(this),this.r=null,a=nd(this,a);var c=this.c.get(a);return c||this.c.set(a,c=[]),c.push(b),this.h++,this},a.remove=function(a){return md(this),a=nd(this,a),this.c.Q(a)?(this.r=null,this.h-=this.c.get(a).length,this.c.remove(a)):!1},a.Q=function(a){return md(this),a=nd(this,a),this.c.Q(a)},a.F=function(){md(this);for(var a=this.c.t(),b=this.c.F(),c=[],d=0;dthis.na?c.w({status:"payload-too-big",Ba:ea("Encoded hit length == %s, but should be <= %s.",d.length,this.na)}):cd(this.$b,function(){c.G(Nc)},d),c};var pd=function(a,b){var c=new ld;return c.add(Q.name,a),ja(b,function(a,b){c.add(a.name,b.toString())}),c.toString()},qd=function(a,b,c){this.k=a,this.Qb=b,this.na=c};qd.prototype.Sa=function(){if(!this.q){var a=this.k;if(!Ib(a.ha).C)throw Error("Cannot construct shared channel prior to settings being ready.");new Fc;var b=new Hc(new od(this.Qb,this.na)),c=new Pc;this.q=new Gc(a,new Qc(a,new Oc(c,b)))}return this.q};var rd=new L,sd=function(){if(!N){var a=new vc("google-analytics");N=new oc(a)}return N};q("goog.async.Deferred",Eb),q("goog.async.Deferred.prototype.addCallback",Eb.prototype.J),q("goog.events.EventTarget",fb),q("goog.events.EventTarget.prototype.listen",fb.prototype.listen),q("analytics.getService",function(a){var b=rd.get(a,null);if(null===b){var b=chrome.runtime.getManifest().version,c=sd();if(!O){var d=sd();O=new zc(d,new qd(d,"https://www.google-analytics.com/collect",8192))}b=new ic("ca1.5.2",a,b,c,O),rd.set(a,b)}return b}),q("analytics.internal.GoogleAnalyticsService",ic),q("analytics.internal.GoogleAnalyticsService.prototype.getTracker",ic.prototype.Cc),q("analytics.internal.GoogleAnalyticsService.prototype.getConfig",ic.prototype.Bc),q("analytics.internal.ServiceSettings",oc),q("analytics.internal.ServiceSettings.prototype.setTrackingPermitted",oc.prototype.Lc),q("analytics.internal.ServiceSettings.prototype.isTrackingPermitted",oc.prototype.va),q("analytics.internal.ServiceSettings.prototype.setSampleRate",oc.prototype.Kc),q("analytics.internal.ServiceTracker",gc),q("analytics.internal.ServiceTracker.prototype.send",gc.prototype.send),q("analytics.internal.ServiceTracker.prototype.sendAppView",gc.prototype.Gc),q("analytics.internal.ServiceTracker.prototype.sendEvent",gc.prototype.Hc),q("analytics.internal.ServiceTracker.prototype.sendSocial",gc.prototype.Jc),q("analytics.internal.ServiceTracker.prototype.sendException",gc.prototype.Ic),q("analytics.internal.ServiceTracker.prototype.sendTiming",gc.prototype.Cb),q("analytics.internal.ServiceTracker.prototype.startTiming",gc.prototype.Mc),q("analytics.internal.ServiceTracker.Timing",hc),q("analytics.internal.ServiceTracker.Timing.prototype.send",hc.prototype.send),q("analytics.internal.ServiceTracker.prototype.forceSessionStart",gc.prototype.Ac),q("analytics.internal.ServiceTracker.prototype.addFilter",gc.prototype.S),q("analytics.internal.FilterChannel.Hit",Sb),q("analytics.internal.FilterChannel.Hit.prototype.getHitType",Sb.prototype.Gb),q("analytics.internal.FilterChannel.Hit.prototype.getParameters",Sb.prototype.T),q("analytics.internal.FilterChannel.Hit.prototype.cancel",Sb.prototype.cancel),q("analytics.ParameterMap",ia),q("analytics.ParameterMap.Entry",ia.Entry),q("analytics.ParameterMap.prototype.set",ia.prototype.set),q("analytics.ParameterMap.prototype.get",ia.prototype.get),q("analytics.ParameterMap.prototype.remove",ia.prototype.remove),q("analytics.ParameterMap.prototype.toObject",ia.prototype.Jb),q("analytics.HitTypes.APPVIEW","appview"),q("analytics.HitTypes.EVENT","event"),q("analytics.HitTypes.SOCIAL","social"),q("analytics.HitTypes.TRANSACTION","transaction"),q("analytics.HitTypes.ITEM","item"),q("analytics.HitTypes.TIMING","timing"),q("analytics.HitTypes.EXCEPTION","exception"),F(X,function(a){var b=a.id.replace(/[A-Z]/,"_$&").toUpperCase();q("analytics.Parameters."+b,a)}),q("analytics.filters.EventLabelerBuilder",ca),q("analytics.filters.EventLabelerBuilder.prototype.appendToExistingLabel",ca.prototype.wc),q("analytics.filters.EventLabelerBuilder.prototype.stripValue",ca.prototype.Nc),q("analytics.filters.EventLabelerBuilder.prototype.powersOfTwo",ca.prototype.Ec),q("analytics.filters.EventLabelerBuilder.prototype.rangeBounds",ca.prototype.Fc),q("analytics.filters.EventLabelerBuilder.prototype.build",ca.prototype.Ca),q("analytics.filters.FilterBuilder",aa),q("analytics.filters.FilterBuilder.builder",ba),q("analytics.filters.FilterBuilder.prototype.when",aa.prototype.when),q("analytics.filters.FilterBuilder.prototype.whenHitType",aa.prototype.zb),q("analytics.filters.FilterBuilder.prototype.whenValue",aa.prototype.Oc),q("analytics.filters.FilterBuilder.prototype.applyFilter",aa.prototype.xb),q("analytics.filters.FilterBuilder.prototype.build",aa.prototype.Ca),q("analytics.EventBuilder",ka),q("analytics.EventBuilder.builder",function(){return la}),q("analytics.EventBuilder.prototype.category",ka.prototype.xc),q("analytics.EventBuilder.prototype.action",ka.prototype.action),q("analytics.EventBuilder.prototype.label",ka.prototype.label),q("analytics.EventBuilder.prototype.value",ka.prototype.value),q("analytics.EventBuilder.prototype.dimension",ka.prototype.yc),q("analytics.EventBuilder.prototype.metric",ka.prototype.Dc),q("analytics.EventBuilder.prototype.send",ka.prototype.send)}();var hex_chr="0123456789abcdef".split("");"5d41402abc4b2a76b9719d911017c592"!=md5("hello");var CanvasImage=function(a){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),document.body.appendChild(this.canvas),this.width=this.canvas.width=a.width,this.height=this.canvas.height=a.height,this.context.drawImage(a,0,0,this.width,this.height)};CanvasImage.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},CanvasImage.prototype.update=function(a){this.context.putImageData(a,0,0)},CanvasImage.prototype.getPixelCount=function(){return this.width*this.height},CanvasImage.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},CanvasImage.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)};var ColorThief=function(){};if(ColorThief.prototype.getColor=function(a,b){var c=this.getPalette(a,5,b),d=c[0];return d},ColorThief.prototype.getPalette=function(a,b,c){"undefined"==typeof b&&(b=10),"undefined"==typeof c&&(c=10);for(var d,e,f,g,h,i=new CanvasImage(a),j=i.getImageData(),k=j.data,l=i.getPixelCount(),m=[],n=0;l>n;n+=c)d=4*n,e=k[d+0],f=k[d+1],g=k[d+2],h=k[d+3],h>=125&&(e>250&&f>250&&g>250||m.push([e,f,g]));var o=MMCQ.quantize(m,b),p=o.palette();return i.removeCanvas(),p},!pv)var pv={map:function(a,b){var c={};return b?a.map(function(a,d){return c.index=d,b.call(c,a)}):a.slice()},naturalOrder:function(a,b){return b>a?-1:a>b?1:0},sum:function(a,b){var c={};return a.reduce(b?function(a,d,e){return c.index=e,a+b.call(c,d)}:function(a,b){return a+b},0)},max:function(a,b){return Math.max.apply(null,b?pv.map(a,b):a)}};var MMCQ=function(){function a(a,b,c){return(a<<2*i)+(b<>j,e=b[1]>>j,f=b[2]>>j,c=a(d,e,f),h[c]=(h[c]||0)+1}),h}function f(a,b){var d,e,f,g=1e6,h=0,i=1e6,k=0,l=1e6,m=0;return a.forEach(function(a){d=a[0]>>j,e=a[1]>>j,f=a[2]>>j,g>d?g=d:d>h&&(h=d),i>e?i=e:e>k&&(k=e),l>f?l=f:f>m&&(m=f)}),new c(g,h,i,k,l,m,b)}function g(b,c){function d(a){var b,d,e,f,g,h=a+"1",j=a+"2",k=0;for(i=c[h];i<=c[j];i++)if(o[i]>n/2){for(e=c.copy(),f=c.copy(),b=i-c[h],d=c[j]-i,g=d>=b?Math.min(c[j]-1,~~(i+d/2)):Math.max(c[h],~~(i-1-b/2));!o[g];)g++;for(k=p[g];!k&&o[g-1];)k=p[--g];return e[j]=g,f[h]=e[j]+1,[e,f]}}if(c.count()){var e=c.r2-c.r1+1,f=c.g2-c.g1+1,g=c.b2-c.b1+1,h=pv.max([e,f,g]);if(1==c.count())return[c.copy()];var i,j,k,l,m,n=0,o=[],p=[];if(h==e)for(i=c.r1;i<=c.r2;i++){for(l=0,j=c.g1;j<=c.g2;j++)for(k=c.b1;k<=c.b2;k++)m=a(i,j,k),l+=b[m]||0;n+=l,o[i]=n}else if(h==f)for(i=c.g1;i<=c.g2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.b1;k<=c.b2;k++)m=a(j,i,k),l+=b[m]||0;n+=l,o[i]=n}else for(i=c.b1;i<=c.b2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.g1;k<=c.g2;k++)m=a(j,k,i),l+=b[m]||0;n+=l,o[i]=n}return o.forEach(function(a,b){p[b]=n-a}),d(h==e?"r":h==f?"g":"b")}}function h(a,c){function h(a,b){for(var c,d=1,e=0;k>e;)if(c=a.pop(),c.count()){var f=g(i,c),h=f[0],j=f[1];if(!h)return;if(a.push(h),j&&(a.push(j),d++),d>=b)return;if(e++>k)return}else a.push(c),e++}if(!a.length||2>c||c>256)return!1;var i=e(a),j=0;i.forEach(function(){j++});var m=f(a,i),n=new b(function(a,b){return pv.naturalOrder(a.count(),b.count())});n.push(m),h(n,l*c);for(var o=new b(function(a,b){return pv.naturalOrder(a.count()*a.volume(),b.count()*b.volume())});n.size();)o.push(n.pop());h(o,c-o.size());for(var p=new d;o.size();)p.push(o.pop());return p}var i=5,j=8-i,k=1e3,l=.75;return c.prototype={volume:function(a){var b=this;return(!b._volume||a)&&(b._volume=(b.r2-b.r1+1)*(b.g2-b.g1+1)*(b.b2-b.b1+1)),b._volume},count:function(b){var c=this,d=c.histo;if(!c._count_set||b){var e,f,g,h=0;for(e=c.r1;e<=c.r2;e++)for(f=c.g1;f<=c.g2;f++)for(g=c.b1;g<=c.b2;g++)index=a(e,f,g),h+=d[index]||0;c._count=h,c._count_set=!0}return c._count},copy:function(){var a=this;return new c(a.r1,a.r2,a.g1,a.g2,a.b1,a.b2,a.histo)},avg:function(b){var c=this,d=c.histo;if(!c._avg||b){var e,f,g,h,j,k=0,l=1<<8-i,m=0,n=0,o=0;for(f=c.r1;f<=c.r2;f++)for(g=c.g1;g<=c.g2;g++)for(h=c.b1;h<=c.b2;h++)j=a(f,g,h),e=d[j]||0,k+=e,m+=e*(f+.5)*l,n+=e*(g+.5)*l,o+=e*(h+.5)*l;c._avg=k?[~~(m/k),~~(n/k),~~(o/k)]:[~~(l*(c.r1+c.r2+1)/2),~~(l*(c.g1+c.g2+1)/2),~~(l*(c.b1+c.b2+1)/2)]}return c._avg},contains:function(a){var b=this,c=a[0]>>j;return gval=a[1]>>j,bval=a[2]>>j,c>=b.r1&&c<=b.r2&&gval>=b.g1&&gval<=b.g2&&bval>=b.b1&&bval<=b.b2}},d.prototype={push:function(a){this.vboxes.push({vbox:a,color:a.avg()})},palette:function(){return this.vboxes.map(function(a){return a.color})},size:function(){return this.vboxes.size()},map:function(a){for(var b=this.vboxes,c=0;c"),this.installScopeStyle(this.transitionStyle,"transition",a.shadowRoot),a._hasTransitionStyle=!0),a.classList.add(this.baseClass),this.transitionType&&a.classList.add(this.baseClass+"-"+this.transitionType)},teardown:function(a){a.classList.remove(this.baseClass),this.transitionType&&a.classList.remove(this.baseClass+"-"+this.transitionType)},transitionOpened:function(a,b){this.listenOnce(a,this.completeEventName,function(){b||a.classList.remove(this.closedClass),this.complete(a)}),a.classList.toggle(this.openedClass,b),a.classList.toggle(this.closedClass,!b)}}),function(){var a;Polymer("paper-toast",{text:"",duration:3e3,opened:!1,responsiveWidth:"480px",swipeDisabled:!1,autoCloseDisabled:!1,narrowMode:!1,eventDelegates:{trackstart:"trackStart",track:"track",trackend:"trackEnd",transitionend:"transitionEnd"},narrowModeChanged:function(){this.classList.toggle("fit-bottom",this.narrowMode),this.opened&&this.$.overlay.resizeHandler()},openedChanged:function(){this.opened?this.dismissJob=this.job(this.dismissJob,this.dismiss,this.duration):(this.dismissJob&&this.dismissJob.stop(),this.dismiss())},toggle:function(){this.opened=!this.opened},show:function(){a&&a.dismiss(),a=this,this.opened=!0},dismiss:function(){this.dragging?this.shouldDismiss=!0:(this.opened=!1,a===this&&(a=null))},trackStart:function(a){this.swipeDisabled||(a.preventTap(),this.vertical=a.yDirection,this.w=this.offsetWidth,this.h=this.offsetHeight,this.dragging=!0,this.classList.add("dragging"))},track:function(a){if(this.dragging){var b=this.style;if(this.vertical){var c=a.dy;b.opacity=(this.h-Math.abs(c))/this.h,b.transform=b.webkitTransform="translate3d(0, "+c+"px, 0)"}else{var d=a.dx;b.opacity=(this.w-Math.abs(d))/this.w,b.transform=b.webkitTransform="translate3d("+d+"px, 0, 0)"}}},trackEnd:function(a){if(this.dragging){this.classList.remove("dragging"),this.style.opacity="",this.style.transform=this.style.webkitTransform="";var b=this.classList;this.vertical?(b.toggle("fade-out-down",1===a.yDirection&&a.dy>0),b.toggle("fade-out-up",-1===a.yDirection&&a.dy<0)):(b.toggle("fade-out-right",1===a.xDirection&&a.dx>0),b.toggle("fade-out-left",-1===a.xDirection&&a.dx<0)),this.dragging=!1}},transitionEnd:function(){var a=this.classList;a.contains("fade-out-right")||a.contains("fade-out-left")||a.contains("fade-out-down")||a.contains("fade-out-up")?(this.dismiss(),a.remove("fade-out-right","fade-out-left","fade-out-down","fade-out-up")):this.shouldDismiss&&this.dismiss(),this.shouldDismiss=!1}})}(),Polymer("core-menu"),Polymer("core-collapse",Polymer.mixin({target:null,horizontal:!1,opened:!1,duration:.33,fixedSize:!1,allowOverflow:!1,created:function(){this.transitionEndListener=this.transitionEnd.bind(this)},ready:function(){this.target=this.target||this},domReady:function(){this.async(function(){this.afterInitialUpdate=!0})},attached:function(){this.resizerAttachedHandler()},detached:function(){this.target&&this.removeListeners(this.target),this.resizableDetachedHandler()},targetChanged:function(a){a&&this.removeListeners(a),this.target&&(this.isTargetReady=!!this.target,this.classList.toggle("core-collapse-closed",this.target!==this),this.toggleOpenedStyle(!1),this.horizontalChanged(),this.addListeners(this.target),this.toggleClosedClass(!0),this.update())},addListeners:function(a){a.addEventListener("transitionend",this.transitionEndListener)},removeListeners:function(a){a.removeEventListener("transitionend",this.transitionEndListener)},horizontalChanged:function(){this.dimension=this.horizontal?"width":"height"},openedChanged:function(){this.update(),this.fire("core-collapse-open",this.opened)},toggle:function(){this.opened=!this.opened},setTransitionDuration:function(a){var b=this.target.style;b.transition=a?this.dimension+" "+a+"s":null,0===a&&this.async("transitionEnd")},transitionEnd:function(){this.opened&&!this.fixedSize&&this.updateSize("auto",null),this.setTransitionDuration(null),this.toggleOpenedStyle(this.opened),this.toggleClosedClass(!this.opened),this.asyncFire("core-resize",null,this.target),this.notifyResize()},toggleClosedClass:function(a){this.hasClosedClass=a,this.target.classList.toggle("core-collapse-closed",a)},toggleOpenedStyle:function(a){this.target.style.overflow=this.allowOverflow&&a?"":"hidden"},updateSize:function(a,b,c){this.setTransitionDuration(b),this.calcSize();var d=this.target.style,e=d[this.dimension]===a;d[this.dimension]=a,c&&e&&this.transitionEnd()},update:function(){this.target&&(this.isTargetReady||this.targetChanged(),this.horizontalChanged(),this[this.opened?"show":"hide"](),this.notifyResize())},calcSize:function(){return this.target.getBoundingClientRect()[this.dimension]+"px"},getComputedSize:function(){return getComputedStyle(this.target)[this.dimension]},show:function(){if(this.toggleClosedClass(!1),!this.afterInitialUpdate)return void this.transitionEnd();if(!this.fixedSize){this.updateSize("auto",null);var a=this.calcSize();if("0px"==a)return void this.transitionEnd();this.updateSize(0,null)}this.async(function(){this.updateSize(this.size||a,this.duration,!0)})},hide:function(){this.toggleOpenedStyle(!1),(!this.hasClosedClass||this.fixedSize)&&(this.fixedSize?this.size=this.getComputedSize():this.updateSize(this.calcSize(),null),this.async(function(){this.updateSize(0,this.duration)}))}},Polymer.CoreResizer)),Polymer("core-submenu",{publish:{active:{value:!1,reflect:!0}},opened:!1,get items(){return this.$.submenu.items},hasItems:function(){return!!this.items.length},unselectAllItems:function(){this.$.submenu.selected=null,this.$.submenu.clearSelection()},activeChanged:function(){this.hasItems()&&(this.opened=this.active),this.active||this.unselectAllItems()},toggle:function(){this.opened=!this.opened},activate:function(){this.hasItems()&&this.active&&(this.toggle(),this.unselectAllItems())}}),Polymer("core-scroll-threshold",{publish:{scrollTarget:null,orient:"v",upperThreshold:null,lowerThreshold:null,upperTriggered:!1,lowerTriggered:!1},observe:{"upperThreshold lowerThreshold scrollTarget orient":"setup"},ready:function(){this._boundScrollHandler=this.checkThreshold.bind(this)},detached:function(){this._scrollTarget&&this._scrollTarget.removeEventListener("scroll",this._boundScrollHandler)},setup:function(){var a=this.scrollTarget||this;this._scrollTarget&&this._scrollTarget!=a&&this._scrollTarget.removeEventListener("scroll",this._boundScrollHandler),a&&(this._scrollTarget=a,this._scrollTarget.addEventListener("scroll",this._boundScrollHandler)),this.style.overflow=a==this?"auto":null,this.scrollPosition="v"==this.orient?"scrollTop":"scrollLeft",this.sizeExtent="v"==this.orient?"offsetHeight":"offsetWidth",this.scrollExtent="v"==this.orient?"scrollHeight":"scrollWidth",this.upperThreshold||(this.upperTriggered=!1),this.lowerThreshold||(this.lowerTriggered=!1)},checkThreshold:function(a){var b=this._scrollTarget[this.scrollPosition];if(this.upperTriggered||null===this.upperThreshold||bd;d++)for(var e=b[d].episode.length,f=0;e>f;f++)b[d].episode[f].podcastRole=this.app.activeUser.podcastRole,f===e-1&&d===c-1&&(this.podcast=b,this.async(this.responseCallback));else if(a.artists&&a.artists.index)this.artist=a.artists.index,this.async(this.responseCallback);else if(a.searchResult3&&a.searchResult3.album)for(var g=a.searchResult3.album,c=a.searchResult3.album.length,h=[],d=0;c>d;d++)this.containsObject(g[d],h)||h.push(g[d]),d===c-1&&(this.wall=h,this.async(this.responseCallback));else this.app.pageLimit=!0;this.isLoading||this.wall[0]||(this.app.dataLoading=!1)}})},artistDetails:function(a,b,c){"use strict";var d=document.getElementById("aDetails");this.app.dataLoading=!0,d.artistId=c.attributes.ident.value,d.queryData()},doAjax:function(){"use strict";this.$.ajax.url=this.app.buildUrl(this.request,this.post),this.$.ajax.go()},getPodcast:function(){"use strict";this.showing="podcast",this.clearData(function(){this.app.pageLimit=!1,this.request="getPodcasts",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},getStarred:function(){"use strict";this.showing=this.listMode,this.clearData(function(){this.app.pageLimit=!1,"ID3"===this.queryMethod?this.request="getStarred2":this.request="getStarred",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},getArtist:function(){"use strict";this.clearData(function(){this.app.pageLimit=!1,this.request="getArtists",this.post.type="",this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.showing="artists",this.doAjax()}.bind(this))},sortChanged:function(){"use strict";this.showing=this.listMode,this.clearData(function(){this.app.pageLimit=!1,"ID3"===this.queryMethod?this.request="getAlbumList2":this.request="getAlbumList",this.post.type=this.sort,this.post.offset=0,chrome.storage.sync.set({sortType:this.post.type,request:this.request,mediaFolder:this.mediaFolder}),this.doAjax()}.bind(this))},resizeLists:function(){"use strict";this.$.cover.updateSize(),this.$.podcast.updateSize(),this.$.artists.updateSize()},errorChanged:function(){"use strict";this.error&&(console.error(this.error),this.app.doToast(chrome.i18n.getMessage("connectionError")))},loadMore:function(){"use strict";this.$.threshold.clearLower(),this.isLoading||"getStarred2"===this.request||"getPodcasts"===this.request||"getArtists"===this.request||this.app.pageLimit||0!==this.app.page||(this.isLoading=!0,this.post.offset=parseInt(this.post.offset,10)+parseInt(this.post.size,10),this.async(function(){this.doAjax()}))},querySizeChanged:function(){"use strict";this.post.size=this.querySize},listModeChanged:function(){"use strict";this.async(function(){this.listMode&&"getArtists"!==this.request&&"getPodcasts"!==this.request&&("cover"===this.listMode?this.showing="cover":this.showing="list",this.app.dataLoading=!1)})},getPaletteFromDb:function(a,b){"use strict";this.app.getDbItem(a+"-palette",function(a){b(a.target.result)}.bind(this))},doPlay:function(a,b){"use strict";this.app.playlist=[a],this.app.playing=0,this.app.playAudio("",a.title,b,a.cover,a.id),this.app.dataLoading=!1},mouseIn:function(a,b,c){c.setZ(2)},mouseOut:function(a,b,c){c.setZ(1)},playPodcast:function(a,b,c){"use strict";this.app.dataLoading=!0;var d,e,f=this.app.buildUrl("getCoverArt",{id:c.attributes.cover.value}),g=this.app.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:c.attributes.streamId.value});c.attributes.cover.value?this.app.getDbItem(c.attributes.cover.value,function(a){if(a.target.result){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d,function(){this.getPaletteFromDb(c.attributes.cover.value,function(a){e.palette=a,this.app.setFabColor(e),this.doPlay(e,g)}.bind(this))}.bind(this))}else this.app.getImageFile(f,c.attributes.cover.value,function(a){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d,function(){this.app.colorThiefHandler(d,c.attributes.cover.value,function(a){e.palette=a,this.app.setFabColor(e),this.doPlay(e,g)}.bind(this))}.bind(this))}.bind(this))}.bind(this)):(d="../../../images/default-cover-art.png",e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d),this.doPlay(e,g),this.app.page=1)},add2Playlist:function(a,b,c){"use strict";var d,e,f=this.app.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:c.attributes.streamId.value});this.app.dataLoading=!0,c.attributes.cover.value?this.app.getDbItem(c.attributes.cover.value,function(a){a.target.result?(d=window.URL.createObjectURL(a.target.result),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.getPaletteFromDb(c.attributes.cover.value,function(a){e.palette=a,this.audio.paused?this.app.getImageForPlayer(d,function(){this.app.setFabColor(e),this.doPlay(e,f),this.app.dataLoading=!1,this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this)):(this.app.dataLoading=!1,this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue")))}.bind(this))):this.app.getImageFile(this.app.buldUrl("getCoverArt",{id:c.attributes.cover.value}),c.attributes.cover.value,function(a){var b=a.target.result;d=window.URL.createObjectURL(b),e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.colorThiefHandler(d,c.attributes.cover.value,function(a){e.palette=a}),this.audio.paused?this.app.getImageForPlayer(d,function(){this.app.dataLoading=!1,this.app.setFabColor(e),this.doPlay(e,f),this.app.doToast(chrome.i18n.getMessage("added2Queue"))}.bind(this)):(this.app.dataLoading=!1,this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue")))}.bind(this))}.bind(this)):(d="../../../images/default-cover-art.png",this.audio.paused?(e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.getImageForPlayer(d),this.doPlay(e,f)):(e={id:c.attributes.streamId.value,artist:"",title:c.attributes.trackTitle.value,cover:d},this.app.playlist.push(e),this.app.doToast(chrome.i18n.getMessage("added2Queue"))))},showingChanged:function(){"use strict";var a=document.getElementById("fab");"podcast"===this.showing?a.state="podcast":a.state="off"},topOfPage:function(){"use strict";this.scrollTarget.scrollTop=0},deleteDialog:function(a,b,c){"use strict";this.app.delID=c.attributes.ident.value,this.app.$.confirmDelete.open()},deleteChannel:function(a){"use strict";this.app.doXhr(this.app.buildUrl("deletePodcastChannel",{id:a}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax()}.bind(this))}.bind(this))},refreshContent:function(){"use strict";0!==this.post.offset&&(this.post.offset=0),this.clearData(function(){this.doAjax()}.bind(this))},downloadEpisode:function(a,b,c){"use strict";this.app.doXhr(this.app.buildUrl("downloadPodcastEpisode",{id:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax(),this.app.doToast(chrome.i18n.getMessage("downloadPodcast"))}.bind(this))}.bind(this))},episodeDialog:function(a,b,c){"use strict";this.app.delID=c.attributes.ident.value,this.app.$.episodeConfirm.open()},deleteEpisode:function(a){"use strict";this.app.doXhr(this.app.buildUrl("deletePodcastEpisode",{id:a}),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&this.clearData(function(){this.doAjax()}.bind(this))}.bind(this))},toggleCollapse:function(a,b,c){"use strict";var d="#"+c.attributes.ident.value;this.$.all.querySelector(d).toggle()},playSomething:function(a,b){"use strict";var c=this.$.all.querySelector("#"+a);c.playAlbum(),b()},findIndexByKeyValue:function(a,b,c){"use strict";for(var d=a.length,e=0;d>e;e+=1)if(a[e][b]===c)return e;return null},jumpToLetter:function(a){"use strict";this.$.artists.scrollToItem(this.findIndexByKeyValue(this.artist,"name",a))},containsObject:function(a,b){"use strict";for(var c=b.length,d=0;c>d;d+=1)if(b[d].id===a.id)return!0;return!1}}),function(){Polymer("core-toolbar",{justify:"",middleJustify:"",bottomJustify:"",justifyChanged:function(a){this.updateBarJustify(this.$.topBar,this.justify,a)},middleJustifyChanged:function(a){this.updateBarJustify(this.$.middleBar,this.middleJustify,a)},bottomJustifyChanged:function(a){this.updateBarJustify(this.$.bottomBar,this.bottomJustify,a)},updateBarJustify:function(a,b,c){c&&a.removeAttribute(this.toLayoutAttrName(c)),b&&a.setAttribute(this.toLayoutAttrName(b),"")},toLayoutAttrName:function(a){return"between"===a?"justified":a+"-justified"}})}(),Polymer("core-header-panel",{publish:{mode:{value:"",reflect:!0},tallClass:"tall",shadow:!1},animateDuration:200,modeConfigs:{shadowMode:{waterfall:1,"waterfall-tall":1},noShadow:{seamed:1,cover:1,scroll:1},tallMode:{"waterfall-tall":1},outerScroll:{scroll:1}},ready:function(){this.scrollHandler=this.scroll.bind(this),this.addListener()},detached:function(){this.removeListener(this.mode)},addListener:function(){this.scroller.addEventListener("scroll",this.scrollHandler)},removeListener:function(a){var b=this.getScrollerForMode(a);b.removeEventListener("scroll",this.scrollHandler)},domReady:function(){this.async("scroll")},modeChanged:function(a){var b=this.modeConfigs,c=this.header;c&&(b.tallMode[a]&&!b.tallMode[this.mode]?(c.classList.remove(this.tallClass),this.async(function(){c.classList.remove("animate")},null,this.animateDuration)):c.classList.toggle("animate",b.tallMode[this.mode])),b&&(b.outerScroll[this.mode]||b.outerScroll[a])&&(this.removeListener(a),this.addListener()),this.scroll()},get header(){return this.$.headerContent.getDistributedNodes()[0]},getScrollerForMode:function(a){return this.modeConfigs.outerScroll[a]?this.$.outerContainer:this.$.mainContainer},get scroller(){return this.getScrollerForMode(this.mode)},scroll:function(){var a=this.modeConfigs,b=this.$.mainContainer,c=this.header,d=b.scrollTop,e=0===d;this.$.dropShadow.classList.toggle("hidden",!this.shadow&&(e&&a.shadowMode[this.mode]||a.noShadow[this.mode])),c&&a.tallMode[this.mode]&&c.classList.toggle(this.tallClass,e||c.classList.contains(this.tallClass)&&b.scrollHeight=this.offsetWidth-this.edgeSwipeSensitivity:a.pageX<=this.edgeSwipeSensitivity)},trackStart:function(a){this.swipeAllowed()&&(this.dragging=!0,this.isMainSelected()&&(this.dragging=this.peeking||this.isEdgeTouch(a)),this.dragging&&(this.width=this.$.drawer.offsetWidth,this.transition=!1,a.preventTap()))},translateXForDeltaX:function(a){var b=this.isMainSelected();return this.rightDrawer?Math.max(0,b?this.width+a:a):Math.min(0,b?a-this.width:a)},trackx:function(a){if(this.dragging){if(this.peeking){if(Math.abs(a.dx)<=this.edgeSwipeSensitivity)return;this.peeking=!1}this.moveDrawer(this.translateXForDeltaX(a.dx))}},trackEnd:function(a){this.dragging&&(this.dragging=!1,this.transition=!0,this.moveDrawer(null),this.rightDrawer?this.selected=a.xDirection>0?"main":"drawer":this.selected=a.xDirection>0?"drawer":"main")},transformForTranslateX:function(a){return null===a?"":this.hasWillChange?"translateX("+a+"px)":"translate3d("+a+"px, 0, 0)"},moveDrawer:function(a){var b=this.$.drawer.style;this.hasTransform?b.transform=this.transformForTranslateX(a):b.webkitTransform=this.transformForTranslateX(a)}}),Polymer("core-range",{value:0,min:0,max:100,step:1,ratio:0,observe:{"value min max step":"update"},calcRatio:function(a){return(this.clampValue(a)-this.min)/(this.max-this.min)},clampValue:function(a){return Math.min(this.max,Math.max(this.min,this.calcStep(a)))},calcStep:function(a){return this.step?Math.round(a/this.step)/(1/this.step):a},validateValue:function(){var a=this.clampValue(this.value);return this.value=this.oldValue=isNaN(a)?this.oldValue:a,this.value!==a},update:function(){this.validateValue(),this.ratio=100*this.calcRatio(this.value)}}),Polymer("paper-progress",{secondaryProgress:0,indeterminate:!1,step:0,observe:{"value secondaryProgress min max indeterminate":"update"},update:function(){this["super"](),this.secondaryProgress=this.clampValue(this.secondaryProgress), +this.secondaryRatio=100*this.calcRatio(this.secondaryProgress),this.$.activeProgress.classList.toggle("indeterminate",this.indeterminate)},transformProgress:function(a,b){var c="scaleX("+b/100+")";a.style.transform=a.style.webkitTransform=c},ratioChanged:function(){this.transformProgress(this.$.activeProgress,this.ratio)},secondaryRatioChanged:function(){this.transformProgress(this.$.secondaryProgress,this.secondaryRatio)}}),Polymer("core-input",{publish:{committedValue:"",preventInvalidInput:!1},previousValidInput:"",eventDelegates:{input:"inputAction",change:"changeAction"},ready:function(){this.disabledHandler(),this.placeholderHandler()},attributeChanged:function(a,b){this[a+"Handler"]&&this[a+"Handler"](b)},disabledHandler:function(){this.disabled?this.setAttribute("aria-disabled",""):this.removeAttribute("aria-disabled")},placeholderHandler:function(){this.placeholder?this.setAttribute("aria-label",this.placeholder):this.removeAttribute("aria-label")},commit:function(){this.committedValue=this.value},changeAction:function(){this.commit()},inputAction:function(a){this.preventInvalidInput&&(a.target.validity.valid?this.previousValidInput=a.target.value:a.target.value=this.previousValidInput)}}),function(){var a=CoreStyle.g.paperInput=CoreStyle.g.paperInput||{};a.labelColor="#757575",a.focusedColor="#4059a9",a.invalidColor="#d34336",Polymer("paper-input-decorator",{publish:{label:"",floatingLabel:!1,disabled:{value:!1,reflect:!0},labelVisible:null,isInvalid:!1,autoValidate:!1,error:"",focused:{value:!1,reflect:!0}},computed:{floatingLabelVisible:"floatingLabel && !_labelVisible",_labelVisible:"(labelVisible === true || labelVisible === false) ? labelVisible : _autoLabelVisible"},ready:function(){Polymer.addEventListener(this,"focus",this.focusAction.bind(this),!0),Polymer.addEventListener(this,"blur",this.blurAction.bind(this),!0)},attached:function(){this.input=this.querySelector("input,textarea"),this.mo=new MutationObserver(function(){this.input=this.querySelector("input,textarea")}.bind(this)),this.mo.observe(this,{childList:!0})},detached:function(){this.mo.disconnect(),this.mo=null},prepareLabelTransform:function(){var a=this.$.floatedLabelText.getBoundingClientRect(),b=this.$.labelText.getBoundingClientRect();if(0!==a.width){var c=a.height/b.height;this.$.labelText.cachedTransform="scale3d("+a.width/b.width+","+c+",1) translate3d(0,"+(a.top-b.top)/c+"px,0)"}},animateFloatingLabel:function(){return!this.floatingLabel||this.labelAnimated?!1:(this.$.labelText.cachedTransform||this.prepareLabelTransform(),this.$.labelText.cachedTransform?(this.labelAnimated=!0,this.async(function(){this.transitionEndAction()},null,250),this._labelVisible?(this.$.labelText.style.webkitTransform||this.$.labelText.style.transform||(this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform,this.$.labelText.style.transform=this.$.labelText.cachedTransform,this.$.labelText.offsetTop),this.$.labelText.style.webkitTransform="",this.$.labelText.style.transform=""):(this.$.labelText.style.webkitTransform=this.$.labelText.cachedTransform,this.$.labelText.style.transform=this.$.labelText.cachedTransform,this.input.placeholder=""),!0):!1)},animateUnderline:function(a){if(this.focused){var b=this.$.underline.getBoundingClientRect(),c=a.x-b.left;this.$.focusedUnderline.style.mozTransformOrigin=c+"px",this.$.focusedUnderline.style.webkitTransformOrigin=c+"px ",this.$.focusedUnderline.style.transformOriginX=c+"px",this.underlineAnimated=!0}},validate:function(){return this.input?(this.isInvalid=!this.input.validity.valid,this.input.validity.valid):!0},_labelVisibleChanged:function(a){void 0!==a&&(this.animateFloatingLabel()||this.updateInputLabel(this.input,this.label))},labelVisibleChanged:function(){"true"===this.labelVisible?this.labelVisible=!0:"false"===this.labelVisible&&(this.labelVisible=!1)},labelChanged:function(){this.input&&this.updateInputLabel(this.input,this.label)},isInvalidChanged:function(){this.classList.toggle("invalid",this.isInvalid)},focusedChanged:function(){this.updateLabelVisibility(this.input&&this.input.value),this.lastEvent&&(this.animateUnderline(this.lastEvent),this.lastEvent=null),this.underlineVisible=this.focused},inputChanged:function(a){this.input&&(this.updateLabelVisibility(this.input.value),this.updateInputLabel(this.input,this.label),this.autoValidate&&this.validate()),a&&this.updateInputLabel(a,"")},focusAction:function(){this.focused=!0},blurAction:function(){this.focused=!1},updateLabelVisibility:function(a){var b=null!==a&&void 0!==a?String(a):a;this._autoLabelVisible=!this.focused&&!b||!this.floatingLabel&&!b},updateInputLabel:function(a,b){this._labelVisible?this.input.placeholder=this.label:this.input.placeholder="",b?a.setAttribute("aria-label",b):a.removeAttribute("aria-label")},inputAction:function(){this.updateLabelVisibility(this.input.value),this.autoValidate&&this.validate()},downAction:function(a){return a.target!==this.input&&this.focused?void a.preventDefault():void(this.lastEvent=a)},tapAction:function(a){this.disabled||this.focused||this.input&&(this.input.focus(),a.preventDefault())},transitionEndAction:function(){this.underlineAnimated=!1,this.labelAnimated=!1,this._labelVisible&&(this.input.placeholder=this.label)},charCounterErrorAction:function(a){this.isInvalid=a.detail.hasError,this.$.errorIcon.hidden=a.detail.hideErrorIcon}})}(),Polymer("paper-input",{publish:{label:"",floatingLabel:!1,disabled:{value:!1,reflect:!0},value:"",committedValue:""},focus:function(){this.$.input.focus()},valueChanged:function(){this.$.decorator.updateLabelVisibility(this.value)},changeAction:function(a){this.fire("change",null,this)}}),Polymer("paper-slider",{snaps:!1,pin:!1,disabled:!1,secondaryProgress:0,editable:!1,maxMarkers:100,dragging:!1,observe:{"step snaps":"update"},ready:function(){this.update()},update:function(){this.positionKnob(this.calcRatio(this.value)),this.updateMarkers()},minChanged:function(){this.update(),this.setAttribute("aria-valuemin",this.min)},maxChanged:function(){this.update(),this.setAttribute("aria-valuemax",this.max)},valueChanged:function(){this.update(),this.setAttribute("aria-valuenow",this.value),this.fire("core-change")},disabledChanged:function(){this.disabled?this.removeAttribute("tabindex"):this.tabIndex=0},immediateValueChanged:function(){this.dragging||(this.value=this.immediateValue),this.editable&&(this.$.input.value=this.immediateValue),this.fire("immediate-value-change")},expandKnob:function(){this.expand=!0},resetKnob:function(){this.expandJob&&this.expandJob.stop(),this.expand=!1},positionKnob:function(a){this.immediateValue=this.calcStep(this.calcKnobPosition(a))||0,this._ratio=this.snaps?this.calcRatio(this.immediateValue):a,this.$.sliderKnob.style.left=100*this._ratio+"%"},inputChange:function(){this.value=this.$.input.value,this.fire("change")},calcKnobPosition:function(a){return(this.max-this.min)*a+this.min},trackStart:function(a){this._w=this.$.sliderBar.offsetWidth,this._x=this._ratio*this._w,this._startx=this._x||0,this._minx=-this._startx,this._maxx=this._w-this._startx,this.$.sliderKnob.classList.add("dragging"),this.dragging=!0,a.preventTap()},trackx:function(a){var b=Math.min(this._maxx,Math.max(this._minx,a.dx));this._x=this._startx+b,this.immediateValue=this.calcStep(this.calcKnobPosition(this._x/this._w))||0;var c=this.$.sliderKnob.style;c.transform=c.webkitTransform="translate3d("+(this.snaps?this.calcRatio(this.immediateValue)*this._w-this._startx:b)+"px, 0, 0)"},trackEnd:function(){var a=this.$.sliderKnob.style;a.transform=a.webkitTransform="",this.$.sliderKnob.classList.remove("dragging"),this.dragging=!1,this.resetKnob(),this.value=this.immediateValue,this.fire("change")},knobdown:function(a){a.preventDefault(),this.expandKnob()},bardown:function(a){a.preventDefault(),this.transiting=!0,this._w=this.$.sliderBar.offsetWidth;var b=this.$.sliderBar.getBoundingClientRect(),c=(a.x-b.left)/this._w;this.positionKnob(c),this.expandJob=this.job(this.expandJob,this.expandKnob,60),this.asyncFire("change")},knobTransitionEnd:function(a){a.target===this.$.sliderKnob&&(this.transiting=!1)},updateMarkers:function(){this.markers=[];var a=(this.max-this.min)/this.step;if(this.snaps||!(a>this.maxMarkers))for(var b=0;a>b;b++)this.markers.push("")},increment:function(){this.value=this.clampValue(this.value+this.step)},decrement:function(){this.value=this.clampValue(this.value-this.step)},incrementKey:function(a,b){"end"===b.key?this.value=this.max:this.increment(),this.fire("change")},decrementKey:function(a,b){"home"===b.key?this.value=this.min:this.decrement(),this.fire("change")}}),Polymer("paper-dialog-base",{publish:{heading:"",transition:"",layered:!0},ready:function(){this["super"](),this.sizingTarget=this.$.scroller},headingChanged:function(a){var b=this.getAttribute("aria-label");b&&b!==a||this.setAttribute("aria-label",this.heading)},openAction:function(){this.$.scroller.scrollTop&&(this.$.scroller.scrollTop=0)}}),Polymer("paper-dialog"),Polymer("paper-action-dialog",{publish:{closeSelector:"[affirmative],[dismissive]"}}),Polymer("core-dropdown-base",{publish:{opened:!1},eventDelegates:{tap:"toggleOverlay"},overlayListeners:{"core-overlay-open":"openAction"},get dropdown(){if(!this._dropdown){this._dropdown=this.querySelector(".dropdown");for(var a in this.overlayListeners)this.addElementListener(this._dropdown,a,this.overlayListeners[a])}return this._dropdown},attached:function(){this.dropdown},addElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.addEventListener(a,b,e,d)},removeElementListener:function(a,b,c,d){var e=this._makeBoundListener(c);a&&e&&Polymer.removeEventListener(a,b,e,d)},_makeBoundListener:function(a){var b=this,c=this[a];if(c){var d="_bound"+a;return this[d]||(this[d]=function(a){c.call(b,a)}),this[d]}},openedChanged:function(){if(!this.disabled){var a=this.dropdown;a&&(a.opened=this.opened)}},openAction:function(a){this.opened=!!a.detail},toggleOverlay:function(a){this.dropdown.contains(a.target)||this.disabled||(this.opened=!this.opened)}}),Polymer("paper-menu-button",{overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction"},activateAction:function(){this.opened=!1}}),function(){function a(a){var b;return((b=document.documentElement)||(b=document.body.parentNode))&&"number"==typeof b[a]?b:document.body}function b(){var b,c,d=a("clientWidth"),e=document.body;return"number"==typeof document.clientWidth?{w:document.clientWidth,h:document.clientHeight}:d===e||(b=Math.max(d.clientWidth,e.clientWidth))>self.innerWidth||(c=Math.max(d.clientHeight,e.clientHeight))>self.innerHeight?{w:e.clientWidth,h:e.clientHeight}:{w:b,h:c}}Polymer("core-dropdown",{publish:{relatedTarget:null,halign:"left",valign:"top"},measure:function(){var a=this.target,b=a.style.position;a.style.position="fixed",a.style.left="0px",a.style.top="0px";var c=a.getBoundingClientRect();return a.style.position=b,a.style.left=null,a.style.top=null,c},resetTargetDimensions:function(){var a=this.dimensions,b=this.target.style;a.position.h_by===this.localName&&(b[a.position.h]=null,a.position.h_by=null),a.position.v_by===this.localName&&(b[a.position.v]=null,a.position.v_by=null);var b=this.sizingTarget.style;b.width=null,b.height=null,this["super"]()},positionTarget:function(){if(!this.relatedTarget&&(this.relatedTarget=this.target.parentElement||this.target.parentNode&&this.target.parentNode.host,!this.relatedTarget))return void this["super"]();var a=this.sizingTarget,b=this.measure();a.style.width=Math.ceil(b.width)+"px",a.style.height=Math.ceil(b.height)+"px",this.layered?this.positionLayeredTarget():this.positionNestedTarget()},positionLayeredTarget:function(){var a=this.target,c=this.relatedTarget.getBoundingClientRect(),d=this.dimensions,e=d.margin,f=b();d.position.h||("right"===this.halign?(a.style.right=f.w-c.right-e.right+"px",d.position.h="right"):(a.style.left=c.left-e.left+"px",d.position.h="left"),d.position.h_by=this.localName),d.position.v||("bottom"===this.valign?(a.style.bottom=f.h-c.bottom-e.bottom+"px",d.position.v="bottom"):(a.style.top=c.top-e.top+"px",d.position.v="top"),d.position.v_by=this.localName),(d.position.h_by||d.position.v_by)&&(a.style.position="fixed")},positionNestedTarget:function(){var a=this.target,b=this.relatedTarget,c=a.offsetParent,d=b.offsetParent;window.ShadowDOMPolyfill&&(c=wrap(c),d=wrap(d)),c!==d&&c!==b&&console.warn("core-dropdown-overlay: dropdown's offsetParent must be the relatedTarget or the relatedTarget's offsetParent!");var e=this.dimensions,f=e.margin,g=c===b;e.position.h||("right"===this.halign?(a.style.right=(g?0:c.offsetWidth-b.offsetLeft-b.offsetWidth)-f.right+"px",e.position.h="right"):(a.style.left=(g?0:b.offsetLeft)-f.left+"px",e.position.h="left"),e.position.h_by=this.localName),e.position.v||("bottom"===this.valign?(a.style.bottom=(g?0:c.offsetHeight-b.offsetTop-b.offsetHeight)-f.bottom+"px",e.position.v="bottom"):(a.style.top=(g?0:b.offsetTop)-f.top+"px",e.position.v="top"),e.position.v_by=this.localName)}})}(),Polymer("paper-dropdown-transition",{publish:{duration:500},setup:function(a){this["super"](arguments);var b={top:"0%",left:"0%",bottom:"100%",right:"100%"},c=a.$.background;c.style.webkitTransformOrigin=b[a.halign]+" "+b[a.valign],c.style.transformOrigin=b[a.halign]+" "+b[a.valign]},transitionOpened:function(a,b){if(this["super"](arguments),b){this.player&&this.player.cancel();var c=Number(a.getAttribute("duration"))||this.duration,d=[],e=a.getBoundingClientRect(),f=a.$.ripple,g=.2;d.push(new Animation(f,[{opacity:.9,transform:"scale(0)"},{opacity:.9,transform:"scale(1)"}],{duration:c*g})),d.push(new Animation(a.$.background,[{opacity:0,transform:"scale(0)"},{opacity:0,transform:"scale(0)"}],{duration:0,delay:0,fill:"forwards"}));var h=a.$.background,i=40/e.width,j=40/e.height;d.push(new Animation(h,[{opacity:.9,transform:"scale("+i+","+j+")"},{opacity:1,transform:"scale("+Math.max(i,.95)+","+Math.max(j,.5)+")"},{opacity:1,transform:"scale(1, 1)"}],{delay:c*g,duration:c*(1-g),fill:"forwards"}));var k=a.querySelector(".menu");if(k){var l=k.items||k.children.array(),m=g+(1-g)/2,n=c*(1-m)/l.length,o="bottom"===this.valign;l.forEach(function(a,b){d.push(new Animation(a,[{opacity:0},{opacity:1}],{delay:c*m+n*(o?l.length-1-b:b),duration:n,fill:"both"}))}.bind(this)),d.push(new Animation(a.$.scroller,[{opacity:1},{opacity:1}],{delay:c*m,duration:n*l.length,fill:"both"}))}else d.push(new Animation(a.$.scroller,[{opacity:0},{opacity:1}],{delay:c*(g+(1-g)/2),duration:.5*c,fill:"both"}));var p=new AnimationGroup(d,{easing:"cubic-bezier(0.4, 0, 0.2, 1)"});this.player=document.timeline.play(p),this.player.onfinish=function(){this.fire("core-transitionend",this,a)}.bind(this)}else this.fire("core-transitionend",this,a)}}),Polymer("paper-dropdown",{publish:{transition:"paper-dropdown-transition"},ready:function(){this["super"](),this.sizingTarget=this.$.scroller}}),function(){var a={publish:{label:"Select an item",openedIcon:"arrow-drop-up",closedIcon:"arrow-drop-down"},selectedItemLabel:"",overlayListeners:{"core-overlay-open":"openAction","core-activate":"activateAction","core-select":"selectAction"},activateAction:function(a){this.opened=!1},selectAction:function(a){var b=a.detail;b.isSelected?(this.$.label.classList.add("selectedItem"),this.selectedItemLabel=b.item.label||b.item.textContent):(this.$.label.classList.remove("selectedItem"),this.selectedItemLabel="")}};Polymer.mixin2(a,Polymer.CoreFocusable),Polymer("paper-dropdown-menu",a)}(),function(){function a(a){return a.id||(a.id="core-label-"+b++),a.id}var b=0;Polymer("core-label",{publish:{"for":{reflect:!0,value:""}},eventDelegates:{tap:"tapHandler"},created:function(){a(this),this._forElement=null},ready:function(){this["for"]||(this._forElement=this.querySelector("[for]"),this._tie())},tapHandler:function(a){this._forElement&&a.target!==this._forElement&&(this._forElement.focus(),this._forElement.click(),this.fire("tap",null,this._forElement))},_tie:function(){this._forElement&&this._forElement.setAttribute("aria-labelledby",this.id)},_findScope:function(){for(var a=this.parentNode;a&&a.parentNode;)a=a.parentNode;return a},forChanged:function(a,b){this._forElement&&this._forElement.removeAttribute("aria-labelledby");var c=this._findScope();c&&(this._forElement=c.querySelector(b),this._forElement&&this._tie())}})}(),Polymer("volume-slider",{created:function(){this.volume=this.volume||100},volumeChanged:function(){var a=document.getElementById("audio");a.volume=this.volume/100,chrome.storage.sync.set({volume:this.volume})}}),Polymer("subsonic-login",{timer:0,ready:function(){"use strict";this.post=[],this.app=document.getElementById("tmpl"),this.urlError=chrome.i18n.getMessage("urlError"),this.urlLabel=chrome.i18n.getMessage("urlLabel"),this.usernameError=chrome.i18n.getMessage("usernameError"),this.usernameLabel=chrome.i18n.getMessage("usernameLabel"),this.passwordLabel=chrome.i18n.getMessage("passwordLabel"),this.showPass=chrome.i18n.getMessage("showPass"),this.hideThePass=chrome.i18n.getMessage("hidePass"),this.submitButton=chrome.i18n.getMessage("submitButton")},submit:function(){"use strict";if(this.invalid1&&this.invalid2&&void 0===this.post.version)this.app.doToast("URL, Username & Version Required");else if(this.invalid1)this.app.doToast("URL Required");else if(this.invalid2)this.app.doToast("Username Required");else if(!this.invalid1&&!this.invalid2&&!this.invalid3){var a=this.post.url.substr(-1);"/"===a&&(this.post.url=this.post.url.substring(0,this.post.url.length-1)),this.$.ajax.go()}},hidePass:function(a,b,c){"use strict";var d=this.$.password.type,e=this.$.showPass,f=this.timer;"text"===d?(this.$.password.type="password",e.innerHTML=this.showPass,f&&(clearTimeout(f),f=0)):(this.$.password.type="text",e.innerHTML=this.hideThePass,f=setTimeout(function(){this.$.password.type="password",e.innerHTML=this.showPass,f=0}.bind(this),15e3))},responseChanged:function(){"use strict";var a=document.getElementById("wall");this.response&&("ok"===this.response["subsonic-response"].status?(chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass}),this.app.url=this.post.url,this.app.user=this.post.user,this.app.pass=this.post.pass,this.app.userDetails(),this.app.version=this.response["subsonic-response"].version,this.app.doToast("Loading Data"),this.app.tracker.sendEvent("API Version",this.response["subsonic-response"].version),this.app.$.firstRun.close(),this.app.doXhr(this.url+"/rest/getMusicFolders.view?u="+this.user+"&p="+this.pass+"&f=json&v="+this.version+"&c=PolySonic","json",function(a){this.app.mediaFolders=a.target.response["subsonic-response"].musicFolders.musicFolder,a.target.response["subsonic-response"].musicFolders.musicFolder[1]||(this.app.$.sortBox.style.display="none")}.bind(this)),setTimeout(function(){a.doAjax()},100)):(console.log(this.response),this.app.doToast(this.response["subsonic-response"].error.message)))},errorChanged:function(){"use strict";0===this.error.statusCode&&this.app.doToast(chrome.i18n.getMessage("connectionError"))},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version}}),Polymer("paper-radio-button",{publish:{checked:{value:!1,reflect:!0},label:"",toggles:!1,disabled:{value:!1,reflect:!0}},eventDelegates:{tap:"tap"},tap:function(){if(!this.disabled){var a=this.checked;this.toggle(),this.checked!==a&&this.fire("change")}},toggle:function(){this.checked=!this.toggles||!this.checked},checkedChanged:function(){this.setAttribute("aria-checked",this.checked?"true":"false"),this.fire("core-change")},labelChanged:function(){this.setAttribute("aria-label",this.label)}}),Polymer("paper-toggle-button",{checked:!1,disabled:!1,eventDelegates:{down:"downAction",up:"upAction",tap:"tap",trackstart:"trackStart",trackx:"trackx",trackend:"trackEnd"},downAction:function(a){var b=this.$.ink.getBoundingClientRect();this.$.ink.downAction({x:b.left+b.width/2,y:b.top+b.height/2})},upAction:function(a){this.$.ink.upAction()},tap:function(){this.disabled||(this.checked=!this.checked,this.fire("change"))},trackStart:function(a){this.disabled||(this._w=this.$.toggleBar.offsetWidth/2,a.preventTap())},trackx:function(a){this._x=Math.min(this._w,Math.max(0,this.checked?this._w+a.dx:a.dx)),this.$.toggleButton.classList.add("dragging");var b=this.$.toggleButton.style;b.webkitTransform=b.transform="translate3d("+this._x+"px,0,0)"},trackEnd:function(){var a=this.$.toggleButton.style;a.transform=a.webkitTransform="",this.$.toggleButton.classList.remove("dragging");var b=this.checked;this.checked=Math.abs(this._x)>this._w/2,this.checked!==b&&this.fire("change")},checkedChanged:function(){this.setAttribute("aria-pressed",Boolean(this.checked)),this.fire("core-change")}}),Polymer("settings-menu",{post:{},manifest:chrome.runtime.getManifest(),urlError:chrome.i18n.getMessage("urlError"),urlLabel:chrome.i18n.getMessage("urlLabel"),usernameError:chrome.i18n.getMessage("usernameError"),usernameLabel:chrome.i18n.getMessage("usernameLabel"),passwordLabel:chrome.i18n.getMessage("passwordLabel"),showPass:chrome.i18n.getMessage("showPass"),hideThePass:chrome.i18n.getMessage("hidePass"),submitButton:chrome.i18n.getMessage("submitButton"),bitrateLabel:chrome.i18n.getMessage("bitrateLabel"),cacheDetails:chrome.i18n.getMessage("cacheDetails"),clearCacheLabel:chrome.i18n.getMessage("clearCacheLabel"),clearSettingsLabel:chrome.i18n.getMessage("clearSettingsLabel"),appName:chrome.i18n.getMessage("appName"),licenseInfoLink:chrome.i18n.getMessage("licenseInfoLink"),showLicenseLabel:chrome.i18n.getMessage("showLicenseLabel"),speeds:[96,128,192,256,320],timer:0,created:function(){this.elementReady=!1},domReady:function(){this.app=document.getElementById("tmpl"),this.wall=document.getElementById("wall"),this.outputVersion(this.manifest),setTimeout(function(){this.elementReady=!0}.bind(this),500)},outputVersion:function(a){this.polysonicVersion=a.version,console.log("App version: "+this.polysonicVersion)},validate:function(a){"use strict";var b=this.$.validate.querySelectorAll("paper-input-decorator");Array.prototype.forEach.call(b,function(a){a.isInvalid=!a.querySelector("input").validity.valid}),a()},submit:function(){"use strict";this.validate(function(){var a=this.$.input1.classList.contains("invalid"),b=this.$.input2.classList.contains("invalid"),c=this.$.input3.classList.contains("invalid");if(a&&b&&void 0===this.post.version?this.app.doToast("URL, Username & Version Required"):a?this.app.doToast("URL Required"):b?this.app.doToast("Username Required"):void 0===this.version&&this.app.doToast("Version Required"),!a&&!b&&!c&&void 0!==this.post.version&&void 0!==this.post.bitRate){var d=this.post.url.substr(-1);"/"===d&&(this.post.url=this.post.url.substring(0,this.post.url.length-1)),this.$.ajax.go(),this.wall.clearData(function(){this.wall.doAjax()}.bind(this))}}.bind(this))},hidePass:function(a,b,c){"use strict";var d=this.$.password.type,e=this.$.showPass,f=this.timer;"text"===d?(this.$.password.type="password",e.innerHTML=this.showPass,f&&(clearTimeout(f),f=0)):(this.$.password.type="text",e.innerHTML=this.hideThePass,f=setTimeout(function(){this.$.password.type="password",e.innerHTML=this.showPass,f=0}.bind(this),15e3))},methodSelect:function(){this.async(function(){chrome.storage.sync.set({queryMethod:this.post.queryMethod}),this.app.queryMethod=this.post.queryMethod,console.log("Query Method: "+this.post.queryMethod)})},doClearCache:function(){this.clearCache(function(){this.app.$.recommendReloadDialog.open()}.bind(this))},clearCache:function(a){var b=indexedDB.deleteDatabase("albumInfo");b.onsuccess=function(){console.log("Deleted database successfully"),this.app.createObjectStore(),this.app.calculateStorageSize()}.bind(this),b.onerror=function(){console.log("Error deleting database"),this.app.calculateStorageSize()}.bind(this),b.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked"),this.app.calculateStorageSize()}.bind(this),a()},clearSettings:function(){chrome.storage.sync.clear(),this.app.url="",this.app.user="",this.app.pass="",this.app.version="",this.app.bitRate="",this.app.querySize="",this.post=[],this.clearCache(function(){this.app.$.reloadAppDialog.open()}.bind(this))},responseChanged:function(){"use strict";if(this.response)if("ok"===this.response["subsonic-response"].status){if(this.post.url!==this.url){var a=indexedDB.deleteDatabase("albumInfo");a.onsuccess=function(){console.log("Deleted database successfully"),this.app.createObjectStore()},a.onerror=function(){console.log("Error deleting database")},a.onblocked=function(){console.log("Couldn't delete database due to the operation being blocked")}}chrome.storage.sync.set({url:this.post.url,user:this.post.user,pass:this.post.pass,version:this.response["subsonic-response"].version,bitRate:this.post.bitRate,querySize:this.post.querySize,queryMethod:this.post.queryMethod}),this.app.url=this.post.url,this.app.user=this.post.user,this.app.pass=this.post.pass,this.app.version=this.response["subsonic-response"].version,this.app.bitRate=this.post.bitRate,this.app.querySize=this.post.querySize,this.app.queryMethod=this.post.queryMethod,this.app.doToast("Settings Saved")}else this.app.doToast("failed"===this.response["subsonic-response"].status?this.response["subsonic-response"].error.message:"Error Connecting to Server. Check Settings")},bitRateSelect:function(){chrome.storage.sync.set({bitRate:this.post.bitRate}),this.app.bitRate=this.post.bitRate,console.log("Bitrate: "+this.post.bitRate)},querySelect:function(){chrome.storage.sync.set({querySize:this.post.querySize}),this.app.querySize=this.post.querySize,console.log("Query Size: "+this.post.querySize)},errorChanged:function(){"use strict";0===this.error.statusCode&&this.app.doToast(chrome.i18n.getMessage("connectionError"))},urlChanged:function(){this.post.url=this.url},userChanged:function(){this.post.user=this.user},passChanged:function(){this.post.pass=this.pass},versionChanged:function(){this.post.version=this.version},bitRateChanged:function(){this.post.bitRate=this.bitRate},querySizeChanged:function(){this.post.querySize=this.querySize},queryMethodChanged:function(){this.post.queryMethod=this.queryMethod},showQuota:function(){this.app.calculateStorageSize(),this.$.quota.toggle()},linkGo:function(a,b,c){var d=c.attributes.link.value;window.open(d,"_blank")},analisticsToggle:function(){chrome.storage.sync.set({analistics:this.app.analisticsEnabled})},getLicense:function(a,b,c){var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),this.app.getLicense(function(){d.cancel()})}}),Polymer("paper-fab",{publish:{src:"",icon:"",mini:!1,raised:!0,recenteringTouch:!0,fill:!1},iconChanged:function(a){var b=this.getAttribute("aria-label");b&&b!==a||this.setAttribute("aria-label",this.icon)}}),Polymer("animated-fab",{created:function(){this.state=this.state||"off",this.page=this.page||0,this.timer=0},domReady:function(){this.app=document.getElementById("tmpl"),this.bottomPos=16,this.ready=!0},pageChanged:function(){var a;1===this.page?(a="Player",this.state="top"):0===this.page?(a="Album Wall",this.state="off"):2===this.page?(a="Settings",this.state="off"):3===this.page?(a="Artist Details",this.state="off"):this.state="off",0===this.page&&"podcast"===this.showing&&(this.state="podcast"),document.getElementById("tmpl").tracker.sendAppView(a)},playingChanged:function(){this.playing&&document.getElementById("tmpl").playThis()},isNowPlayingChanged:function(a,b){a?(this.bottomPos=105,clearTimeout(this.timer),this.timer=0):this.ready&&this.app&&(this.app.playlist[0]?this.timer=setTimeout(function(){this.bottomPos=16}.bind(this),12e4):this.bottomPos=16)}}),function(){var a=navigator.userAgent.match(/iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/),b=a&&a[1]>=8;Polymer("core-list",Polymer.mixin({publish:{data:null,groups:null,scrollTarget:null,selectionEnabled:!0,multi:!1,selection:null,grid:!1,width:null,height:200,runwayFactor:4},eventDelegates:{tap:"tapHandler","core-resize":"updateSize"},_scrollTop:0,observe:{"isAttached data grid width template scrollTarget":"initialize","multi selectionEnabled":"_resetSelection"},ready:function(){this._boundScrollHandler=this.scrollHandler.bind(this),this._boundPositionItems=this._positionItems.bind(this),this._oldMulti=this.multi,this._oldSelectionEnabled=this.selectionEnabled,this._virtualStart=0,this._virtualCount=0,this._physicalStart=0,this._physicalOffset=0,this._physicalSize=0,this._physicalSizes=[],this._physicalAverage=0,this._itemSizes=[],this._dividerSizes=[],this._repositionedItems=[],this._aboveSize=0,this._nestedGroups=!1,this._groupStart=0,this._groupStartIndex=0},attached:function(){this.isAttached=!0,this.template=this.querySelector("template"),this.template.bindingDelegate||(this.template.bindingDelegate=this.element.syntax),this.resizableAttachedHandler()},detached:function(){this.isAttached=!1,this._target&&this._target.removeEventListener("scroll",this._boundScrollHandler),this.resizableDetachedHandler()},updateSize:function(){this._positionPending||this._needItemInit||(this._resetIndex(this._getFirstVisibleIndex()||0),this.initialize())},_resetSelection:function(){this._oldMulti!=this.multi&&!this.multi||this._oldSelectionEnabled!=this.selectionEnabled&&!this.selectionEnabled?(this._clearSelection(),this.refresh()):this.selection=this.$.selection.getSelection(),this._oldMulti=this.multi,this._oldSelectionEnabled=this.selectionEnabled},_adjustVirtualIndex:function(a,b){if(0!==this._targetSize){for(var c=0,d=0;d=this._virtualStart)break;var i=Math.max(g.addedCount-g.removed.length,h-this._virtualStart);if(c+=i,this._physicalStart+=i,this._virtualStart+=i,this._grouped){if(b)f=g.index;else{var j=this.groupForVirtualIndex(g.index);e=j.group,f=j.groupIndex}e==this._groupStart&&f0;){var b=this.getGroupLen()-this._groupStartIndex-1;a>b?(a-=b+1,this._groupStart++,this._groupStartIndex=0):(this._groupStartIndex+=a,a=0)}for(;0>a;)-a>this._groupStartIndex?(a+=this._groupStartIndex,this._groupStart--,this._groupStartIndex=this.getGroupLen()):(this._groupStartIndex+=a,a=this.getGroupLen())}this.grid&&(a=this._grouped?this._groupStartIndex%this._rowFactor:this._virtualStart%this._rowFactor,a&&this.changeStartIndex(-a))},getRowCount:function(a){if(this.grid){if(this._grouped){if(0>a){if(this._groupStartIndex>0)return-Math.min(this._rowFactor,this._groupStartIndex);var b=this.getGroupLen(this._groupStart-1);return-Math.min(this._rowFactor,b%this._rowFactor||this._rowFactor)}return Math.min(this._rowFactor,this.getGroupLen()-this._groupStartIndex)}return a*this._rowFactor}return a},_virtualToPhysical:function(a){var b=(a-this._physicalStart)%this._physicalCount;return 0>b?this._physicalCount+b:b},groupForVirtualIndex:function(a){if(this._grouped){var b;for(b=0;ba)break;a-=c}return{group:b,groupIndex:a}}return{}},virtualIndexForGroup:function(a,b){for(b=b?Math.min(b,this.getGroupLen(a)):0,a--;a>=0;)b+=this.getGroupLen(a--);return b},dataForIndex:function(a,b,c){if(this.data){if(!this._nestedGroups)return this.data[a];if(ad?-1:d>0?1:0,Math.abs(d)>Math.max(this._physicalSize,this._targetSize))b=Math.round(d/this._physicalAverage*this._rowFactor),b=Math.max(b,-this._virtualStart),b=Math.min(b,this._virtualCount-this._virtualStart-1),this._physicalOffset+=Math.max(d,-this._physicalOffset),this.changeStartIndex(b);else{var e=this._aboveSize+this._physicalOffset,f=.3*Math.max((this._physicalSize-this._targetSize,this._physicalSize));this._upperBound=e+f,this._lowerBound=e+this._physicalSize-this._targetSize-f;var g=this._dir>0?this._upperBound:this._lowerBound;if(this._dir>0&&this._scrollTop>g||this._dir<0&&this._scrollTop0&&(this._dir<0&&this._virtualStart>0||this._dir>0&&this._virtualStart0?this._virtualStart:this._virtualStart+this._physicalCount-1),j=this._physicalSizes[i];h-=j;var k=this.getRowCount(this._dir);this._dir>0&&(this._physicalOffset+=j),this.changeStartIndex(k),this._dir<0&&this._repositionedItems.push(this._virtualStart)}}}this._updateItems(!d)&&(Observer.hasObjectObserve?this.async(this._boundPositionItems):(Platform.flush(),Platform.endOfMicrotask(this._boundPositionItems)))},_updateItems:function(a){var b,c,d,e=!1,f=this._groupStart,g=this._groupStartIndex;for(b=0;b=this.getGroupLen(f)&&(g=0,f++);return e},_positionItems:function(){var a,b,c,d;if(this.updateMetrics(),this._dir<0){for(;this._repositionedItems.length;)b=this._repositionedItems.pop(),c=this._virtualToPhysical(b),this._physicalOffset-=this._physicalSizes[c];this._scrollTop+this._targetSize=this._rowFactor&&(f=0,h+=i),g=this._rowMargin+f*this.width):h+=i;this._scrollTop>=0&&this._updateViewportHeight()},_updateViewportHeight:function(){var a=Math.max(this._virtualCount-this._virtualStart-this._physicalCount,0);a=Math.ceil(a/this._rowFactor);var b=this._physicalOffset+this._physicalSize+a*this._physicalAverage;this._viewportSize!=b&&(this._viewportSize=b,this.$.viewport.style.height=this._viewportSize+"px",this.syncScroller())},_updateScrollPosition:function(a){var b=0===this._virtualStart?this._physicalOffset:Math.min(a+this._physicalOffset,0);b&&(this.adjustPositionAllowed&&(this._scrollTop=this.setScrollTop(a-b)),this._physicalOffset-=b)},tapHandler:function(a){var b=a.target,c=a.path;this.selectionEnabled&&b!==this&&requestAnimationFrame(function(){var a=window.ShadowDOMPolyfill?wrap(document.activeElement):this.shadowRoot.activeElement;if((!a||a==this||a.parentElement==this||document.activeElement==document.body)&&"input"!=c[0].localName&&"button"!=c[0].localName&&"select"!=c[0].localName){var d=b.templateInstance&&b.templateInstance.model;if(d){var e=this.dataForIndex(d.index,d.groupIndex,d.groupItemIndex),f=this._physicalItems[d.physicalIndex];this.$.selection.select(this.multi||e!=this.selection?e:null),this.asyncFire("core-activate",{data:e,item:f})}}}.bind(this))},selectedHandler:function(a,b){this.selection=this.$.selection.getSelection();var c=this.indexesForData(b.item);this._selectedData.set(b.item,b.isSelected),c.physical>=0&&c.virtual>=0&&this.refresh()},selectItem:function(a){if(this.selectionEnabled){var b=this.data[a];b&&this.$.selection.select(b)}},setItemSelected:function(a,b){var c=this.data[a];c&&this.$.selection.setItemSelected(c,b)},indexesForData:function(a){var b=-1,c=0;if(this._nestedGroups)for(var d=0;db)){b+=c;break}c+=this.data[d].length}else b=this.data.indexOf(a);var e=this.virtualToPhysicalIndex(b);return{virtual:b,physical:e}},virtualToPhysicalIndex:function(a){for(var b=0,c=this._physicalData.length;c>b;b++)if(this._physicalData[b].index===a)return b;return-1},clearSelection:function(){this._clearSelection(),this.refresh()},_clearSelection:function(){this._selectedData=new WeakMap,this.$.selection.clear(),this.selection=this.$.selection.getSelection()},_getFirstVisibleIndex:function(){for(var a=0;a=this._scrollTop-this._aboveSize)return b}},_resetIndex:function(a){a=Math.min(a,this._virtualCount-1),a=Math.max(a,0),this.changeStartIndex(a-this._virtualStart),this._scrollTop=this.setScrollTop(this._aboveSize+a/this._rowFactor*this._physicalAverage),this._physicalOffset=this._scrollTop-this._aboveSize,this._dir=0},scrollToItem:function(a){this.scrollToGroupItem(null,a)},scrollToGroup:function(a){this.scrollToGroupItem(a,0)},scrollToGroupItem:function(a,b){null!=a&&(b=this.virtualIndexForGroup(a,b)),this._resetIndex(b),this.refresh()}},Polymer.CoreResizable))}(),Polymer("artist-details",{domReady:function(){this.app=document.getElementById("tmpl"),this.scrollTarget=this.app.appScroller()},queryData:function(){this.async(function(){this.app.doXhr(this.app.buildUrl("getArtist",{id:this.artistId}),"json",function(a){this.data=a.target.response["subsonic-response"].artist.album,this.app.dataLoading=!1,this.async(function(){this.app.page=3})}.bind(this))})},playSomething:function(a,b){var c=this.$.all.querySelector("#"+a);console.log(c),c.$.detailsDialog.close(),c.doPlayback(),this.async(b)}}),Polymer("download-manager",{downloads:[],app:document.querySelector("#tmpl"),removeDownloadLabel:chrome.i18n.getMessage("removeDownloadLabel"),saveFileLabel:chrome.i18n.getMessage("saveFileLabel"),pauseDownload:chrome.i18n.getMessage("abortDownload"),hasSaved:!1,removeThis:function(a,b,c){this.parentNode.removeChild(this),this.async(function(){0===this.app.$.downloads.childElementCount&&(this.app.isDownloading=!1)},null,100)},formatBytes:function(a){return 1024>a?a+" Bytes":1048576>a?(a/1024).toFixed(2)+" KB":1073741824>a?(a/1048576).toFixed(2)+" MB":(a/1073741824).toFixed(2)+" GB"},doXhr:function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.responseType=b,d.onload=c,d.onerror=this.errorHandler,d.onprogress=this.xhrProgress.bind(this),d.send(),this.request=d},xhrProgress:function(a){this.progress=Math.floor(a.loaded/this.downloadSize*100);var b=new Date,c=b.getTime(),d=8*a.loaded,e=(c-this.start)/1e3,f=Math.round(d/e),g=(f/1024).toFixed(2),h=(g/1024).toFixed(2);1>h?this.rate=g+" Kbps":this.rate=h+" Mbps",this.output=this.formatBytes(a.loaded)+" of "+this.downloadSizeReadable+" Downloaded"},progressChanged:function(){this.progress&&100===this.progress&&this.app.doToast(chrome.i18n.getMessage("downloadFinished"))},errorHandler:function(a){console.error(a)},waitForIO:function(a,b){var c=Date.now(),d=function(){return a.readyState===a.WRITING&&Date.now()-c<4e3?void setTimeout(d,100):void(a.readyState===a.WRITING?(console.error("Write operation taking too long, aborting! (current writer readyState is "+a.readyState+")"),a.abort()):b())};setTimeout(d,100)},writeFileEntry:function(a,b,c){a.createWriter(function(a){a.onerror=this.errorHandler,a.onwriteend=c,a.truncate(b.size),this.waitForIO(a,function(){a.seek(0),a.write(b)})}.bind(this),this.errorHandler)},downloadTrack:function(a,b){var c=this.app.buildUrl("download",{id:a}),d=this.app.buildUrl("getSong",{id:a});this.doXhr(d,"json",function(a){var d=a.target.response["subsonic-response"].song;this.fileName=d.artist+" - "+d.title+"."+d.suffix,this.downloadSize=d.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize),this.app.doToast(chrome.i18n.getMessage("downloadStarted")),b(),this.isDownloading=!0;var e=new Date;this.start=e.getTime(),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1}.bind(this))}.bind(this))},downloadAlbum:function(a,b){var c=this.app.buildUrl("download",{id:a.id});this.fileName=a.artist+" - "+a.album+".zip",this.isDownloading=!0,this.downloadSize=a.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize);var d=new Date;this.start=d.getTime(),this.app.doToast(chrome.i18n.getMessage("downloadStarted")),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1,this.progress=100,b()}.bind(this))},downloadSinglePodcast:function(a,b){var c=this.app.buildUrl("download",{id:a.id});this.app.doNotify(this.app.downloadStarted),this.fileName=a.title.replace(":","")+"."+a.suffix,this.isDownloading=!0,this.downloadSize=a.size,this.downloadSizeReadable=this.formatBytes(this.downloadSize);var d=new Date;this.start=d.getTime(),this.doXhr(c,"blob",function(a){this.blob=a.target.response,this.downloadSizeReadable=this.formatBytes(this.blob.size),this.output="File Downloaded "+this.downloadSizeReadable,this.isDownloading=!1,this.progress=100,b()}.bind(this))},doSave:function(){this.output="Saving.. "+this.downloadSizeReadable;var a={type:"saveFile",suggestedName:this.fileName};chrome.fileSystem.chooseEntry(a,function(a){a?this.writeFileEntry(a,this.blob,function(){this.output="File Saved "+this.downloadSizeReadable,this.hasSaved=!0}.bind(this)):console.error("Error Downloading",e)}.bind(this))},abortDownload:function(){this.request.abort(),this.removeThis()}}),Polymer("mini-player",{ready:function(){"use strict";this.timer=0,this.label=chrome.i18n.getMessage("nowPlayingTitle")},domReady:function(){"use strict";this.app=document.getElementById("tmpl")},setPlaying:function(a){"use strict";this.img=a.cover,this.artist=a.artist,this.track=a.title},waitingToPlayChanged:function(){"use strict";this.waitingToPlay?this.$.spinner.hidden=!1:this.$.spinner.hidden=!0},isNowPlayingChanged:function(a,b){"use strict";a?(this.page=1,clearTimeout(this.timer),this.timer=0):this.app&&(this.app.playlist[0]?this.timer=setTimeout(function(){this.page=0}.bind(this),12e4):this.page=0),this.app&&(this.app.$.audio.paused?this.$.playButton.icon="av:play-arrow":this.$.playButton.icon="av:pause")},toPlayer:function(){"use strict";this.app.nowPlaying()},playPause:function(){"use strict";this.app.$.audio.paused?this.$.playButton.icon="av:pause":this.$.playButton.icon="av:play-arrow",this.app.playPause()},openPlaylist:function(){"use strict";this.app.showPlaylist("bottom")},progressClick:function(a,b){"use strict";this.async(function(){var a=this.app.$.audio,b=this.progress/100;a.currentTime=a.duration-(a.duration-a.duration*b)})}}),function(){"use strict";function a(a){return 1024>a?a+" Bytes":1048576>a?(a/1024).toFixed(2)+" KB":1073741824>a?(a/1048576).toFixed(2)+" MB":(a/1073741824).toFixed(2)+" GB"}function b(){f.$.audio.paused&&(f.doShufflePlayback(),f.dataLoading=!1,f.closePlaylists())}function c(a){"ok"===a.target.response["subsonic-response"].status?(f.doToast(chrome.i18n.getMessage("playlistCreated")),f.$.createPlaylist.close(),f.savingPlaylist=!1):(f.doToast(chrome.i18n.getMessage("playlistError")),f.savingPlaylist=!1)}function d(a){var b=[];for(var c in a)c=encodeURIComponent(c),b.push(null===a[c]?c:c+"="+encodeURIComponent(a[c]));return b.join("&")}function e(a){for(var b="",c="ABCD/EFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",d=0;a>d;d++)b+=c.charAt(Math.floor(Math.random()*c.length));return b}var f=document.querySelector("#tmpl");f.scrolling=!1,f.addEventListener("template-bound",function(){f.sizePlayer(),chrome.storage.sync.get(function(a){void 0===a.url&&f.$.firstRun.open(),f.url=a.url,f.user=a.user,f.pass=a.pass,f.listMode="cover",f.bitRate=a.bitRate||320,f.shuffleSettings.size=f.shuffleSettings.size||"50",f.version="1.11.0",f.querySize=40,f.volume=a.volume||100,f.queryMethod=a.queryMethod||"ID3",f.colorThiefEnabled=!0,f.dataLoading=!1,f.params={u:f.user,v:f.version,c:"PolySonic",f:"json"},f.url&&f.user&&f.pass&&f.version&&f.doXhr(f.buildUrl("ping",""),"json",function(b){200===b.target.status?(f.version=b.target.response["subsonic-response"].version,"ok"===b.target.response["subsonic-response"].status?(f.userDetails(),console.log("Connected to Subconic loading data"),f.doXhr(f.buildUrl("getMusicFolders",""),"json",function(b){f.mediaFolders=b.target.response["subsonic-response"].musicFolders.musicFolder,f.folder=a.mediaFolder||0,b.target.response["subsonic-response"].musicFolders.musicFolder[1]||(f.$.sortBox.style.display="none"),f.tracker.sendAppView("Album Wall")})):(f.tracker.sendEvent("Connection Error",b.target.response["subsonic-response"].error.meessage),f.$.firstRun.toggle(),f.doToast(b.target.response["subsonic-response"].error.meessage))):(f.tracker.sendEvent("Connection Error",b.target.response["subsonic-response"].error.meessage),f.$.firstRun.toggle(),f.doToast(b.target.response["subsonic-response"].error.meessage))})});var a=f.$.audio;f.appScroller().onscroll=f.scrollCallback,a.onwaiting=f.playerProgress,a.onprogress=f.buffering,a.ontimeupdate=f.playerProgress,a.onended=f.nextTrack,a.onerror=function(a){f.page=0,console.error("audio playback error ",a),f.doToast("Audio Playback Error"),f.tracker.sendEvent("Audio Playback Error",a.target)},f.service=analytics.getService("PolySonic"),f.tracker=this.service.getTracker("UA-50154238-6")}),f.shuffleSettings={},f.appName=chrome.i18n.getMessage("appName"),f.appDesc=chrome.i18n.getMessage("appDesc"),f.folderSelector=chrome.i18n.getMessage("folderSelector"),f.shuffleButton=chrome.i18n.getMessage("shuffleButton"),f.artistButton=chrome.i18n.getMessage("artistButton"),f.podcastButton=chrome.i18n.getMessage("podcastButton"),f.favoritesButton=chrome.i18n.getMessage("favoritesButton"),f.searchButton=chrome.i18n.getMessage("searchButton"),f.settingsButton=chrome.i18n.getMessage("settingsButton"),f.nowPlayingLabel=chrome.i18n.getMessage("nowPlayingLabel"),f.folderSelectorLabel=chrome.i18n.getMessage("folderSelectorLabel"),f.clearQueue=chrome.i18n.getMessage("clearQueue"),f.volumeLabel=chrome.i18n.getMessage("volumeLabel"),f.analistics=chrome.i18n.getMessage("analistics"),f.accept=chrome.i18n.getMessage("accept"),f.decline=chrome.i18n.getMessage("decline"),f.shuffleOptionsLabel=chrome.i18n.getMessage("shuffleOptionsLabel"),f.optional=chrome.i18n.getMessage("optional"),f.artistLabel=chrome.i18n.getMessage("artistLabel"),f.albumLabel=chrome.i18n.getMessage("albumLabel"),f.genreLabel=chrome.i18n.getMessage("genreLabel"),f.songReturn=chrome.i18n.getMessage("songReturn"),f.playButton=chrome.i18n.getMessage("playButton"),f.yearError=chrome.i18n.getMessage("yearError"),f.releasedAfter=chrome.i18n.getMessage("releasedAfter"),f.releasedBefore=chrome.i18n.getMessage("releasedBefore"),f.submitButton=chrome.i18n.getMessage("submitButton"),f.deleteConfirm=chrome.i18n.getMessage("deleteConfirm"),f.noResults=chrome.i18n.getMessage("noResults"),f.urlError=chrome.i18n.getMessage("urlError"),f.podcastSubmissionLabel=chrome.i18n.getMessage("podcastSubmissionLabel"),f.diskUsed=chrome.i18n.getMessage("diskused"),f.diskRemaining=chrome.i18n.getMessage("diskRemaining"),f.playlistsButton=chrome.i18n.getMessage("playlistsButton"),f.createPlaylistLabel=chrome.i18n.getMessage("createPlaylistLabel"),f.playlistLabel=chrome.i18n.getMessage("playlistLabel"),f.reloadAppLabel=chrome.i18n.getMessage("reloadApp"),f.settingsDeleted=chrome.i18n.getMessage("settingsDeleted"),f.recommendReload=chrome.i18n.getMessage("recommendReload"),f.jumpToLabel=chrome.i18n.getMessage("jumpToLabel"),f.closeLabel=chrome.i18n.getMessage("closeLabel"),f.moreOptionsLabel=chrome.i18n.getMessage("moreOptionsLabel"),f.refreshPodcastLabel=chrome.i18n.getMessage("refreshPodcast"),f.registeredEmail=chrome.i18n.getMessage("registeredEmail"),f.licenseKey=chrome.i18n.getMessage("licenseKey"),f.keyDate=chrome.i18n.getMessage("keyDate"),f.validLicense=chrome.i18n.getMessage("validLicense"),f.invalidLicense=chrome.i18n.getMessage("invalidLicense"),f.adjustVolumeLabel=chrome.i18n.getMessage("adjustVolumeLabel"),f.showDownloads=chrome.i18n.getMessage("showDownloads"),f.shuffleSizes=[20,40,50,75,100,200],f.sortTypes=[{sort:"newest",name:chrome.i18n.getMessage("newButton")},{sort:"alphabeticalByArtist",name:chrome.i18n.getMessage("byArtistButton")},{sort:"alphabeticalByName",name:chrome.i18n.getMessage("titleButton")},{sort:"frequent",name:chrome.i18n.getMessage("frequentButton")},{sort:"recent",name:chrome.i18n.getMessage("recentButton")}],f.indexedDB=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,f.IDBTransaction=window.IDBTransaction||window.webkitIDBTransaction||window.OIDBTransaction||window.msIDBTransaction,f.dbVersion=1,f.request=f.indexedDB.open("albumInfo",f.dbVersion),f.request.onerror=function(){console.log("Error creating/accessing IndexedDB database")},f.request.onsuccess=function(){if(console.log("Success creating/accessing IndexedDB database"),f.db=f.request.result,f.db.setVersion&&f.db.version!==f.dbVersion){var a=f.db.setVersion(this.dbVersion);a.onsuccess=function(){f.createObjectStore(this.db)}}},f.request.onupgradeneeded=function(a){f.createObjectStore(a.target.result)},f.createObjectStore=function(a){console.log("Creating objectStore"),a.createObjectStore("albumInfo")},f.dbErrorHandler=function(a){console.error(a)},f.getImageFile=function(a,b,c){f.doXhr(a,"blob",function(a){f.putInDb(new Blob([a.target.response],{type:"image/jpeg"}),b,c),console.log("Image Added to indexedDB "+b)})},f.putInDb=function(a,b,c){var d=f.db.transaction(["albumInfo"],"readwrite");b&&(d.objectStore("albumInfo").put(a,b),d.objectStore("albumInfo").get(b).onsuccess=c)},f.calculateStorageSize=function(){navigator.webkitTemporaryStorage.queryUsageAndQuota(function(b,c){f.storageQuota=f.diskUsed+": "+a(b)+", "+f.diskRemaining+": "+a(c)},function(a){console.log("Error",a)})},f.getDbItem=function(a,b){if(a){var c=f.db.transaction(["albumInfo"],"readwrite"),d=c.objectStore("albumInfo").get(a);d.onsuccess=b,d.onerror=f.dbErrorHandler}},f.doXhr=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.responseType=b,d.onload=c,d.onerror=function(d){f.dataLoading=!1,f.doToast(chrome.i18n.getMessage("connectionError")),f.async(function(){f.doToast(chrome.i18n.getMessage("reconnecting")),f.doXhr(a,b,c)},null,15e3)},d.send()},f.playlist=[],f.page=f.page||0,f.pageLimit=!1,f.reloadApp=function(){chrome.runtime.reload()},f.minimize=function(){chrome.app.window.current().minimize()},f.openDownloads=function(){f.$.downloadDialog.open()},f.closeDownloads=function(){f.$.downloadDialog.close()},f.closeDrawer=function(a){f.dataLoading=!0,f.$.panel.closeDrawer(),a&&f.async(a,null,500)},f.openPanel=function(){f.$.panel.openDrawer()},f.appScroller=function(){return f.$.headerPanel.scroller},f.doToast=function(a){var b=f.$.toast;b.text=a,b.show()},f.scrollCallback=function(){var a=f.$.fab,b=f.$.wall,c=f.appScroller(),d=0;0===f.page&&"off"!==a.state&&c.scrollTopf.position&&"podcast"!==b.showing?a.state="bottom":3===f.page&&"off"!==a.state&&c.scrollTopf.position&&(a.state="bottom"),f.position=c.scrollTop,f.scrolling=!0,d?(clearTimeout(d),d=0):d=setTimeout(function(){f.scrolling=!1}.bind(this),50)},f.close=function(){f.checkUnsavedDownloads(function(){window.close()},function(){this.$.unsavedDownloads.open()}.bind(this))},f.checkUnsavedDownloads=function(a,b){if(0!==this.$.downloads.childElementCount)for(var c=this.$.downloads.querySelectorAll("download-manager"),d=c.length,e=0,f=0;d>f;f++)c[f].hasSaved||(e+=1),f===d-1&&0===e?a():b();else a()},f.closeAnyway=function(){window.close()},f.getColor=function(a){var b=new ColorThief;return b.getPalette(a,4)},f.getContrast50=function(a){return parseInt(a,16)>8388607.5?"black":"white"},f.componentToHex=function(a){var b=a.toString(16);return 1===b.length?"0"+b:b},f.rgbToHex=function(a,b,c){return f.componentToHex(a)+f.componentToHex(b)+f.componentToHex(c)},f.colorThiefHandler=function(a,b,c){var d=new Image;d.src=a,d.onload=function(){var a=f.getColor(d),e=[],g=a[1][0],h=a[1][1],i=a[1][2],j=f.rgbToHex(g,h,i);e[0]="rgb("+g+","+h+","+i+");",e[1]=f.getContrast50(j),e[2]="rgba("+g+","+h+","+i+",0.4);","white"!==e[1]?e[3]="#444444":e[3]="#c8c8c8",f.putInDb(e,b+"-palette",function(){c&&c(e),console.log("Color palette saved "+b)})}},f.playAudio=function(a,b,c,d,e){for(var g=document.querySelectorAll("mini-player"),h=g.length,i=0;h>i;i++)g[i].setPlaying({artist:a,title:b,cover:d});var j=f.$.audio,k=f.$.playNotify;""===a?(f.currentPlaying=b,k.title=b):(f.currentPlaying=a+" - "+b,k.title=a+" - "+b),f.activeUser.scrobblingEnabled&&f.doXhr(f.buildUrl("scrobble",{id:e,time:(new Date).getTime()}),"json",function(a){"failed"===a.target.response["subsonic-response"].status&&(console.log("Last FM submission: "+a.target.response["subsonic-response"].status),f.tracker.sendEvent("Last FM submission","Failed"))}),j.src=c,k.icon=d,j.play(),k.show(),f.tracker.sendEvent("Audio","Playing")},f.playNext=function(a){f.playlist[a]?f.playing=a:(f.$.audio.pause(),f.clearPlaylist())},f.nextTrack=function(){f.playNext(f.playing+1)},f.lastTrack=function(){f.playNext(f.playing-1)},f.playThis=function(){f.async(function(){f.setFabColor(this.playlist[this.playing]);var a;a=""===f.playlist[f.playing].artist?f.buildUrl("stream",{format:"raw",estimateContentLength:!0,id:f.playlist[this.playing].id}):f.buildUrl("stream",{maxBitRate:f.bitRate,id:f.playlist[f.playing].id}),f.playAudio(f.playlist[f.playing].artist,f.playlist[f.playing].title,a,f.playlist[f.playing].cover,f.playlist[f.playing].id),f.playlist[f.playing].cover?f.getImageForPlayer(f.playlist[f.playing].cover):f.defaultPlayImage()})},f.playPause=function(){var a=f.$.audio;a.paused?a.play():a.pause()},f.playPlaylist=function(a,c,d){f.dataLoading=!0,f.playlist=null,f.playlist=[],f.$.audio.pause(),f.doXhr(f.buildUrl("getPlaylist",{id:d.attributes.ident.value}),"json",function(a){for(var c=a.target.response["subsonic-response"].playlist.entry,d=c.length,e=0;d>e;e++){var g=Math.floor(c[e].duration/60),h={id:c[e].id,artist:c[e].artist,title:c[e].title,duration:g+":"+("0"+Math.floor(c[e].duration-60*g)).slice(-2),cover:"al-"+c[e].albumId};f.fixCoverArtForShuffle(h,b)}})},f.shufflePlay=function(){f.dataLoading=!0,f.shuffleLoading=!0,f.playlist=null,f.playlist=[],f.startYearInvalid||f.endYearInvalid?(f.shuffleLoading=!1,f.doToast(chrome.i18n.getMessage("invalidEntry"))):(f.$.audio.pause(),f.doXhr(f.buildUrl("getRandomSongs",f.shuffleSettings),"json",function(a){var c=a.target.response["subsonic-response"].randomSongs.song,d=c.length;if(c)for(var e=0;d>e;e++){var g=Math.floor(c[e].duration/60),h={id:c[e].id,artist:c[e].artist,title:c[e].title,duration:g+":"+("0"+Math.floor(c[e].duration-60*g)).slice(-2),cover:"al-"+c[e].albumId};f.fixCoverArtForShuffle(h,b)}else f.doToast(chrome.i18n.getMessage("noMatch")),f.shuffleLoading=!1}))},f.doShufflePlayback=function(){f.$.audio.paused&&(f.playing=0,f.playAudio(f.playlist[0].artist,f.playlist[0].title,f.buildUrl("stream",{maxBitRate:f.bitRate,id:f.playlist[0].id}),f.playlist[0].cover,f.playlist[0].id),f.getImageForPlayer(f.playlist[0].cover,function(){f.setFabColor(f.playlist[0]),f.$.shuffleOptions.close(),f.shuffleLoading=!1}))},f.clearPlaylist=function(){f.$.audio.pause(),f.$.playlistDialog.close(),f.page=0,f.playlist=null,f.playlist=[]},f.toggleVolume=function(){f.$.volumeDialog.open()},f.closeVolume=function(){f.$.volumeDialog.close()},f.volUp=function(){f.volume<100&&(f.volume=f.volume+2)},f.volDown=function(){f.volume>0&&(f.volume=f.volume-2)},f.getImageForPlayer=function(a,b){f.$.coverArt.style.backgroundImage="url('"+a+"')",f.$.playNotify.icon=a,b&&f.async(b)},f.defaultPlayImage=function(){f.$.coverArt.style.backgroundImage="url('images/default-cover-art.png')",f.$.playNotify.icon="images/default-cover-art.png"},f.buffering=function(a){var b=a.srcElement;b.duration?f.buffer=Math.floor(b.buffered.end(0)/b.duration*100):f.buffer=0,b=null,a=null},f.playerProgress=function(a){var b=a.srcElement;a&&("waiting"===a.type?f.waitingToPlay=!0:"timeupdate"===a.type&&(f.waitingToPlay=!1)),f.currentMins=Math.floor(b.currentTime/60),f.currentSecs=Math.floor(b.currentTime-60*f.currentMins),f.totalMins=Math.floor(b.duration/60),f.totalSecs=Math.floor(b.duration-60*f.totalMins),b.paused?f.$.avIcon.icon="av:play-arrow":(f.$.avIcon.icon="av:pause",b.duration?(f.playTime=f.currentMins+":"+("0"+f.currentSecs).slice(-2)+" / "+f.totalMins+":"+("0"+f.totalSecs).slice(-2),f.progress=Math.floor(b.currentTime/b.duration*100)):(f.playTime=f.currentMins+":"+("0"+f.currentSecs).slice(-2)+" / ?:??",f.progress=0)),b.paused?f.isNowPlaying=!1:f.isNowPlaying=!0,b=null,a=null},f.showApp=function(){var a=document.getElementById("loader"),b=document.getElementById("box"); -return this.nearest(a)},nearest:function(a){for(var b,c,d,e=this.vboxes,f=0;fc||void 0===b)&&(b=c,d=e.peek(f).color);return d},forcebw:function(){var a=this.vboxes;a.sort(function(a,b){return pv.naturalOrder(pv.sum(a.color),pv.sum(b.color))});var b=a[0].color;b[0]<5&&b[1]<5&&b[2]<5&&(a[0].color=[0,0,0]);var c=a.length-1,d=a[c].color;d[0]>251&&d[1]>251&&d[2]>251&&(a[c].color=[255,255,255])}},{quantize:h}}(); +a.classList.contains("hide")||(a.classList.add("hide"),b.classList.add("hide"),b.classList.add("hide"),f.askAnalistics())},f.sizePlayer=function(){var a=window.innerHeight-256+"px",b=window.innerWidth+"px",c=f.$.coverArt;c.style.width=b,c.style.height=a,c.style.backgroundSize=b},f.askAnalistics=function(){chrome.storage.sync.get(function(a){f.service.getConfig().addCallback(function(b){void 0===a.analistics?f.$.analistics.open():(b.setTrackingPermitted(a.analistics),f.analisticsEnabled=a.analistics),f.allowAnalistics=function(){f.analisticsEnabled=!0,b.setTrackingPermitted(!0),chrome.storage.sync.set({analistics:!0})},f.disAllowAnalistics=function(){f.analisticsEnabled=!1,b.setTrackingPermitted(!1),chrome.storage.sync.set({analistics:!1})}})})},f.jumpTo=function(a,b,c){f.$.wall.jumpToLetter(c.attributes.it.value)},f.setFolder=function(a,b,c){f.folder=parseInt(c.attributes.i.value,10),chrome.storage.sync.set({mediaFolder:f.folder})},f.fixCoverArtForShuffle=function(a,b){var c=a.cover;f.getDbItem(c,function(d){if(d.target.result){var e=window.URL.createObjectURL(d.target.result);a.cover=e,f.getDbItem(c+"-palette",function(c){a.palette=c.target.result,f.playlist.push(a),f.async(b)})}else f.getImageFile(f.buildUrl("getCoverArt",{id:c}),c,function(d){var e=window.URL.createObjectURL(d.target.result);a.cover=e,f.colorThiefHandler(e,c,function(c){a.palette=c,f.playlist.push(a),f.async(b)})})})},f.setFabColor=function(a){f.colorThiefEnabled&&a.palette&&(f.colorThiefFab=a.palette[0],f.colorThiefFabOff=a.palette[1],f.colorThiefBuffered=a.palette[2],f.colorThiefProgBg=a.palette[3])},f.progressClick=function(a){var b=a.x/window.innerWidth;f.$.progress.value=100*b,f.$.audio.currentTime=audio.duration-(audio.duration-audio.duration*b)},f.savePlayQueue=function(){f.$.playlistDialog.close(),f.$.createPlaylist.open(),f.defaultName=(new Date).toGMTString()},f.savePlayQueue2Playlist=function(){var a=f.buildUrl("createPlaylist",{name:f.defaultName}),b=f.playlist.length;f.savingPlaylist=!0;for(var d=0;b>d;d++)a=a+"&songId="+f.playlist[d].id,d===b-1&&f.doXhr(a,"json",c)},f.closePlaylistSaver=function(){f.$.createPlaylist.close()},f.doAction=function(a,b,c){var d=f.appScroller(),e=f.$.wall,g=new CoreAnimation;g.duration=1e3,g.iterations="Infinity",g.keyframes=[{opacity:1},{opacity:0}],g.target=c,0===f.page&&0!==d.scrollTop&&"podcast"!==e.showing&&"bottom"===f.$.fab.state&&(d.scrollTop=0),0===f.page&&"podcast"===e.showing&&f.$.addPodcast.open(),1===f.page&&f.showPlaylist(),0===f.page&&"mid"===f.$.fab.state&&(g.play(),f.$.wall.playSomething(c.ident,function(){g.cancel(),f.$.fab.state="bottom"})),3===f.page&&(g.play(),f.$.aDetails.playSomething(c.ident,function(){g.cancel(),f.$.fab.state="bottom"}))},f.doSearch=function(){f.searchQuery?f.async(function(){f.closeDrawer(function(){f.async(function(){f.doXhr(f.buildUrl("search3",{query:encodeURIComponent(f.searchQuery)}),"json",function(a){if(f.dataLoading=!0,"ok"===a.target.response["subsonic-response"].status){f.searchQuery="";var b=a.target.response;b["subsonic-response"].searchResult3.album?f.async(function(){f.$.wall.clearData(function(){f.$.wall.response=b,f.showing=f.listMode})}):(f.dataLoading=!1,f.doToast(chrome.i18n.getMessage("noResults")))}})})})}):f.doToast(chrome.i18n.getMessage("noSearch"))},f.showPlaylist=function(a){a?f.$.playlistDialog.transition="core-transition-bottom":f.$.playlistDialog.transition="core-transition-top",f.async(function(){f.$.playlistDialog.toggle()})},f.closePlaylist=function(){f.async(function(){f.$.playlistDialog.close()})},f.openPlaylists=function(){f.closeDrawer(function(){f.dataLoading=!1,f.playlistsLoading=!0,f.doXhr(f.buildUrl("getPlaylists",""),"json",function(a){f.playlistsLoading=!1,f.playlists=a.target.response["subsonic-response"].playlists.playlist,f.async(function(){f.$.playlistsDialog.open()})})})},f.closePlaylists=function(){f.async(function(){f.$.playlistsDialog.close()})},f.reallyDelete=function(a,b,c){f.delID=c.attributes.ident.value,f.async(function(){f.$.playlistsDialog.close(),f.$.playlistConfirm.open()})},f.deletePlaylist=function(a,b,c){f.doXhr(f.buildUrl("deletePlaylist",{id:c.attributes.ident.value}),"json",function(a){"ok"===a.target.response["subsonic-response"].status?(f.playlistsLoading=!0,f.doXhr(f.buildUrl("getPlaylists",""),"json",function(a){f.playlistsLoading=!1,f.playlists=a.target.response["subsonic-response"].playlists.playlist,f.async(function(){f.$.playlistsDialog.open()})})):f.doToast(chrome.i18n.getMessage("deleteError"))})},f.closeShuffleOptions=function(){f.async(function(){f.$.shuffleOptions.close()})},f.shuffleOptions=function(){f.closeDrawer(function(){f.doXhr(f.buildUrl("getGenres",""),"json",function(a){f.genres=a.target.response["subsonic-response"].genres.genre,f.dataLoading=!1,f.async(function(){f.$.shuffleOptions.open()})})})},f.closePodcastDialog=function(){f.async(function(){f.$.addPodcast.close()})},f.toggleWall=function(){f.dataLoading=!0;var a=f.$.wall;"cover"===a.listMode?(a.listMode="list",chrome.storage.sync.set({listMode:"list"})):(a.listMode="cover",chrome.storage.sync.set({listMode:"cover"})),f.tracker.sendEvent("ListMode Changed",a.listMode)},f.back2List=function(){f.async(function(){f.page=0})},f.nowPlaying=function(){f.async(function(){f.page=1})},f.selectAction=function(a,b,c){var d=f.$.wall;f.closeDrawer(function(){d.sort===c.attributes.i.value&&(f.pageLimit=!1,"ID3"===f.queryMethod?d.request="getAlbumList2":d.request="getAlbumList",d.post.type=c.attributes.i.value,d.refreshContent(),d.showing=f.listMode,d.$.threshold.clearLower()),d.sort=c.attributes.i.value})},f.getPodcast=function(){f.closeDrawer(function(){f.$.wall.getPodcast()})},f.getStarred=function(){f.closeDrawer(function(){f.$.wall.getStarred()})},f.getArtist=function(){f.closeDrawer(function(){f.$.wall.getArtist()})},f.gotoSettings=function(){f.async(function(){f.$.panel.closeDrawer(),f.page=2})},f.refreshPodcast=function(a,b,c){var d=new CoreAnimation;d.duration=1e3,d.iterations="Infinity",d.keyframes=[{opacity:1},{opacity:0}],d.target=c,d.play(),f.doXhr(f.buildUrl("refreshPodcasts",""),"json",function(a){"ok"===a.target.response["subsonic-response"].status&&(d.cancel(),f.$.wall.refreshContent(),f.doToast(chrome.i18n.getMessage("podcastCheck")))})},f.addChannel=function(){f.castURL||f.doToast(f.urlError),f.invalidURL||(f.addingChannel=!0,f.doXhr(f.buildUrl("createPodcastChannel",{url:encodeURIComponent(f.castURL)}),"json",function(a){"ok"===a.target.response["subsonic-response"].status?(f.addingChannel=!1,f.$.addPodcast.close(),f.$.wall.refreshContent(),f.doToast(chrome.i18n.getMessage("channelAdded")),f.castURL=""):f.doToast(chrome.i18n.getMessage("podcastError"))}))},f.doDelete=function(a,b,c){f.$.wall.deleteChannel(c.attributes.ident.value)},f.deleteEpisode=function(a,b,c){f.$.wall.deleteEpisode(c.attributes.ident.value)},f.getLicense=function(a){f.doXhr(f.buildUrl("getLicense",""),"json",function(b){var c=b.target.response["subsonic-response"];if("ok"===c.status){f.serverLicense=c.license;var d=new Date(f.serverLicense.date),e=Math.floor(d.getFullYear()+1),g=new Date(d.setFullYear(e)),h=new Date,i=6e4,j=60*i,k=24*j,l=Math.ceil((g.getTime()-h.getTime())/k),m=Math.ceil((g.getTime()-h.getTime())/j);l>0?f.serverLicense.daysLeft=l+" days":f.serverLicense.daysLeft=m+"hours",f.$.licenseDialog.open(),f.async(a)}})},f.licenseDialogClose=function(){f.$.licenseDialog.close()},f.userDetails=function(){f.async(function(){f.doXhr(f.buildUrl("getUser",{username:f.user}),"json",function(a){var b=a.target.response["subsonic-response"];"ok"===b.status?f.activeUser=b.user:console.error("Error getting User details")})})},String.prototype.hexEncode=function(){for(var a,b="",c=0;ca?-1:a>b?1:0},u=Array.prototype,v=u.indexOf?function(a,b,c){return u.indexOf.call(a,b,c)}:function(a,b,c){if(c=null==c?0:0>c?Math.max(0,a.length+c):c,h(a))return h(b)&&1==b.length?a.indexOf(b,c):-1;for(;cf;f++)f in e&&b.call(c,e[f],f,a)},x=u.some?function(a,b,c){return u.some.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=h(a)?a.split(""):a,f=0;d>f;f++)if(f in e&&b.call(c,e[f],f,a))return!0;return!1},y=u.every?function(a,b,c){return u.every.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=h(a)?a.split(""):a,f=0;d>f;f++)if(f in e&&!b.call(c,e[f],f,a))return!1;return!0},z=function(a){var b;a:{b=ed;for(var c=a.length,d=h(a)?a.split(""):a,e=0;c>e;e++)if(e in d&&b.call(void 0,d[e],e,a)){b=e;break a}b=-1}return 0>b?null:h(a)?a.charAt(b):a[b]},A=function(a,b){var c,d=v(a,b);return(c=d>=0)&&u.splice.call(a,d,1),c},B=function(a){return u.concat.apply(u,arguments)},C=function(a,b,c){return 2>=arguments.length?u.slice.call(a,b):u.slice.call(a,b,c)},D="StopIteration"in c?c.StopIteration:Error("StopIteration"),E=function(){};E.prototype.next=function(){throw D},E.prototype.vc=function(){return this};var F=function(a,b,c){for(var d in a)b.call(c,a[d],d,a)},G=function(a){var b,c=[],d=0;for(b in a)c[d++]=a[b];return c},H=function(a){var b,c=[],d=0;for(b in a)c[d++]=b;return c},I=function(a,b){var c;a:{for(c in a)if(b.call(void 0,a[c],c,a))break a;c=void 0}return c&&a[c]},J="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" "),K=function(a,b){for(var c,d,e=1;e1){if(c%2)throw Error("Uneven number of arguments");for(var d=0;c>d;d+=2)this.set(arguments[d],arguments[d+1])}else a&&this.ia(a)};L.prototype.t=function(){M(this);for(var a=[],b=0;b2*this.h&&M(this),!0):!1};var M=function(a){if(a.h!=a.b.length){for(var b=0,c=0;b=c.length)throw D;var g=c[b++];return a?g:d[g]}},g};var N,O,P=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)},Q={id:"hitType",name:"t",valueType:"text",maxLength:void 0,defaultValue:void 0},R={id:"sessionControl",name:"sc",valueType:"text",maxLength:void 0,defaultValue:void 0},S={id:"description",name:"cd",valueType:"text",maxLength:2048,defaultValue:void 0},T={id:"eventCategory",name:"ec",valueType:"text",maxLength:150,defaultValue:void 0},U={id:"eventAction",name:"ea",valueType:"text",maxLength:500,defaultValue:void 0},V={id:"eventLabel",name:"el",valueType:"text",maxLength:500,defaultValue:void 0},W={id:"eventValue",name:"ev",valueType:"integer",maxLength:void 0,defaultValue:void 0},X={pd:Q,Qc:{id:"anonymizeIp",name:"aip",valueType:"boolean",maxLength:void 0,defaultValue:void 0},Ad:{id:"queueTime",name:"qt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Wc:{id:"cacheBuster",name:"z",valueType:"text",maxLength:void 0,defaultValue:void 0},Gd:R,Wd:{id:"userId",name:"uid",valueType:"text",maxLength:void 0,defaultValue:void 0},xd:{id:"nonInteraction",name:"ni",valueType:"boolean",maxLength:void 0,defaultValue:void 0},fd:S,Pd:{id:"title",name:"dt",valueType:"text",maxLength:1500,defaultValue:void 0},Sc:{id:"appId",name:"aid",valueType:"text",maxLength:150,defaultValue:void 0},Tc:{id:"appInstallerId",name:"aiid",valueType:"text",maxLength:150,defaultValue:void 0},jd:T,hd:U,kd:V,ld:W,Id:{id:"socialNetwork",name:"sn",valueType:"text",maxLength:50,defaultValue:void 0},Hd:{id:"socialAction",name:"sa",valueType:"text",maxLength:50,defaultValue:void 0},Jd:{id:"socialTarget",name:"st",valueType:"text",maxLength:2048,defaultValue:void 0},Sd:{id:"transactionId",name:"ti",valueType:"text",maxLength:500,defaultValue:void 0},Rd:{id:"transactionAffiliation",name:"ta",valueType:"text",maxLength:500,defaultValue:void 0},Td:{id:"transactionRevenue",name:"tr",valueType:"currency",maxLength:void 0,defaultValue:void 0},Ud:{id:"transactionShipping",name:"ts",valueType:"currency",maxLength:void 0,defaultValue:void 0},Vd:{id:"transactionTax",name:"tt",valueType:"currency",maxLength:void 0,defaultValue:void 0},dd:{id:"currencyCode",name:"cu",valueType:"text",maxLength:10,defaultValue:void 0},td:{id:"itemPrice",name:"ip",valueType:"currency",maxLength:void 0,defaultValue:void 0},ud:{id:"itemQuantity",name:"iq",valueType:"integer",maxLength:void 0,defaultValue:void 0},rd:{id:"itemCode",name:"ic",valueType:"text",maxLength:500,defaultValue:void 0},sd:{id:"itemName",name:"in",valueType:"text",maxLength:500,defaultValue:void 0},qd:{id:"itemCategory",name:"iv",valueType:"text",maxLength:500,defaultValue:void 0},bd:{id:"campaignSource",name:"cs",valueType:"text",maxLength:100,defaultValue:void 0},$c:{id:"campaignMedium",name:"cm",valueType:"text",maxLength:50,defaultValue:void 0},ad:{id:"campaignName",name:"cn",valueType:"text",maxLength:100,defaultValue:void 0},Zc:{id:"campaignKeyword",name:"ck",valueType:"text",maxLength:500,defaultValue:void 0},Xc:{id:"campaignContent",name:"cc",valueType:"text",maxLength:500,defaultValue:void 0},Yc:{id:"campaignId",name:"ci",valueType:"text",maxLength:100,defaultValue:void 0},od:{id:"gclid",name:"gclid",valueType:"text",maxLength:void 0,defaultValue:void 0},ed:{id:"dclid",name:"dclid",valueType:"text",maxLength:void 0,defaultValue:void 0},zd:{id:"pageLoadTime",name:"plt",valueType:"integer",maxLength:void 0,defaultValue:void 0},gd:{id:"dnsTime",name:"dns",valueType:"integer",maxLength:void 0,defaultValue:void 0},Kd:{id:"tcpConnectTime",name:"tcp",valueType:"integer",maxLength:void 0,defaultValue:void 0},Fd:{id:"serverResponseTime",name:"srt",valueType:"integer",maxLength:void 0,defaultValue:void 0},yd:{id:"pageDownloadTime",name:"pdt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Bd:{id:"redirectResponseTime",name:"rrt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Ld:{id:"timingCategory",name:"utc",valueType:"text",maxLength:150,defaultValue:void 0},Od:{id:"timingVar",name:"utv",valueType:"text",maxLength:500,defaultValue:void 0},Nd:{id:"timingValue",name:"utt",valueType:"integer",maxLength:void 0,defaultValue:void 0},Md:{id:"timingLabel",name:"utl",valueType:"text",maxLength:500,defaultValue:void 0},md:{id:"exDescription",name:"exd",valueType:"text",maxLength:150,defaultValue:void 0},nd:{id:"exFatal",name:"exf",valueType:"boolean",maxLength:void 0,defaultValue:"1"}},Y=function(a){if(1>a||a>200)throw Error("Expected dimension index range 1-200, but was : "+a);return{id:"dimension"+a,name:"cd"+a,valueType:"text",maxLength:150,defaultValue:void 0}},Z=function(a){if(1>a||a>200)throw Error("Expected metric index range 1-200, but was : "+a);return{id:"metric"+a,name:"cm"+a,valueType:"integer",maxLength:void 0,defaultValue:void 0}},$=function(a){return 1>a?"0":3>a?"1-2":(a=Math.floor(Math.log(a-1)/Math.log(2)),Math.pow(2,a)+1+"-"+Math.pow(2,a+1))},_=function(a,b){for(var c=0,d=a.length-1,e=0;d>=c;){var f=Math.floor((c+d)/2),e=a[f];if(e>=b){if(d=0==f?0:a[f-1],b>d)return(d+1).toString()+"-"+e.toString();d=f-1}else if(b>e){if(f>=a.length-1)return(a[a.length-1]+1).toString()+"+";c=f+1}}return"<= 0"},aa=function(){this.ab=[]},ba=function(){return new aa};a=aa.prototype,a.when=function(a){return this.ab.push(a),this},a.zb=function(a){var b=arguments;return this.when(function(a){return 0<=v(b,a.Gb())}),this},a.Oc=function(a,b){var c=C(arguments,1);return this.when(function(b){return b=b.T().get(a),0<=v(c,b)}),this},a.xb=function(a,b){if(k(this.e))throw Error("Filter has already been set.");return this.e=k(b)?n(a,b):a,this},a.Ca=function(){if(0==this.ab.length)throw Error("Must specify at least one predicate using #when or a helper method.");if(!k(this.e))throw Error("Must specify a delegate filter using #applyFilter.");return n(function(a){y(this.ab,function(b){return b(a)})&&this.e(a)},this)};var ca=function(){this.Ab=!1,this.Bb="",this.qb=!1,this.za=null};ca.prototype.wc=function(a){return this.Ab=!0,this.Bb=a||" - ",this},ca.prototype.Nc=function(){return this.qb=!0,this},ca.prototype.Ec=function(){return da(this,$)},ca.prototype.Fc=function(a){return da(this,o(_,a))};var da=function(a,b){if(null!=a.za)throw Error("LabelerBuilder: Only one labeling strategy may be used.");return a.za=n(function(a){var c=a.T().get(W),d=a.T().get(V);i(c)&&(c=b(c),null!=d&&this.Ab&&(c=d+this.Bb+c),a.T().set(V,c))},a),a};ca.prototype.Ca=function(){if(null==this.za)throw Error("LabelerBuilder: a labeling strategy must be specified prior to calling build().");return ba().zb("event").xb(n(function(a){this.za(a),this.qb&&a.T().remove(W)},this)).Ca()};var ea=function(a,b){var c=Array.prototype.slice.call(arguments),d=c.shift();if("undefined"==typeof d)throw Error("[goog.string.format] Template required");return d.replace(/%([0\-\ \+]*)(\d+)?(\.(\d+))?([%sfdiu])/g,function(a,b,d,e,f,g,h,i){if("%"==g)return"%";var j=c.shift();if("undefined"==typeof j)throw Error("[goog.string.format] Not enough arguments");return arguments[0]=j,fa[g].apply(null,arguments)})},fa={s:function(a,b,c){return isNaN(c)||""==c||a.length>=c?a:a=-1a?"-":0<=b.indexOf("+")?"+":0<=b.indexOf(" ")?" ":"",a>=0&&(d=f+d),isNaN(c)||d.length>=c?d:(d=isNaN(e)?Math.abs(a).toString():Math.abs(a).toFixed(e),a=c-d.length-f.length,d=0<=b.indexOf("-",0)?f+d+Array(a+1).join(" "):f+Array(a+1).join(0<=b.indexOf("0",0)?"0":" ")+d)},d:function(a,b,c,d,e,f,g,h){return fa.f(parseInt(a,10),b,c,d,0,f,g,h)}};fa.i=fa.d,fa.u=fa.d;var ga=function(a){if("function"==typeof a.t)return a.t();if(h(a))return a.split("");if(g(a)){for(var b=[],c=a.length,d=0;c>d;d++)b.push(a[d]);return b}return G(a)},ha=function(a,b){if("function"==typeof a.forEach)a.forEach(b,void 0);else if(g(a)||h(a))w(a,b,void 0);else{var c;if("function"==typeof a.F)c=a.F();else if("function"!=typeof a.t)if(g(a)||h(a)){c=[];for(var d=a.length,e=0;d>e;e++)c.push(e)}else c=H(a);else c=void 0;for(var d=ga(a),e=d.length,f=0;e>f;f++)b.call(void 0,d[f],c&&c[f],a)}},ia=function(a){this.B=new L;for(var b=arguments,c=0;cparseFloat(b))?String(a):b)}(),za={},Aa=function(a){var b;if(!(b=za[a])){b=0;for(var c=String(ya).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),e=Math.max(c.length,d.length),f=0;0==b&&e>f;f++){var g=c[f]||"",h=d[f]||"",i=RegExp("(\\d*)(\\D*)","g"),j=RegExp("(\\d*)(\\D*)","g");do{var k=i.exec(g)||["","",""],l=j.exec(h)||["","",""];if(0==k[0].length&&0==l[0].length)break;b=t(0==k[1].length?0:parseInt(k[1],10),0==l[1].length?0:parseInt(l[1],10))||t(0==k[2].length,0==l[2].length)||t(k[2],l[2])}while(0==b)}b=za[a]=b>=0}return b},Ba=c.document,Ca=Ba&&ua?xa()||("CSS1Compat"==Ba.compatMode?parseInt(ya,10):5):void 0,Da=!ua||ua&&Ca>=9,Ea=ua&&!Aa("9"),Fa=!wa||Aa("528"),Ga=va&&Aa("1.9b")||ua&&Aa("8")||ta&&Aa("9.5")||wa&&Aa("528"),Ha=va&&!Aa("8")||ua&&!Aa("9"),Ia=function(a,b){if(na.call(this,a?a.type:""),this.relatedTarget=this.currentTarget=this.target=null,this.charCode=this.keyCode=this.button=this.screenY=this.screenX=this.clientY=this.clientX=this.offsetY=this.offsetX=0,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.Db=this.state=null,a){var c=this.type=a.type;this.target=a.target||a.srcElement,this.currentTarget=b;var d=a.relatedTarget;if(d){if(va){var e;a:{try{oa(d.nodeName),e=!0;break a}catch(f){}e=!1}e||(d=null)}}else"mouseover"==c?d=a.fromElement:"mouseout"==c&&(d=a.toElement);this.relatedTarget=d,this.offsetX=wa||void 0!==a.offsetX?a.offsetX:a.layerX,this.offsetY=wa||void 0!==a.offsetY?a.offsetY:a.layerY,this.clientX=void 0!==a.clientX?a.clientX:a.pageX,this.clientY=void 0!==a.clientY?a.clientY:a.pageY,this.screenX=a.screenX||0,this.screenY=a.screenY||0,this.button=a.button,this.keyCode=a.keyCode||0,this.charCode=a.charCode||("keypress"==c?a.keyCode:0),this.ctrlKey=a.ctrlKey,this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.metaKey=a.metaKey,this.state=a.state,this.Db=a,a.defaultPrevented&&this.preventDefault()}};r(Ia,na),Ia.prototype.preventDefault=function(){Ia.L.preventDefault.call(this);var a=this.Db;if(a.preventDefault)a.preventDefault();else if(a.returnValue=!1,Ea)try{(a.ctrlKey||112<=a.keyCode&&123>=a.keyCode)&&(a.keyCode=-1)}catch(b){}},Ia.prototype.l=function(){};var Ja="closure_listenable_"+(1e6*Math.random()|0),Ka=function(a){return!(!a||!a[Ja])},La=0,Ma=function(a,b,c,d,e){this.O=a,this.proxy=null,this.src=b,this.type=c,this.pa=!!d,this.sa=e,this.key=++La,this.removed=this.qa=!1},Na=function(a){a.removed=!0,a.O=null,a.proxy=null,a.src=null,a.sa=null},Oa=function(a){this.src=a,this.j={},this.Z=0};Oa.prototype.add=function(a,b,c,d,e){var f=a.toString();a=this.j[f],a||(a=this.j[f]=[],this.Z++);var g=Qa(a,b,d,e);return g>-1?(b=a[g],c||(b.qa=!1)):(b=new Ma(b,this.src,f,!!d,e),b.qa=c,a.push(b)),b},Oa.prototype.remove=function(a,b,c,d){if(a=a.toString(),!(a in this.j))return!1;var e=this.j[a];return b=Qa(e,b,c,d),b>-1?(Na(e[b]),u.splice.call(e,b,1),0==e.length&&(delete this.j[a],this.Z--),!0):!1};var Pa=function(a,b){var c=b.type;if(!(c in a.j))return!1;var d=A(a.j[c],b);return d&&(Na(b),0==a.j[c].length&&(delete a.j[c],a.Z--)),d};Oa.prototype.removeAll=function(a){a=a&&a.toString();var b,c=0;for(b in this.j)if(!a||b==a){for(var d=this.j[b],e=0;e-1?a[e]:null};var Qa=function(a,b,c,d){for(var e=0;ee.keyCode||void 0!=e.returnValue)){a:{var g=!1;if(0==e.keyCode)try{e.keyCode=-1;break a}catch(h){g=!0}(g||void 0==e.returnValue)&&(e.returnValue=!0)}for(e=[],g=d.currentTarget;g;g=g.parentNode)e.push(g);for(var g=a.type,i=e.length-1;!d.U&&i>=0;i--)d.currentTarget=e[i],f&=_a(e[i],g,!0,d);for(i=0;!d.U&&i>>0),eb=function(a){return j(a)?a:(a[db]||(a[db]=function(b){return a.handleEvent(b)}),a[db])},fb=function(){ma.call(this),this.A=new Oa(this),this.kc=this,this.Qa=null};r(fb,ma),fb.prototype[Ja]=!0,a=fb.prototype,a.addEventListener=function(a,b,c,d){Ua(this,a,b,c,d)},a.removeEventListener=function(a,b,c,d){Ya(this,a,b,c,d)},a.dispatchEvent=function(a){var b,c=this.Qa;if(c){b=[];for(var d=1;c;c=c.Qa)b.push(c),++d}if(c=this.kc,d=a.type||a,h(a))a=new na(a,c);else if(a instanceof na)a.target=a.target||c;else{var e=a;a=new na(d,c),K(a,e)}var f,e=!0;if(b)for(var g=b.length-1;!a.U&&g>=0;g--)f=a.currentTarget=b[g],e=gb(f,d,!0,a)&&e;if(a.U||(f=a.currentTarget=c,e=gb(f,d,!0,a)&&e,a.U||(e=gb(f,d,!1,a)&&e)),b)for(g=0;!a.U&&g=0&&e>1));g++);f>=0&&(0==c.m&&1==e?ub(c,b):(e=c.n.splice(f,1)[0],Ab(c),e.Ma(b)))}}else xb(a,3,b)},vb=function(a,b){a.n&&a.n.length||2!=a.m&&3!=a.m||zb(a),a.n||(a.n=[]),a.n.push(b)},wb=function(a,b,c,d){var e={wa:null,jb:null,Ma:null};return e.wa=new tb(function(a,f){e.jb=b?function(c){try{var e=b.call(d,c);a(e)}catch(g){f(g)}}:a,e.Ma=c?function(b){try{var e=c.call(d,b);void 0===e&&b instanceof Db?f(b):a(e)}catch(g){f(g)}}:f}),e.wa.o=a,vb(a,e),e.wa};tb.prototype.vb=function(a){this.m=0,xb(this,2,a)},tb.prototype.wb=function(a){this.m=0,xb(this,3,a)};var xb=function(a,b,c){if(0==a.m){if(a==c)b=3,c=new TypeError("Promise cannot resolve to itself");else{if(sb(c))return a.m=1,void c.then(a.vb,a.wb,a);if(k(c))try{var d=c.then;if(j(d))return void yb(a,c,d)}catch(e){b=3,c=e}}a.v=c,a.m=b,zb(a),3!=b||c instanceof Db||Bb(a,c)}},yb=function(a,b,c){a.m=1;var d=!1,e=function(b){d||(d=!0,a.vb(b))},f=function(b){d||(d=!0,a.wb(b))};try{c.call(b,e,f)}catch(g){f(g)}},zb=function(a){a.La||(a.La=!0,lb(a.uc,a))};tb.prototype.uc=function(){for(;this.n&&this.n.length;){var a=this.n;this.n=[];for(var b=0;b=b.Ia&&b.cancel())}this.hb?this.hb.call(this.gb,this):this.Ka=!0,this.C||this.w(new Ob)}},Eb.prototype.ib=function(a,b){this.Ja=!1,Fb(this,a,b)};var Fb=function(a,b,c){a.C=!0,a.v=c,a.W=!b,Kb(a)},Gb=function(a){if(a.C){if(!a.Ka)throw new Nb;a.Ka=!1}};Eb.prototype.G=function(a){Gb(this),Fb(this,!0,a)},Eb.prototype.w=function(a){Gb(this),Fb(this,!1,a)},Eb.prototype.J=function(a,b){return Hb(this,a,null,b)};var Hb=function(a,b,c,d){return a.ja.push([b,c,d]),a.C&&Kb(a),a};Eb.prototype.then=function(a,b,c){var d,e,f=new tb(function(a,b){d=a,e=b});return Hb(this,d,function(a){a instanceof Ob?f.cancel():e(a)}),f.then(a,b,c)},rb(Eb);var Ib=function(a){var b=new Eb;return Hb(a,b.G,b.w,b),b},Jb=function(a){return x(a.ja,function(a){return j(a[1])})},Kb=function(a){if(a.ka&&a.C&&Jb(a)){var b=a.ka,d=Qb[b];d&&(c.clearTimeout(d.ma),delete Qb[b]),a.ka=0}a.o&&(a.o.Ia--,delete a.o);for(var b=a.v,e=d=!1;a.ja.length&&!a.Ja;){var f=a.ja.shift(),g=f[0],h=f[1],f=f[2];if(g=a.W?h:g)try{var i=g.call(f||a.gb,b);void 0!==i&&(a.W=a.W&&(i==b||i instanceof Error),a.v=b=i),sb(b)&&(e=!0,a.Ja=!0)}catch(j){b=j,a.W=!0,Jb(a)||(d=!0)}}a.v=b,e&&(i=n(a.ib,a,!0),e=n(a.ib,a,!1),b instanceof Eb?(Hb(b,i,e),b.Lb=!0):b.then(i,e)),d&&(b=new Pb(b),Qb[b.ma]=b,a.ka=b.ma)},Lb=function(a){var b=new Eb;return b.G(a),b},Mb=function(){var a=Kc,b=new Eb;return b.w(a),b},Nb=function(){s.call(this)};r(Nb,s),Nb.prototype.message="Deferred has already fired",Nb.prototype.name="AlreadyCalledError";var Ob=function(){s.call(this)};r(Ob,s),Ob.prototype.message="Deferred was canceled",Ob.prototype.name="CanceledError";var Pb=function(a){this.ma=c.setTimeout(n(this.pc,this),0),this.ga=a};Pb.prototype.pc=function(){throw delete Qb[this.ma],this.ga};var Qb={},Rb=function(a){this.$a=[],this.e=a};Rb.prototype.S=function(a){if(!j(a))throw Error("Invalid filter. Must be a function.");this.$a.push(a)},Rb.prototype.send=function(a,b){for(var c=new Sb(a,b),d=0;d=9||va&&Aa("1.9.1"),ua&&Aa("9");var Ub={id:"apiVersion",name:"v",valueType:"text",maxLength:void 0,defaultValue:void 0},Vb={id:"appName",name:"an",valueType:"text",maxLength:100,defaultValue:void 0},Wb={id:"appVersion",name:"av",valueType:"text",maxLength:100,defaultValue:void 0},Xb={id:"clientId",name:"cid",valueType:"text",maxLength:void 0,defaultValue:void 0},Yb={id:"language",name:"ul",valueType:"text",maxLength:20,defaultValue:void 0},Zb={id:"libVersion",name:"_v",valueType:"text",maxLength:void 0,defaultValue:void 0},$b={id:"sampleRateOverride",name:"usro",valueType:"integer",maxLength:void 0,defaultValue:void 0},_b={id:"screenColors",name:"sd",valueType:"text",maxLength:20,defaultValue:void 0},ac={id:"screenResolution",name:"sr",valueType:"text",maxLength:20,defaultValue:void 0},bc={id:"trackingId",name:"tid",valueType:"text",maxLength:void 0,defaultValue:void 0},cc={id:"viewportSize",name:"vp",valueType:"text",maxLength:20,defaultValue:void 0},dc={Rc:Ub,Uc:Vb,Vc:Wb,cd:Xb,vd:Yb,wd:Zb,Cd:$b,Dd:_b,Ed:ac,Qd:bc,Xd:cc},ec=function(a){if(!h(a))return a;var b=fc(a,X);if(k(b))return b;if(b=fc(a,dc),k(b))return b;if(b=/^dimension(\d+)$/.exec(a),null!==b)return Y(parseInt(b[1],10));if(b=/^metric(\d+)$/.exec(a),null!==b)return Z(parseInt(b[1],10));throw Error(a+" is not a valid parameter name.")},fc=function(a,b){var c=I(b,function(b){return b.id==a&&"metric"!=a&&"dimension"!=a});return k(c)?c:null},gc=function(a,b){this.Zb=b,this.q=b.Sa(),this.sb=new ia,this.Ya=!1};a=gc.prototype,a.set=function(a,b){var c=ec(a);this.sb.set(c,b)},a.S=function(a){this.Zb.S(a)},a.send=function(a,b){if(a instanceof ka)return a.send(this);var c=this.sb.clone();return b instanceof ia?c.ia(b):k(b)&&F(b,function(a,b){null!=a&&c.set(ec(b),a)},this),this.Ya&&(this.Ya=!1,c.set(R,"start")),this.q.send(a,c)},a.Gc=function(a){var b={description:a};return this.set(S,a),this.send("appview",b)},a.Hc=function(a,b,c,d){return this.send("event",{eventCategory:a,eventAction:b,eventLabel:c,eventValue:d})},a.Jc=function(a,b,c){return this.send("social",{socialNetwork:a,socialAction:b,socialTarget:c})},a.Ic=function(a,b){return this.send("exception",{exDescription:a,exFatal:b})},a.Cb=function(a,b,c,d,e){return this.send("timing",{timingCategory:a,timingVar:b,timingLabel:d,timingValue:c,sampleRateOverride:e})},a.Ac=function(){this.Ya=!0},a.Mc=function(a,b,c,d){return new hc(this,a,b,c,d)};var hc=function(a,b,c,d,e){this.yb=a,this.bc=b,this.ec=c,this.cc=d,this.V=e,this.dc=p()};hc.prototype.send=function(){var a=this.yb.Cb(this.bc,this.ec,p()-this.dc,this.cc,this.V);return this.yb=null,a};var ic=function(a,b,c,d,e){this.ic=a,this.fc=b,this.gc=c,this.k=d,this.hc=e};ic.prototype.Cc=function(a){var b=new gc(0,this.hc.create());return b.set(Zb,this.ic),b.set(Ub,1),b.set(Vb,this.fc),b.set(Wb,this.gc),b.set(bc,a),a=window.navigator.language,b.set(Yb,a),a=screen.colorDepth+"-bit",b.set(_b,a),a=[screen.width,screen.height].join("x"),b.set(ac,a),a=window.document,a="CSS1Compat"==a.compatMode?a.documentElement:a.body,a=new Tb(a.clientWidth,a.clientHeight),a=[a.width,a.height].join("x"),b.set(cc,a),b},ic.prototype.Bc=function(){return Ib(this.k.ha)};var jc=function(a){this.sc=a};jc.prototype.send=function(a,b){return this.sc.push({Ub:a,Vb:b}),Lb()};var kc=function(a,b,c){this.k=a,this.ra=[],this.M={enabled:new jc(this.ra),disabled:c},this.q=this.M.enabled,Hb(Ib(this.k.ha),o(this.Pb,b),this.Ob,this)};kc.prototype.Pb=function(a){this.M.enabled=a(),lc(this),w(this.ra,function(a){this.send(a.Ub,a.Vb)},this),this.ra=null,rc(this.k,n(this.Xb,this))},kc.prototype.Ob=function(){this.q=this.M.enabled=this.M.disabled,this.ra=null},kc.prototype.send=function(a,b){return this.q.send(a,b)};var lc=function(a){a.q=a.k.va()?a.M.enabled:a.M.disabled};kc.prototype.Xb=function(a){switch(a){case"analytics.tracking-permitted":lc(this)}};var mc=function(a,b,c,d,e,f){for(Eb.call(this,e,f),this.Na=a,this.Oa=[],this.lb=!!b,this.Nb=!!c,this.Mb=!!d,b=this.mb=0;bb;b++)switch(a[b]){case"x":a[b]=Math.floor(16*Math.random()).toString(16);break;case"y":a[b]=(Math.floor(4*Math.random())+8).toString(16)}a=a.join(""),this.H.set("analytics.user-id",a)}this.la=a},a)};oc.prototype.Kc=function(a){this.V=a};var uc=function(a){w(a.nb,function(a){a("analytics.tracking-permitted")})},vc=function(a){fb.call(this),this.Wa=a,this.H=chrome.storage.local,chrome.storage.onChanged.addListener(n(this.nc,this))};r(vc,fb),vc.prototype.nc=function(a){wc(this,a)&&this.dispatchEvent("a")};var wc=function(a,b){return x(H(b),function(a){return 0==a.lastIndexOf(this.Wa,0)},a)};vc.prototype.get=function(a){var b=new Eb,c=this.Wa+"."+a;return this.H.get(c,function(a){var d=chrome.runtime.lastError;d?b.w(d):b.G(a[c])}),b},vc.prototype.set=function(a,b){var c=new Eb,d={};return d[this.Wa+"."+a]=b,this.H.set(d,function(){var a=chrome.runtime.lastError;a?c.w(a):c.G()}),c};var xc=function(){};xc.Yb=function(){return xc.Ib?xc.Ib:xc.Ib=new xc},xc.prototype.send=function(){return Lb()};var yc=function(a,b){this.Xa=[];var c=n(function(){return this.Aa=new Rb(b.Sa()),w(this.Xa,function(a){this.Aa.S(a)},this),this.Xa=null,this.Aa},this);this.q=new kc(a,c,xc.Yb())};yc.prototype.Sa=function(){return this.q},yc.prototype.S=function(a){this.Aa?this.Aa.S(a):this.Xa.push(a)};var zc=function(a,b){this.k=a,this.mc=b};zc.prototype.create=function(){return new yc(this.k,this.mc)};var Ac=function(a,b){fb.call(this),this.ya=a||1,this.R=b||c,this.Ra=n(this.lc,this),this.Ta=p()};r(Ac,fb),a=Ac.prototype,a.enabled=!1,a.g=null,a.lc=function(){if(this.enabled){var a=p()-this.Ta;a>0&&a<.8*this.ya?this.g=this.R.setTimeout(this.Ra,this.ya-a):(this.g&&(this.R.clearTimeout(this.g),this.g=null),this.dispatchEvent("tick"),this.enabled&&(this.g=this.R.setTimeout(this.Ra,this.ya),this.Ta=p()))}},a.start=function(){this.enabled=!0,this.g||(this.g=this.R.setTimeout(this.Ra,this.ya),this.Ta=p())},a.stop=function(){this.enabled=!1,this.g&&(this.R.clearTimeout(this.g),this.g=null)},a.l=function(){Ac.L.l.call(this),this.stop(),delete this.R};var Bc=function(a,b,d){if(j(a))d&&(a=n(a,d));else{if(!a||"function"!=typeof a.handleEvent)throw Error("Invalid listener argument");a=n(a.handleEvent,a)}return b>2147483647?-1:c.setTimeout(a,b||0)},Cc=function(a){ma.call(this),this.Ua=a,this.b={}};r(Cc,ma);var Dc=[];Cc.prototype.listen=function(a,b,c,d){f(b)||(b&&(Dc[0]=b.toString()),b=Dc);for(var e=0;eb.maxLength&&a.set(b,c.substring(0,b.maxLength))})},Jc=function(a){ja(a,function(b,c){void 0!==b.defaultValue&&c==b.defaultValue&&a.remove(b)})},Kc={status:"device-offline",Ba:void 0},Lc={status:"rate-limited",Ba:void 0},Mc={status:"sampled-out",Ba:void 0},Nc={status:"sent",Ba:void 0},Oc=function(a,b){this.Wb=a,this.e=b};Oc.prototype.send=function(a,b){var c;c=this.Wb;var d=c.pb(),e=Math.floor((d-c.ob)*c.Sb);return e>0&&(c.$=Math.min(c.$+e,c.Tb),c.ob=d),1>c.$?c=!1:(c.$-=1,c=!0),c||"item"==a||"transaction"==a?this.e.send(a,b):Lb(Lc)};var Pc=function(){this.$=60,this.Tb=500,this.Sb=5e-4,this.pb=function(){return(new Date).getTime()},this.ob=this.pb()},Qc=function(a,b){this.k=a,this.e=b};Qc.prototype.send=function(a,b){var c,d=b.get(Xb),d=parseInt(d.split("-")[1],16);return"timing"!=a?c=this.k.V:((c=b.get($b))&&b.remove($b),c||(c=this.k.V)),655.36*c>d?this.e.send(a,b):Lb(Mc)};var Rc=/^(?:([^:/?#.]+):)?(?:\/\/(?:([^/?#]*)@)?([^/#?]*?)(?::([0-9]+))?(?=[/#?]|$))?([^?#]+)?(?:\?([^#]*))?(?:#(.*))?$/,Sc=wa,Tc=function(a,b){if(Sc){Sc=!1;var d=c.location;if(d){var e=d.href;if(e&&(e=(e=Tc(3,e))?decodeURI(e):e)&&e!=d.hostname)throw Sc=!0,Error()}}return b.match(Rc)[a]||null},Uc=function(){};Uc.prototype.Eb=null;var Vc,Wc=function(a){var b;return(b=a.Eb)||(b={},Zc(a)&&(b[0]=!0,b[1]=!0),b=a.Eb=b),b},Xc=function(){};r(Xc,Uc);var Yc=function(a){return(a=Zc(a))?new ActiveXObject(a):new XMLHttpRequest},Zc=function(a){if(!a.Hb&&"undefined"==typeof XMLHttpRequest&&"undefined"!=typeof ActiveXObject){for(var b=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],c=0;c=0?(e=b[c].substring(0,d),f=b[c].substring(d+1)):e=b[c],e=decodeURIComponent(e.replace(/\+/g," ")),e=nd(a,e),a.add(e,f?decodeURIComponent(f.replace(/\+/g," ")):"")}};a=ld.prototype,a.c=null,a.h=null,a.add=function(a,b){md(this),this.r=null,a=nd(this,a);var c=this.c.get(a);return c||this.c.set(a,c=[]),c.push(b),this.h++,this},a.remove=function(a){return md(this),a=nd(this,a),this.c.Q(a)?(this.r=null,this.h-=this.c.get(a).length,this.c.remove(a)):!1},a.Q=function(a){return md(this),a=nd(this,a),this.c.Q(a)},a.F=function(){md(this);for(var a=this.c.t(),b=this.c.F(),c=[],d=0;dthis.na?c.w({status:"payload-too-big",Ba:ea("Encoded hit length == %s, but should be <= %s.",d.length,this.na)}):cd(this.$b,function(){c.G(Nc)},d),c};var pd=function(a,b){var c=new ld;return c.add(Q.name,a),ja(b,function(a,b){c.add(a.name,b.toString())}),c.toString()},qd=function(a,b,c){this.k=a,this.Qb=b,this.na=c};qd.prototype.Sa=function(){if(!this.q){var a=this.k;if(!Ib(a.ha).C)throw Error("Cannot construct shared channel prior to settings being ready.");new Fc;var b=new Hc(new od(this.Qb,this.na)),c=new Pc;this.q=new Gc(a,new Qc(a,new Oc(c,b)))}return this.q};var rd=new L,sd=function(){if(!N){var a=new vc("google-analytics");N=new oc(a)}return N};q("goog.async.Deferred",Eb),q("goog.async.Deferred.prototype.addCallback",Eb.prototype.J),q("goog.events.EventTarget",fb),q("goog.events.EventTarget.prototype.listen",fb.prototype.listen),q("analytics.getService",function(a){var b=rd.get(a,null);if(null===b){var b=chrome.runtime.getManifest().version,c=sd();if(!O){var d=sd();O=new zc(d,new qd(d,"https://www.google-analytics.com/collect",8192))}b=new ic("ca1.5.2",a,b,c,O),rd.set(a,b)}return b}),q("analytics.internal.GoogleAnalyticsService",ic),q("analytics.internal.GoogleAnalyticsService.prototype.getTracker",ic.prototype.Cc),q("analytics.internal.GoogleAnalyticsService.prototype.getConfig",ic.prototype.Bc),q("analytics.internal.ServiceSettings",oc),q("analytics.internal.ServiceSettings.prototype.setTrackingPermitted",oc.prototype.Lc),q("analytics.internal.ServiceSettings.prototype.isTrackingPermitted",oc.prototype.va),q("analytics.internal.ServiceSettings.prototype.setSampleRate",oc.prototype.Kc),q("analytics.internal.ServiceTracker",gc),q("analytics.internal.ServiceTracker.prototype.send",gc.prototype.send),q("analytics.internal.ServiceTracker.prototype.sendAppView",gc.prototype.Gc),q("analytics.internal.ServiceTracker.prototype.sendEvent",gc.prototype.Hc),q("analytics.internal.ServiceTracker.prototype.sendSocial",gc.prototype.Jc),q("analytics.internal.ServiceTracker.prototype.sendException",gc.prototype.Ic),q("analytics.internal.ServiceTracker.prototype.sendTiming",gc.prototype.Cb),q("analytics.internal.ServiceTracker.prototype.startTiming",gc.prototype.Mc),q("analytics.internal.ServiceTracker.Timing",hc),q("analytics.internal.ServiceTracker.Timing.prototype.send",hc.prototype.send),q("analytics.internal.ServiceTracker.prototype.forceSessionStart",gc.prototype.Ac),q("analytics.internal.ServiceTracker.prototype.addFilter",gc.prototype.S),q("analytics.internal.FilterChannel.Hit",Sb),q("analytics.internal.FilterChannel.Hit.prototype.getHitType",Sb.prototype.Gb),q("analytics.internal.FilterChannel.Hit.prototype.getParameters",Sb.prototype.T),q("analytics.internal.FilterChannel.Hit.prototype.cancel",Sb.prototype.cancel),q("analytics.ParameterMap",ia),q("analytics.ParameterMap.Entry",ia.Entry),q("analytics.ParameterMap.prototype.set",ia.prototype.set),q("analytics.ParameterMap.prototype.get",ia.prototype.get),q("analytics.ParameterMap.prototype.remove",ia.prototype.remove),q("analytics.ParameterMap.prototype.toObject",ia.prototype.Jb),q("analytics.HitTypes.APPVIEW","appview"),q("analytics.HitTypes.EVENT","event"),q("analytics.HitTypes.SOCIAL","social"),q("analytics.HitTypes.TRANSACTION","transaction"),q("analytics.HitTypes.ITEM","item"),q("analytics.HitTypes.TIMING","timing"),q("analytics.HitTypes.EXCEPTION","exception"),F(X,function(a){var b=a.id.replace(/[A-Z]/,"_$&").toUpperCase();q("analytics.Parameters."+b,a)}),q("analytics.filters.EventLabelerBuilder",ca),q("analytics.filters.EventLabelerBuilder.prototype.appendToExistingLabel",ca.prototype.wc),q("analytics.filters.EventLabelerBuilder.prototype.stripValue",ca.prototype.Nc),q("analytics.filters.EventLabelerBuilder.prototype.powersOfTwo",ca.prototype.Ec),q("analytics.filters.EventLabelerBuilder.prototype.rangeBounds",ca.prototype.Fc),q("analytics.filters.EventLabelerBuilder.prototype.build",ca.prototype.Ca),q("analytics.filters.FilterBuilder",aa),q("analytics.filters.FilterBuilder.builder",ba),q("analytics.filters.FilterBuilder.prototype.when",aa.prototype.when),q("analytics.filters.FilterBuilder.prototype.whenHitType",aa.prototype.zb),q("analytics.filters.FilterBuilder.prototype.whenValue",aa.prototype.Oc),q("analytics.filters.FilterBuilder.prototype.applyFilter",aa.prototype.xb),q("analytics.filters.FilterBuilder.prototype.build",aa.prototype.Ca),q("analytics.EventBuilder",ka),q("analytics.EventBuilder.builder",function(){return la}),q("analytics.EventBuilder.prototype.category",ka.prototype.xc),q("analytics.EventBuilder.prototype.action",ka.prototype.action),q("analytics.EventBuilder.prototype.label",ka.prototype.label),q("analytics.EventBuilder.prototype.value",ka.prototype.value),q("analytics.EventBuilder.prototype.dimension",ka.prototype.yc),q("analytics.EventBuilder.prototype.metric",ka.prototype.Dc),q("analytics.EventBuilder.prototype.send",ka.prototype.send)}();var hex_chr="0123456789abcdef".split("");"5d41402abc4b2a76b9719d911017c592"!=md5("hello");var CanvasImage=function(a){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),document.body.appendChild(this.canvas),this.width=this.canvas.width=a.width,this.height=this.canvas.height=a.height,this.context.drawImage(a,0,0,this.width,this.height)};CanvasImage.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},CanvasImage.prototype.update=function(a){this.context.putImageData(a,0,0)},CanvasImage.prototype.getPixelCount=function(){return this.width*this.height},CanvasImage.prototype.getImageData=function(){return this.context.getImageData(0,0,this.width,this.height)},CanvasImage.prototype.removeCanvas=function(){this.canvas.parentNode.removeChild(this.canvas)};var ColorThief=function(){};if(ColorThief.prototype.getColor=function(a,b){var c=this.getPalette(a,5,b),d=c[0];return d},ColorThief.prototype.getPalette=function(a,b,c){"undefined"==typeof b&&(b=10),"undefined"==typeof c&&(c=10);for(var d,e,f,g,h,i=new CanvasImage(a),j=i.getImageData(),k=j.data,l=i.getPixelCount(),m=[],n=0;l>n;n+=c)d=4*n,e=k[d+0],f=k[d+1],g=k[d+2],h=k[d+3],h>=125&&(e>250&&f>250&&g>250||m.push([e,f,g]));var o=MMCQ.quantize(m,b),p=o.palette();return i.removeCanvas(),p},!pv)var pv={map:function(a,b){var c={};return b?a.map(function(a,d){return c.index=d,b.call(c,a)}):a.slice()},naturalOrder:function(a,b){return b>a?-1:a>b?1:0},sum:function(a,b){var c={};return a.reduce(b?function(a,d,e){return c.index=e,a+b.call(c,d)}:function(a,b){return a+b},0)},max:function(a,b){return Math.max.apply(null,b?pv.map(a,b):a)}};var MMCQ=function(){function a(a,b,c){return(a<<2*i)+(b<>j,e=b[1]>>j,f=b[2]>>j,c=a(d,e,f),h[c]=(h[c]||0)+1}),h}function f(a,b){var d,e,f,g=1e6,h=0,i=1e6,k=0,l=1e6,m=0;return a.forEach(function(a){d=a[0]>>j,e=a[1]>>j,f=a[2]>>j,g>d?g=d:d>h&&(h=d),i>e?i=e:e>k&&(k=e),l>f?l=f:f>m&&(m=f)}),new c(g,h,i,k,l,m,b)}function g(b,c){function d(a){var b,d,e,f,g,h=a+"1",j=a+"2",k=0;for(i=c[h];i<=c[j];i++)if(o[i]>n/2){for(e=c.copy(),f=c.copy(),b=i-c[h],d=c[j]-i,g=d>=b?Math.min(c[j]-1,~~(i+d/2)):Math.max(c[h],~~(i-1-b/2));!o[g];)g++;for(k=p[g];!k&&o[g-1];)k=p[--g];return e[j]=g,f[h]=e[j]+1,[e,f]}}if(c.count()){var e=c.r2-c.r1+1,f=c.g2-c.g1+1,g=c.b2-c.b1+1,h=pv.max([e,f,g]);if(1==c.count())return[c.copy()];var i,j,k,l,m,n=0,o=[],p=[];if(h==e)for(i=c.r1;i<=c.r2;i++){for(l=0,j=c.g1;j<=c.g2;j++)for(k=c.b1;k<=c.b2;k++)m=a(i,j,k),l+=b[m]||0;n+=l,o[i]=n}else if(h==f)for(i=c.g1;i<=c.g2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.b1;k<=c.b2;k++)m=a(j,i,k),l+=b[m]||0;n+=l,o[i]=n}else for(i=c.b1;i<=c.b2;i++){for(l=0,j=c.r1;j<=c.r2;j++)for(k=c.g1;k<=c.g2;k++)m=a(j,k,i),l+=b[m]||0;n+=l,o[i]=n}return o.forEach(function(a,b){p[b]=n-a}),d(h==e?"r":h==f?"g":"b")}}function h(a,c){function h(a,b){for(var c,d=1,e=0;k>e;)if(c=a.pop(),c.count()){var f=g(i,c),h=f[0],j=f[1];if(!h)return;if(a.push(h),j&&(a.push(j),d++),d>=b)return;if(e++>k)return}else a.push(c),e++}if(!a.length||2>c||c>256)return!1;var i=e(a),j=0;i.forEach(function(){j++});var m=f(a,i),n=new b(function(a,b){return pv.naturalOrder(a.count(),b.count())});n.push(m),h(n,l*c);for(var o=new b(function(a,b){return pv.naturalOrder(a.count()*a.volume(),b.count()*b.volume())});n.size();)o.push(n.pop());h(o,c-o.size());for(var p=new d;o.size();)p.push(o.pop());return p}var i=5,j=8-i,k=1e3,l=.75;return c.prototype={volume:function(a){var b=this;return(!b._volume||a)&&(b._volume=(b.r2-b.r1+1)*(b.g2-b.g1+1)*(b.b2-b.b1+1)),b._volume},count:function(b){var c=this,d=c.histo;if(!c._count_set||b){var e,f,g,h=0;for(e=c.r1;e<=c.r2;e++)for(f=c.g1;f<=c.g2;f++)for(g=c.b1;g<=c.b2;g++)index=a(e,f,g),h+=d[index]||0;c._count=h,c._count_set=!0}return c._count},copy:function(){var a=this;return new c(a.r1,a.r2,a.g1,a.g2,a.b1,a.b2,a.histo)},avg:function(b){var c=this,d=c.histo;if(!c._avg||b){var e,f,g,h,j,k=0,l=1<<8-i,m=0,n=0,o=0;for(f=c.r1;f<=c.r2;f++)for(g=c.g1;g<=c.g2;g++)for(h=c.b1;h<=c.b2;h++)j=a(f,g,h),e=d[j]||0,k+=e,m+=e*(f+.5)*l,n+=e*(g+.5)*l,o+=e*(h+.5)*l;c._avg=k?[~~(m/k),~~(n/k),~~(o/k)]:[~~(l*(c.r1+c.r2+1)/2),~~(l*(c.g1+c.g2+1)/2),~~(l*(c.b1+c.b2+1)/2)]}return c._avg},contains:function(a){var b=this,c=a[0]>>j;return gval=a[1]>>j,bval=a[2]>>j,c>=b.r1&&c<=b.r2&&gval>=b.g1&&gval<=b.g2&&bval>=b.b1&&bval<=b.b2}},d.prototype={push:function(a){this.vboxes.push({vbox:a,color:a.avg()})},palette:function(){return this.vboxes.map(function(a){return a.color; + +})},size:function(){return this.vboxes.size()},map:function(a){for(var b=this.vboxes,c=0;cc||void 0===b)&&(b=c,d=e.peek(f).color);return d},forcebw:function(){var a=this.vboxes;a.sort(function(a,b){return pv.naturalOrder(pv.sum(a.color),pv.sum(b.color))});var b=a[0].color;b[0]<5&&b[1]<5&&b[2]<5&&(a[0].color=[0,0,0]);var c=a.length-1,d=a[c].color;d[0]>251&&d[1]>251&&d[2]>251&&(a[c].color=[255,255,255])}},{quantize:h}}(); diff --git a/build/background.js b/build/background.js index 9dac7cc..6631146 100755 --- a/build/background.js +++ b/build/background.js @@ -18,22 +18,3 @@ chrome.app.runtime.onLaunched.addListener(function() { } }); }); -function sendMessage() { - chrome.runtime.sendMessage({command: "play"}, function(response) { - console.log(response.farewell); - }); -} -chrome.commands.onCommand.addListener(function (command) { - if (command === "playPauseMediaKey") { - // - } else if (command === "nextTrackMediaKey") { - // - } else if (command === "lastTrackMediaKey") { - // - } else if (command === "MediaPlayPause") { - // - } else if (commane === "testKey") { - sendMessage(); - } -}); - diff --git a/build/images/icon_128.png b/build/images/icon_128.png index 25d6aef..362f4e3 100755 Binary files a/build/images/icon_128.png and b/build/images/icon_128.png differ diff --git a/build/index.html b/build/index.html index 8f657d4..ea1edaa 100644 --- a/build/index.html +++ b/build/index.html @@ -224,7 +224,7 @@ Anonymous usage statistics
{{cacheDetails}} {{storageQuota}} -

{{clearCacheLabel}}


{{clearSettingsLabel}}
Icon
Icon
- + @@ -238,6 +240,9 @@
+ + +