(function(){"use strict";function a(){var b=Ha(["",""]);return a=function(){return b},b}function b(){var a=Ha(["",""]);return b=function(){return a},a}function c(){var a=Ha(["\n
a.parentNode.removeChild(a))}function Ra(a){var b=vb.get(a.type);void 0===b&&(b={stringsArray:new WeakMap,keyString:new Map},vb.set(a.type,b));var c=b.stringsArray.get(a.strings);if(void 0!==c)return c;var d=a.strings.join(Ua);return c=b.keyString.get(d),void 0===c&&(c=new Xa(a,a.getTemplateElement()),b.keyString.set(d,c)),b.stringsArray.set(a.strings,c),c}Pa.r(Oa);var Sa="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,Ta=function(a,b){for(var c=2"),Wa=new RegExp("".concat(Ua,"|").concat(Va));class Xa{constructor(a,b){this.parts=[],this.element=b;for(var e=[],g=[],h=document.createTreeWalker(b.content,133,null,!1),i=0,j=-1,k=0,{strings:m,values:{length:d}}=a;k {var c=a.length-b.length;return 0<=c&&a.slice(c)===b},Za=a=>-1!==a.index,$a=()=>document.createComment(""),ab=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/,_a=a=>{for(var b=11===a.nodeType?0:1,c=document.createTreeWalker(a,133,null,!1);c.nextNode();)b++;return b},bb=function(a){for(var b,c=1 function(){var b=a(...arguments);return cb.set(b,!0),b},eb=a=>"function"==typeof a&&cb.has(a),fb={},gb={};class hb{constructor(a,b,c){this.__parts=[],this.template=a,this.processor=b,this.options=c}update(a){var b=0;for(var c of this.__parts)void 0!==c&&c.setValue(a[b]),b++;for(var d of this.__parts)void 0!==d&&d.commit()}_clone(){for(var b,d=Sa?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),f=[],e=this.template.parts,g=document.createTreeWalker(d,133,null,!1),h=0,i=0,j=g.nextNode();h ",g+1);var h=ab.exec(f);b+=null===h?f+(c?ib:Va):f.substr(0,h.index)+h[1]+h[2]+"$lit$"+h[3]+Ua}return b+=this.strings[a],b}getTemplateElement(){var a=document.createElement("template");return a.innerHTML=this.getHTML(),a}}var kb=a=>null===a||"object"!=typeof a&&"function"!=typeof a,lb=a=>Array.isArray(a)||a&&a[Symbol.iterator];class mb{constructor(a,b,c){this.dirty=!0,this.element=a,this.name=b,this.strings=c,this.parts=[];for(var d=0;d {try{var a={get capture(){return sb=!0,!1}};window.addEventListener("test",a,a),window.removeEventListener("test",a,a)}catch(a){}})();class tb{constructor(a,b,c){this.value=void 0,this.__pendingValue=void 0,this.element=a,this.eventName=b,this.eventContext=c,this.__boundHandleEvent=a=>this.handleEvent(a)}setValue(a){this.__pendingValue=a}commit(){for(;eb(this.__pendingValue);){var d=this.__pendingValue;this.__pendingValue=fb,d(this)}if(this.__pendingValue!==fb){var a=this.__pendingValue,b=this.value,c=null==a||null!=b&&(a.capture!==b.capture||a.once!==b.once||a.passive!==b.passive);c&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),null!=a&&(null==b||c)&&(this.__options=ub(a),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=a,this.__pendingValue=fb}}handleEvent(a){"function"==typeof this.value?this.value.call(this.eventContext||this.element,a):this.value.handleEvent(a)}}var ub=a=>a&&(sb?{capture:a.capture,passive:a.passive,once:a.once}:a.capture),vb=new Map,wb=new WeakMap,xb=new class{handleAttributeExpressions(a,b,c,d){var e=b[0];return"."===e?new qb(a,b.slice(1),c).parts:"@"===e?[new tb(a,b.slice(1),d.eventContext)]:"?"===e?[new pb(a,b.slice(1),c)]:new mb(a,b,c).parts}handleTextExpression(a){return new ob(a)}};"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.2.1");var yb=function(a){for(var b=arguments.length,c=Array(1"".concat(a,"--").concat(b),Ab=!0;void 0===window.ShadyCSS?Ab=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),Ab=!1);var Bb=a=>b=>{var c=zb(b.type,a),d=vb.get(c);void 0===d&&(d={stringsArray:new WeakMap,keyString:new Map},vb.set(c,d));var e=d.stringsArray.get(b.strings);if(void 0!==e)return e;var f=b.strings.join(Ua);if(e=d.keyString.get(f),void 0===e){var g=b.getTemplateElement();Ab&&window.ShadyCSS.prepareTemplateDom(g,a),e=new Xa(b,g),d.keyString.set(f,e)}return d.stringsArray.set(b.strings,e),e},Cb=["html","svg"],Db=new Set,Eb=(b,d,e)=>{Db.add(b);var f=e?e.element:document.createElement("template"),g=d.querySelectorAll("style"),{length:h}=g;if(0===h)return void window.ShadyCSS.prepareTemplateStyles(f,b);for(var i,j=document.createElement("style"),k=0;k {Cb.forEach(b=>{var c=vb.get(zb(b,a));void 0!==c&&c.keyString.forEach(a=>{var{element:{content:b}}=a,c=new Set;Array.from(b.querySelectorAll("style")).forEach(a=>{c.add(a)}),Qa(a,c)})})})(b);var l=f.content;e?function(b,d){var e=2 a;var Fb={toAttribute(a,b){return b===Boolean?a?"":null:b===Object||b===Array?null==a?a:JSON.stringify(a):a},fromAttribute(a,b){return b===Boolean?null!==a:b===Number?null===a?null:+a:b===Object||b===Array?JSON.parse(a):a}},Gb=(a,b)=>b!==a&&(b==b||a==a),Hb={attribute:!0,type:String,converter:Fb,reflect:!1,hasChanged:Gb};class Ib extends HTMLElement{constructor(){super(),this._updateState=0,this._instanceProperties=void 0,this._updatePromise=new Promise(a=>this._enableUpdatingResolver=a),this._changedProperties=new Map,this._reflectingProperties=void 0,this.initialize()}static get observedAttributes(){this.finalize();var a=[];return this._classProperties.forEach((b,c)=>{var d=this._attributeNameForProperty(c,b);void 0!==d&&(this._attributeToPropertyMap.set(d,c),a.push(d))}),a}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;var a=Object.getPrototypeOf(this)._classProperties;void 0!==a&&a.forEach((a,b)=>this._classProperties.set(b,a))}}static createProperty(a){var b=1 {if(this.hasOwnProperty(b)){var c=this[b];delete this[b],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(b,c)}})}_applyInstanceProperties(){this._instanceProperties.forEach((a,b)=>this[b]=a),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(a,b,c){b!==c&&this._attributeToProperty(a,c)}_propertyToAttribute(a,b){var c=2 this._propertyToAttribute(b,this[b],a)),this._reflectingProperties=void 0),this._markUpdated()}updated(){}firstUpdated(){}}Ib.finalized=!0;var Jb="adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Kb=Symbol();class Lb{constructor(a,b){if(b!==Kb)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=a}get styleSheet(){return void 0===this._styleSheet&&(Jb?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}var Mb=function(a){for(var b=arguments.length,c=Array(1b+(a=>{if(a instanceof Lb)return a.cssText;if("number"==typeof a)return a;throw new Error("Value passed to 'css' function must be a 'css' function result: ".concat(a,". Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security."))})(c)+a[d+1],a[0]);return new Lb(e,Kb)};(window.litElementVersions||(window.litElementVersions=[])).push("2.3.1");var Nb={};class Ob extends Ib{static getStyles(){return this.styles}static _getUniqueStyles(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_styles",this))){var a=this.getStyles();if(void 0===a)this._styles=[];else if(Array.isArray(a)){var b=(a,c)=>a.reduceRight((a,c)=>Array.isArray(c)?b(c,a):(a.add(c),a),c),c=b(a,new Set),d=[];c.forEach(a=>d.unshift(a)),this._styles=d}else this._styles=[a]}}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow({mode:"open"})}adoptStyles(){var a=this.constructor._styles;0!==a.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Jb?this.renderRoot.adoptedStyleSheets=a.map(a=>a.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(a.map(a=>a.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(a){var b=this.render();super.update(a),b!==Nb&&this.constructor.render(b,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(a=>{var b=document.createElement("style");b.textContent=a.cssText,this.renderRoot.appendChild(b)}))}render(){return Nb}}Ob.finalized=!0,Ob.render=(b,d,e)=>{if(!e||"object"!=typeof e||!e.scopeName)throw new Error("The `scopeName` option is required.");var f=e.scopeName,g=wb.has(d),h=Ab&&11===d.nodeType&&!!d.host,i=h&&!Db.has(f),a=i?document.createDocumentFragment():d;if(((a,b,c)=>{var d=wb.get(b);void 0===d&&(Ta(b,b.firstChild),wb.set(b,d=new ob(Object.assign({templateFactory:Ra},c))),d.appendInto(b)),d.setValue(a),d.commit()})(b,a,Object.assign({templateFactory:Bb(f)},e)),i){var c=wb.get(a);wb.delete(a);var j=c.value instanceof hb?c.value.template:void 0;Eb(f,a,j),Ta(d,d.firstChild),d.appendChild(a),wb.set(d,c)}!g&&h&&window.ShadyCSS.styleElement(d.host)};class Pb{constructor(a){this.classes=new Set,this.changed=!1,this.element=a;var b=(a.getAttribute("class")||"").split(/\s+/);for(var c of b)this.classes.add(c)}add(a){this.classes.add(a),this.changed=!0}remove(a){this.classes.delete(a),this.changed=!0}commit(){if(this.changed){var a="";this.classes.forEach(b=>a+=b+" "),this.element.setAttribute("class",a)}}}var Qb=new WeakMap,Rb=db(a=>b=>{if(!(b instanceof nb)||b instanceof rb||"class"!==b.committer.name||1 {b in a||(g.remove(b),f.delete(b))}),a){var h=a[e];h!=f.has(e)&&(h?(g.add(e),f.add(e)):(g.remove(e),f.delete(e)))}"function"==typeof g.commit&&g.commit()}),Sb=new WeakMap,Tb=db(a=>b=>{if(!(b instanceof nb)||b instanceof rb||"style"!==b.committer.name||1 {b in a||(f.delete(b),-1===b.indexOf("-")?d[b]=null:d.removeProperty(b))}),a)f.add(e),-1===e.indexOf("-")?d[e]=a[e]:d.setProperty(e,a[e])}),Ub=Pa(62),Vb={shuffle:!0,power_state:!0,artwork_border:!0,icon_state:!0,sound_mode:!0,runtime:!0,volume:!1,volume_level:!0,controls:!1,play_pause:!1,play_stop:!0,prev:!1,next:!1},Wb="mdi:chevron-down",Xb={true:"mdi:volume-off",false:"mdi:volume-high"},Yb="mdi:skip-next",Zb={true:"mdi:pause",false:"mdi:play"},$b={true:"mdi:stop",false:"mdi:play"},_b=["entity","_overflow","break","thumbnail","prevThumbnail","edit","idle","cardHeight","backgroundColor","foregroundColor"],ac=["media_duration","media_position","media_position_updated_at"],bc=[{attr:"media_title"},{attr:"media_artist"},{attr:"media_series_title"},{attr:"media_season",prefix:"S"},{attr:"media_episode",prefix:"E"},{attr:"app_name"}],cc="squeezebox",dc="soundtouch",ec=a=>{(a=>{if(!a.entity||"media_player"!==a.entity.split(".")[0])throw new Error("Specify an entity from within the media_player domain.")})(a);var b=Ja(Ja({artwork:"default",info:"default",more_info:!0,source:"default",sound_mode:"default",toggle_power:!0,volume_step:null,tap_action:{action:"more-info"}},a),{},{hide:Ja(Ja({},Vb),a.hide),speaker_group:Ja(Ja({show_group_count:!0,platform:"sonos"},a.sonos),a.speaker_group),shortcuts:Ja({label:"Shortcuts..."},a.shortcuts)});return b.max_volume=+b.max_volume||100,b.min_volume=+b.min_volume||0,b.collapse=b.hide.controls||b.hide.volume,b.info=b.collapse&&"scroll"!==b.info?"short":b.info,b.flow=b.hide.icon&&b.hide.name&&b.hide.info,b},fc=a=>{var b="";return[].slice.call(new Uint8Array(a)).forEach(a=>b+=D(a)),window.btoa(b)};class gc{constructor(a,b,c){this.hass=a||{},this.config=b||{},this.entity=c||{},this.state=c.state,this.attr=c.attributes,this.idle=!!b.idle_view&&this.idleView,this.active=this.isActive}get id(){return this.entity.entity_id}get icon(){return this.attr.icon}get isPaused(){return"paused"===this.state}get isPlaying(){return"playing"===this.state}get isIdle(){return"idle"===this.state}get isStandby(){return"standby"===this.state}get isUnavailable(){return"unavailable"===this.state}get isOff(){return"off"===this.state}get isActive(){return!this.isOff&&!this.isUnavailable&&!this.idle||!1}get shuffle(){return this.attr.shuffle||!1}get content(){return this.attr.media_content_type||"none"}get mediaDuration(){return this.attr.media_duration||0}get updatedAt(){return this.attr.media_position_updated_at||0}get position(){return this.attr.media_position||0}get name(){return this.attr.friendly_name||""}get groupCount(){return this.group.length}get isGrouped(){return 1 Ja({text:this.attr[a.attr],prefix:""},a)).filter(a=>a.text)}get hasProgress(){return!this.config.hide.progress&&!this.idle&&ac.every(a=>a in this.attr)}get progress(){return this.position+(Date.now()-new Date(this.updatedAt).getTime())/1e3}get idleView(){var a=this.config.idle_view;return!!(a.when_idle&&this.isIdle||a.when_standby&&this.isStandby||a.when_paused&&this.isPaused)||this.updatedAt&&a.after&&!this.isPlaying&&this.checkIdleAfter(a.after)}get trackIdle(){return this.active&&!this.isPlaying&&this.updatedAt&&this.config.idle_view&&this.config.idle_view.after}checkIdleAfter(a){var b=(Date.now()-new Date(this.updatedAt).getTime())/1e3;return this.idle=b>60*a,this.active=this.isActive,this.idle}get supportsShuffle(){return void 0!==this.attr.shuffle}get supportsMute(){return void 0!==this.attr.is_volume_muted}get supportsVolumeSet(){return void 0!==this.attr.volume_level}get supportsMaster(){return this.platform!==cc}fetchArtwork(){var a=this;return Ma(function*(){var b=a.attr.entity_picture_local?a.hass.hassUrl(a.picture):a.picture;try{var c=yield fetch(new Request(b)),d=yield c.arrayBuffer(),e=fc(d);return"url(data:".concat(c.headers.get("Content-Type")||"image/jpeg",";base64,").concat(e,")")}catch(a){return!1}})()}getAttribute(a){return this.attr[a]||""}toggle(a){return this.config.toggle_power?this.callService(a,"toggle"):this.isOff?this.callService(a,"turn_on"):void this.callService(a,"turn_off")}toggleMute(a){this.config.speaker_group.sync_volume?this.group.forEach(b=>{this.callService(a,"volume_mute",{entity_id:b,is_volume_muted:!this.muted})}):this.callService(a,"volume_mute",{is_volume_muted:!this.muted})}toggleShuffle(a){this.callService(a,"shuffle_set",{shuffle:!this.shuffle})}setSource(a,b){this.callService(a,"select_source",{source:b})}setMedia(a,b){this.callService(a,"play_media",Ja({},b))}playPause(a){this.callService(a,"media_play_pause")}playStop(a){this.isPlaying?this.callService(a,"media_stop"):this.callService(a,"media_play")}setSoundMode(a,b){this.callService(a,"select_sound_mode",{sound_mode:b})}next(a){this.callService(a,"media_next_track")}prev(a){this.callService(a,"media_previous_track")}stop(a){this.callService(a,"media_stop")}volumeUp(a){this.supportsVolumeSet&&0 {var d=this.config.speaker_group.entities.find(a=>a.entity_id===c)||{},e=b;d.volume_offset&&(e+=d.volume_offset/100,1 e&&(e=0)),this.callService(a,"volume_set",{entity_id:c,volume_level:e})}):this.callService(a,"volume_set",{entity_id:this.config.entity,volume_level:b})}handleGroupChange(a,b,c){var{platform:d}=this,e={entity_id:b};if(c)switch(e.master=this.config.entity,d){case dc:return this.handleSoundtouch(a,this.isGrouped?"ADD_ZONE_SLAVE":"CREATE_ZONE",b);case cc:return this.callService(a,"sync",{entity_id:this.config.entity,other_player:b},cc);default:return this.callService(a,"join",e,d);}else return d===dc?this.handleSoundtouch(a,"REMOVE_ZONE_SLAVE",b):d===cc?this.callService(a,"unsync",e,cc):this.callService(a,"unjoin",e,d)}handleSoundtouch(a,b,c){return this.callService(a,b,{master:this.master,slaves:c},dc,!0)}toggleScript(a,b){var c=2 {var d=[a,b,c].map(a=>{var b=a;return b/=255,.03928>=b?b/12.92:((b+.055)/1.055)**2.4});return .2126*d[0]+.7152*d[1]+.0722*d[2]},lc=(a,b)=>Ha(100*(((a,b)=>{var c=kc(...a),d=kc(...b);return(Ka(c,d)+.05)/(Ia(c,d)+.05)})(a,b)+Number.EPSILON))/100,mc=a=>{function b(a){return e.has(a)||e.set(a,lc(d.rgb,a.rgb)),4.5 b.population-a.population);for(var c,d=a[0],e=new Map,f=1;f =La(h.rgb[0]-g.rgb[0])+La(h.rgb[1]-g.rgb[1])+La(h.rgb[2]-g.rgb[2])&&b(g)&&b(g)){c=g.hex;break}}return void 0===c&&(c=d.bodyTextColor),[c,d.hex]};Pa(186);var nc={en:{placeholder:{tts:"Text to speech"},label:{leave:"Leave",ungroup:"Ungroup",group_all:"Group all",send:"Send",master:"Master"},state:{idle:"Idle",unavailable:"Unavailable"},title:{speaker_management:"Group management"}},fr:{placeholder:{tts:"Texte \xE0 lire"},label:{leave:"Quitter",ungroup:"D\xE9grouper",group_all:"Grouper tous",send:"Envoyer"},state:{idle:"Inactif",unavailable:"Indisponible"},title:{speaker_management:"Gestion des groupes"}},hu:{placeholder:{tts:"Sz\xF6vegfelolvas\xE1s"},label:{leave:"Kil\xE9p\xE9s",ungroup:"\xD6sszes ki",group_all:"\xD6sszes be",send:"K\xFCld\xE9s",master:"Forr\xE1s"},state:{idle:"T\xE9tlen",unavailable:"Nem el\xE9rhet\u0151"},title:{speaker_management:"Hangsz\xF3r\xF3k csoportos\xEDt\xE1sa"}},pl:{placeholder:{tts:"Zamie\u0144 tekst na mow\u0119"},label:{leave:"Opu\u015B\u0107",ungroup:"Usu\u0144 grup\u0119",group_all:"Grupuj wszystkie",send:"Wy\u015Blij"},state:{idle:"nieaktywny",unavailable:"niedost\u0119pny"},title:{speaker_management:"Zarz\u0105dzanie grup\u0105"}},uk:{placeholder:{tts:"\u0422\u0435\u043A\u0441\u0442 \u0434\u043B\u044F \u0432\u0456\u0434\u0442\u0432\u043E\u0440\u0435\u043D\u043D\u044F"},label:{leave:"\u0417\u0430\u043B\u0438\u0448\u0438\u0442\u0438",ungroup:"\u0420\u043E\u0437\u0433\u0440\u0443\u043F\u0443\u0432\u0430\u0442\u0438",group_all:"\u0417\u0433\u0440\u0443\u043F\u0443\u0432\u0430\u0442\u0438 \u0432\u0441\u0456",send:"\u041D\u0430\u0434\u0456\u0441\u043B\u0430\u0442\u0438",master:"\u0413\u043E\u043B\u043E\u0432\u043D\u0438\u0439"},state:{idle:"\u0431\u0435\u0437\u0434\u0456\u044F\u043B\u044C\u043D\u0456\u0441\u0442\u044C",unavailable:"\u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u0438\u0439"},title:{speaker_management:"\u0423\u043F\u0440\u0430\u0432\u043B\u0456\u043D\u043D\u044F \u0433\u0440\u0443\u043F\u043E\u044E"}}},oc=(a,b)=>b.split(".").reduce((a,b)=>a&&a[b]||null,a),pc=function(a,b,c){var d=3 a.stopPropagation(),this.handleClick,this.item.name,this.master?yb(Da(),pc(this.hass,"label.master")):"")}handleClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("change",{detail:{entity:this.item.entity_id,checked:!this.checked}}))}static get styles(){return Mb(Ca())}}),customElements.define("mmp-button",class extends Ob{render(){return yb(Ba())}static get styles(){return Mb(Aa())}}),customElements.define("mmp-group-list",class extends Ob{static get properties(){return{hass:{},entities:{},player:{},visible:Boolean}}get group(){return this.player.group}get master(){return this.player.master}get isMaster(){return this.player.isMaster}get isGrouped(){return this.player.isGrouped}handleGroupChange(a){var{entity:b,checked:c}=a.detail;this.player.handleGroupChange(a,b,c)}render(){if(!this.visible)return yb(za());var{group:a,isMaster:b,isGrouped:c}=this,{id:d}=this.player;return yb(ya(),pc(this.hass,"title.speaker_management"),this.entities.map(a=>this.renderItem(a,d)),!c,a=>this.player.handleGroupChange(a,d,!1),pc(this.hass,"label.leave"),c&&b?yb(xa(),b=>this.player.handleGroupChange(b,a,!1),pc(this.hass,"label.ungroup")):yb(wa()),!b,a=>this.player.handleGroupChange(a,this.entities.map(a=>a.entity_id),!0),pc(this.hass,"label.group_all"))}renderItem(a,b){var c=a.entity_id;return yb(va(),this.handleGroupChange,a,c===b||this.group.includes(c),c===b||!this.isMaster,c===this.master)}static get styles(){return Mb(ua())}}),customElements.define("mmp-dropdown",class extends Ob{static get properties(){return{items:[],label:String,selected:String}}get selectedId(){return this.items.map(a=>a.id).indexOf(this.selected)}onChange(a){var b=a.target.selected;b!==this.selectedId&&this.items[b]&&(this.dispatchEvent(new CustomEvent("change",{detail:this.items[b]})),a.target.selected=-1)}render(){return yb(ta(),"right","top",44,a=>a.stopPropagation(),this.icon?yb(sa(),Wb):yb(ra(),this.selected||this.label,Wb),this.selectedId,this.onChange,this.items.map(a=>yb(qa(),a.id||a.name,a.icon?yb(pa(),a.icon):"",a.name?yb(oa(),a.name):"")))}static get styles(){return[ic,Mb(na())]}}),customElements.define("mmp-shortcuts",class extends Ob{static get properties(){return{player:{},shortcuts:{}}}get buttons(){return this.shortcuts.buttons}get list(){return this.shortcuts.list}get show(){return!this.shortcuts.hide_when_off||this.player.active}get active(){return this.player.getAttribute(this.shortcuts.attribute)}get height(){return this.shortcuts.column_height||36}render(){if(!this.show)return yb(ma());var{active:a}=this,b=this.list?yb(la(),this.handleShortcut,this.list,this.shortcuts.label,a):"",c=this.buttons?yb(ka(),this.buttons.map(b=>yb(ja(),Tb(this.shortcutStyle(b)),this.shortcuts.columns,b.id===a,a=>this.handleShortcut(a,b),this.shortcuts.align_text,b.icon?yb(ia(),b.icon):"",b.image?yb(ha(),b.image):"",b.name?yb(ga(),b.name):""))):"";return yb(fa(),c,b)}handleShortcut(a,b){var{type:c,id:d,data:e}=b||a.detail;if("source"===c)return this.player.setSource(a,d);if("service"===c)return this.player.toggleService(a,d,e);if("script"===c)return this.player.toggleScript(a,d,e);if("sound_mode"===c)return this.player.setSoundMode(a,d);this.player.setMedia(a,{media_content_type:c,media_content_id:d})}shortcutStyle(a){return Ja({"min-height":this.height+"px"},a.cover&&{"background-image":"url(".concat(a.cover,")")})}static get styles(){return[ic,Mb(ea())]}}),customElements.define("mmp-tts",class extends Ob{static get properties(){return{hass:{},config:{},player:{}}}get label(){return pc(this.hass,"placeholder.tts","ui.card.media_player.text_to_speak","Say")}get input(){return this.shadowRoot.getElementById("tts-input")}get message(){return this.input.value}render(){return yb(da(),this.label,a=>a.stopPropagation(),this.handleTts,pc(this.hass,"label.send"))}handleTts(a){var{config:b,message:c}=this,d=Ja({message:c,entity_id:b.entity_id||this.player.id},"group"===b.entity_id&&{entity_id:this.player.group});b.language&&(d.language=b.language),"alexa"===b.platform?this.hass.callService("notify","alexa_media",{message:c,data:{type:b.type||"tts"},target:d.entity_id}):"sonos"===b.platform?this.hass.callService("script","sonos_say",{sonos_entity:d.entity_id,volume:b.volume||.5,message:c}):"webos"===b.platform?this.hass.callService("notify",d.entity_id.split(".").slice(-1)[0],{message:c}):"ga"===b.platform?this.hass.callService("notify","ga_broadcast",{message:c}):this.hass.callService("tts",b.platform+"_say",d),a.stopPropagation(),this.reset()}reset(){this.input.value=""}static get styles(){return Mb(ca())}});var qc=a=>{var b=parseInt(a%60,10),c=parseInt(a/60%60,10),d=parseInt(a/3600%24,10);return d=10>d?"0"+d:d,c=10>c?"0"+c:c,b=10>b?"0"+b:b,"".concat("00"===d?"":d+":").concat(c,":").concat(b)};customElements.define("mmp-progress",class extends Ob{static get properties(){return{_player:{},showTime:Boolean,progress:Number,duration:Number,tracker:{},seekProgress:Number,seekWidth:Number,track:Boolean}}set player(a){this._player=a,this.hasProgress&&this.trackProgress()}get duration(){return this.player.mediaDuration}get player(){return this._player}get hasProgress(){return this.player.hasProgress}get width(){return this.shadowRoot.querySelector(".mmp-progress").offsetWidth}get offset(){return this.getBoundingClientRect().left}get classes(){return Rb({transiting:!this.seekProgress,seeking:this.seekProgress})}render(){return yb(ba(),this.initSeek,this.handleSeek,this.initSeek,this.handleSeek,this.resetSeek,a=>a.stopPropagation(),!this.player.isPlaying,this.showTime?yb(aa(),qc(this.seekProgress||this.progress),qc(this.duration)):"",this.classes,this.seekProgress||this.progress,this.duration)}trackProgress(){this.progress=this.player.progress,this.tracker||(this.tracker=setInterval(()=>this.trackProgress(),1e3)),this.player.isPlaying||(clearInterval(this.tracker),this.tracker=null)}initSeek(a){var b=a.offsetX||a.touches[0].pageX-this.offset;this.seekWidth=this.width,this.seekProgress=this.calcProgress(b),this.addEventListener("touchmove",this.moveSeek),this.addEventListener("mousemove",this.moveSeek)}resetSeek(){this.seekProgress=null,this.removeEventListener("touchmove",this.moveSeek),this.removeEventListener("mousemove",this.moveSeek)}moveSeek(a){a.preventDefault();var b=a.offsetX||a.touches[0].pageX-this.offset;this.seekProgress=this.calcProgress(b)}handleSeek(a){this.resetSeek();var b=a.offsetX||a.changedTouches[0].pageX-this.offset,c=this.calcProgress(b);this.player.seek(a,c)}disconnectedCallback(){super.disconnectedCallback(),this.resetSeek(),clearInterval(this.tracker),this.tracker=null}connectedCallback(){super.connectedCallback(),this.hasProgress&&this.trackProgress()}calcProgress(a){var b=a/this.seekWidth*this.duration;return Ia(Ka(b,.1),this.duration)}static get styles(){return Mb(_())}}),customElements.define("mmp-source-menu",class extends Ob{static get properties(){return{player:{},icon:Boolean}}get source(){return this.player.source}get sources(){return this.player.sources.map(a=>({name:a,id:a,type:"source"}))}render(){return yb($(),this.handleSource,this.sources,this.source,this.source,this.icon)}handleSource(a){var{id:b}=a.detail;this.player.setSource(a,b)}static get styles(){return Mb(Z())}}),customElements.define("mmp-sound-menu",class extends Ob{static get properties(){return{player:{},selected:String,icon:Boolean}}get mode(){return this.player.soundMode}get modes(){return this.player.soundModes.map(a=>({name:a,id:a,type:"soundMode"}))}render(){return yb(Y(),this.handleChange,this.modes,this.mode,this.selected||this.mode,this.icon)}handleChange(a){var{id:b}=a.detail;this.player.setSoundMode(a,b),this.selected=b}static get styles(){return Mb(X())}}),customElements.define("mmp-media-controls",class extends Ob{static get properties(){return{player:{},config:{},break:Boolean}}get showShuffle(){return!this.config.hide.shuffle&&this.player.supportsShuffle}get maxVol(){return this.config.max_volume||100}get minVol(){return this.config.min_volume||0}get vol(){return Ha(100*this.player.vol)}render(){var{hide:a}=this.config;return yb(W(),a.volume?yb(V()):this.renderVolControls(this.player.muted),this.showShuffle?yb(U(),a=>this.player.toggleShuffle(a),"mdi:shuffle",this.player.shuffle):yb(T()),a.controls?yb(S()):yb(R(),this.config.flow||this.break,a.prev?"":yb(Q(),a=>this.player.prev(a),"mdi:skip-previous"),this.renderPlayButtons(),a.next?"":yb(P(),a=>this.player.next(a),Yb)))}renderVolControls(a){var b=this.config.volume_stateless?this.renderVolButtons(a):this.renderVolSlider(a),c=Rb({"--buttons":this.config.volume_stateless,"mmp-media-controls__volume":!0,flex:!0}),d=!this.config.hide.volume_level;return yb(O(),c,b,d?this.renderVolLevel():"")}renderVolSlider(a){return yb(N(),this.renderMuteButton(a),this.handleVolumeChange,a=>a.stopPropagation(),a,this.minVol,this.maxVol,100*this.player.vol,this.config.volume_step||1,"ltr")}renderVolButtons(a){return yb(M(),this.renderMuteButton(a),a=>this.player.volumeDown(a),"mdi:volume-minus",a=>this.player.volumeUp(a),"mdi:volume-plus")}renderVolLevel(){return yb(L(),this.vol)}renderMuteButton(a){if(!this.config.hide.mute)switch(this.config.replace_mute){case"play":case"play_pause":return yb(K(),a=>this.player.playPause(a),Zb[this.player.isPlaying]);case"stop":return yb(J(),a=>this.player.stop(a),$b.true);case"play_stop":return yb(I(),a=>this.player.playStop(a),$b[this.player.isPlaying]);case"next":return yb(H(),a=>this.player.next(a),Yb);default:return this.player.supportsMute?yb(G(),a=>this.player.toggleMute(a),Xb[a]):void 0;}}renderPlayButtons(){var{hide:a}=this.config;return yb(F(),a.play_pause?yb(E()):yb(C(),a=>this.player.playPause(a),Zb[this.player.isPlaying]),a.play_stop?yb(B()):yb(A(),a=>this.handleStop(a),a.play_pause?$b[this.player.isPlaying]:$b.true))}handleStop(a){return this.config.hide.play_pause?this.player.playStop(a):this.player.stop(a)}handleVolumeChange(a){var b=parseFloat(a.target.value)/100;this.player.setVolume(a,b)}static get styles(){return[ic,Mb(z())]}}),customElements.define("mmp-powerstrip",class extends Ob{static get properties(){return{hass:{},player:{},config:{},groupVisible:Boolean,idle:Boolean}}get icon(){return this.config.speaker_group.icon||"mdi:speaker-multiple"}get showGroupButton(){return this.config.speaker_group.entities}get showPowerButton(){return!this.config.hide.power}get powerColor(){return this.player.active&&!this.config.hide.power_state}get sourceSize(){return"icon"===this.config.source||this.hasControls||this.idle}get soundSize(){return"icon"===this.config.sound_mode||this.hasControls||this.idle}get hasControls(){return this.player.active&&this.config.hide.controls!==this.config.hide.volume}get hasSource(){return 0 this.player.toggle(a),this.powerColor):"")}handleGroupClick(a){a.stopPropagation(),this.dispatchEvent(new CustomEvent("toggleGroupList"))}get renderIdleView(){return this.player.isPaused?yb(r(),Zb[this.player.isPlaying],a=>this.player.playPause(a)):yb(q(),pc(this.hass,"state.idle","state.media_player.idle"))}static get styles(){return[ic,Mb(p())]}}),customElements.define("mini-media-player",class extends Ob{constructor(){super(),this._overflow=!1,this.initial=!0,this.picture=!1,this.thumbnail="",this.prevThumbnail="",this.edit=!1,this.rtl=!1,this.cardHeight=0,this.foregroundColor="",this.backgroundColor=""}static get properties(){return{_hass:{},config:{},entity:{},player:{},_overflow:Boolean,break:Boolean,initial:Boolean,picture:String,thumbnail:String,prevThumbnail:String,edit:Boolean,rtl:Boolean,idle:Boolean,cardHeight:Number,foregroundColor:String,backgroundColor:String}}static get styles(){return[ic,hc]}set hass(a){if(a){var b=a.states[this.config.entity];this._hass=a,b&&this.entity!==b&&(this.entity=b,this.player=new gc(a,this.config,b),this.rtl=this.computeRTL(a),this.idle=this.player.idle,this.player.trackIdle&&this.updateIdleStatus())}}get hass(){return this._hass}set overflow(a){this._overflow!==a&&(this._overflow=a)}get overflow(){return this._overflow}get name(){return this.config.name||this.player.name}setConfig(a){this.config=ec(a)}shouldUpdate(a){return void 0===this.break&&this.computeRect(this),a.has("prevThumbnail")&&this.prevThumbnail&&setTimeout(()=>{this.prevThumbnail=""},1e3),a.has("player")&&"material"===this.config.artwork&&this.setColors(),_b.some(b=>a.has(b))&&this.player}firstUpdated(){new Ub.a(a=>{a.forEach(a=>{window.requestAnimationFrame(()=>{"scroll"===this.config.info&&this.computeOverflow(),this._resizeTimer||(this.computeRect(a),this._resizeTimer=setTimeout(()=>{this._resizeTimer=null,this.computeRect(this._resizeEntry),this.measureCard()},250)),this._resizeEntry=a})})}).observe(this),setTimeout(()=>this.initial=!1,250),this.edit=this.config.speaker_group.expanded||!1}updated(){"scroll"===this.config.info&&setTimeout(()=>{this.computeOverflow()},10)}render(){var{config:a}=0 this.handlePopup(a),a.artwork,this.player.content,this.renderBackground(),this.renderArtwork(),this.renderGradient(),this.player.idle,this.renderIcon(),this.renderEntityName(),this.renderMediaInfo(),this.toggleGroupList,this.hass,this.player,a,this.edit,this.idle,a.flow,!a.collapse&&this.player.active?yb(n(),this.player,a,this.break):"",this.player,a.shortcuts,a.tts?yb(m(),a.tts,this.hass,this.player):"",this.hass,this.edit,a.speaker_group.entities,this.player,this.player.active&&this.player.hasProgress?yb(l(),this.player,!this.config.hide.runtime):"")}computeClasses(){var{config:a}=0 {var f;switch(d.action){case"more-info":f=new Event("hass-more-info",{composed:!0}),f.detail={entityId:d.entity||e},a.dispatchEvent(f);break;case"navigate":if(!d.navigation_path)return;window.history.pushState(null,"",d.navigation_path),f=new Event("location-changed",{composed:!0}),f.detail={replace:!1},window.dispatchEvent(f);break;case"call-service":{if(!d.service)return;var[h,i]=d.service.split(".",2),g=Ja({},d.service_data);b.callService(h,i,g);break}case"url":if(!d.url)return;d.new_tab?window.open(d.url,"_blank"):window.location.href=d.url;}})(this,this._hass,this.config,this.config.tap_action,this.player.id)}renderIcon(){if(!this.config.hide.icon){if(this.player.active&&this.thumbnail&&"default"===this.config.artwork)return yb(g(),this.thumbnail,!this.config.hide.artwork_border,this.player.state);var a=!this.config.hide.icon_state&&this.player.isActive;return yb(f(),a,this.computeIcon())}}renderEntityName(){if(!this.config.hide.name)return yb(e(),this.name,this.speakerCount())}renderMediaInfo(){if(!this.config.hide.info){var e=this.player.mediaInfo;return yb(d(),"short"===this.config.info||!this.player.active,"scroll"===this.config.info,this.overflow,this.overflow,"scroll"===this.config.info?yb(c(),e.map(a=>yb(b(),"attr__"+a.attr,a.prefix+a.text))):"",e.map(b=>yb(a(),"attr__"+b.attr,b.prefix+b.text)))}}speakerCount(){if(this.config.speaker_group.show_group_count){var a=this.player.groupCount;return 1a.parentNode.clientWidth;this.overflow=b&&this.player.active&&7.5+a.clientWidth/50}}computeRect(a){var{left:b,width:c}=a.contentRect||a.getBoundingClientRect();this.break=390>c+2*b}computeRTL(a){var b=a.language||"en";return a.translationMetadata.translations[b]&&a.translationMetadata.translations[b].isRTL||!1}toggleGroupList(){this.edit=!this.edit}updateIdleStatus(){this._idleTracker&&clearTimeout(this._idleTracker);var a=(Date.now()-new Date(this.player.updatedAt).getTime())/1e3;this._idleTracker=setTimeout(()=>{this.idle=this.player.checkIdleAfter(this.config.idle_view.after),this.player.idle=this.idle,this._idleTracker=null},1e3*(60*this.config.idle_view.after-a))}getCardSize(){return this.config.collapse?1:2}setColors(){var a=this;return Ma(function*(){if(a.player.picture!==a.picture){if(!a.player.picture)return a.foregroundColor="",void(a.backgroundColor="");try{[a.foregroundColor,a.backgroundColor]=yield(b=a.player.picture,new jc(b,{colorCount:16,generator:mc}).getPalette())}catch(b){console.error("Error getting Image Colors",b),a.foregroundColor="",a.backgroundColor=""}var b}})()}})}])})})();