dropdown menu */
.actions-dropdown-menu > ha-dropdown > ha-assist-chip {
/*--ha-assist-chip-container-color: var(--card-background-color);*/ /* transparent is default. */
--ha-assist-chip-container-shape: 10px; /* 0px=square corner, 10px=rounded corner */
--md-assist-chip-trailing-space: 0px; /* no label, so no trailing space */
--md-assist-chip-container-height: 1.5rem; /* height of the dropdown menu container */
}
/* style ha-icon-button controls in header actions: icon size, title text */
ha-icon-button[slot="icon-button"] {
--ha-button-height: 30px;
--ha-icon-button-size: 30px;
--ha-icon-size: 24px;
vertical-align: middle;
padding: 0px 2px 0px 2px;
}
ha-icon-button[slot="icon-button-selected"] {
--ha-button-height: 30px;
--ha-icon-button-size: 30px;
--ha-icon-size: 24px;
vertical-align: middle;
padding: 0px 2px 0px 2px;
color: red;
}
/* style ha-icon-button controls in header actions: icon size, title text */
ha-icon-button[slot="icon-button-small"] {
--ha-button-height: 20px;
--ha-icon-button-size: 20px;
--ha-icon-size: 20px;
vertical-align: middle;
padding: 0px 2px 0px 2px;
}
ha-icon-button[slot="icon-button-small-selected"] {
--ha-button-height: 20px;
--ha-icon-button-size: 20px;
--ha-icon-size: 20px;
vertical-align: middle;
padding: 0px 2px 0px 2px;
color: red;
}
/* style ha-alert controls */
ha-alert {
display: block;
margin-bottom: 0.25rem;
}
.icon-button {
width: 100%;
}
*[hide="true"] {
display: none !important;
}
*[hide="false"] {
display: flex !important;
}
*[hide] {
display: none;
}
.flex-1 {
flex: 1;
}
.flex-items {
display: block;
flex-grow: 0;
flex-shrink: 1;
flex-basis: auto;
align-self: auto;
order: 0;
}
.display-inline {
display: inline;
padding-left: 6px;
}
`,ri=ne+"-card-progress-ended";const oi=ne+"-card-progress-started";class ai extends re{constructor(){super(),this.isUpdateInProgress=!1,this.isCardInEditPreview=!1}connectedCallback(){super.connectedCallback(),this.store&&this.store.card&&(this.isCardInEditPreview=ut(this.store.card))}alertClear(){this.alertError=void 0,this.alertInfo=void 0}alertErrorClear(){this.alertError=void 0}alertErrorSet(e){this.alertError=e,this.alertInfo=void 0}alertInfoClear(){this.alertInfo=void 0}alertInfoSet(e){this.alertInfo=e,this.alertError=void 0}progressHide(){this.isUpdateInProgress=!1,this.store&&this.store.card&&this.store.card.dispatchEvent(new CustomEvent(ri,{bubbles:!0,composed:!0,detail:{}}))}progressShow(){this.store&&this.store.card&&this.store.card.dispatchEvent(new CustomEvent(oi,{bubbles:!0,composed:!0,detail:{}}))}}Ie([Ve({attribute:!1})],ai.prototype,"store",void 0),Ie([De()],ai.prototype,"alertError",void 0),Ie([De()],ai.prototype,"alertInfo",void 0);const ni=Fe(ce+":fav-actions-base");class li extends ai{constructor(e){super(),this.section=e}render(){this.player=this.store.player,this.spotifyPlusService=this.store.spotifyPlusService}firstUpdated(e){super.firstUpdated(e),this.updateActions(this.player,[])}hideSearchType(e){return!!(this.store.config.searchMediaBrowserSearchTypes&&this.store.config.searchMediaBrowserSearchTypes.length>0)&&!this.store.config.searchMediaBrowserSearchTypes?.includes(e)}onClickMediaItem(e){this.PlayMediaItem(e)}async AddPlayerQueueItem(e){try{this.progressShow(),await this.spotifyPlusService.AddPlayerQueueItems(this.player,e.uri)}catch(e){this.alertErrorSet("Could not add media item to play queue. "+yt(e))}finally{this.progressHide()}}async PlayMediaItem(e){try{this.progressShow(),await this.spotifyPlusService.Card_PlayMediaBrowserItem(this.player,e),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not play media item. "+yt(e))}finally{this.progressHide()}}async onClickAction(e){throw new Error('onClickAction not implemented for action "'+e+'".')}updateActions(e,t){return ni.enabled&&ni("updateActions - updating actions: %s",JSON.stringify(Array.from(t.values()))),this.isUpdateInProgress?(this.alertErrorSet("Previous refresh is still in progress - please wait"),!1):(this.isUpdateInProgress=!0,this.isCardInEditPreview?(this.isUpdateInProgress=!1,!1):e||this.section==et.DEVICES?this.mediaItem.uri||this.section==et.DEVICES?(this.alertClear(),!0):(this.isUpdateInProgress=!1,this.alertErrorSet("MediaItem not set in updateActions"),!1):(this.isUpdateInProgress=!1,this.alertErrorSet("Player reference not set in updateActions"),!1))}}Ie([Ve({attribute:!1})],li.prototype,"mediaItem",void 0);const ci=ne+"-card-search-media";class di{constructor(e,t=null,i=null,s=null,r=null,o=null){this.searchType=e||Et.PLAYLISTS,this.searchCriteria=t||"",this.title=i||"",this.uri=s||"",this.subtype=r||"",this.parentMediaItem=o}}function hi(e,t,i=null,s=null,r=null,o=null){const a=new di(e);return a.searchCriteria=(t||"").trim(),a.title=i||"",a.uri=s||"",a.subtype=r||"",a.parentMediaItem=o,a.subtype||(e==Et.AUDIOBOOK_EPISODES?a.subtype="audiobook":e==Et.SHOW_EPISODES&&(a.subtype="podcast")),new CustomEvent(ci,{bubbles:!0,composed:!0,detail:a})}const pi="turn_on",ui="turn_off",mi="volume_down",vi="volume_up",fi="volume_mute",gi="volume_set",Ai="select_source";class yi{constructor(e){this.hassService=e}async clear_playlist(e){const t={domain:le,service:"clear_playlist",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async join(e,t){const i={domain:le,service:"join",serviceData:{entity_id:e,group_members:t}};await this.hassService.CallService(i)}async media_next_track(e){const t={domain:le,service:"media_next_track",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async media_pause(e){const t={domain:le,service:"media_pause",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async media_play(e){const t={domain:le,service:"media_play",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async media_play_pause(e){const t={domain:le,service:"media_play_pause",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async media_previous_track(e){if(!e.isUserProductPremium())throw new Error(Se);const t={domain:le,service:"media_previous_track",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async media_seek(e,t){if(!e.isUserProductPremium())throw new Error(Se);const i={domain:le,service:"media_seek",serviceData:{entity_id:e.id,seek_position:t}};await this.hassService.CallService(i)}async media_stop(e){const t={domain:le,service:"media_stop",serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async play_media(e,t){const i={domain:le,service:"play_media",serviceData:{entity_id:e.id,media_content_id:t.media_content_id,media_content_type:t.media_content_type}};await this.hassService.CallService(i)}async repeat_set(e,t){const i={domain:le,service:"repeat_set",serviceData:{entity_id:e.id,repeat:t}};await this.hassService.CallService(i)}async select_sound_mode(e,t){const i={domain:le,service:"select_sound_mode",serviceData:{entity_id:e.id,sound_mode:t}};await this.hassService.CallService(i)}async select_source(e,t){if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const i={domain:le,service:Ai,serviceData:{entity_id:e.id,source:t}};await this.hassService.CallService(i)}async shuffle_set(e,t){if(!e.isUserProductPremium())throw new Error(Se);const i={domain:le,service:"shuffle_set",serviceData:{entity_id:e.id,shuffle:t}};await this.hassService.CallService(i)}async turn_off(e){const t={domain:le,service:ui,serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async turn_on(e){const t={domain:le,service:pi,serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async unJoin(e){const t={domain:le,service:"unjoin",serviceData:{entity_id:e}};await this.hassService.CallService(t)}async volume_mute(e,t){const i={domain:le,service:fi,serviceData:{entity_id:e.id,is_volume_muted:t}};await this.hassService.CallService(i)}async volume_mute_toggle(e){const t=!e.isMuted();await this.volume_mute(e,t)}async volume_set(e,t){const i=t/100,s={domain:le,service:gi,serviceData:{entity_id:e.id,volume_level:i}};await this.hassService.CallService(s)}async volume_down(e){const t={domain:le,service:mi,serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}async volume_up(e){const t={domain:le,service:vi,serviceData:{entity_id:e.id}};await this.hassService.CallService(t)}}var bi,wi,Ci;!function(e){e.ALL="all",e.OFF="off",e.ONE="one"}(bi||(bi={})),function(e){e[e.PAUSE=1]="PAUSE",e[e.SEEK=2]="SEEK",e[e.VOLUME_SET=4]="VOLUME_SET",e[e.VOLUME_MUTE=8]="VOLUME_MUTE",e[e.PREVIOUS_TRACK=16]="PREVIOUS_TRACK",e[e.NEXT_TRACK=32]="NEXT_TRACK",e[e.TURN_ON=128]="TURN_ON",e[e.TURN_OFF=256]="TURN_OFF",e[e.PLAY_MEDIA=512]="PLAY_MEDIA",e[e.VOLUME_STEP=1024]="VOLUME_STEP",e[e.SELECT_SOURCE=2048]="SELECT_SOURCE",e[e.STOP=4096]="STOP",e[e.CLEAR_PLAYLIST=8192]="CLEAR_PLAYLIST",e[e.PLAY=16384]="PLAY",e[e.SHUFFLE_SET=32768]="SHUFFLE_SET",e[e.SELECT_SOUND_MODE=65536]="SELECT_SOUND_MODE",e[e.BROWSE_MEDIA=131072]="BROWSE_MEDIA",e[e.REPEAT_SET=262144]="REPEAT_SET",e[e.GROUPING=524288]="GROUPING",e[e.MEDIA_ANNOUNCE=1048576]="MEDIA_ANNOUNCE",e[e.MEDIA_ENQUEUE=2097152]="MEDIA_ENQUEUE"}(wi||(wi={})),function(e){e.OFF="off",e.ON="on",e.IDLE="idle",e.PLAYING="playing",e.PAUSED="paused",e.STANDBY="standby",e.BUFFERING="buffering",e.UNKNOWN="unknown"}(Ci||(Ci={}));const Si=Fe(ce+":spotifyplus-service");class Ii{constructor(e,t,i){this.hass=e,this.card=t,this.config=i}getDeviceId(e,t=null){return null==t&&(t=e.attributes.sp_device_is_brand_sonos?e.attributes.source||null:this.config.deviceControlByName?e.attributes.source||e.attributes.sp_device_id||null:e.attributes.sp_device_id||e.attributes.source||null),this.config.deviceDefaultId&&(t=this.config.deviceDefaultId,Si("getDeviceId - overriding device_id with config option deviceDefaultId: \n%s",JSON.stringify(this.config.deviceDefaultId))),t}async CallService(e){try{Si.enabled&&Si("%cCallService - Calling service %s (no response)\n%s","color: orange",JSON.stringify(e.service),JSON.stringify(e,null,2)),await this.hass.callService(e.domain,e.service,e.serviceData,e.target)}finally{}}async CallServiceWithResponse(e){try{Si.enabled&&Si("%cCallServiceWithResponse - Calling service %s (with response)\n%s","color: orange",JSON.stringify(e.service),JSON.stringify(e,null,2));return(await this.hass.callService(e.domain,e.service,e.serviceData,e.target,void 0,!0)).response||{}}finally{}}async AddPlayerQueueItems(e,t=null,i=null,s=!0,r=null){try{if(!e.isUserProductPremium())throw new Error(Se);i=this.getDeviceId(e,i);const o={entity_id:e.id,uris:t};null!=i&&(o.device_id=i),null!=s&&(o.verify_device_id=s),null!=r&&(o.delay=r);const a={domain:ne,service:"add_player_queue_items",serviceData:o};await this.CallService(a)}finally{}}async CheckAlbumFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_album_favorites",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async CheckArtistsFollowing(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_artists_following",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async CheckAudiobookFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_audiobook_favorites",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async CheckEpisodeFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_episode_favorites",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async CheckPlaylistFollowers(e,t,i=null){try{const s={entity_id:e.id,playlist_id:t};null!=i&&(s.user_ids=i);const r={domain:ne,service:"check_playlist_followers",serviceData:s};return(await this.CallServiceWithResponse(r)).result}finally{}}async CheckShowFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_show_favorites",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async CheckTrackFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"check_track_favorites",serviceData:i};return(await this.CallServiceWithResponse(s)).result}finally{}}async FollowArtists(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"follow_artists",serviceData:i};await this.CallService(s)}finally{}}async FollowPlaylist(e,t=null,i=!0){try{const s={entity_id:e.id};null!=t&&(s.playlist_id=t),null!=i&&(s.public=i);const r={domain:ne,service:"follow_playlist",serviceData:s};await this.CallService(r)}finally{}}async GetAlbum(e,t=null,i=null,s=!0){try{const r={entity_id:e.id};null!=t&&(r.album_id=t),null!=i&&(r.market=i);const o={domain:ne,service:"get_album",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;return s&&null!=a&&null!=a.tracks&&(a.available_markets=[],a.images=[],a.tracks.items.forEach((e=>{e.available_markets=[]}))),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetAlbumFavorites(e,t=null,i=null,s=null,r=null,o=null,a=!0){try{null==s&&(s=e.attributes.sp_user_country);const n={entity_id:e.id};null!=t&&(n.limit=t),null!=i&&(n.offset=i),null!=s&&(n.market=s),null!=r&&(n.limit_total=r),null!=o&&(n.sort_result=o);const l={domain:ne,service:"get_album_favorites",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;return a&&null!=c&&null!=c.items&&c.items.forEach((e=>{e.album.images=[],e.album.available_markets=[],e.album.tracks&&(e.album.tracks=JSON.parse("{ }"))})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetAlbumTracks(e,t=null,i=null,s=null,r=null,o=null,a=!0){try{const n={entity_id:e.id};null!=t&&(n.album_id=t),null!=i&&(n.limit=i),null!=s&&(n.offset=s),null!=r&&(n.market=r),null!=o&&(n.limit_total=o);const l={domain:ne,service:"get_album_tracks",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;return a&&null!=c&&null!=c.items&&c.items.forEach((e=>{e.available_markets=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetArtistAlbums(e,t=null,i=null,s=null,r=null,o=null,a=null,n=null,l=!0){try{const c={entity_id:e.id};null!=t&&(c.artist_id=t),null!=i&&(c.include_groups=i),null!=s&&(c.limit=s),null!=r&&(c.offset=r),null!=o&&(c.market=o),null!=a&&(c.limit_total=a),null!=n&&(c.sort_result=n);const d={domain:ne,service:"get_artist_albums",serviceData:c},h=(await this.CallServiceWithResponse(d)).result;return l&&null!=h&&null!=h.items&&h.items.forEach((e=>{e.images=[],e.available_markets=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(d.service),JSON.stringify(h,null,2)),h}finally{}}async GetArtistInfo(e,t=null,i=!0){try{const i={entity_id:e.id};null!=t&&(i.artist_id=t);const s={domain:ne,service:"get_artist_info",serviceData:i},r=(await this.CallServiceWithResponse(s)).result;return Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(s.service),JSON.stringify(r,null,2)),r}finally{}}async GetArtistRelatedArtists(e,t=null,i=null,s=!0){try{const r={entity_id:e.id};null!=t&&(r.artist_id=t),null!=i&&(r.sort_result=i);const o={domain:ne,service:"get_artist_related_artists",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;return s&&null!=a&&a.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetArtistTopTracks(e,t=null,i=null,s=null,r=!0){try{const o={entity_id:e.id};null!=t&&(o.artist_id=t),null!=i&&(o.market=i),null!=s&&(o.sort_result=s);const a={domain:ne,service:"get_artist_top_tracks",serviceData:o},n=(await this.CallServiceWithResponse(a)).result;return r&&null!=n&&n.forEach((e=>{e.available_markets=[],e.album.available_markets=[],e.album.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(a.service),JSON.stringify(n,null,2)),n}finally{}}async GetArtistsFollowed(e,t=null,i=null,s=null,r=null,o=!0){try{const a={entity_id:e.id};null!=t&&(a.after=t),null!=i&&(a.limit=i),null!=s&&(a.limit_total=s),null!=r&&(a.sort_result=r);const n={domain:ne,service:"get_artists_followed",serviceData:a},l=(await this.CallServiceWithResponse(n)).result;return o&&null!=l&&null!=l.items&&l.items.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(n.service),JSON.stringify(l,null,2)),l}finally{}}async GetAudiobook(e,t=null,i=null,s=!0){try{const r={entity_id:e.id};null!=t&&(r.audiobook_id=t),null!=i&&(r.market=i);const o={domain:ne,service:"get_audiobook",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;return s&&null!=a&&(a.available_markets=[],a.images=[],a.chapters?.forEach((e=>{e.items?.forEach((e=>{e.available_markets=[],e.description="see html_description",e.images=[]}))}))),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetAudiobookChapters(e,t=null,i=null,s=null,r=null,o=null,a=!0){try{const n={entity_id:e.id};null!=t&&(n.audiobook_id=t),null!=i&&(n.limit=i),null!=s&&(n.offset=s),null!=r&&(n.market=r),null!=o&&(n.limit_total=o);const l={domain:ne,service:"get_audiobook_chapters",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;return a&&null!=c&&null!=c.items&&c.items.forEach((e=>{e.available_markets=[],e.description="see html_description",e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetAudiobookFavorites(e,t=null,i=null,s=null,r=null,o=!0){try{const a={entity_id:e.id};null!=t&&(a.limit=t),null!=i&&(a.offset=i),null!=s&&(a.limit_total=s),null!=r&&(a.sort_result=r);const n={domain:ne,service:"get_audiobook_favorites",serviceData:a},l=(await this.CallServiceWithResponse(n)).result;return o&&null!=l&&null!=l.items&&l.items.forEach((e=>{e.available_markets=[],e.description="see html_description",e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(n.service),JSON.stringify(l,null,2)),l}finally{}}async GetBrowseCategorysList(e,t=null,i=null,s=null,r=!0){try{const o={entity_id:e.id};null!=t&&(o.country=t),null!=i&&(o.locale=i),null!=s&&(o.refresh=s);const a={domain:ne,service:"get_browse_categorys_list",serviceData:o},n=(await this.CallServiceWithResponse(a)).result;return r&&null!=n&&null!=n.items&&n.items.forEach((e=>{e.icons=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(a.service),JSON.stringify(n,null,2)),n}finally{}}async GetCategoryPlaylists(e,t=null,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,category_id:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.country=r),null!=o&&(l.limit_total=o),null!=a&&(l.sort_result=a);const c={domain:ne,service:"get_category_playlists",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async GetChapter(e,t=null,i=null,s=!0){try{const r={entity_id:e.id};null!=t&&(r.chapter_id=t),null!=i&&(r.market=i);const o={domain:ne,service:"get_chapter",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;return s&&null!=a&&(a.available_markets=[],a.description="see html_description",a.images=[],a.audiobook&&(a.audiobook.available_markets=[],a.audiobook.images=[],a.audiobook.description="see html_description")),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetEpisode(e,t=null,i=null,s=!0){try{const r={entity_id:e.id};null!=t&&(r.episode_id=t),null!=i&&(r.market=i);const o={domain:ne,service:"get_episode",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;return s&&null!=a&&(a.description="see html_description",a.images=[],a.show&&(a.show.available_markets=[],a.show.images=[],a.show.description="see html_description")),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetEpisodeFavorites(e,t=null,i=null,s=null,r=null,o=!0){try{const a={entity_id:e.id};null!=t&&(a.limit=t),null!=i&&(a.offset=i),null!=s&&(a.limit_total=s),null!=r&&(a.sort_result=r);const n={domain:ne,service:"get_episode_favorites",serviceData:a},l=(await this.CallServiceWithResponse(n)).result;return o&&null!=l&&null!=l.items&&l.items.forEach((e=>{e.episode.description="see html_description",e.episode.images=[],e.episode.show.available_markets=[],e.episode.show.description="see html_description",e.episode.show.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(n.service),JSON.stringify(l,null,2)),l}finally{}}async GetPlayerQueueInfo(e,t=!0){try{if(!e.isUserProductPremium())throw new Error(Se);const i={entity_id:e.id},s={domain:ne,service:"get_player_queue_info",serviceData:i},r=(await this.CallServiceWithResponse(s)).result;if(t&&null!=r&&null!=r.queue){if(null!=r.currently_playing)if("track"==r.currently_playing_type){const e=r.currently_playing;e.available_markets=[],e.album&&(e.album.available_markets=[],e.album.images=[])}else if("episode"==r.currently_playing_type){const e=r.currently_playing;e.description="see html_description",e.show&&(e.show.available_markets=[],e.show.description="see html_description",e.show.images=[])}r.queue.forEach((e=>{if("track"==e.type){const t=e;t.available_markets=[],t.album&&(t.album.available_markets=[],t.album.images=[])}else if("episode"==e.type){const t=e;t.description="see html_description",t.show&&(t.show.available_markets=[],t.show.description="see html_description",t.show.images=[])}}))}return Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(s.service),JSON.stringify(r,null,2)),r}finally{}}async GetPlayerRecentTracks(e,t=null,i=null,s=null,r=null,o=!0){try{const a={entity_id:e.id};null!=t&&(a.limit=t),null!=i&&(a.after=i),null!=s&&(a.before=s),null!=r&&(a.limit_total=r);const n={domain:ne,service:"get_player_recent_tracks",serviceData:a},l=(await this.CallServiceWithResponse(n)).result;return o&&null!=l&&null!=l.items&&l.items.forEach((e=>{e.track.available_markets=[],e.track.album.images=[],e.track.album.available_markets=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(n.service),JSON.stringify(l,null,2)),l}finally{}}async GetPlaylistFavorites(e,t=null,i=null,s=null,r=null,o=!0){try{const a={entity_id:e.id};null!=t&&(a.limit=t),null!=i&&(a.offset=i),null!=s&&(a.limit_total=s),null!=r&&(a.sort_result=r);const n={domain:ne,service:"get_playlist_favorites",serviceData:a},l=(await this.CallServiceWithResponse(n)).result;return o&&null!=l&&null!=l.items&&l.items.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(n.service),JSON.stringify(l,null,2)),l}finally{}}async GetPlaylistItems(e,t=null,i=null,s=null,r=null,o=null,a=null,n=null,l=!0){try{const c={entity_id:e.id};null!=t&&(c.playlist_id=t),null!=i&&(c.limit=i),null!=s&&(c.offset=s),null!=r&&(c.market=r),null!=o&&(c.fields=o),null!=a&&(c.additional_types=a),null!=n&&(c.limit_total=n);const d={domain:ne,service:"get_playlist_items",serviceData:c},h=(await this.CallServiceWithResponse(d)).result;return l&&null!=h&&null!=h.items&&h.items.forEach((e=>{e.track&&(e.track.available_markets&&(e.track.available_markets=[]),e.track.album&&(e.track.album.images=[],e.track.album.available_markets&&(e.track.album.available_markets=[])))})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(d.service),JSON.stringify(h,null,2)),h}finally{}}async GetSpotifyConnectDevice(e,t,i=null,s=null,r=null,o=null,a=null){try{const n={entity_id:e.id,device_value:t};null!=i&&(n.verify_user_context=i),null!=s&&(n.verify_timeout=s),null!=r&&(n.refresh_device_list=r),null!=o&&(n.activate_device=o),null!=a&&(n.delay=a);const l={domain:ne,service:"get_spotify_connect_device",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;if(null!=c){const e=(c.Name||"").toLocaleLowerCase();"group"==(c.DeviceInfo.GroupStatus||"").toLocaleLowerCase()?c.image_url=St(Qt):e.includes("web player (chrome)")?c.image_url=St(Vt):e.includes("web player (microsoft edge)")?c.image_url=St(Gt):e.includes("web player")?c.image_url=St(ei):1==c.IsChromeCast?c.image_url=St(Bt):c.image_url=St(Xt)}return Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetSpotifyConnectDevices(e,t=null,i=null,s=null){try{Si.enabled&&Si("%cGetSpotifyConnectDevices - retrieving device list from %s","color: orange;",t?"real-time query":"internal device cache");const r={entity_id:e.id};null!=t&&(r.refresh=t),null!=i&&(r.sort_result=i);const o={domain:ne,service:"get_spotify_connect_devices",serviceData:r},a=(await this.CallServiceWithResponse(o)).result;if(null!=a&&null!=a.Items){for(let e=a.Items.length-1;e>=0;e--){let t=a.Items[e].Name.toLowerCase();t=t.replaceAll("\n",""),t=t.replaceAll("\r",""),(s?.includes(t)||s?.includes(a.Items[e].Id.toLowerCase()))&&a.Items.splice(e,1)}a.Items.forEach((e=>{const t=(e.Name||"").toLocaleLowerCase();"group"==(e.DeviceInfo.GroupStatus||"").toLocaleLowerCase()?e.image_url=St(Qt):t.includes("web player (chrome)")?e.image_url=St(Vt):t.includes("web player (microsoft edge)")?e.image_url=St(Gt):t.includes("web player")?e.image_url=St(ei):1==e.IsChromeCast?e.image_url=St(Bt):e.image_url=St(Xt)}))}return Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(o.service),JSON.stringify(a,null,2)),a}finally{}}async GetShowEpisodes(e,t=null,i=null,s=null,r=null,o=null,a=!0){try{const n={entity_id:e.id};null!=t&&(n.show_id=t),null!=i&&(n.limit=i),null!=s&&(n.offset=s),null!=r&&(n.market=r),null!=o&&(n.limit_total=o);const l={domain:ne,service:"get_show_episodes",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;return a&&null!=c&&null!=c.items&&c.items.forEach((e=>{e.description="see html_description",e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetShowFavorites(e,t=null,i=null,s=null,r=null,o=!0,a=!0){try{const n={entity_id:e.id};null!=t&&(n.limit=t),null!=i&&(n.offset=i),null!=s&&(n.limit_total=s),null!=r&&(n.sort_result=r),null!=o&&(n.exclude_audiobooks=o);const l={domain:ne,service:"get_show_favorites",serviceData:n},c=(await this.CallServiceWithResponse(l)).result;return a&&null!=c&&null!=c.items&&c.items.forEach((e=>{e.show.available_markets=[],e.show.description="see html_description",e.show.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(l.service),JSON.stringify(c,null,2)),c}finally{}}async GetTrack(e,t=null,i=!0){try{const s={entity_id:e.id};null!=t&&(s.track_id=t);const r={domain:ne,service:"get_track",serviceData:s},o=(await this.CallServiceWithResponse(r)).result;return i&&null!=o&&(o.available_markets=[],o.album.available_markets=[],o.album.images=[]),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(r.service),JSON.stringify(o,null,2)),o}finally{}}async GetTrackFavorites(e,t=null,i=null,s=null,r=null,o=null,a=null,n=null,l=!0){try{const c={entity_id:e.id};null!=t&&(c.limit=t),null!=i&&(c.offset=i),null!=s&&(c.market=s),null!=r&&(c.limit_total=r),null!=o&&(c.sort_result=o),null!=a&&(c.filter_artist=a),null!=n&&(c.filter_album=n);const d={domain:ne,service:"get_track_favorites",serviceData:c},h=(await this.CallServiceWithResponse(d)).result;return l&&null!=h&&null!=h.items&&h.items.forEach((e=>{e.track.available_markets=[],e.track.album.available_markets=[],e.track.album.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(d.service),JSON.stringify(h,null,2)),h}finally{}}async GetTrackRecommendations(e,t=null,i=null,s=null,r=!0){try{const o={entity_id:e.id};null!=i&&(o.limit=i),null!=s&&(o.market=s),t&&(t.seed_artists&&(o.seed_artists=t.seed_artists),t.seed_genres&&(o.seed_genres=t.seed_genres),t.seed_tracks&&(o.seed_tracks=t.seed_tracks),t.max_acousticness&&(o.max_acousticness=t.max_acousticness),t.min_acousticness&&(o.min_acousticness=t.min_acousticness),t.target_acousticness&&(o.target_acousticness=t.target_acousticness),t.max_danceability&&(o.max_danceability=t.max_danceability),t.min_danceability&&(o.min_danceability=t.min_danceability),t.target_danceability&&(o.target_danceability=t.target_danceability),t.max_duration_ms&&(o.max_duration_ms=t.max_duration_ms),t.min_duration_ms&&(o.min_duration_ms=t.min_duration_ms),t.target_duration_ms&&(o.target_duration_ms=t.target_duration_ms),t.max_energy&&(o.max_energy=t.max_energy),t.min_energy&&(o.min_energy=t.min_energy),t.target_energy&&(o.target_energy=t.target_energy),t.max_instrumentalness&&(o.max_instrumentalness=t.max_instrumentalness),t.min_instrumentalness&&(o.min_instrumentalness=t.min_instrumentalness),t.target_instrumentalness&&(o.target_instrumentalness=t.target_instrumentalness),t.max_key&&(o.max_key=t.max_key),t.min_key&&(o.min_key=t.min_key),t.target_key&&(o.target_key=t.target_key),t.max_liveness&&(o.max_liveness=t.max_liveness),t.min_liveness&&(o.min_liveness=t.min_liveness),t.target_liveness&&(o.target_liveness=t.target_liveness),t.max_loudness&&(o.max_loudness=t.max_loudness),t.min_loudness&&(o.min_loudness=t.min_loudness),t.target_loudness&&(o.target_loudness=t.target_loudness),t.max_mode&&(o.max_mode=t.max_mode),t.min_mode&&(o.min_mode=t.min_mode),t.target_mode&&(o.target_mode=t.target_mode),t.max_popularity&&(o.max_popularity=t.max_popularity),t.min_popularity&&(o.min_popularity=t.min_popularity),t.target_popularity&&(o.target_popularity=t.target_popularity),t.max_speechiness&&(o.max_speechiness=t.max_speechiness),t.min_speechiness&&(o.min_speechiness=t.min_speechiness),t.target_speechiness&&(o.target_speechiness=t.target_speechiness),t.max_tempo&&(o.max_tempo=t.max_tempo),t.min_tempo&&(o.min_tempo=t.min_tempo),t.target_tempo&&(o.target_tempo=t.target_tempo),t.max_time_signature&&(o.max_time_signature=t.max_time_signature),t.min_time_signature&&(o.min_time_signature=t.min_time_signature),t.target_time_signature&&(o.target_time_signature=t.target_time_signature),t.max_valence&&(o.max_valence=t.max_valence),t.min_valence&&(o.min_valence=t.min_valence),t.target_valence&&(o.target_valence=t.target_valence));const a={domain:ne,service:"get_track_recommendations",serviceData:o},n=(await this.CallServiceWithResponse(a)).result;return r&&null!=n&&n.tracks.forEach((e=>{e.available_markets=[],e.album.available_markets=[],e.album.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(a.service),JSON.stringify(n,null,2)),n}finally{}}async PlayerMediaPlayContext(e,t,i=null,s=null,r=null,o=null,a=null,n=null){try{if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);if(!t)throw new Error("STPC0005 context_uri argument was not supplied to the PlayerMediaPlayContext service.");o=this.getDeviceId(e,o);const l={entity_id:e.id,context_uri:t};null!=i&&(l.offset_uri=i),null!=s&&(l.offset_position=s),null!=r&&(l.position_ms=r),null!=o&&(l.device_id=o),null!=a&&(l.delay=a),null!=n&&(l.shuffle=n);const c={domain:ne,service:"player_media_play_context",serviceData:l};await this.CallService(c)}finally{}}async PlayerMediaPlayTrackFavorites(e,t=null,i=null,s=null,r=null,o=null,a=null,n=null){try{if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);t=this.getDeviceId(e,t);const l={entity_id:e.id};null!=t&&(l.device_id=t),null!=i&&(l.shuffle=i),null!=s&&(l.delay=s),null!=r&&(l.resolve_device_id=r),null!=o&&(l.limit_total=o),null!=a&&(l.filter_artist=a),null!=n&&(l.filter_album=n);const c={domain:ne,service:"player_media_play_track_favorites",serviceData:l};await this.CallService(c)}finally{}}async PlayerMediaPlayTracks(e,t,i=null,s=null,r=null,o=null){try{if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);if(!t)throw new Error("STPC0005 uris argument was not supplied to the PlayerMediaPlayTracks service.");null==i&&(i=0),s=this.getDeviceId(e,s);const a={entity_id:e.id,uris:t};null!=i&&(a.position_ms=i),null!=s&&(a.device_id=s),null!=r&&(a.delay=r),null!=o&&(a.shuffle=o);const n={domain:ne,service:"player_media_play_tracks",serviceData:a};await this.CallService(n)}finally{}}async PlayerSetShuffleMode(e,t=null,i=null,s=null){try{if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);t=this.getDeviceId(e,t);const r={entity_id:e.id};null!=i&&(r.state=i),null!=t&&(r.device_id=t),null!=s&&(r.delay=s);const o={domain:ne,service:"player_set_shuffle_mode",serviceData:r};await this.CallService(o)}finally{}}async PlayerTransferPlayback(e,t=null,i=!0,s=null,r=!0,o=!0,a=null){try{if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);null==i&&(i=!0),t=this.getDeviceId(e,t);const n={entity_id:e.id};null!=t&&(n.device_id=t),null!=i&&(n.play=i),null!=s&&(n.delay=s),null!=r&&(n.refresh_device_list=r),null!=o&&(n.force_activate_device=o),null!=a&&(n.device_id_from=a);const l={domain:ne,service:"player_transfer_playback",serviceData:n};await this.CallService(l)}finally{}}async RemoveAlbumFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"remove_album_favorites",serviceData:i};await this.CallService(s)}finally{}}async RemoveAudiobookFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"remove_audiobook_favorites",serviceData:i};await this.CallService(s)}finally{}}async RemoveEpisodeFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"remove_episode_favorites",serviceData:i};await this.CallService(s)}finally{}}async RemoveShowFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"remove_show_favorites",serviceData:i};await this.CallService(s)}finally{}}async RemoveTrackFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"remove_track_favorites",serviceData:i};await this.CallService(s)}finally{}}async SaveAlbumFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"save_album_favorites",serviceData:i};await this.CallService(s)}finally{}}async SaveAudiobookFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"save_audiobook_favorites",serviceData:i};await this.CallService(s)}finally{}}async SaveEpisodeFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"save_episode_favorites",serviceData:i};await this.CallService(s)}finally{}}async SaveShowFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"save_show_favorites",serviceData:i};await this.CallService(s)}finally{}}async SaveTrackFavorites(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"save_track_favorites",serviceData:i};await this.CallService(s)}finally{}}async Search(e,t,i,s=null,r=null,o=null,a=null,n=null){try{if(e==Et.ALBUMS)return await this.SearchAlbums(t,i,s,r,o,a,n);if(e==Et.ARTISTS)return await this.SearchArtists(t,i,s,r,o,a,n);if(e==Et.AUDIOBOOKS)return await this.SearchAudiobooks(t,i,s,r,o,a,n);if(e==Et.EPISODES)return await this.SearchEpisodes(t,i,s,r,o,a,n);if(e==Et.PLAYLISTS)return await this.SearchPlaylists(t,i,s,r,o,a,n);if(e==Et.SHOWS)return await this.SearchShows(t,i,s,r,o,a,n);if(e==Et.TRACKS)return await this.SearchTracks(t,i,s,r,o,a,n);throw new Error('searchMediaType was not recognized: "'+e+'".')}finally{}}async SearchAlbums(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_albums",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[],e.available_markets=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchArtists(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_artists",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchAudiobooks(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_audiobooks",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[],e.available_markets=[],e.description="see html_description"})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchEpisodes(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_episodes",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[],e.description="see html_description"})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchPlaylists(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_playlists",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchShows(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_shows",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.images=[],e.available_markets=[],e.description="see html_description"})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async SearchTracks(e,t,i=null,s=null,r=null,o=null,a=null,n=!0){try{const l={entity_id:e.id,criteria:t};null!=i&&(l.limit=i),null!=s&&(l.offset=s),null!=r&&(l.market=r),null!=o&&(l.include_external=o),null!=a&&(l.limit_total=a);const c={domain:ne,service:"search_tracks",serviceData:l},d=(await this.CallServiceWithResponse(c)).result;return n&&null!=d&&null!=d.items&&d.items.forEach((e=>{e.album&&(e.album.images=[],e.album.available_markets=[]),e.available_markets=[]})),Si.enabled&&Si("%cCallServiceWithResponse - Service %s response (trimmed):\n%s","color: orange",JSON.stringify(c.service),JSON.stringify(d,null,2)),d}finally{}}async UnfollowArtists(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.ids=t);const s={domain:ne,service:"unfollow_artists",serviceData:i};await this.CallService(s)}finally{}}async UnfollowPlaylist(e,t=null){try{const i={entity_id:e.id};null!=t&&(i.playlist_id=t);const s={domain:ne,service:"unfollow_playlist",serviceData:i};await this.CallService(s)}finally{}}async VolumeSetStepLevel(e,t){const i=t/100,s={domain:ne,service:"volume_set_step",serviceData:{entity_id:e.id,level:i}};await this.CallService(s)}async ZeroconfDeviceConnect(e,t,i=null,s=null,r=null,o=!0,a=!0,n=null){try{Si.enabled&&Si("ZeroconfDeviceDisconnect - device item:\n%s",JSON.stringify(t,null,2));const l={entity_id:e.id,host_ipv4_address:t.DiscoveryResult.HostIpAddress,host_ip_port:t.DiscoveryResult.HostIpPort,cpath:t.DiscoveryResult.SpotifyConnectCPath,version:t.DiscoveryResult.SpotifyConnectVersion,use_ssl:t.DiscoveryResult.ZeroconfApiEndpointAddUser.startsWith("https:")};null!=i&&(l.username=i),null!=s&&(l.password=s),null!=r&&(l.loginid=r),null!=o&&(l.pre_disconnect=o),null!=a&&(l.verify_device_list_entry=a),null!=n&&(l.delay=n);const c={domain:ne,service:"zeroconf_device_connect",serviceData:l};return(await this.CallServiceWithResponse(c)).result}finally{}}async ZeroconfDeviceDisconnect(e,t,i=null){try{Si.enabled&&Si("ZeroconfDeviceDisconnect - device item:\n%s",JSON.stringify(t,null,2));const s={entity_id:e.id,host_ipv4_address:t.DiscoveryResult.HostIpAddress,host_ip_port:t.DiscoveryResult.HostIpPort,cpath:t.DiscoveryResult.SpotifyConnectCPath,version:t.DiscoveryResult.SpotifyConnectVersion,use_ssl:t.DiscoveryResult.ZeroconfApiEndpointAddUser.startsWith("https:")};null!=i&&(s.delay=i);const r={domain:ne,service:"zeroconf_device_disconnect",serviceData:s};return(await this.CallServiceWithResponse(r)).result}finally{}}async select_source(e,t=null){if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const i={entity_id:e.id};t&&(i.source=t);const s={domain:le,service:Ai,serviceData:i};await this.CallService(s)}async turn_off(e){const t={entity_id:e.id},i={domain:le,service:ui,serviceData:t};await this.CallService(i)}async turn_on(e){const t={entity_id:e.id},i={domain:le,service:pi,serviceData:t};await this.CallService(i),this.config.deviceDefaultId&&(e.isUserProductPremium()||e.attributes.sp_user_has_web_player_credentials)&&await this.PlayerTransferPlayback(e,this.config.deviceDefaultId,!0)}async volume_mute(e,t){if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const i={domain:le,service:fi,serviceData:{entity_id:e.id,is_volume_muted:t}};await this.CallService(i)}async volume_mute_toggle(e){const t=!e.isMuted();await this.volume_mute(e,t)}async volume_set(e,t){if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const i=t/100,s={domain:le,service:gi,serviceData:{entity_id:e.id,volume_level:i}};await this.CallService(s)}async volume_down(e){const t={domain:le,service:mi,serviceData:{entity_id:e.id}};await this.CallService(t)}async volume_up(e){const t={domain:le,service:vi,serviceData:{entity_id:e.id}};await this.CallService(t)}async Card_PlayMediaBrowserItem(e,t){if(!e.isUserProductPremium()&&!e.attributes.sp_user_has_web_player_credentials)throw new Error(Se);if(!e)throw new Error("Media player argument was not supplied to the PlayMediaBrowserItem service.");if(!t)throw new Error("Media browser item argument was not supplied to the PlayMediaBrowserItem service.");try{const i=function(e){let t=e;if(e){const i=e.indexOf(":");if(i>-1){const s=e.lastIndexOf(":");s>-1&&(t=e.substring(i+1,s))}}return t}(t.uri)||"";if(Si.enabled&&Si("Card_PlayMediaBrowserItem - play media item\n- player.id = %s\n- mediaItem.uri = %s\n- uriType = %s",JSON.stringify(e.id),JSON.stringify(t.uri),JSON.stringify(i)),["album","artist","playlist","show","audiobook","podcast"].indexOf(i)>-1)await this.PlayerMediaPlayContext(e,t.uri||"");else{if(!(["track","episode","chapter"].indexOf(i)>-1))throw new Error('unknown media type "'+i+'".');await this.PlayerMediaPlayTracks(e,t.uri||"")}}finally{}}}function Ti(e){let t=e;if(e){const i=e.lastIndexOf(":");i>-1&&(t=e.substring(i+1))}return t}function ki(e,t){null==t&&(t="; ");let i="";if(e)for(const s of e.copyrights||[])null!=s&&null!=s.text&&s.text.length>0&&(i.length>0&&(i+=t),i+=s.text);return i}const Ei=Fe(ce+":user-presets");function _i(e,t=null){const i={name:e.name,image_url:e.image_url||"",subtitle:t||e.type,type:e.type,uri:e.uri};return Ei.enabled&&Ei("%cGetUserPresetConfigEntry - preset object:\n%s","color: orange",JSON.stringify(i,null,2)),i}function $i(e,t=null){const i=_i(e,t),s="\n";let r="";return r+=" - name: "+i.name+s,r+=" subtitle: "+i.type+s,r+=" image_url: "+i.image_url+s,r+=" uri: "+i.uri+s,r+=" type: "+i.type+s,r}function Pi(e,t=null){const i=_i(e,t),s="\n";let r="";return r+=" {\n",r+=' "name": "'+i.name+'",'+s,r+=' "subtitle": "'+i.type+'",'+s,r+=' "image_url": "'+i.image_url+'",'+s,r+=' "uri": "'+i.uri+'",'+s,r+=' "type": "'+i.type+'"'+s,r+=" },\n",r}function Fi(e){if(!e||"object"!=typeof e)return e;if("[object Date]"==Object.prototype.toString.call(e))return new Date(e.getTime());if(Array.isArray(e))return e.map(Fi);var t={};return Object.keys(e).forEach((function(i){t[i]=Fi(e[i])})),t}const Ri=Fe(ce+":hass-service");class Li{constructor(e){this.hass=e}async CallService(e){try{Ri.enabled&&Ri("%cCallService - Calling service %s (no response)\n%s","color: orange;",JSON.stringify(e.service),JSON.stringify(e,null,2)),await this.hass.callService(e.domain,e.service,e.serviceData,e.target)}finally{}}async browseMedia(e,t,i){return await this.hass.callWS({type:"media_player/browse_media",entity_id:e.id,media_content_id:i,media_content_type:t})}async getRelatedEntities(e,...t){return new Promise((async(i,s)=>{const r={type:"render_template",template:"{{ device_entities(device_id('"+e.id+"')) }}"};try{const e=await this.hass.connection.subscribeMessage((s=>{e(),i(s.result.filter((e=>t.some((t=>e.includes(t))))).map((e=>this.hass.states[e])))}),r)}catch(e){s(e)}}))}}class Oi{constructor(e){this.id=e.entity_id,this.state=e.state,this.attributes=e.attributes,this.name=this.attributes.friendly_name||""}getVolume(){return this.attributes.volume_level?Math.round(100*this.attributes.volume_level):0}isIdle(){return this.state===Ci.IDLE}isIdleOrUnknown(){return this.state===Ci.IDLE||this.state===Ci.UNKNOWN}isUserProductPremium(){return"premium"===this.attributes.sp_user_product}isPlaying(){return this.state===Ci.PLAYING}isPoweredOff(){return this.state===Ci.OFF}isPoweredOffOrIdle(){return this.state===Ci.OFF||this.state===Ci.IDLE||this.state===Ci.UNKNOWN}isPoweredOffOrUnknown(){return this.state===Ci.OFF||this.state===Ci.UNKNOWN}isMuted(){return this.attributes.is_volume_muted||!1}supportsFeature(e){return!!((this.attributes.supported_features||0)&e)}}function Mi(e,t){let i=null;const s=Object.values(e.entities).filter((e=>e.entity_id.match(t)));if(!s)return i;const r=t.toLowerCase();return s.forEach((e=>{const t=e;t.entity_id.toLowerCase()==r&&(i=t)})),i}function xi(e,t){let i=null;const s=Object.values(e.states).filter((e=>e.entity_id.match(t)));if(!s)return i;const r=t.toLowerCase();return s.forEach((e=>{const t=e;t.entity_id.toLowerCase()==r&&(i=t)})),i}const Bi=Fe(ce+":store");class Ui{constructor(e,t,i,s){if(!e)throw new Error("STPC0005 hass property has not been set!");this.hass=e,this.config=t,this.card=i,this.hassService=new Li(e),this.mediaControlService=new yi(this.hassService),this.spotifyPlusService=new Ii(e,i,t),this.player=this.getMediaPlayerObject(),this.section=s,Bi.enabled}getMediaPlayerObject(){const e=this.config.entity+"";let t=null,i="";for(;;){if(!this.config||!this.config.entity||""==this.config.entity.trim())break;const s=Mi(this.hass,e);if(!s){i="Card configuration `entity` value "+JSON.stringify(e)+" is not defined in HA entities table; is it disabled? is `entity` value spelled correctly (search is case-sensitive)?";break}if(s.platform!=ne){i="Card configuration `entity` value "+JSON.stringify(e)+" is not a "+JSON.stringify(ne)+" platform media player.";break}const r=xi(this.hass,this.config.entity);if(!r){i="Card configuration `entity` value "+JSON.stringify(e)+" could not be found in the HA state machine.";break}if(t=new Oi(r),t)return t;i="Card configuration `entity` value "+JSON.stringify(e)+" was not found in the HA state machine; is it disabled?";break}return t=new Oi({entity_id:"",state:"",last_changed:"",last_updated:"",attributes:{sp_config_state:i},context:{id:"",user_id:"",parent_id:""}}),t}}Ui.selectedConfigArea=tt.GENERAL,Ui.hasCardEditLoadedMediaList={};const Hi=Fe(ce+":lovelace-config-utils");function Vi(e,t,i,s){if("object"!=typeof e||null===e)return e;if(e.hasOwnProperty("type")&&e.type===s.type&&e.hasOwnProperty(t)&&e[t]===i)return s;const r=Fi(e);for(const o in e)e.hasOwnProperty(o)&&(r[o]=Vi(e[o],t,i,s));return r}async function Di(e){try{if(Hi.enabled&&Hi("%cupdateCardConfigurationStorage - updating Lovelace Card Configuration storage\n- cardUniqueId = %s\n- card configuration object:\n%s","color: white",JSON.stringify(e.cardUniqueId),JSON.stringify(e,null,2)),!e.cardUniqueId)throw new Error("Card Configuration does not have a cardUniqueId option value; this value is required in order to update the card programatically outside of the card editor UI.");const t=function(){let e=document.querySelector("home-assistant");if(e=e&&e.shadowRoot,e=e&&e.querySelector("home-assistant-main"),e=e&&e.shadowRoot,e=e&&e.querySelector("app-drawer-layout partial-panel-resolver, ha-drawer partial-panel-resolver"),e=e&&e.shadowRoot||e,e=e&&e.querySelector("ha-panel-lovelace"),e=e&&e.shadowRoot,e=e&&e.querySelector("hui-root"),e){const t=e.lovelace;return t.current_view=e.___curView,t}return null}();if(!t)throw new Error("Could not get HA lovelace object reference; please notify the card developer of this error.");Hi.enabled&&(Hi("%cupdateCardConfigurationStorage - Lovelace.rawConfig object BEFORE replace:\n%s","color: orange",JSON.stringify(t.rawConfig,null,2)),Hi("%cupdateCardConfigurationStorage - card configuration that contains cardUniqueId = %s will be replaced","color: gold",JSON.stringify(e.cardUniqueId)));const i=Vi(t.rawConfig,"cardUniqueId",e.cardUniqueId,e);Hi.enabled&&(Hi("%cupdateCardConfigurationStorage - Lovelace.rawConfig object AFTER replace:\n%s","color: gold",JSON.stringify(i,null,2)),Hi("%cupdateCardConfigurationStorage - Saving Lovelace raw configuration to storage","color: white")),t.saveConfig(i),Hi.enabled&&Hi("%cupdateCardConfigurationStorage - Lovelace raw configuration saved to storage","color: white"),Ui.selectedConfigArea=pt(et.USERPRESETS)}catch(e){const t=yt(e);throw Hi.enabled&&Hi("%cupdateCardConfigurationStorage - Configuration update failed:\n%s","color: red",JSON.stringify(t)),new Error("Configuration update failed: "+t)}}var Ni;!function(e){e.AlbumCopyPresetToClipboard="AlbumCopyPresetToClipboard",e.AlbumCopyPresetJsonToClipboard="AlbumCopyPresetJsonToClipboard",e.AlbumCopyUriToClipboard="AlbumCopyUriToClipboard",e.AlbumFavoriteAdd="AlbumFavoriteAdd",e.AlbumFavoriteRemove="AlbumFavoriteRemove",e.AlbumFavoriteUpdate="AlbumFavoriteUpdate",e.AlbumPlayTrackFavorites="AlbumPlayTrackFavorites",e.AlbumTrackQueueAdd="AlbumTrackQueueAdd",e.AlbumTracksUpdate="AlbumTracksUpdate",e.AlbumSearchRadio="AlbumSearchRadio",e.AlbumShowTracks="AlbumShowTracks",e.AlbumUserPresetAdd="AlbumUserPresetAdd",e.ArtistCopyPresetToClipboard="ArtistCopyPresetToClipboard",e.ArtistCopyPresetJsonToClipboard="ArtistCopyPresetJsonToClipboard",e.ArtistCopyUriToClipboard="ArtistCopyUriToClipboard",e.ArtistFavoriteAdd="ArtistFavoriteAdd",e.ArtistFavoriteRemove="ArtistFavoriteRemove",e.ArtistFavoriteUpdate="ArtistFavoriteUpdate",e.ArtistPlayTrackFavorites="ArtistPlayTrackFavorites",e.ArtistSearchPlaylists="ArtistSearchPlaylists",e.ArtistSearchRadio="ArtistSearchRadio",e.ArtistSearchTracks="ArtistSearchTracks",e.ArtistShowAlbums="ArtistShowAlbums",e.ArtistShowAlbumsAppearsOn="ArtistShowAlbumsAppearsOn",e.ArtistShowAlbumsCompilation="ArtistShowAlbumsCompilation",e.ArtistShowAlbumsSingle="ArtistShowAlbumsSingle",e.ArtistShowRelatedArtists="ArtistShowRelatedArtists",e.ArtistShowTopTracks="ArtistShowTopTracks",e.ArtistUserPresetAdd="ArtistUserPresetAdd"}(Ni||(Ni={}));class qi extends li{constructor(){super(et.ALBUM_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(Ni.ArtistFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(Ni.ArtistFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
this.onClickAction(Ni.AlbumFavoriteAdd)}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(Ni.AlbumFavoriteRemove)}
slot="icon-button-small-selected"
>
`,r=U`
Tt(this.mediaItem.artists[0].external_urls.spotify||"")}
slot="icon-button-small"
>
`,o=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,a=U`
this.onClickAction(Ni.AlbumPlayTrackFavorites)}>
Play Favorite Tracks from this Album
this.onClickAction(Ni.AlbumShowTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Album Tracks
this.onClickAction(Ni.AlbumSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Album Radio
this.onClickAction(Ni.AlbumUserPresetAdd)}>
Add Album to User Presets
this.onClickAction(Ni.AlbumCopyPresetToClipboard)}>
Copy Album Preset Info to Clipboard
this.onClickAction(Ni.AlbumCopyPresetJsonToClipboard)}>
Copy Album Preset JSON to Clipboard
this.onClickAction(Ni.AlbumCopyUriToClipboard)}>
Copy Album URI to Clipboard
`,n=U`
this.onClickAction(Ni.ArtistPlayTrackFavorites)}>
Play Favorite Tracks from this Artist
this.onClickAction(Ni.ArtistSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Artist
this.onClickAction(Ni.ArtistSearchTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Search Tracks for Artist
this.onClickAction(Ni.ArtistSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Artist Radio
this.onClickAction(Ni.ArtistShowTopTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Artist Top Tracks
this.onClickAction(Ni.ArtistShowAlbums)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums
this.onClickAction(Ni.ArtistShowAlbumsCompilation)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Compilations
this.onClickAction(Ni.ArtistShowAlbumsSingle)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Singles
this.onClickAction(Ni.ArtistShowAlbumsAppearsOn)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums AppearsOn
this.onClickAction(Ni.ArtistShowRelatedArtists)} hide=${this.hideSearchType(Et.ARTISTS)}>
Show Related Artists
this.onClickAction(Ni.ArtistUserPresetAdd)}>
Add Artist to User Presets
this.onClickAction(Ni.ArtistCopyPresetToClipboard)}>
Copy Artist Preset Info to Clipboard
this.onClickAction(Ni.ArtistCopyPresetJsonToClipboard)}>
Copy Artist Preset JSON to Clipboard
this.onClickAction(Ni.ArtistCopyUriToClipboard)}>
Copy Artist URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.album-info-grid {
grid-template-columns: auto auto;
justify-content: left;
}
.album-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
/* style tracks container and grid */
.tracks-grid {
grid-template-columns: 40px 30px auto auto 60px;
}
/* style ha-icon-button controls in tracks grid: icon size, title text */
.tracks-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{if(e==Ni.AlbumCopyPresetToClipboard)return st($i(this.mediaItem,this.mediaItem.artists[0].name)),this.alertInfoSet(we),!0;if(e==Ni.AlbumCopyPresetJsonToClipboard)return st(Pi(this.mediaItem,this.mediaItem.artists[0].name)),this.alertInfoSet(Ce),!0;if(e==Ni.AlbumCopyUriToClipboard)return st(this.mediaItem.uri),!0;if(e==Ni.AlbumSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.name+ve+this.mediaItem.artists[0].name)),!0;if(e==Ni.AlbumShowTracks)return this.dispatchEvent(hi(Et.ALBUM_TRACKS,this.mediaItem.name+"; "+this.mediaItem.artists[0].name,this.mediaItem.name,this.mediaItem.uri,null,this.mediaItem)),!0;if(e==Ni.ArtistCopyPresetToClipboard)return this.mediaItem.artists[0].image_url=this.mediaItem.image_url,st($i(this.mediaItem.artists[0])),this.alertInfoSet(we),!0;if(e==Ni.ArtistCopyPresetJsonToClipboard)return this.mediaItem.artists[0].image_url=this.mediaItem.image_url,st(Pi(this.mediaItem.artists[0])),this.alertInfoSet(Ce),!0;if(e==Ni.ArtistCopyUriToClipboard)return st(this.mediaItem.artists[0].uri),!0;if(e==Ni.ArtistSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.artists[0].name)),!0;if(e==Ni.ArtistSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.artists[0].name+ve)),!0;if(e==Ni.ArtistShowAlbums)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistShowAlbumsAppearsOn)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_APPEARSON,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistShowAlbumsCompilation)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_COMPILATION,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistShowAlbumsSingle)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_SINGLE,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistShowRelatedArtists)return this.dispatchEvent(hi(Et.ARTIST_RELATED_ARTISTS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistShowTopTracks)return this.dispatchEvent(hi(Et.ARTIST_TOP_TRACKS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==Ni.ArtistSearchTracks)return this.dispatchEvent(hi(Et.TRACKS,this.mediaItem.artists[0].name)),!0;this.progressShow();const t=Ti(this.mediaItem.artists[0].uri);if(e==Ni.AlbumUserPresetAdd)this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide();else if(e==Ni.AlbumFavoriteAdd)await this.spotifyPlusService.SaveAlbumFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[Ni.AlbumFavoriteUpdate]);else if(e==Ni.AlbumFavoriteRemove)await this.spotifyPlusService.RemoveAlbumFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[Ni.AlbumFavoriteUpdate]);else if(e==Ni.AlbumPlayTrackFavorites){const e=this.store.config.albumFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,null,this.mediaItem.uri),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else if(e==Ni.ArtistUserPresetAdd)this.mediaItem.artists[0].image_url=this.mediaItem.image_url,this.store.config.userPresets?.unshift(_i(this.mediaItem.artists[0])),await Di(this.store.config),this.progressHide();else if(e==Ni.ArtistFavoriteAdd)await this.spotifyPlusService.FollowArtists(this.player,t),this.updateActions(this.player,[Ni.ArtistFavoriteUpdate]);else if(e==Ni.ArtistFavoriteRemove)await this.spotifyPlusService.UnfollowArtists(this.player,t),this.updateActions(this.player,[Ni.ArtistFavoriteUpdate]);else if(e==Ni.ArtistPlayTrackFavorites){const e=this.store.config.artistFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,this.mediaItem.artists[0].uri,null),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(Ni.AlbumTracksUpdate)||0==t.length){const t=new Promise(((t,i)=>{const s=this.mediaItem.total_tracks;this.spotifyPlusService.GetAlbumTracks(e,this.mediaItem.id,0,0,null,s).then((e=>{this.albumTracks=e,t(!0)})).catch((e=>{this.albumTracks=void 0,this.alertErrorSet("Get Album Tracks failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Ni.AlbumFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckAlbumFavorites(e,this.mediaItem.id).then((e=>{this.isAlbumFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isAlbumFavorite=void 0,this.alertErrorSet("Check Album Favorite failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Ni.ArtistFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckArtistsFollowing(e,this.mediaItem.artists[0].id).then((e=>{this.isArtistFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isArtistFavorite=void 0,this.alertErrorSet("Check Artist Following failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Album actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],qi.prototype,"mediaItem",void 0),Ie([De()],qi.prototype,"albumTracks",void 0),Ie([De()],qi.prototype,"isAlbumFavorite",void 0),Ie([De()],qi.prototype,"isArtistFavorite",void 0),customElements.define("spc-album-actions",qi);const Gi=a`
.media-browser-section {
color: var(--secondary-text-color);
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.media-browser-section-title {
padding: 0.2rem;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-weight: bold;
font-size: var(--spc-media-browser-section-title-font-size, 1.0rem);
line-height: var(--spc-media-browser-section-title-font-size, 1.0rem);
color: var(--spc-media-browser-section-title-color, var(--secondary-text-color, #ffffff));
color: var(--spc-media-browser-section-title-color);
}
.media-browser-section-subtitle {
padding: 0.2rem;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-weight: normal;
font-size: var(--spc-media-browser-section-subtitle-font-size, 0.85rem);
line-height: var(--spc-media-browser-section-subtitle-font-size, 0.85rem);
color: var(--spc-media-browser-section-subtitle-color, var(--secondary-text-color, #ffffff));
}
.media-browser-controls {
padding: 0.2rem 0.4rem 0.2rem;
white-space: nowrap;
--ha-select-height: 2.5rem; /* ha dropdown control height */
--mdc-menu-item-height: 2.5rem; /* mdc dropdown list item height */
--ha-icon-button-size: 2.5rem; /* mdc icon button size */
--md-menu-item-top-space: 0.5rem; /* top spacing between items */
--md-menu-item-bottom-space: 0.5rem; /* bottom spacing between items */
--md-menu-item-one-line-container-height: 2.0rem; /* menu item height */
display: inline-flex;
align-items: center;
justify-content: center;
flex-direction: row;
}
.media-browser-control-filter {
padding-right: 0.5rem;
padding-left: 0.5rem;
width: 100%;
}
.media-browser-control-filter-disabled {
padding-right: 0.5rem;
padding-left: 0.5rem;
width: 100%;
align-self: center;
color: var(--dark-primary-color);
overflow: hidden;
text-overflow: ellipsis;
}
.media-browser-content {
margin: 0.5rem;
flex: 3;
max-height: 100vh;
overflow-y: auto;
scrollbar-color: var(--primary-text-color) var(--secondary-background-color);
scrollbar-width: inherit;
}
.media-browser-list {
height: 100%;
}
.media-browser-actions {
height: 100%;
}
ha-alert {
display: block;
margin-bottom: 0.25rem;
}
*[hide] {
display: none;
}
`;const Ji=new class{constructor(){this._propValues={}}addPropertyValue(e){if(!this._propValues.hasOwnProperty(e)){const t=window.localStorage.getItem(e);this._propValues[e]=t?JSON.parse(t):null}}getPropertyValue(e){return this._propValues[e]}setPropertyValue(e,t){this._propValues[e]=t}saveProperties(){for(const e in this._propValues)this._propValues.hasOwnProperty(e)&&window.localStorage.setItem(e,JSON.stringify(this._propValues[e]))}saveProperty(e){this._propValues.hasOwnProperty(e)&&window.localStorage.setItem(e,JSON.stringify(this._propValues[e]))}getStorageValue(e,t=null){const i=window.localStorage.getItem(e);return i?JSON.parse(i):t}setStorageValue(e,t){window.localStorage.setItem(e,JSON.stringify(t))}clearStorageValue(e){window.localStorage.removeItem(e)}clearStorage(){window.localStorage.clear();for(const e in this._propValues)this._propValues.hasOwnProperty(e)&&(this._propValues[e]=null)}clearStorageByKey(e){this._propValues.hasOwnProperty(e)&&(window.localStorage.removeItem(e),this._propValues[e]=null)}},Wi=Fe(ce+":fav-browser-base"),zi="_filtercriteria",ji="_medialist",Yi="_medialistlastupdated",Ki="Previous refresh is still in progress - please wait";class Zi extends ai{constructor(e){super(),this.EDITOR_LIMIT_TOTAL_MAX=25,this.LIMIT_TOTAL_MAX=200,this.isActionsEnabled=!0,this.isMediaListRefreshedOnSectionEntry=!1,this.mediaType=e,this.shuffleOnPlay=!1,this.onKeyDown_EventListenerBound=this.onKeyDown.bind(this)}render(){Wi.enabled&&Wi("render - rendering control: %s\n- mediaListLastUpdatedOn = %s\n- scrollTopSaved = %s\n- filterItemCount = %s (pre-render)",JSON.stringify(this.mediaType),JSON.stringify(this.mediaListLastUpdatedOn),JSON.stringify(this.scrollTopSaved),JSON.stringify(this.filterItemCount)),this.hass=this.store.hass,this.config=this.store.config,this.player=this.store.player,this.spotifyPlusService=this.store.spotifyPlusService,this.isCardInEditPreview=ut(this.store.card),this.setScrollPosition(),this.isFilterCriteriaReadOnly=!1,this.isFilterCriteriaVisible=!0,this.filterCriteriaHtml=U`
`,this.filterCriteriaReadOnlyHtml=U`
${this.filterCriteria}
`,this.refreshMediaListHtml=U`
`,this.formatMediaListHtml=U`
`,this.btnHideActionsHtml=U`
`}styleMediaBrowser(){const e=this.config.mediaBrowserSectionTitleColor,t=this.config.mediaBrowserSectionTitleFontSize,i=this.config.mediaBrowserSectionSubTitleColor,s=this.config.mediaBrowserSectionSubTitleFontSize,r=this.config.mediaBrowserItemsSvgIconColor,o={};return e&&(o["--spc-media-browser-section-title-color"]=`${e}`),t&&(o["--spc-media-browser-section-title-font-size"]=`${t}`),i&&(o["--spc-media-browser-section-subtitle-color"]=`${i}`),s&&(o["--spc-media-browser-section-subtitle-font-size"]=`${s}`),r&&(o["--spc-media-browser-items-svgicon-color"]=`${r}`),xe(o)}static get styles(){return[Gi,a`
/* extra styles not defined in sharedStylesFavBrowser would go here. */
/* you can also copy this method into any inheriting class to apply fav-browser specific styles. */
ha-input-search {
color: orange;
font-size: 16px;
}
ha-input-search::part(input) {
color: orange;
font-size: 20px;
}
ha-input-search::part(input)::placeholder {
color: orange;
font-size: 24px;
}
ha-input-search ha-svg-icon {
color: var(--secondary-text-color);
}
`]}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.onKeyDown_EventListenerBound)}disconnectedCallback(){document.removeEventListener("keydown",this.onKeyDown_EventListenerBound),super.disconnectedCallback()}firstUpdated(e){if(super.firstUpdated(e),Wi.enabled&&Wi("%cfirstUpdated (base) - isMediaListRefreshedOnSectionEntry = %s\n- changedProperties keys for mediaType %s:\n- %s","color: yellow;",JSON.stringify(this.isMediaListRefreshedOnSectionEntry),JSON.stringify(this.mediaType),JSON.stringify(Array.from(e.keys()))),(async()=>{await gt()})(),this.cacheKeyBase=ne+"_"+(this.player.attributes.sp_user_id||"nospuserid")+"_",1==this.isMediaListRefreshedOnSectionEntry&&(this.isCardInEditPreview||(Wi.enabled&&Wi("%cfirstUpdated - %s mediaList will be updated on section entry","color: yellow;",JSON.stringify(this.mediaType)),this.storageValuesClear())),this.storageValuesLoad(),0==(this.mediaListLastUpdatedOn||0)){if(this.isCardInEditPreview&&this.mediaType in Ui.hasCardEditLoadedMediaList)return void(Wi.enabled&&Wi("%cfirstUpdated - %s mediaList already updated; updateMediaList will not be called again while editing card configuration!","color: yellow;",JSON.stringify(this.mediaType)));Wi.enabled&&Wi("%cfirstUpdated - %s mediaList will be updated on first update","color: yellow;",JSON.stringify(this.mediaType)),this.updateMediaList(this.player)}else this.isCardInEditPreview&&this.updatedMediaListOk(!1)}filterSectionMedia(e){Wi.enabled&&Wi("filterSectionMedia - filtering section media:\n%s",JSON.stringify(e,null,2)),this.filterCriteria=e.filterCriteria,this.updateMediaList(this.player)}storageValuesClear(){Ji.clearStorageValue(this.cacheKeyBase+this.mediaType+Yi),Ji.clearStorageValue(this.cacheKeyBase+this.mediaType+ji),Ji.clearStorageValue(this.cacheKeyBase+this.mediaType+zi),this.mediaType in Ui.hasCardEditLoadedMediaList&&delete Ui.hasCardEditLoadedMediaList[this.mediaType],Wi.enabled&&Wi("storageValuesClear - %s parameters were cleared from cache:\n mediaListLastUpdatedOn, mediaList, filterCriteria",JSON.stringify(this.mediaType))}storageValuesLoad(){this.mediaListLastUpdatedOn=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+Yi,0),this.mediaList=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+ji,void 0),this.filterCriteria=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+zi,void 0),Wi.enabled&&Wi("storageValuesLoad - %s parameters were loaded from cache:\n mediaListLastUpdatedOn, mediaList, filterCriteria",JSON.stringify(this.mediaType))}storageValuesSave(){Ji.setStorageValue(this.cacheKeyBase+this.mediaType+Yi,this.mediaListLastUpdatedOn),Ji.setStorageValue(this.cacheKeyBase+this.mediaType+ji,this.mediaList),Ji.setStorageValue(this.cacheKeyBase+this.mediaType+zi,this.filterCriteria),Wi.enabled&&Wi("storageValuesSave - %s parameters were saved to cache:\n mediaListLastUpdatedOn, mediaList, filterCriteria",JSON.stringify(this.mediaType))}onFilterCriteriaChange(e){this.filterCriteria=e.target.value,""==this.filterCriteria&&Ji.clearStorageValue(this.cacheKeyBase+this.mediaType+zi)}onFilterCriteriaKeyPress(e){"Enter"===e.key&&this.updateMediaList(this.player)}onFilterActionsClick(e){const t=e.currentTarget.getAttribute("action");"refresh"===t?(this.storageValuesClear(),this.updateMediaList(this.player)):"hideactions"===t&&(this.isActionsVisible=!1,setTimeout((()=>{this.requestUpdate()}),50))}onItemSelected(e){Wi.enabled&&Wi("onItemSelected - media item selected:\n%s",JSON.stringify(e.detail,null,2));const t=e.detail;this.PlayMediaItem(t)}onItemSelectedWithHold(e){Wi.enabled&&Wi("onItemSelectedWithHold - media item selected:\n%s",JSON.stringify(e.detail,null,2)),this.isActionsEnabled?this.isCardInEditPreview?this.alertInfo="Cannot display actions while editing card configuration":(this.mediaItem=e.detail,this.scrollTopSaved=this.mediaBrowserContentElement.scrollTop,this.isActionsVisible=!this.isActionsVisible,this.isActionsVisible&&this.alertClear()):this.onItemSelected(e)}onKeyDown(e){"Escape"===e.key&&(this.isActionsVisible=!1,setTimeout((()=>{this.requestUpdate()}),50))}onFormatMediaListChanged(e){const t=Number(e.target.value);null!=t&&(this.favBrowserItemsPerRow=t,Wi.enabled&&Wi("onFormatMediaListChanged - changed favBrowserItemsPerRow, value = %s",JSON.stringify(this.favBrowserItemsPerRow)))}async PlayMediaItem(e){try{this.progressShow(),Wi.enabled&&Wi("PlayMediaItem \n- shuffleOnPlay = %s\n- player.attributes.shuffle = %s",JSON.stringify(this.shuffleOnPlay),JSON.stringify(this.player.attributes.shuffle)),this.shuffleOnPlay&&!this.player.attributes.shuffle&&await this.spotifyPlusService.PlayerSetShuffleMode(this.player,null,!0),await this.spotifyPlusService.Card_PlayMediaBrowserItem(this.player,e),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not play media item. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}async QueueMediaItem(e){try{this.progressShow(),await this.spotifyPlusService.AddPlayerQueueItems(this.player,e.uri),this.alertInfo='Item added to play queue: "'+e.name+'".',this.mediaBrowserContentElement.scrollTop=0}catch(e){this.alertErrorSet("Could not queue media item. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}setScrollPosition(){if(this.isActionsVisible)return;if(0==this.scrollTopSaved)return;if(!this.hasUpdated)return;const e=this.shadowRoot?.querySelector(".media-browser-list");e&&e.shadowRoot&&e?.updateComplete&&(this.mediaBrowserContentElement.scrollTop=this.scrollTopSaved||0,setTimeout((()=>{this.setScrollPosition(),this.scrollTopSaved=0}),50))}updateMediaList(e){return this.isUpdateInProgress?(this.alertErrorSet(Ki),!1):(this.isUpdateInProgress=!0,e?(this.isActionsVisible=!1,this.mediaBrowserContentElement.scrollTop=0,this.scrollTopSaved=0,this.mediaListLastUpdatedOn=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+Yi,0),this.isCardInEditPreview&&0!=this.mediaListLastUpdatedOn?(this.isUpdateInProgress=!1,!1):(this.alertClear(),Wi.enabled&&Wi("%cupdateMediaList - updating %s medialist","color: yellow;",JSON.stringify(this.mediaType)),!0)):(this.isUpdateInProgress=!1,this.alertErrorSet("Player reference not set in updateMediaList"),!1))}updatedMediaListOk(e=!0){if(this.alertError==Ki&&this.alertErrorClear(),this.mediaList&&0==this.mediaList.length&&(this.alertInfo="No items found"),e&&this.storageValuesSave(),this.isCardInEditPreview){const e=function(e,t){let i;if((e?.length||0)>t){i="Limited to "+t+" items while editing card configuration.";for(let i=0,s=e?.length||0;i<=s;i++)i>t&&e?.pop()}return i}(this.mediaList,this.EDITOR_LIMIT_TOTAL_MAX);this.mediaType in Ui.hasCardEditLoadedMediaList||(this.alertInfo=e),Ui.hasCardEditLoadedMediaList[this.mediaType]=!0}}updatedMediaListError(e=null){this.alertInfoClear(),Wi.enabled&&Wi("%cupdatedMediaListError - error updating %s mediaList:\n %s","color:red",JSON.stringify(this.mediaType),JSON.stringify(e)),this.alertErrorSet(e||"Unknown Error")}}Ie([Ve({attribute:!1})],Zi.prototype,"hass",void 0),Ie([De()],Zi.prototype,"isActionsEnabled",void 0),Ie([De()],Zi.prototype,"isActionsVisible",void 0),Ie([De()],Zi.prototype,"isMediaListRefreshedOnSectionEntry",void 0),Ie([De()],Zi.prototype,"scrollTopSaved",void 0),Ie([De()],Zi.prototype,"mediaItem",void 0),Ie([De()],Zi.prototype,"filterCriteria",void 0),Ie([De()],Zi.prototype,"isFilterCriteriaReadOnly",void 0),Ie([De()],Zi.prototype,"isFilterCriteriaVisible",void 0),Ie([De()],Zi.prototype,"favBrowserItemsPerRow",void 0),Ie([qe("#mediaBrowserContentElement",!0)],Zi.prototype,"mediaBrowserContentElement",void 0),Ie([qe("#filterCriteria",!0)],Zi.prototype,"filterCriteriaElement",void 0);let Xi=class extends Zi{constructor(){super(et.ALBUM_FAVORITES),this.filterCriteriaPlaceholder="filter by album name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t)||-1!==e.artists[0].name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.albumFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.albumFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.shuffleOnPlay=this.config.albumFavBrowserShuffleOnPlay||!1,this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.albumFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.albumFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.albumFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.albumFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetAlbumFavorites(e,0,0,null,s,r).then((e=>{this.mediaList=function(e){const t=new Array;if(e)for(const i of e.items||[])t.push(i.album);return t}(e),this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Album Favorites failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Album favorites refresh failed: "+yt(e)),!0}}};Xi=Ie([Be("spc-album-fav-browser")],Xi);const Qi=Fe(ce+":artist-actions");var es;!function(e){e.ArtistAlbumsUpdate="ArtistAlbumsUpdate",e.ArtistCopyPresetToClipboard="ArtistCopyPresetToClipboard",e.ArtistCopyPresetJsonToClipboard="ArtistCopyPresetJsonToClipboard",e.ArtistCopyUriToClipboard="ArtistCopyUriToClipboard",e.ArtistGetInfo="ArtistGetInfo",e.ArtistFavoriteAdd="ArtistFavoriteAdd",e.ArtistFavoriteRemove="ArtistFavoriteRemove",e.ArtistFavoriteUpdate="ArtistFavoriteUpdate",e.ArtistPlayTrackFavorites="ArtistPlayTrackFavorites",e.ArtistSearchPlaylists="ArtistSearchPlaylists",e.ArtistSearchRadio="ArtistSearchRadio",e.ArtistSearchTracks="ArtistSearchTracks",e.ArtistShowAlbums="ArtistShowAlbums",e.ArtistShowAlbumsAppearsOn="ArtistShowAlbumsAppearsOn",e.ArtistShowAlbumsCompilation="ArtistShowAlbumsCompilation",e.ArtistShowAlbumsSingle="ArtistShowAlbumsSingle",e.ArtistShowRelatedArtists="ArtistShowRelatedArtists",e.ArtistShowTopTracks="ArtistShowTopTracks",e.ArtistUserPresetAdd="ArtistUserPresetAdd"}(es||(es={}));class ts extends li{constructor(){super(et.ARTIST_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(es.ArtistFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(es.ArtistFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(es.ArtistPlayTrackFavorites)}>
Play Favorite Tracks from this Artist
this.onClickAction(es.ArtistSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Artist
this.onClickAction(es.ArtistSearchTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Search Tracks for Artist
this.onClickAction(es.ArtistSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Artist Radio
this.onClickAction(es.ArtistShowTopTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Artist Top Tracks
this.onClickAction(es.ArtistShowAlbums)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums
this.onClickAction(es.ArtistShowAlbumsCompilation)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Compilations
this.onClickAction(es.ArtistShowAlbumsSingle)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Singles
this.onClickAction(es.ArtistShowAlbumsAppearsOn)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums AppearsOn
this.onClickAction(es.ArtistShowRelatedArtists)} hide=${this.hideSearchType(Et.ARTISTS)}>
Show Related Artists
this.onClickAction(es.ArtistUserPresetAdd)}>
Add Artist to User Presets
this.onClickAction(es.ArtistCopyPresetToClipboard)}>
Copy Artist Preset Info to Clipboard
this.onClickAction(es.ArtistCopyPresetJsonToClipboard)}>
Copy Artist Preset JSON to Clipboard
this.onClickAction(es.ArtistCopyUriToClipboard)}>
Copy Artist URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.artist-info-grid {
grid-template-columns: auto auto auto;
justify-content: left;
}
.artist-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
/* style albums container and grid */
.albums-grid {
grid-template-columns: 40px 30px auto auto auto;
}
/* style ha-icon-button controls in tracks grid: icon size, title text */
.albums-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{if(e==es.ArtistCopyPresetToClipboard)return st($i(this.mediaItem)),this.alertInfoSet(we),!0;if(e==es.ArtistCopyPresetJsonToClipboard)return st(Pi(this.mediaItem)),this.alertInfoSet(Ce),!0;if(e==es.ArtistCopyUriToClipboard)return st(this.mediaItem.uri),!0;if(e==es.ArtistSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.name)),!0;if(e==es.ArtistSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.name+" Radio")),!0;if(e==es.ArtistShowAlbums)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistShowAlbumsAppearsOn)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_APPEARSON,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistShowAlbumsCompilation)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_COMPILATION,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistShowAlbumsSingle)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_SINGLE,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistShowRelatedArtists)return this.dispatchEvent(hi(Et.ARTIST_RELATED_ARTISTS,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistShowTopTracks)return this.dispatchEvent(hi(Et.ARTIST_TOP_TRACKS,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0;if(e==es.ArtistSearchTracks)return this.dispatchEvent(hi(Et.TRACKS,this.mediaItem.name)),!0;if(this.progressShow(),e==es.ArtistFavoriteAdd)await this.spotifyPlusService.FollowArtists(this.player,this.mediaItem.id),this.updateActions(this.player,[es.ArtistFavoriteUpdate]);else if(e==es.ArtistFavoriteRemove)await this.spotifyPlusService.UnfollowArtists(this.player,this.mediaItem.id),this.updateActions(this.player,[es.ArtistFavoriteUpdate]);else if(e==es.ArtistPlayTrackFavorites){const e=this.store.config.artistFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,this.mediaItem.uri,null),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else e==es.ArtistUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide()):this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(es.ArtistGetInfo)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.GetArtistInfo(e,this.mediaItem.id).then((e=>{this.artistInfo=e,t(!0)})).catch((e=>{Qi.enabled&&Qi("updateActions - Get Artist Info failed: "+yt(e)),this.artistInfo=void 0,i(!0)}))}));i.push(t)}if(-1!=t.indexOf(es.ArtistFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckArtistsFollowing(e,this.mediaItem.id).then((e=>{this.isArtistFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isArtistFavorite=void 0,this.alertErrorSet("Check Artist Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Artist actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],ts.prototype,"mediaItem",void 0),Ie([De()],ts.prototype,"artistInfo",void 0),Ie([De()],ts.prototype,"isArtistFavorite",void 0),customElements.define("spc-artist-actions",ts);let is=class extends Zi{constructor(){super(et.ARTIST_FAVORITES),this.filterCriteriaPlaceholder="filter by artist name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.artistFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.artistFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.shuffleOnPlay=this.config.artistFavBrowserShuffleOnPlay||!1,this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.artistFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.artistFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.artistFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.artistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistsFollowed(e,0,0,s,r).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Artist Followed failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Artist followed refresh failed: "+yt(e)),!0}}};function ss(e){let t="";return e&&(t=e.fully_played?"completed":0==(e.resume_position_ms||0)?"starts at beginning":"resumes at "+ct(e.resume_position_ms||0)),t}var rs;is=Ie([Be("spc-artist-fav-browser")],is),function(e){e.AudiobookCopyPresetToClipboard="AudiobookCopyPresetToClipboard",e.AudiobookCopyPresetJsonToClipboard="AudiobookCopyPresetJsonToClipboard",e.AudiobookCopyUriToClipboard="AudiobookCopyUriToClipboard",e.AudiobookFavoriteAdd="AudiobookFavoriteAdd",e.AudiobookFavoriteRemove="AudiobookFavoriteRemove",e.AudiobookFavoriteUpdate="AudiobookFavoriteUpdate",e.AudiobookChaptersUpdate="AudiobookChaptersUpdate",e.AudiobookSearchAuthor="AudiobookSearchAuthor",e.AudiobookSearchNarrator="AudiobookSearchNarrator",e.AudiobookUserPresetAdd="AudiobookUserPresetAdd"}(rs||(rs={}));class os extends li{constructor(){super(et.AUDIOBOOK_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(rs.AudiobookFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(rs.AudiobookFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(rs.AudiobookSearchAuthor)} hide=${this.hideSearchType(Et.AUDIOBOOKS)}>
Other Audiobooks by same Author
this.onClickAction(rs.AudiobookSearchNarrator)} hide=${this.hideSearchType(Et.AUDIOBOOKS)}>
Other Audiobooks by same Narrator
this.onClickAction(rs.AudiobookUserPresetAdd)}>
Add Audiobook to User Presets
this.onClickAction(rs.AudiobookCopyPresetToClipboard)}>
Copy Audiobook Preset Info to Clipboard
this.onClickAction(rs.AudiobookCopyPresetJsonToClipboard)}>
Copy Audiobook Preset JSON to Clipboard
this.onClickAction(rs.AudiobookCopyUriToClipboard)}>
Copy Audiobook URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.audiobook-info-grid {
grid-template-columns: auto auto;
justify-content: left;
}
.audiobook-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
/* style chapters container and grid */
.chapters-grid {
grid-template-columns: 40px auto auto auto;
margin-top: 1.0rem;
}
/* style ha-icon-button controls in tracks grid: icon size, title text */
.chapters-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{return e==rs.AudiobookCopyPresetToClipboard?(st($i(this.mediaItem,_t(this.mediaItem,", "))),this.alertInfoSet(we),!0):e==rs.AudiobookCopyPresetJsonToClipboard?(st(Pi(this.mediaItem,_t(this.mediaItem,", "))),this.alertInfoSet(Ce),!0):e==rs.AudiobookCopyUriToClipboard?(st(this.mediaItem.uri||""),!0):e==rs.AudiobookSearchAuthor?(this.dispatchEvent(hi(Et.AUDIOBOOKS,_t(this.mediaItem," "))),!0):e==rs.AudiobookSearchNarrator?(this.dispatchEvent(hi(Et.AUDIOBOOKS,$t(this.mediaItem," "))),!0):(this.progressShow(),e==rs.AudiobookUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide()):e==rs.AudiobookFavoriteAdd?(await this.spotifyPlusService.SaveAudiobookFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[rs.AudiobookFavoriteUpdate])):e==rs.AudiobookFavoriteRemove?(await this.spotifyPlusService.RemoveAudiobookFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[rs.AudiobookFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(rs.AudiobookChaptersUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.GetAudiobookChapters(e,this.mediaItem.id,0,0,null,200).then((e=>{this.audiobookChapters=e,t(!0)})).catch((e=>{this.audiobookChapters=void 0,this.alertErrorSet("Get Audiobook Chapters failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(rs.AudiobookFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckAudiobookFavorites(e,this.mediaItem.id).then((e=>{this.isAudiobookFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isAudiobookFavorite=void 0,this.alertErrorSet("Check Audiobook Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Audiobook actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],os.prototype,"mediaItem",void 0),Ie([De()],os.prototype,"audiobookChapters",void 0),Ie([De()],os.prototype,"isAudiobookFavorite",void 0),customElements.define("spc-audiobook-actions",os);let as=class extends Zi{constructor(){super(et.AUDIOBOOK_FAVORITES),this.filterCriteriaPlaceholder="filter by audiobook name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t)||-1!==e.authors[0].name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.audiobookFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.audiobookFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.audiobookFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.audiobookFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.audiobookFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.audiobookFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetAudiobookFavorites(e,0,0,s,r).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Audiobook Favorites failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Audiobook favorites refresh failed: "+yt(e)),!0}}};var ns;as=Ie([Be("spc-audiobook-fav-browser")],as),function(e){e.PlaylistCopyPresetToClipboard="PlaylistCopyPresetToClipboard",e.PlaylistCopyPresetJsonToClipboard="PlaylistCopyPresetJsonToClipboard",e.PlaylistCopyUriToClipboard="PlaylistCopyUriToClipboard",e.PlaylistDelete="PlaylistDelete",e.PlaylistFavoriteAdd="PlaylistFavoriteAdd",e.PlaylistFavoriteRemove="PlaylistFavoriteRemove",e.PlaylistFavoriteUpdate="PlaylistFavoriteUpdate",e.PlaylistItemsUpdate="PlaylistItemsUpdate",e.PlaylistRecoverWebUI="PlaylistRecoverWebUI",e.PlaylistUserPresetAdd="PlaylistUserPresetAdd"}(ns||(ns={}));class ls extends li{constructor(){super(et.PLAYLIST_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(ns.PlaylistFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(ns.PlaylistFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(ns.PlaylistRecoverWebUI)}>
Recover Playlist via Spotify Web UI
this.onClickAction(ns.PlaylistDelete)}>
Delete (unfollow) Playlist
this.onClickAction(ns.PlaylistUserPresetAdd)}>
Add Playlist to User Presets
this.onClickAction(ns.PlaylistCopyPresetToClipboard)}>
Copy Playlist Preset Info to Clipboard
this.onClickAction(ns.PlaylistCopyPresetJsonToClipboard)}>
Copy Playlist Preset JSON to Clipboard
this.onClickAction(ns.PlaylistCopyUriToClipboard)}>
Copy Playlist URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.playlist-info-grid {
grid-template-columns: 80px auto 10px auto auto;
justify-content: left;
margin: 0.5rem;
max-width: 21rem;
}
.playlist-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.colspan-r3-c2 {
grid-row: 3 / 3; /* grid row 3 */
grid-column: 2 / 6; /* grid columns 2 thru 5 */
}
.colspan-r4-c2 {
grid-row: 4 / 4; /* grid row 4 */
grid-column: 2 / 6; /* grid columns 2 thru 5 */
}
.colspan-r5-c2 {
grid-row: 5 / 5; /* grid row 5 */
grid-column: 2 / 6; /* grid columns 2 thru 5 */
}
/* style tracks container and grid */
.tracks-grid {
grid-template-columns: 30px 45px auto auto auto 60px;
margin-top: 1.0rem;
}
/* style ha-icon-button controls in tracks grid: icon size, title text */
.tracks-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{return e==ns.PlaylistCopyUriToClipboard?(st(this.mediaItem.uri),!0):e==ns.PlaylistRecoverWebUI?(Tt("https://www.spotify.com/us/account/recover-playlists/"),!0):e==ns.PlaylistCopyPresetToClipboard?(st($i(this.mediaItem)),this.alertInfoSet(we),!0):e==ns.PlaylistCopyPresetJsonToClipboard?(st(Pi(this.mediaItem)),this.alertInfoSet(Ce),!0):(this.progressShow(),e==ns.PlaylistUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide()):e==ns.PlaylistDelete?(await this.spotifyPlusService.UnfollowPlaylist(this.player,this.mediaItem.id),this.updateActions(this.player,[ns.PlaylistFavoriteUpdate])):e==ns.PlaylistFavoriteAdd?(await this.spotifyPlusService.FollowPlaylist(this.player,this.mediaItem.id),this.updateActions(this.player,[ns.PlaylistFavoriteUpdate])):e==ns.PlaylistFavoriteRemove?(await this.spotifyPlusService.UnfollowPlaylist(this.player,this.mediaItem.id),this.updateActions(this.player,[ns.PlaylistFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(ns.PlaylistItemsUpdate)||0==t.length){const t=new Promise(((t,i)=>{const s=this.mediaItem.tracks.total;this.spotifyPlusService.GetPlaylistItems(e,this.mediaItem.id,0,0,null,null,null,s).then((e=>{this.playlistTracks=function(e){const t=new Array;return e&&e.items.forEach((e=>{null!=e.track.name&&t.push(e)})),t}(e),t(!0)})).catch((e=>{this.playlistTracks=void 0,this.alertErrorSet("Get Playlist Items failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(ns.PlaylistFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckPlaylistFollowers(e,this.mediaItem.id).then((e=>{this.isPlaylistFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isPlaylistFavorite=void 0,this.alertErrorSet("Check Playlist Followers failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Playlist actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],ls.prototype,"mediaItem",void 0),Ie([De()],ls.prototype,"playlistTracks",void 0),Ie([De()],ls.prototype,"isPlaylistFavorite",void 0),customElements.define("spc-playlist-actions",ls);const cs=Fe(ce+":category-browser");let ds=class extends Zi{constructor(){super(et.CATEGORYS),this.filterCriteriaPlaceholder="filter by category name"}render(){let e,t;if(super.render(),!this.isActionsVisible){const i=(this.filterCriteria||"").toLocaleLowerCase();this.isCategoryVisible?(e=this.categoryPlaylists?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(i))),this.filterItemCount=e?.length):(t=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(i))),this.filterItemCount=t?.length)}let i="",s="";return this.isCategoryVisible?(i=It(this.config.categoryBrowserTitle,this.config,this.player,this.categoryPlaylistsLastUpdatedOn,this.categoryPlaylists,e),s=It(this.config.categoryBrowserSubTitle,this.config,this.player,this.categoryPlaylistsLastUpdatedOn,this.categoryPlaylists,e)):(i=It(this.config.categoryBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,t),s=It(this.config.categoryBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,t)),this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.categoryBrowserItemsPerRow||4),U`
`}displayCategory(e){cs.enabled&&cs("displayCategory - displaying Spotify category:\n%s",JSON.stringify(e,null,2)),this.categoryId=Ti(e.uri)||"",this.isCategoryVisible=!0,this.categoryListFilter=e.title||"",this.categoryListScrollTopSaved=this.scrollTopSaved,this.filterCriteria=e.filterCriteria,this.categoryPlaylists=void 0,this.requestUpdate(),this.updateMediaList(this.player)}onFilterActionsClick(e){"hideactions"===e.currentTarget.getAttribute("action")?this.isActionsVisible?super.onFilterActionsClick(e):this.isCategoryVisible&&(this.categoryId="",this.isCategoryVisible=!1,this.filterCriteria=this.categoryListFilter,this.scrollTopSaved=this.categoryListScrollTopSaved,setTimeout((()=>{this.requestUpdate()}),50)):super.onFilterActionsClick(e)}onItemSelected(e){cs.enabled&&cs("onItemSelected - media item selected:\n%s",JSON.stringify(e.detail,null,2));if("category"==e.detail.type){const t=e.detail;this.scrollTopSaved=this.mediaBrowserContentElement.scrollTop,this.categoryId=t.id,this.isCategoryVisible=!0,this.categoryListFilter=this.filterCriteria,this.categoryListScrollTopSaved=this.scrollTopSaved,this.filterCriteria="",this.categoryPlaylists=void 0,this.requestUpdate(),this.updateMediaList(this.player)}else super.onItemSelected(e)}onItemSelectedWithHold(e){cs.enabled&&cs("onItemSelectedWithHold - media item selected:\n%s",JSON.stringify(e.detail,null,2));"category"==e.detail.type?this.onItemSelected(e):super.onItemSelectedWithHold(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array;if(this.isCategoryVisible){const i=new Promise(((t,i)=>{const s=this.config.searchMediaBrowserSearchLimit||50,r=this.config.searchMediaBrowserItemsSortTitle||!1;this.spotifyPlusService.GetCategoryPlaylists(e,this.categoryId,0,0,null,s,r).then((e=>{this.categoryPlaylists=e.items,this.categoryPlaylistsLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.categoryPlaylists=void 0,this.categoryPlaylistsLastUpdatedOn=0,super.updatedMediaListError("Get Category Playlist failed: "+yt(e)),i(e)}))}));t.push(i)}else{const i=new Promise(((t,i)=>{this.spotifyPlusService.GetBrowseCategorysList(e,null,null,!0).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Category List failed: "+yt(e)),i(e)}))}));t.push(i)}return this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Category List refresh failed: "+yt(e)),!0}}};var hs;Ie([De()],ds.prototype,"isCategoryVisible",void 0),Ie([De()],ds.prototype,"categoryId",void 0),ds=Ie([Be("spc-category-browser")],ds),function(e){e.DeviceDisconnect="DeviceDisconnect",e.DeviceConnect="DeviceConnect",e.DeviceGetInfo="DeviceGetInfo"}(hs||(hs={}));class ps extends li{constructor(){super(et.DEVICES)}render(){super.render(),this.deviceInfo||(this.deviceInfo=this.mediaItem);const e=this.deviceInfo?.IsInDeviceList?"device-list-in":"device-list-out",t=U`
this.onClickAction(hs.DeviceConnect)}>
Connect / Login to this device
this.onClickAction(hs.DeviceDisconnect)}>
Disconnect / Logout from this device
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
`}static get styles(){return[ti,ii,si,a`
.device-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.device-grid {
grid-template-columns: auto auto;
justify-content: left;
}
.device-list-in {
color: limegreen;
font-weight: bold;
}
.device-list-out {
color: red;
font-weight: bold;
}
/* reduce image size for device */
.media-info-content .img {
background-size: contain !important;
background-repeat: no-repeat !important;
background-position: center !important;
mask-repeat: no-repeat !important;
mask-position: center !important;
max-width: 100px;
min-height: 100px;
border-radius: var(--control-button-border-radius, 10px) !important;
}
.padT {
padding-top: 0.2rem;
}
.padL {
padding-left: 0.2rem;
}
/* style ha-alert controls */
ha-alert {
display: block;
margin-bottom: 0.25rem;
}
`]}styleMediaBrowserItemImage(e){const t={};return e?.includes("svg+xml")?(t["mask-image"]=`url(${e})`,t["background-color"]=`var(--spc-media-browser-items-svgicon-color, ${o(ye)})`):(t["background-image"]=`url(${e})`,t["background-color"]="var(--spc-media-browser-items-svgicon-color, transparent)"),xe(t)}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{return this.progressShow(),e==hs.DeviceConnect?this.deviceInfo?.DiscoveryResult.IsDynamicDevice?(this.alertInfoSet("Dynamic devices cannot be managed."),this.progressHide()):this.mediaItem.IsChromeCast?(this.alertInfoSet("Chromecast devices do not support Spotify Connect connect."),this.progressHide()):(this.alertInfoSet("Connecting to Spotify Connect device ..."),await this.spotifyPlusService.ZeroconfDeviceConnect(this.player,this.mediaItem,null,null,null,!0,!0,1),this.alertInfoSet("Spotify Connect device should be connected."),this.updateActions(this.player,[hs.DeviceGetInfo])):e==hs.DeviceDisconnect?this.mediaItem.DiscoveryResult.IsDynamicDevice?(this.alertInfoSet("Dynamic devices cannot be managed."),this.progressHide()):this.mediaItem.IsChromeCast?(this.alertInfoSet("Chromecast devices do not support Spotify Connect disconnect."),this.progressHide()):"librespot"==this.mediaItem.DeviceInfo.BrandDisplayName?(this.alertInfoSet("Librespot devices do not support Spotify Connect disconnect."),this.progressHide()):(this.alertInfoSet("Disconnecting from Spotify Connect device ..."),await this.spotifyPlusService.ZeroconfDeviceDisconnect(this.player,this.mediaItem,1),this.alertInfoSet("Spotify Connect device was disconnected."),this.updateActions(this.player,[hs.DeviceGetInfo])):this.progressHide(),!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(hs.DeviceGetInfo)){const t=new Promise(((t,i)=>{this.alertInfo='Retrieving Spotify Connect status for "'+this.mediaItem.Name+'" ...';this.spotifyPlusService.GetSpotifyConnectDevice(e,this.mediaItem.Id,null,null,!0,!1).then((e=>{this.alertInfo?.startsWith("Retrieving ")&&this.alertInfoClear(),this.deviceInfo=e,e&&(this.mediaItem=e),t(!0)})).catch((e=>{this.deviceInfo=void 0,this.alertErrorSet("Get Spotify Connect Device failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Update device actions failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],ps.prototype,"mediaItem",void 0),Ie([De()],ps.prototype,"deviceInfo",void 0),customElements.define("spc-device-actions",ps);const us=Fe(ce+":device-browser");let ms=class extends Zi{constructor(){super(et.DEVICES),this.filterCriteriaPlaceholder="filter by device name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.Name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.deviceBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.deviceBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.deviceBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=!0),super.firstUpdated(e)}onFilterActionsClick(e){"refresh"===e.currentTarget.getAttribute("action")&&(this.refreshDeviceList=!0),super.onFilterActionsClick(e)}onItemSelected(e){us.enabled&&us("onItemSelected - device item selected:\n%s",JSON.stringify(e.detail,null,2));const t=e.detail;this.SelectSource(t)}async SelectSource(e){try{this.progressShow(),this.alertInfo='Transferring playback to device "'+e.Name+'" ...';let t="";t=e.IsSonos?e.Name:this.config.deviceControlByName?e.Name||e.Id||"":e.Id||e.Name||"",await this.store.mediaControlService.select_source(this.player,t),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not select source. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.refreshDeviceList||!1;let r=e.attributes.sp_source_list_hide||[];1==(this.config.deviceBrowserItemsShowHiddenDevices&&!0)&&(r=[]),this.spotifyPlusService.GetSpotifyConnectDevices(e,s,!0,r).then((e=>{this.mediaList=e.Items,this.mediaListLastUpdatedOn=e.DateLastRefreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Spotify Connect Devices failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Spotify Connect Device refresh failed: "+yt(e)),!0}}};var vs;ms=Ie([Be("spc-device-browser")],ms),function(e){e.EpisodeCopyPresetToClipboard="EpisodeCopyPresetToClipboard",e.EpisodeCopyPresetJsonToClipboard="EpisodeCopyPresetJsonToClipboard",e.EpisodeCopyUriToClipboard="EpisodeCopyUriToClipboard",e.EpisodeFavoriteAdd="EpisodeFavoriteAdd",e.EpisodeFavoriteRemove="EpisodeFavoriteRemove",e.EpisodeFavoriteUpdate="EpisodeFavoriteUpdate",e.EpisodeUpdate="EpisodeUpdate",e.EpisodeUserPresetAdd="EpisodeUserPresetAdd",e.ShowCopyPresetToClipboard="ShowCopyPresetToClipboard",e.ShowCopyPresetJsonToClipboard="ShowCopyPresetJsonToClipboard",e.ShowCopyUriToClipboard="ShowCopyUriToClipboard",e.ShowFavoriteAdd="ShowFavoriteAdd",e.ShowFavoriteRemove="ShowFavoriteRemove",e.ShowFavoriteUpdate="ShowFavoriteUpdate",e.ShowSearchEpisodes="ShowSearchEpisodes",e.ShowUserPresetAdd="ShowUserPresetAdd"}(vs||(vs={}));class fs extends li{constructor(){super(et.EPISODE_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(vs.ShowFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(vs.ShowFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
this.onClickAction(vs.EpisodeFavoriteAdd)}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(vs.EpisodeFavoriteRemove)}
slot="icon-button-small-selected"
>
`,r=U`
Tt(this.episode?.show.external_urls.spotify||"")}
slot="icon-button-small"
>
`,o=U`
Tt(this.episode?.external_urls.spotify||"")}
slot="icon-button-small"
>
`,a=U`
this.onClickAction(vs.ShowSearchEpisodes)} hide=${this.hideSearchType(Et.EPISODES)}>
Search for Show Episodes
this.onClickAction(vs.ShowUserPresetAdd)}>
Add Show to User Presets
this.onClickAction(vs.ShowCopyPresetToClipboard)}>
Copy Show Preset Info to Clipboard
this.onClickAction(vs.ShowCopyPresetJsonToClipboard)}>
Copy Show Preset JSON to Clipboard
this.onClickAction(vs.ShowCopyUriToClipboard)}>
Copy Show URI to Clipboard
`,n=U`
this.onClickAction(vs.EpisodeUserPresetAdd)}>
Add Episode to User Presets
this.onClickAction(vs.EpisodeCopyPresetToClipboard)}>
Copy Episode Preset Info to Clipboard
this.onClickAction(vs.EpisodeCopyPresetJsonToClipboard)}>
Copy Episode Preset JSON to Clipboard
this.onClickAction(vs.EpisodeCopyUriToClipboard)}>
Copy Episode URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.episode?.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.episode-info-grid {
grid-template-columns: auto auto 30px auto auto;
justify-content: left;
}
.episode-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.colspan-r3-c2 {
grid-row: 3 / 3; /* grid row 3 */
grid-column: 2 / 6; /* grid columns 2 thru 5 */
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{return e==vs.EpisodeCopyPresetToClipboard?(st($i(this.episode,this.episode?.show.name)),this.alertInfoSet(we),!0):e==vs.EpisodeCopyPresetJsonToClipboard?(st(Pi(this.episode,this.episode?.show.name)),this.alertInfoSet(Ce),!0):e==vs.EpisodeCopyUriToClipboard?(st(this.episode?.uri||""),!0):e==vs.ShowCopyPresetToClipboard?(st($i(this.episode?.show,"Podcast")),this.alertInfoSet(we),!0):e==vs.ShowCopyPresetJsonToClipboard?(st(Pi(this.episode?.show,"Podcast")),this.alertInfoSet(Ce),!0):e==vs.ShowCopyUriToClipboard?(st(this.episode?.show.uri||""),!0):e==vs.ShowSearchEpisodes?(this.dispatchEvent(hi(Et.SHOW_EPISODES,this.episode?.show.name,this.episode?.show.name,this.episode?.show.uri)),!0):(this.progressShow(),e==vs.EpisodeUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.episode)),await Di(this.store.config),this.progressHide()):e==vs.EpisodeFavoriteAdd?(await this.spotifyPlusService.SaveEpisodeFavorites(this.player,this.episode?.id),this.updateActions(this.player,[vs.EpisodeFavoriteUpdate])):e==vs.EpisodeFavoriteRemove?(await this.spotifyPlusService.RemoveEpisodeFavorites(this.player,this.episode?.id),this.updateActions(this.player,[vs.EpisodeFavoriteUpdate])):e==vs.ShowUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.episode?.show)),await Di(this.store.config),this.progressHide()):e==vs.ShowFavoriteAdd?(await this.spotifyPlusService.SaveShowFavorites(this.player,this.episode?.show.id),this.updateActions(this.player,[vs.ShowFavoriteUpdate])):e==vs.ShowFavoriteRemove?(await this.spotifyPlusService.RemoveShowFavorites(this.player,this.episode?.show.id),this.updateActions(this.player,[vs.ShowFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const s=new Array;if(-1!=t.indexOf(vs.EpisodeUpdate)||0==t.length){if(this.isEpisodeFavorite=void 0,this.isShowFavorite=void 0,"object"==typeof(i=this.mediaItem)&&null!==i&&"show"in i)return this.episode=this.mediaItem,this.isUpdateInProgress=!1,setTimeout((()=>{this.updateActions(e,[vs.EpisodeFavoriteUpdate,vs.ShowFavoriteUpdate])}),50),!0;const t=new Promise(((t,i)=>{this.spotifyPlusService.GetEpisode(e,this.mediaItem.id).then((i=>{this.episode=i,setTimeout((()=>{this.updateActions(e,[vs.EpisodeFavoriteUpdate,vs.ShowFavoriteUpdate])}),50),t(!0)})).catch((e=>{this.episode=void 0,this.alertErrorSet("Get Episode call failed: "+yt(e)),i(e)}))}));s.push(t)}if(-1!=t.indexOf(vs.ShowFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckShowFavorites(e,this.episode?.show.id).then((e=>{this.isShowFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isShowFavorite=void 0,this.alertErrorSet("Check Show Favorite failed: "+yt(e)),i(e)}))}));s.push(t)}if(-1!=t.indexOf(vs.EpisodeFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckEpisodeFavorites(e,this.episode?.id).then((e=>{this.isEpisodeFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isEpisodeFavorite=void 0,this.alertErrorSet("Check Episode Favorites failed: "+yt(e)),i(e)}))}));s.push(t)}return this.progressShow(),Promise.allSettled(s).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Episode actions refresh failed: "+yt(e)),!0}var i}}Ie([Ve({attribute:!1})],fs.prototype,"mediaItem",void 0),Ie([De()],fs.prototype,"isEpisodeFavorite",void 0),Ie([De()],fs.prototype,"isShowFavorite",void 0),Ie([De()],fs.prototype,"episode",void 0),customElements.define("spc-episode-actions",fs);let gs=class extends Zi{constructor(){super(et.EPISODE_FAVORITES),this.filterCriteriaPlaceholder="filter by episode name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t)||-1!==e.show.name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.episodeFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.episodeFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.episodeFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.episodeFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.episodeFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.episodeFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetEpisodeFavorites(e,0,0,s,r).then((e=>{this.mediaList=function(e){const t=new Array;if(e)for(const i of e.items||[])t.push(i.episode);return t}(e),this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Episode Favorites failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Episode favorites refresh failed: "+yt(e)),!0}}};gs=Ie([Be("spc-episode-fav-browser")],gs);class As extends ai{constructor(){super(...arguments),this.mediaDuration=0}render(){this.player=this.store.player,this.mediaDuration=this.player?.attributes.media_duration||0;return this.mediaDuration>0?(this.trackProgress(),U`
${ys(this.playingProgress)}
-${ys(this.mediaDuration-this.playingProgress)}
`):U``}disconnectedCallback(){this.tracker&&(clearInterval(this.tracker),this.tracker=void 0),super.disconnectedCallback()}async onSeekBarClick(e){try{const t=this.progressBar.offsetWidth,i=e.offsetX/t,s=this.mediaDuration*i;return this.progressShow(),await this.store.mediaControlService.media_seek(this.player,s),!0}catch(e){return this.alertErrorSet("Seek position failed: "+yt(e)),!0}finally{this.progressHide()}}alertErrorSet(e){const t=ft("#spcPlayer",this);t&&t.alertErrorSet(e)}styleProgressBar(e){return xe({width:this.playingProgress/e*100+"%"})}trackProgress(){const e=this.player?.attributes.media_position||0,t=this.player?.isPlaying(),i=this.player?.attributes.media_position_updated_at||0;if(t){const t=e+Math.floor((Date.now()-new Date(i).getTime())/1e3);this.playingProgress=t}else this.playingProgress=e;this.tracker||(this.tracker=setInterval((()=>this.trackProgress()),1e3)),t||(clearInterval(this.tracker),this.tracker=void 0)}static get styles(){return a`
.progress {
width: 100%;
font-size: var(--spc-player-progress-label-font-size, x-small);
display: flex;
color: var(--spc-player-progress-label-color, var(--spc-player-controls-color, #ffffff));
padding-bottom: 0.2rem;
}
.progress-pad-left {
padding-left: var(--spc-player-progress-label-padding-lr, 0rem);
}
.progress-pad-right {
padding-right: var(--spc-player-progress-label-padding-lr, 0rem);
}
.bar {
display: flex;
flex-grow: 1;
align-items: center;
align-self: center;
margin-left: 5px;
margin-right: 5px;
height: 14px;
cursor: pointer;
background-clip: padding-box;
border: 1px solid rgba(255, 255, 255, 0.10);
border-radius: 0.25rem;
}
.progress-bar {
align-self: center;
background-color: var(--spc-player-progress-slider-color, var(--spc-player-controls-color, var(--dark-primary-color, ${o(ye)})));
margin-left: 2px;
margin-right: 2px;
height: 50%;
transition: width 0.1s linear;
border-radius: 0.18rem;
}
.progress-time {
mix-blend-mode: normal;
}
`}}Ie([De()],As.prototype,"playingProgress",void 0),Ie([qe(".bar")],As.prototype,"progressBar",void 0);const ys=e=>{const t=new Date(1e3*e).toISOString().substring(11,19);return t.startsWith("00:")?t.substring(3):t};customElements.define("spc-player-progress",As);class bs extends re{render(){this.config=this.store.config,this.player=this.store.player;const e=this.config.playerHeaderHideProgressBar||!1,t=It(this.config.playerHeaderTitle,this.config,this.player);let i=It(this.config.playerHeaderArtistTrack,this.config,this.player),s=It(this.config.playerHeaderAlbum,this.config,this.player);i&&(i=i.replace(/^ - | - $/g,""));let r,o=!1,a=U``,n=U``;if(this.player.isPlaying()){const e=this.parentElement?.querySelector(".player-section-body-content");if(e){const t=e.tagName.toLowerCase();if("spc-player-body-track"==t){const t=e;r=t.isTrackFavorite,a=t.actionTrackFavoriteAdd,n=t.actionTrackFavoriteRemove,o=!0,t.mediaContentId=this.player.attributes.media_content_id}else if("spc-player-body-show"==t){const t=e;r=t.isEpisodeFavorite,a=t.actionEpisodeFavoriteAdd,n=t.actionEpisodeFavoriteRemove,o=!0,t.mediaContentId=this.player.attributes.media_content_id}else if("spc-player-body-audiobook"==t){const t=e;r=t.isAudiobookFavorite,a=t.actionAudiobookFavoriteAdd,n=t.actionAudiobookFavoriteRemove,o=!0,t.mediaContentId=this.player.attributes.media_content_id}}}return this.player.attributes.media_title||(i=It(this.config.playerHeaderNoMediaPlayingText,this.config,this.player)||"No Media Playing",s=void 0),U`
`}styleContainer(){return xe({})}static get styles(){return[si,a`
.player-header-container {
max-width: var(--spc-player-controls-max-width, 40rem);
text-align: center;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
box-sizing: border-box;
/*border: 1px solid red; /* FOR TESTING CONTROL LAYOUT CHANGES */
}
.header-title {
overflow: hidden;
text-overflow: ellipsis;
font-size: var(--spc-player-header-title1-font-size, 1.0rem);
line-height: var(--spc-player-header-title1-font-size, 1.0rem);
font-weight: 500;
text-shadow: 0 0 2px var(--spc-player-palette-vibrant);
color: var(--spc-player-header-title1-color, #ffffff);
white-space: nowrap;
mix-blend-mode: normal;
min-height: 0.5rem;
padding: 0.2rem;
}
.header-artist-track {
overflow: hidden;
text-overflow: ellipsis;
font-size: var(--spc-player-header-title2-font-size, 1.15rem);
line-height: var(--spc-player-header-title2-font-size, 1.15rem);
font-weight: 400;
text-shadow: 0 0 2px var(--spc-player-palette-vibrant);
color: var(--spc-player-header-title2-color, #ffffff);
mix-blend-mode: normal;
padding: 0.1rem;
/* the following is used to correctly align the favorite indicator to the right of the track. */
display: inline-flex;
justify-content: center;
align-items: center;
width: 100%;
}
.header-artist-album {
overflow: hidden;
text-overflow: ellipsis;
font-size: var(--spc-player-header-title3-font-size, 1.0rem);
line-height: var(--spc-player-header-title3-font-size, 1.0rem);
font-weight: 400;
text-shadow: 0 0 2px var(--spc-player-palette-vibrant);
color: var(--spc-player-header-title3-color, #ffffff);
mix-blend-mode: normal;
padding: 0.1rem;
}
///* when the user prefers dark theme mode */
//@media (prefers-color-scheme: dark) {
// .header-title {
// color: var(--spc-player-header-title1-color, #ffffff);
// }
// .header-artist-track {
// color: var(--spc-player-header-title2-color, #ffffff);
// }
// .header-artist-album {
// color: var(--spc-player-header-title3-color, #ffffff);
// }
//}
`]}}Ie([Ve({attribute:!1})],bs.prototype,"store",void 0),customElements.define("spc-player-header",bs);const ws=Fe(ce+":player-body-base");class Cs extends ai{constructor(){super(),this.mediaType=et.PLAYER}render(){this.player=this.store.player,this.spotifyPlusService=this.store.spotifyPlusService,this.isPlayerStopped=[Ci.PLAYING,Ci.PAUSED,Ci.BUFFERING].includes(this.player.state)&&V}firstUpdated(e){super.firstUpdated(e),(async()=>{await gt()})(),this.isCardInEditPreview||this.updateActions(this.store.player,[])}update(e){super.update(e);const t=Array.from(e.keys());if(this.hasUpdated&&!this.isCardInEditPreview)return t.includes("mediaContentId")?(ws.enabled&&ws("%cupdate - player content changed:\n- NEW CONTENT ID = %s\n- isCardInEditPreview = %s","color: gold;",JSON.stringify(this.player.attributes.media_content_id),JSON.stringify(this.isCardInEditPreview)),void setTimeout((()=>{this.updateActions(this.store.player,[])}),100)):void 0}hideSearchType(e){return!!(this.store.config.searchMediaBrowserSearchTypes&&this.store.config.searchMediaBrowserSearchTypes.length>0)&&!this.store.config.searchMediaBrowserSearchTypes?.includes(e)}async onClickAction(e,t=null){throw new Error('onClickAction not implemented for action "'+e+'".')}updateActions(e,t){return ws.enabled&&ws("updateActions - updating actions: %s\n- isCardInEditPreview = %s\n- hasCardEditLoadedMediaList:\n%s",JSON.stringify(Array.from(t.values())),JSON.stringify(this.isCardInEditPreview),JSON.stringify(Ui.hasCardEditLoadedMediaList,null,2)),this.isUpdateInProgress?(ws.enabled&&ws("updateActions - update in progress; ignoring updateActions request"),!1):(this.isUpdateInProgress=!0,this.isCardInEditPreview?(this.isUpdateInProgress=!1,ws.enabled&&ws("updateActions - card is in editpreview; ignoring updateActions request"),!1):e?this.player.attributes.media_content_id?(this.alertClear(),!0):(this.isUpdateInProgress=!1,ws.enabled&&ws("updateActions - player media_content_id reference not set; ignoring updateActions request"),!1):(this.isUpdateInProgress=!1,ws.enabled&&ws("updateActions - player reference not set; ignoring updateActions request"),!1))}updateActionsComplete(e){this.isCardInEditPreview&&0==e.length&&(Ui.hasCardEditLoadedMediaList[this.mediaType]=!0)}}var Ss;Ie([De()],Cs.prototype,"mediaContentId",void 0),function(e){e.AudiobookCopyPresetToClipboard="AudiobookCopyPresetToClipboard",e.AudiobookCopyPresetJsonToClipboard="AudiobookCopyPresetJsonToClipboard",e.AudiobookCopyUriToClipboard="AudiobookCopyUriToClipboard",e.AudiobookFavoriteAdd="AudiobookFavoriteAdd",e.AudiobookFavoriteRemove="AudiobookFavoriteRemove",e.AudiobookFavoriteUpdate="AudiobookFavoriteUpdate",e.AudiobookSearchAuthor="AudiobookSearchAuthor",e.AudiobookSearchNarrator="AudiobookSearchNarrator",e.AudiobookUserPresetAdd="AudiobookUserPresetAdd",e.ChapterCopyPresetToClipboard="ChapterCopyPresetToClipboard",e.ChapterCopyPresetJsonToClipboard="ChapterCopyPresetJsonToClipboard",e.ChapterCopyUriToClipboard="ChapterCopyUriToClipboard",e.ChapterFavoriteAdd="ChapterFavoriteAdd",e.ChapterFavoriteRemove="ChapterFavoriteRemove",e.ChapterFavoriteUpdate="ChapterFavoriteUpdate",e.GetPlayingItem="GetPlayingItem"}(Ss||(Ss={}));class Is extends Cs{render(){super.render(),this.actionAudiobookFavoriteAdd=U`
this.onClickAction(Ss.AudiobookFavoriteAdd)}
slot="icon-button-small"
>
`,this.actionAudiobookFavoriteRemove=U`
this.onClickAction(Ss.AudiobookFavoriteRemove)}
slot="icon-button-small-selected"
>
`;const e=U`
this.onClickAction(Ss.ChapterFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(Ss.ChapterFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
Tt(this.chapter?.audiobook.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
Tt(this.chapter?.external_urls.spotify||"")}
slot="icon-button-small"
>
`,r=U`
this.onClickAction(Ss.AudiobookSearchAuthor)} hide=${this.hideSearchType(Et.AUDIOBOOKS)}>
Other Audiobooks by same Author
this.onClickAction(Ss.AudiobookSearchNarrator)} hide=${this.hideSearchType(Et.AUDIOBOOKS)}>
Other Audiobooks by same Narrator
this.onClickAction(Ss.AudiobookUserPresetAdd)}>
Add Audiobook to User Presets
this.onClickAction(Ss.AudiobookCopyPresetToClipboard)}>
Copy Audiobook Preset Info to Clipboard
this.onClickAction(Ss.AudiobookCopyPresetJsonToClipboard)}>
Copy Audiobook Preset JSON to Clipboard
this.onClickAction(Ss.AudiobookCopyUriToClipboard)}>
Copy Audiobook URI to Clipboard
`,o=U`
this.onClickAction(Ss.ChapterCopyPresetToClipboard)}>
Copy Chapter Preset Info to Clipboard
this.onClickAction(Ss.ChapterCopyPresetJsonToClipboard)}>
Copy Chapter Preset JSON to Clipboard
this.onClickAction(Ss.ChapterCopyUriToClipboard)}>
Copy Chapter URI to Clipboard
`,a=U`
`;return U`
${this.alertError?U`${this.alertError}`:""}
${this.alertInfo?U`${this.alertInfo}`:""}
${(()=>"audiobook"==this.player.attributes.sp_item_type?U`${a}`:U``)()}
`}static get styles(){return[ti,ii,si,a`
.audiobook-info-grid {
grid-template-columns: auto auto 30px auto auto 30px auto auto;
justify-content: left;
}
.colspan-c2-end {
grid-column: 2 / 9; /* grid columns 2 thru 8 */
}
.colspan-c5-end {
grid-column: 5 / 9; /* grid columns 5 thru 8 */
}
`]}async onClickAction(e){try{return e==Ss.AudiobookCopyPresetToClipboard?(st($i(this.chapter?.audiobook,_t(this.chapter?.audiobook,", "))),this.alertInfoSet(we),!0):e==Ss.AudiobookCopyPresetJsonToClipboard?(st(Pi(this.chapter?.audiobook,_t(this.chapter?.audiobook,", "))),this.alertInfoSet(Ce),!0):e==Ss.AudiobookCopyUriToClipboard?(st(this.chapter?.audiobook.uri||""),!0):e==Ss.AudiobookSearchAuthor?(this.dispatchEvent(hi(Et.AUDIOBOOKS,_t(this.chapter?.audiobook," "))),!0):e==Ss.AudiobookSearchNarrator?(this.dispatchEvent(hi(Et.AUDIOBOOKS,$t(this.chapter?.audiobook," "))),!0):e==Ss.ChapterCopyPresetToClipboard?(st($i(this.chapter,this.chapter?.audiobook.name)),this.alertInfoSet(we),!0):e==Ss.ChapterCopyPresetJsonToClipboard?(st(Pi(this.chapter,this.chapter?.audiobook.name)),this.alertInfoSet(Ce),!0):e==Ss.ChapterCopyUriToClipboard?(st(this.chapter?.uri||""),!0):(this.progressShow(),e==Ss.AudiobookUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.chapter?.audiobook)),await Di(this.store.config),this.progressHide()):e==Ss.AudiobookFavoriteAdd?(await this.spotifyPlusService.SaveAudiobookFavorites(this.player,this.chapter?.audiobook.id),this.updateActions(this.player,[Ss.AudiobookFavoriteUpdate])):e==Ss.AudiobookFavoriteRemove?(await this.spotifyPlusService.RemoveAudiobookFavorites(this.player,this.chapter?.audiobook.id),this.updateActions(this.player,[Ss.AudiobookFavoriteUpdate])):e==Ss.ChapterFavoriteAdd?(await this.spotifyPlusService.SaveEpisodeFavorites(this.player,this.chapter?.id),this.updateActions(this.player,[Ss.ChapterFavoriteUpdate])):e==Ss.ChapterFavoriteRemove?(await this.spotifyPlusService.RemoveEpisodeFavorites(this.player,this.chapter?.id),this.updateActions(this.player,[Ss.ChapterFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(Ss.GetPlayingItem)||0==t.length){this.isAudiobookFavorite=void 0,this.isChapterFavorite=void 0;const t=new Promise(((t,i)=>{const s=Ti(this.player.attributes.media_content_id);this.spotifyPlusService.GetChapter(e,s).then((i=>{this.chapter=i,setTimeout((()=>{this.updateActions(e,[Ss.AudiobookFavoriteUpdate,Ss.ChapterFavoriteUpdate])}),50),t(!0)})).catch((e=>{this.chapter=void 0,this.alertErrorSet("Get Episode call failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Ss.AudiobookFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckAudiobookFavorites(e,this.chapter?.audiobook.id).then((e=>{this.isAudiobookFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isAudiobookFavorite=void 0,this.alertErrorSet("Check Audiobook Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Ss.ChapterFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckEpisodeFavorites(e,this.chapter?.id).then((e=>{this.isChapterFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isChapterFavorite=void 0,this.alertErrorSet("Check Episode Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide(),this.updateActionsComplete(t)})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Audiobook actions refresh failed: "+yt(e)),!0}}}Ie([De()],Is.prototype,"isAudiobookFavorite",void 0),Ie([De()],Is.prototype,"isChapterFavorite",void 0),Ie([De()],Is.prototype,"chapter",void 0),customElements.define("spc-player-body-audiobook",Is);customElements.define("spc-player-body-idle",class extends Cs{render(){super.render();const e=It(this.store.config.playerHeaderNoMediaPlayingText,this.store.config,this.player)||"No Media Playing";return U`
`}static get styles(){return[ti,ii,si,a`
/* style container */
.player-idle-container {
display: flex;
align-items: center;
justify-content: flex-start;
margin-top: 0.5rem;
}
.thumbnail {
min-height: var(--spc-player-controls-icon-size, ${o(Ae)});
min-width: var(--spc-player-controls-icon-size, ${o(Ae)});
max-height: var(--spc-player-controls-icon-size, ${o(Ae)});
max-width: var(--spc-player-controls-icon-size, ${o(Ae)});
background-repeat: no-repeat;
background-position: center center;
background-size: 70%;
}
.title {
overflow: hidden;
text-overflow: ellipsis;
font-size: var(--spc-player-minimized-title-font-size, 1.0rem);
line-height: var(--spc-player-minimized-title-font-size, 1.3rem);
font-weight: 500;
text-shadow: 0 0 2px;
color: var(--spc-player-minimized-title-color, #ffffff);
white-space: nowrap;
mix-blend-mode: normal;
min-height: 0.5rem;
padding-left: 0.5rem;
}
`]}styleMediaBrowserItemImage(e){const t={};return e?.includes("svg+xml")?(t["mask-image"]=`url(${e})`,t["background-color"]=`var(--spc-media-browser-items-svgicon-color, ${o(ye)})`):(t["background-image"]=`url(${e})`,t["background-color"]="var(--spc-media-browser-items-svgicon-color, transparent)"),xe(t)}});const Ts=Fe(ce+":player-body-queue");var ks,Es,_s;!function(e){e.EpisodePlay="EpisodePlay",e.GetPlayerQueueInfo="GetPlayerQueueInfo",e.TrackPlay="TrackPlay"}(ks||(ks={}));class $s extends Cs{render(){super.render();let e=U`No items found in Queue
`;return(this.queueInfo?.queue||[]).length>0&&(e=U`${this.queueInfo?.queue.map(((e,t)=>U`
${(()=>"episode"==e.type?U`
this.onClickAction(ks.EpisodePlay,e)}
slot="icon-button"
>
${t+1}
${e.name||""}
${e.show?.name||""}
`:U`
this.onClickAction(ks.TrackPlay,e)}
slot="icon-button"
>
${t+1}
${e.name||""}
${e.artists[0].name||""}
`)()}
`))}`),U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
Player Queue Items
`}static get styles(){return[ti,ii,si,a`
/* style grid container */
.queue-info-grid-container {
margin: 0.25rem;
}
/* style grid container and grid items */
.queue-info-grid {
grid-template-columns: 30px 45px auto auto;
}
/* style grid container and grid items */
.queue-info-grid-no-items {
grid-column-start: 1;
grid-column-end: 4;
}
/* style ha-icon-button controls in grid: icon size, title text */
.queue-info-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}refreshQueueItems(){this.updateActions(this.player,[ks.GetPlayerQueueInfo])}async onClickAction(e,t=null){try{if(this.progressShow(),e==ks.GetPlayerQueueInfo)this.updateActions(this.player,[ks.GetPlayerQueueInfo]);else if(e==ks.EpisodePlay)await this.spotifyPlusService.Card_PlayMediaBrowserItem(this.player,t),this.progressHide();else if(e==ks.TrackPlay){const{uris:e}=kt(this.queueInfo?.queue,t);this.spotifyPlusService.PlayerMediaPlayTracks(this.player,e.join(","),null,null,null,!1),this.progressHide()}else this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(ks.GetPlayerQueueInfo)){if(!e.isUserProductPremium())throw new Error(Se);const t=new Promise(((t,i)=>{this.spotifyPlusService.GetPlayerQueueInfo(e).then((e=>{this.queueInfo=e,Ts.enabled&&Ts("updateActions - queueInfo refreshed successfully"),t(!0)})).catch((e=>{this.queueInfo=void 0,this.alertErrorSet("Get Player Queue Info call failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide(),this.updateActionsComplete(t)})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Queue info refresh failed: "+yt(e)),!0}}}Ie([De()],$s.prototype,"queueInfo",void 0),customElements.define("spc-player-body-queue",$s),function(e){e.EpisodeCopyPresetToClipboard="EpisodeCopyPresetToClipboard",e.EpisodeCopyPresetJsonToClipboard="EpisodeCopyPresetJsonToClipboard",e.EpisodeCopyUriToClipboard="EpisodeCopyUriToClipboard",e.EpisodeFavoriteAdd="EpisodeFavoriteAdd",e.EpisodeFavoriteRemove="EpisodeFavoriteRemove",e.EpisodeFavoriteUpdate="EpisodeFavoriteUpdate",e.EpisodeUserPresetAdd="EpisodeUserPresetAdd",e.GetPlayingItem="GetPlayingItem",e.ShowCopyPresetToClipboard="ShowCopyPresetToClipboard",e.ShowCopyPresetJsonToClipboard="ShowCopyPresetJsonToClipboard",e.ShowCopyUriToClipboard="ShowCopyUriToClipboard",e.ShowFavoriteAdd="ShowFavoriteAdd",e.ShowFavoriteRemove="ShowFavoriteRemove",e.ShowFavoriteUpdate="ShowFavoriteUpdate",e.ShowSearchEpisodes="ShowSearchEpisodes",e.ShowUserPresetAdd="ShowUserPresetAdd"}(Es||(Es={}));class Ps extends Cs{render(){super.render();const e=U`
this.onClickAction(Es.ShowFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(Es.ShowFavoriteRemove)}
slot="icon-button-small-selected"
>
`;this.actionEpisodeFavoriteAdd=U`
this.onClickAction(Es.EpisodeFavoriteAdd)}
slot="icon-button-small"
>
`,this.actionEpisodeFavoriteRemove=U`
this.onClickAction(Es.EpisodeFavoriteRemove)}
slot="icon-button-small-selected"
>
`;const i=U`
Tt(this.episode?.show.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
Tt(this.episode?.external_urls.spotify||"")}
slot="icon-button-small"
>
`,r=U`
this.onClickAction(Es.ShowSearchEpisodes)} hide=${this.hideSearchType(Et.EPISODES)}>
Search for Show Episodes
this.onClickAction(Es.ShowUserPresetAdd)}>
Add Show to User Presets
this.onClickAction(Es.ShowCopyPresetToClipboard)}>
Copy Show Preset Info to Clipboard
this.onClickAction(Es.ShowCopyPresetJsonToClipboard)}>
Copy Show Preset JSON to Clipboard
this.onClickAction(Es.ShowCopyUriToClipboard)}>
Copy Show URI to Clipboard
`,o=U`
this.onClickAction(Es.EpisodeUserPresetAdd)}>
Add Episode to User Presets
this.onClickAction(Es.EpisodeCopyPresetToClipboard)}>
Copy Episode Preset Info to Clipboard
this.onClickAction(Es.EpisodeCopyPresetJsonToClipboard)}>
Copy Episode Preset JSON to Clipboard
this.onClickAction(Es.EpisodeCopyUriToClipboard)}>
Copy Episode URI to Clipboard
`,a=U`
`;return U`
${this.alertError?U`${this.alertError}`:""}
${this.alertInfo?U`${this.alertInfo}`:""}
${(()=>"podcast"==this.player.attributes.sp_item_type?U`${a}`:U``)()}
`}static get styles(){return[ti,ii,si,a`
.show-info-grid {
grid-template-columns: auto auto 30px auto auto 30px auto auto;
justify-content: left;
}
.colspan-c2-end {
grid-column: 2 / 9; /* grid columns 2 thru 8 */
}
`]}async onClickAction(e){try{return e==Es.EpisodeCopyPresetToClipboard?(st($i(this.episode,this.episode?.show.name)),this.alertInfoSet(we),!0):e==Es.EpisodeCopyPresetJsonToClipboard?(st(Pi(this.episode,this.episode?.show.name)),this.alertInfoSet(Ce),!0):e==Es.EpisodeCopyUriToClipboard?(st(this.episode?.uri||""),!0):e==Es.ShowCopyPresetToClipboard?(st($i(this.episode?.show,"Podcast")),this.alertInfoSet(we),!0):e==Es.ShowCopyPresetJsonToClipboard?(st(Pi(this.episode?.show,"Podcast")),this.alertInfoSet(Ce),!0):e==Es.ShowCopyUriToClipboard?(st(this.episode?.show.uri||""),!0):e==Es.ShowSearchEpisodes?(this.dispatchEvent(hi(Et.SHOW_EPISODES,this.episode?.show.name,this.episode?.show.name,this.episode?.show.uri)),!0):(this.progressShow(),e==Es.ShowUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.episode?.show)),await Di(this.store.config),this.progressHide()):e==Es.ShowFavoriteAdd?(await this.spotifyPlusService.SaveShowFavorites(this.player,this.episode?.show.id),this.updateActions(this.player,[Es.ShowFavoriteUpdate])):e==Es.ShowFavoriteRemove?(await this.spotifyPlusService.RemoveShowFavorites(this.player,this.episode?.show.id),this.updateActions(this.player,[Es.ShowFavoriteUpdate])):e==Es.EpisodeUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.episode)),await Di(this.store.config),this.progressHide()):e==Es.EpisodeFavoriteAdd?(await this.spotifyPlusService.SaveEpisodeFavorites(this.player,this.episode?.id),this.updateActions(this.player,[Es.EpisodeFavoriteUpdate])):e==Es.EpisodeFavoriteRemove?(await this.spotifyPlusService.RemoveEpisodeFavorites(this.player,this.episode?.id),this.updateActions(this.player,[Es.EpisodeFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Show action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(Es.GetPlayingItem)||0==t.length){this.isEpisodeFavorite=void 0,this.isShowFavorite=void 0;const t=new Promise(((t,i)=>{const s=Ti(this.player.attributes.media_content_id);this.spotifyPlusService.GetEpisode(e,s).then((i=>{this.episode=i,setTimeout((()=>{this.updateActions(e,[Es.ShowFavoriteUpdate,Es.EpisodeFavoriteUpdate])}),50),t(!0)})).catch((e=>{this.episode=void 0,this.alertErrorSet("Get Episode call failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Es.ShowFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckShowFavorites(e,this.episode?.show.id).then((e=>{this.isShowFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isShowFavorite=void 0,this.alertErrorSet("Check Show Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(Es.EpisodeFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckEpisodeFavorites(e,this.episode?.id).then((e=>{this.isEpisodeFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isEpisodeFavorite=void 0,this.alertErrorSet("Check Episode Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide(),this.updateActionsComplete(t)})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Show actions refresh failed: "+yt(e)),!0}}}Ie([De()],Ps.prototype,"isShowFavorite",void 0),Ie([De()],Ps.prototype,"isEpisodeFavorite",void 0),Ie([De()],Ps.prototype,"episode",void 0),customElements.define("spc-player-body-show",Ps),function(e){e.GetPlayingItem="GetPlayingItem",e.AlbumCopyPresetToClipboard="AlbumCopyPresetToClipboard",e.AlbumCopyPresetJsonToClipboard="AlbumCopyPresetJsonToClipboard",e.AlbumCopyUriToClipboard="AlbumCopyUriToClipboard",e.AlbumFavoriteAdd="AlbumFavoriteAdd",e.AlbumFavoriteRemove="AlbumFavoriteRemove",e.AlbumFavoriteUpdate="AlbumFavoriteUpdate",e.AlbumPlay="AlbumPlay",e.AlbumPlayTrackFavorites="AlbumPlayTrackFavorites",e.AlbumSearchRadio="AlbumSearchRadio",e.AlbumShowTracks="AlbumShowTracks",e.AlbumUserPresetAdd="AlbumUserPresetAdd",e.ArtistCopyPresetToClipboard="ArtistCopyPresetToClipboard",e.ArtistCopyPresetJsonToClipboard="ArtistCopyPresetJsonToClipboard",e.ArtistCopyUriToClipboard="ArtistCopyUriToClipboard",e.ArtistFavoriteAdd="ArtistFavoriteAdd",e.ArtistFavoriteRemove="ArtistFavoriteRemove",e.ArtistFavoriteUpdate="ArtistFavoriteUpdate",e.ArtistPlayTrackFavorites="ArtistPlayTrackFavorites",e.ArtistSearchPlaylists="ArtistSearchPlaylists",e.ArtistSearchRadio="ArtistSearchRadio",e.ArtistSearchTracks="ArtistSearchTracks",e.ArtistShowAlbums="ArtistShowAlbums",e.ArtistShowAlbumsAppearsOn="ArtistShowAlbumsAppearsOn",e.ArtistShowAlbumsCompilation="ArtistShowAlbumsCompilation",e.ArtistShowAlbumsSingle="ArtistShowAlbumsSingle",e.ArtistShowRelatedArtists="ArtistShowRelatedArtists",e.ArtistShowTopTracks="ArtistShowTopTracks",e.ArtistUserPresetAdd="ArtistUserPresetAdd",e.TrackCopyPresetToClipboard="TrackCopyPresetToClipboard",e.TrackCopyPresetJsonToClipboard="TrackCopyPresetJsonToClipboard",e.TrackCopyUriToClipboard="TrackCopyUriToClipboard",e.TrackFavoriteAdd="TrackFavoriteAdd",e.TrackFavoriteRemove="TrackFavoriteRemove",e.TrackFavoriteUpdate="TrackFavoriteUpdate",e.TrackSearchPlaylists="TrackSearchPlaylists",e.TrackSearchRadio="TrackSearchRadio",e.TrackUserPresetAdd="TrackUserPresetAdd"}(_s||(_s={}));class Fs extends Cs{render(){super.render();const e=U`
this.onClickAction(_s.ArtistFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(_s.ArtistFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
this.onClickAction(_s.AlbumFavoriteAdd)}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(_s.AlbumFavoriteRemove)}
slot="icon-button-small-selected"
>
`;this.actionTrackFavoriteAdd=U`
this.onClickAction(_s.TrackFavoriteAdd)}
slot="icon-button-small"
>
`,this.actionTrackFavoriteRemove=U`
this.onClickAction(_s.TrackFavoriteRemove)}
slot="icon-button-small-selected"
>
`;const r=U`
Tt(this.track?.artists[0].external_urls.spotify||"")}
slot="icon-button-small"
>
`,o=U`
Tt(this.track?.album.external_urls.spotify||"")}
slot="icon-button-small"
>
`,a=U`
Tt(this.track?.external_urls.spotify||"")}
slot="icon-button-small"
>
`,n=U`
this.onClickAction(_s.TrackSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Track
this.onClickAction(_s.TrackSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Track Radio
this.onClickAction(_s.TrackUserPresetAdd)}>
Add Track to User Presets
this.onClickAction(_s.TrackCopyPresetToClipboard)}>
Copy Track Preset Info to Clipboard
this.onClickAction(_s.TrackCopyPresetJsonToClipboard)}>
Copy Track Preset JSON to Clipboard
this.onClickAction(_s.TrackCopyUriToClipboard)}>
Copy Track URI to Clipboard
`,l=U`
this.onClickAction(_s.AlbumPlay)}>
Play Album
this.onClickAction(_s.AlbumPlayTrackFavorites)}>
Play Favorite Tracks from this Album
this.onClickAction(_s.AlbumShowTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Album Tracks
this.onClickAction(_s.AlbumSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Album Radio
this.onClickAction(_s.AlbumUserPresetAdd)}>
Add Album to User Presets
this.onClickAction(_s.AlbumCopyPresetToClipboard)}>
Copy Album Preset Info to Clipboard
this.onClickAction(_s.AlbumCopyPresetJsonToClipboard)}>
Copy Album Preset JSON to Clipboard
this.onClickAction(_s.AlbumCopyUriToClipboard)}>
Copy Album URI to Clipboard
`,c=U`
this.onClickAction(_s.ArtistPlayTrackFavorites)}>
Play Favorite Tracks from this Artist
this.onClickAction(_s.ArtistSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Artist
this.onClickAction(_s.ArtistSearchTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Search Tracks for Artist
this.onClickAction(_s.ArtistSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Artist Radio
this.onClickAction(_s.ArtistShowTopTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Artist Top Tracks
this.onClickAction(_s.ArtistShowAlbums)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums
this.onClickAction(_s.ArtistShowAlbumsCompilation)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Compilations
this.onClickAction(_s.ArtistShowAlbumsSingle)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Singles
this.onClickAction(_s.ArtistShowAlbumsAppearsOn)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums AppearsOn
this.onClickAction(_s.ArtistShowRelatedArtists)} hide=${this.hideSearchType(Et.ARTISTS)}>
Show Related Artists
this.onClickAction(_s.ArtistUserPresetAdd)}>
Add Artist to User Presets
this.onClickAction(_s.ArtistCopyPresetToClipboard)}>
Copy Artist Preset Info to Clipboard
this.onClickAction(_s.ArtistCopyPresetJsonToClipboard)}>
Copy Artist Preset JSON to Clipboard
this.onClickAction(_s.ArtistCopyUriToClipboard)}>
Copy Artist URI to Clipboard
`,d=U`
`;return U`
${this.alertError?U`${this.alertError}`:""}
${this.alertInfo?U`${this.alertInfo}`:""}
${(()=>"track"==this.player.attributes.sp_item_type?U`${d}`:U``)()}
`}static get styles(){return[ti,ii,si,a`
.track-info-grid {
grid-template-columns: auto auto 30px auto auto 30px auto auto;
justify-content: left;
}
.colspan-c2-end {
grid-column: 2 / 9; /* grid columns 2 thru 8 */
}
`]}async onClickAction(e){try{if(this.isCardInEditPreview)return!1;if(e==_s.AlbumCopyPresetToClipboard)return st($i(this.track?.album,this.track?.album.artists[0].name)),this.alertInfoSet(we),!0;if(e==_s.AlbumCopyPresetJsonToClipboard)return st(Pi(this.track?.album,this.track?.album.artists[0].name)),this.alertInfoSet(Ce),!0;if(e==_s.AlbumCopyUriToClipboard)return st(this.track?.album.uri||""),!0;if(e==_s.AlbumSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.track?.album.name+ve+this.track?.artists[0].name)),!0;if(e==_s.AlbumShowTracks)return this.dispatchEvent(hi(Et.ALBUM_TRACKS,this.track?.album.name+"; "+this.track?.artists[0].name,this.track?.album.name,this.track?.album.uri,null,this.track?.album)),!0;if(e==_s.ArtistCopyPresetToClipboard)return st($i(this.track?.artists[0])),this.alertInfoSet(we),!0;if(e==_s.ArtistCopyPresetJsonToClipboard)return st(Pi(this.track?.artists[0])),this.alertInfoSet(Ce),!0;if(e==_s.ArtistCopyUriToClipboard)return st(this.track?.artists[0].uri||""),!0;if(e==_s.ArtistSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.track?.artists[0].name)),!0;if(e==_s.ArtistSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.track?.artists[0].name+ve)),!0;if(e==_s.ArtistSearchTracks)return this.dispatchEvent(hi(Et.TRACKS,this.track?.artists[0].name)),!0;if(e==_s.ArtistShowAlbums)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.ArtistShowAlbumsAppearsOn)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_APPEARSON,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.ArtistShowAlbumsCompilation)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_COMPILATION,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.ArtistShowAlbumsSingle)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_SINGLE,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.ArtistShowRelatedArtists)return this.dispatchEvent(hi(Et.ARTIST_RELATED_ARTISTS,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.ArtistShowTopTracks)return this.dispatchEvent(hi(Et.ARTIST_TOP_TRACKS,this.track?.artists[0].name,this.track?.artists[0].name,this.track?.artists[0].uri)),!0;if(e==_s.TrackCopyPresetToClipboard)return st($i(this.track,this.track?.artists[0].name)),this.alertInfoSet(we),!0;if(e==_s.TrackCopyPresetJsonToClipboard)return st(Pi(this.track,this.track?.artists[0].name)),this.alertInfoSet(Ce),!0;if(e==_s.TrackCopyUriToClipboard)return st(this.track?.uri||""),!0;if(e==_s.TrackSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.track?.name+" "+this.track?.artists[0].name)),!0;if(e==_s.TrackSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.track?.name+ve+this.track?.artists[0].name)),!0;if(this.progressShow(),e==_s.AlbumUserPresetAdd)this.store.config.userPresets?.unshift(_i(this.track?.album)),await Di(this.store.config),this.progressHide();else if(e==_s.AlbumFavoriteAdd)await this.spotifyPlusService.SaveAlbumFavorites(this.player,this.track?.album.id),this.updateActions(this.player,[_s.AlbumFavoriteUpdate]);else if(e==_s.AlbumFavoriteRemove)await this.spotifyPlusService.RemoveAlbumFavorites(this.player,this.track?.album.id),this.updateActions(this.player,[_s.AlbumFavoriteUpdate]);else if(e==_s.AlbumPlay)await this.spotifyPlusService.PlayerMediaPlayContext(this.player,this.track?.album.uri),this.progressHide(),this.store.card.SetSection(et.PLAYER);else if(e==_s.AlbumPlayTrackFavorites){const e=this.store.config.albumFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,null,this.track?.album.uri),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else if(e==_s.ArtistUserPresetAdd)this.track&&(this.track.artists[0].image_url=this.track?.album.image_url,this.store.config.userPresets?.unshift(_i(this.track?.artists[0])),await Di(this.store.config),this.progressHide());else if(e==_s.ArtistFavoriteAdd)await this.spotifyPlusService.FollowArtists(this.player,this.track?.artists[0].id),this.updateActions(this.player,[_s.ArtistFavoriteUpdate]);else if(e==_s.ArtistFavoriteRemove)await this.spotifyPlusService.UnfollowArtists(this.player,this.track?.artists[0].id),this.updateActions(this.player,[_s.ArtistFavoriteUpdate]);else if(e==_s.ArtistPlayTrackFavorites){const e=this.store.config.artistFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,this.track?.artists[0].uri,null),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else e==_s.TrackUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.track)),await Di(this.store.config),this.progressHide()):e==_s.TrackFavoriteAdd?(await this.spotifyPlusService.SaveTrackFavorites(this.player,this.track?.id),this.updateActions(this.player,[_s.TrackFavoriteUpdate])):e==_s.TrackFavoriteRemove?(await this.spotifyPlusService.RemoveTrackFavorites(this.player,this.track?.id),this.updateActions(this.player,[_s.TrackFavoriteUpdate])):this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Track action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(_s.GetPlayingItem)||0==t.length){this.isAlbumFavorite=void 0,this.isArtistFavorite=void 0,this.isTrackFavorite=void 0;const t=new Promise(((t,i)=>{const s=Ti(this.player.attributes.media_content_id);this.spotifyPlusService.GetTrack(e,s).then((i=>{this.track=i,setTimeout((()=>{this.updateActions(e,[_s.TrackFavoriteUpdate,_s.AlbumFavoriteUpdate,_s.ArtistFavoriteUpdate])}),50),t(!0)})).catch((e=>{this.track=void 0,this.alertErrorSet("Get Track call failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(_s.AlbumFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckAlbumFavorites(e,this.track?.album.id).then((e=>{this.isAlbumFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isAlbumFavorite=void 0,this.alertErrorSet("Check Album Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(_s.ArtistFavoriteUpdate)){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckArtistsFollowing(e,this.track?.artists[0].id).then((e=>{this.isArtistFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isArtistFavorite=void 0,this.alertErrorSet("Check Artist Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(_s.TrackFavoriteUpdate)){const t=new Promise(((t,i)=>{let s=this.track?.id;this.track?.is_linked_from&&(s=this.track?.id+","+this.track?.id_origin),this.spotifyPlusService.CheckTrackFavorites(e,s).then((e=>{const i=Object.keys(e);this.isTrackFavorite=e[i[0]],i.length>1&&(this.isTrackFavorite=e[i[0]]||e[i[1]]),t(!0)})).catch((e=>{this.isTrackFavorite=void 0,this.alertErrorSet("Check Track Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide(),this.updateActionsComplete(t)})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Track actions refresh failed: "+yt(e)),!0}}}Ie([De()],Fs.prototype,"isAlbumFavorite",void 0),Ie([De()],Fs.prototype,"isArtistFavorite",void 0),Ie([De()],Fs.prototype,"isTrackFavorite",void 0),Ie([De()],Fs.prototype,"track",void 0),customElements.define("spc-player-body-track",Fs);const Rs=Fe(ce+":player-controls"),{NEXT_TRACK:Ls,PAUSE:Os,PLAY:Ms,PREVIOUS_TRACK:xs,REPEAT_SET:Bs,SHUFFLE_SET:Us,TURN_ON:Hs,TURN_OFF:Vs}=wi,Ds=9e11,Ns=99e10,qs=999e9;class Gs extends ai{render(){this.config=this.store.config,this.player=this.store.player,this.mediaControlService=this.store.mediaControlService,this.spotifyPlusService=this.store.spotifyPlusService;const e=[Ci.ON,Ci.PLAYING,Ci.PAUSED,Ci.BUFFERING].includes(this.player.state)&&V,t=[Ci.IDLE].includes(this.player.state)&&V,i=[Ci.OFF].includes(this.player.state)&&V,s=[bi.ONE,bi.ALL].includes(this.player.attributes.repeat||bi.OFF),r=this.player.attributes.shuffle,o=this.player.state==Ci.PAUSED,a=this.player.state==Ci.OFF,n=this.isActionFavoritesVisible,l=this.isQueueItemsVisible;return U`
this.onClickAction(Ds)} hide=${this.hideFeature(Ds)} .path=${"M11 9H13V7H11V9M14 17V15H13V11H10V13H11V15H10V17H14M5 3H19C20.1 3 21 3.89 21 5V19C21 19.53 20.79 20.04 20.41 20.41C20.04 20.79 19.53 21 19 21H5C4.47 21 3.96 20.79 3.59 20.41C3.21 20.04 3 19.53 3 19V5C3 3.89 3.89 3 5 3M19 19V5H5V19H19Z"} label="More Information" style=${this.styleIcon(n)}>
this.onClickAction(Us)} hide=${this.hideFeature(Us)} .path=${this.getShuffleIcon()} label="Shuffle" style=${this.styleIcon(r)}>
this.onClickAction(xs)} hide=${this.hideFeature(xs)} .path=${"M6,18V6H8V18H6M9.5,12L18,6V18L9.5,12Z"} label="Previous Track" style=${this.styleIcon()}>
this.onClickAction(Ms)} hide=${this.hideFeature(Ms)} .path=${Wt} label="Play" style=${this.styleIcon(o)}>
this.onClickAction(Os)} hide=${this.hideFeature(Os)} .path=${"M14,19H18V5H14M6,19H10V5H6V19Z"} label="Pause" style=${this.styleIcon()}>
this.onClickAction(Ls)} hide=${this.hideFeature(Ls)} .path=${"M16,18H18V6H16M6,18L14.5,12L6,6V18Z"} label="Next Track" style=${this.styleIcon()}>
this.onClickAction(Bs)} hide=${this.hideFeature(Bs)} .path=${this.getRepeatIcon()} label="Repeat" style=${this.styleIcon(s)} >
this.onClickAction(Ns)} hide=${this.hideFeature(Ns)} .path=${zt} label="Play Queue Information" style=${this.styleIcon(l)} >
this.onClickAction(Hs)} hide=${this.hideFeature(Hs)} .path=${Kt} label="Turn On" style=${this.styleIcon(a)}>
this.onClickAction(qs)} hide=${this.hideFeature(qs)} .path=${Xt} label="Devices" style=${this.styleIcon()}>
this.onClickAction(Vs)} hide=${this.hideFeature(Vs)} .path=${Kt} label="Turn Off" style=${this.styleIcon()}>
this.onClickAction(Ms)} hide=${this.hideFeature(Ms)} .path=${Wt} label="Play" style=${this.styleIcon(!0)}>
this.onClickAction(qs)} hide=${this.hideFeature(qs)} .path=${Xt} label="Devices" style=${this.styleIcon()}>
`}static get styles(){return a`
.player-controls-container {
max-width: var(--spc-player-controls-max-width, 40rem);
text-align: center;
overflow: hidden auto;
box-sizing: border-box;
/* border: 1px solid red; /* FOR TESTING CONTROL LAYOUT CHANGES */
}
.player-volume-container {
max-width: var(--spc-player-controls-max-width, 40rem);
text-align: center;
overflow: hidden auto;
box-sizing: border-box;
/* border: 1px solid blue; /* FOR TESTING CONTROL LAYOUT CHANGES */
}
.icons {
display: inline-flex;
align-items: center;
justify-content: var(--spc-player-controls-icon-justify-content, center);
overflow: hidden;
color: var(--spc-player-controls-icon-color, #ffffff);
--ha-icon-button-size: var(--spc-player-controls-icon-button-size, ${o(ge)});
--mdc-icon-size: var(--spc-player-controls-icon-size, ${o(Ae)});
mix-blend-mode: normal;
width: 100%;
}
.iconsPower {
display: inline-flex;
align-items: center;
justify-content: var(--spc-player-controls-icon-justify-content, center);
overflow: hidden;
color: var(--spc-player-controls-icon-color, #ffffff);
--ha-icon-button-size: var(--spc-player-controls-icon-button-size, ${o(ge)});
--mdc-icon-size: var(--spc-player-controls-icon-size, ${o(Ae)});
mix-blend-mode: normal;
width: 100%;
}
.iconsVolume {
display: inline;
align-items: center;
overflow: hidden;
color: var(--spc-player-controls-icon-color, #ffffff);
--ha-icon-button-size: var(--spc-player-controls-icon-button-size, ${o(ge)});
--mdc-icon-size: var(--spc-player-controls-icon-size, ${o(Ae)});
mix-blend-mode: normal;
}
*[hide] {
display: none;
}
.flex-1 {
flex: 1;
}
`}constructor(){super(),this.onKeyDown_EventListenerBound=this.onKeyDown.bind(this)}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.onKeyDown_EventListenerBound)}disconnectedCallback(){document.removeEventListener("keydown",this.onKeyDown_EventListenerBound),super.disconnectedCallback()}update(e){super.update(e);Array.from(e.keys()).includes("mediaContentId")&&setTimeout((()=>{this.toggleDisplayPlayerBodyQueue()}),50)}toggleDisplayActionFavorites(){const e=this.parentElement?.querySelector(".player-section-body-content");e&&(e.style.display=this.isActionFavoritesVisible?"block":"none",e.style.opacity=this.isActionFavoritesVisible?"1":"0")}toggleDisplayPlayerBodyQueue(){const e=this.parentElement?.querySelector("#elmPlayerBodyQueue");e?(e.style.display=this.isQueueItemsVisible?"block":"none",e.style.opacity=this.isQueueItemsVisible?"1":"0",this.isQueueItemsVisible?(Rs("toggleDisplayPlayerBodyQueue - calling for refresh of queue items"),e.refreshQueueItems()):Rs("toggleDisplayPlayerBodyQueue - queue items not visible; isQueueItemsVisible = %s",JSON.stringify(this.isQueueItemsVisible))):Rs("toggleDisplayPlayerBodyQueue - could not find queue items #elmPlayerBodyQueue selector!")}onKeyDown(e){"Escape"===e.key&&(this.isActionFavoritesVisible?this.onClickAction(Ds):this.isQueueItemsVisible&&this.onClickAction(Ns))}async onClickAction(e){try{if(e==Ds)return this.isCardInEditPreview?(this.alertInfoSet("Action Favorites cannot be displayed while editing card configuration"),!0):(this.isActionFavoritesVisible=!this.isActionFavoritesVisible,Rs.enabled&&Rs("update - action favorites toggled - isActionFavoritesVisible = %s",JSON.stringify(this.isActionFavoritesVisible)),this.isQueueItemsVisible?(Rs("update - queue items visible; imediately closing queue items, and delay opening action favorites"),this.isQueueItemsVisible=!1,this.toggleDisplayPlayerBodyQueue(),setTimeout((()=>{this.toggleDisplayActionFavorites()}),250)):(Rs("update - queue items not visible; immediately toggling action favorites"),this.toggleDisplayActionFavorites()),!0);if(e==qs)this.store.card.SetSection(et.DEVICES);else if(e==Ns)return this.isCardInEditPreview?(this.alertInfoSet("Queue items cannot be displayed while editing card configuration"),!0):(this.isQueueItemsVisible=!this.isQueueItemsVisible,Rs.enabled&&Rs("update - queue items toggled - isQueueItemsVisible = %s",JSON.stringify(this.isQueueItemsVisible)),this.isActionFavoritesVisible?(Rs("update - action favorites visible; imeediately closing action favorites, and delay opening queue items"),this.isActionFavoritesVisible=!1,this.toggleDisplayActionFavorites(),setTimeout((()=>{this.toggleDisplayPlayerBodyQueue()}),250)):(Rs("update - action favorites not visible; immediately opening queue items"),this.toggleDisplayPlayerBodyQueue()),!0);if(this.progressShow(),e==Os)await this.mediaControlService.media_pause(this.player);else if(e==Ms)await this.mediaControlService.media_play(this.player);else if(e==Ls)await this.mediaControlService.media_next_track(this.player);else if(e==xs){const e=this.player?.attributes.media_position||0,t=this.player?.isPlaying(),i=this.player?.attributes.media_position_updated_at||0;let s=e;t&&(s=e+(Date.now()-new Date(i).getTime())/1e3),s>8?await this.mediaControlService.media_seek(this.player,0):await this.mediaControlService.media_previous_track(this.player)}else if(e==Bs){let e=bi.OFF;this.player.attributes.repeat==bi.OFF?e=bi.ONE:this.player.attributes.repeat==bi.ONE?e=bi.ALL:this.player.attributes.repeat==bi.ALL&&(e=bi.OFF),await this.mediaControlService.repeat_set(this.player,e)}else e==Us?await this.mediaControlService.shuffle_set(this.player,!this.player.attributes.shuffle):e==Vs?await this.spotifyPlusService.turn_off(this.player):e==Hs&&await this.spotifyPlusService.turn_on(this.player);return this.progressHide(),!0}catch(e){return this.alertErrorSet("Control action failed: "+yt(e)),this.progressHide(),!0}}hideFeature(e){if(e==Os){if(this.player.supportsFeature(Os)){if(this.player.state==Ci.PAUSED)return;return this.config.playerControlsHidePlayPause||V}}else if(e==Ms){if(this.player.supportsFeature(Ms)){if(this.player.state==Ci.PLAYING)return;return this.config.playerControlsHidePlayPause||V}}else if(e==Ls){if(this.player.supportsFeature(Ls))return this.config.playerControlsHideTrackNext||V}else if(e==xs){if(this.player.supportsFeature(xs))return this.config.playerControlsHideTrackPrev||V}else if(e==Bs){if(this.player.supportsFeature(Bs))return this.config.playerControlsHideRepeat||V}else if(e==Us){if(this.player.supportsFeature(Us))return this.config.playerControlsHideShuffle||V}else{if(e==Ds)return this.config.playerControlsHideFavorites||V;if(e==Ns)return this.config.playerControlsHidePlayQueue||V;if(e==Hs){if(this.player.supportsFeature(Hs))return![Ci.OFF,Ci.STANDBY].includes(this.player.state)||(!!this.config.playerVolumeControlsHidePower||V)}else if(e==Vs){if(this.player.supportsFeature(Vs))return![Ci.IDLE].includes(this.player.state)||(!!this.config.playerVolumeControlsHidePower||V)}else if(e==qs&&this.config.playerMinimizeOnIdle&&this.config.sections?.includes(et.DEVICES))return V}return!0}alertInfoSet(e){const t=ft("#spcPlayer",this);t&&t.alertInfoSet(e)}alertErrorSet(e){const t=ft("#spcPlayer",this);t&&t.alertErrorSet(e)}getRepeatIcon(){return this.player.attributes.repeat==bi.ALL?"M17,17H7V14L3,18L7,22V19H19V13H17M7,7H17V10L21,6L17,2V5H5V11H7V7Z":this.player.attributes.repeat==bi.ONE?"M13,15V9H12L10,10V11H11.5V15M17,17H7V14L3,18L7,22V19H19V13H17M7,7H17V10L21,6L17,2V5H5V11H7V7Z":"M2,5.27L3.28,4L20,20.72L18.73,22L15.73,19H7V22L3,18L7,14V17H13.73L7,10.27V11H5V8.27L2,5.27M17,13H19V17.18L17,15.18V13M17,5V2L21,6L17,10V7H8.82L6.82,5H17Z"}getShuffleIcon(){return this.player.attributes.shuffle?"M14.83,13.41L13.42,14.82L16.55,17.95L14.5,20H20V14.5L17.96,16.54L14.83,13.41M14.5,4L16.54,6.04L4,18.59L5.41,20L17.96,7.46L20,9.5V4M10.59,9.17L5.41,4L4,5.41L9.17,10.58L10.59,9.17Z":"M16,4.5V7H5V9H16V11.5L19.5,8M16,12.5V15H5V17H16V19.5L19.5,16"}styleContainer(e,t){const i={"margin-bottom":"0px"};return this.config.playerMinimizeOnIdle&&(e||t)&&(i.margin="0px",i.padding="2px"),xe(i)}styleIcon(e=null){const t={},i=this.config.playerControlsIconMargin;return i&&(t.margin=`${i}`),e&&(t.color=`var(--spc-player-controls-icon-toggle-color, ${ye})`),xe(t)}}Ie([Ve({attribute:!1})],Gs.prototype,"mediaContentId",void 0),Ie([De()],Gs.prototype,"isActionFavoritesVisible",void 0),Ie([De()],Gs.prototype,"isQueueItemsVisible",void 0),customElements.define("spc-player-controls",Gs);const{TURN_OFF:Js,TURN_ON:Ws,VOLUME_MUTE:zs,VOLUME_SET:js,VOLUME_STEP:Ys}=wi,Ks=9e11,Zs=900000000001;class Xs extends ai{constructor(){super(...arguments),this.slim=!1}render(){this.config=this.store.config,this.spotifyPlusService=this.store.spotifyPlusService;const e=this.config.playerVolumeControlsHideMute||!1,t=this.config.playerVolumeControlsHideLevels||!1,i=this.player.isMuted()?"M3,9H7L12,4V20L7,15H3V9M16.59,12L14,9.41L15.41,8L18,10.59L20.59,8L22,9.41L19.41,12L22,14.59L20.59,16L18,13.41L15.41,16L14,14.59L16.59,12Z":"M14,3.23V5.29C16.89,6.15 19,8.83 19,12C19,15.17 16.89,17.84 14,18.7V20.77C18,19.86 21,16.28 21,12C21,7.72 18,4.14 14,3.23M16.5,12C16.5,10.23 15.5,8.71 14,7.97V16C15.5,15.29 16.5,13.76 16.5,12M3,9V15H7L12,20V4L7,9H3Z",s=this.config.playerVolumeControlsShowPlusMinus&&!0,r=this.player.state==Ci.OFF,o=this.player.attributes.is_volume_muted,a=this.player.getVolume(),n=Math.round(Math.abs((a-0)/100*100));return U`
${e?U``:U`
`}
${s?U`
this.onClickAction(Ks)} hide=${this.hideFeature(Ys)} label="Decrease">
`:U``}
${s?U`
this.onClickAction(Zs)} hide=${this.hideFeature(Ys)} label="Increase">
`:U``}
this.onClickAction(Ws)} hide=${this.hideFeature(Ws)} label="Turn On" style=${this.styleIcon(r)}>
this.onClickAction(Js)} hide=${this.hideFeature(Js)} label="Turn Off" style=${this.styleIcon()}>
`}async onVolumeValueChanged(e){try{this.progressShow();let t=Number.parseInt(e?.target?.value);const i=this.config.playerVolumeMaxValue||100;if(t>i){t=i;const s=e?.target;s&&(s.value=t+""),this.alertInfoSet("Selected volume level was greater than Max Volume limit set in card configuration; max limit value of "+i+" was applied.")}return await this.spotifyPlusService.volume_set(this.player,t),!0}catch(e){return this.alertErrorSet("Volume set failed: "+yt(e)),!0}finally{this.progressHide()}}async onMuteClick(){try{return this.progressShow(),await this.spotifyPlusService.volume_mute_toggle(this.player),!0}catch(e){return this.alertErrorSet("Volume mute failed: "+yt(e)),!0}finally{this.progressHide()}}styleVolumeSlider(){if(this.config.playerVolumeControlsHideSlider||!1)return"display: none"}async onClickAction(e){try{return this.progressShow(),e==Js?await this.spotifyPlusService.turn_off(this.player):e==Ws?await this.spotifyPlusService.turn_on(this.player):e==Ks?await this.spotifyPlusService.volume_down(this.player):e==Zs&&await this.spotifyPlusService.volume_up(this.player),!0}catch(e){return this.alertErrorSet("Volume action failed: "+yt(e)),!0}finally{this.progressHide()}}hideFeature(e){if(e==Ws){if(this.player.supportsFeature(Ws))return![Ci.OFF,Ci.UNKNOWN,Ci.STANDBY].includes(this.player.state)||(!!this.config.playerVolumeControlsHidePower||V)}else if(e==Js){if(this.player.supportsFeature(Js))return!![Ci.OFF,Ci.UNKNOWN,Ci.STANDBY].includes(this.player.state)||(!!this.config.playerVolumeControlsHidePower||V)}else if(e==zs){if(this.player.supportsFeature(zs))return V}else if(e==js){if(this.player.supportsFeature(js))return V}else if(e==Ys&&this.player.supportsFeature(Ys))return V;return!0}alertErrorSet(e){const t=ft("#spcPlayer",this);t&&t.alertErrorSet(e)}alertInfoSet(e){const t=ft("#spcPlayer",this);t&&t.alertInfoSet(e)}styleIcon(e=null){const t={},i=this.config.playerControlsIconMargin;return i&&(t.margin=`${i}`),e&&(t.color=`var(--spc-player-controls-icon-toggle-color, ${ye})`),xe(t)}static get styles(){return a`
ha-control-slider {
--control-slider-color: var(--spc-player-volume-slider-color, var(--spc-player-controls-color, var(--dark-primary-color, ${o(ye)})));
--control-slider-thickness: var(--spc-player-volume-slider-thickness, 1rem);
border: 1px solid rgba(255, 255, 255, 0.10);
border-radius: var(--control-slider-border-radius);
box-sizing: border-box;
}
ha-control-slider[disabled] {
--control-slider-color: var(--disabled-text-color);
--control-slider-thickness: var(--spc-player-volume-slider-thickness, 1rem);
border: 1px solid rgba(255, 255, 255, 0.10);
border-radius: var(--control-slider-border-radius);
box-sizing: border-box;
}
.volume-container {
flex: 1;
/*border: 1px solid blue; /* FOR TESTING CONTROL LAYOUT CHANGES */
}
.volume-slider {
flex: 1;
padding-right: 0.0rem;
align-content: flex-end;
color: var(--spc-player-volume-label-color, var(--spc-player-controls-color, #ffffff));
}
.volume-level {
font-size: var(--spc-player-volume-label-font-size, x-small);
display: flex;
}
.volume-level-min {
flex: 0;
text-align: left;
margin-right: 4px;
}
.volume-level-pct {
text-align: right;
color: var(--spc-player-volume-slider-color, var(--spc-player-controls-color, var(--dark-primary-color, ${o(ye)})));
}
.volume-level-max {
flex: 100;
text-align: right;
margin-left: 4px;
}
*[slim] * {
--control-slider-thickness: var(--spc-player-volume-slider-thickness, 10px);
--ha-icon-button-size: 30px;
--mdc-icon-size: 20px;
}
*[slim] .volume-level {
display: none;
}
*[slim] .volume-slider {
display: flex;
align-items: center;
}
.icons {
justify-content: center;
display: inline-flex;
align-items: center;
mix-blend-mode: normal;
overflow: hidden;
color: var(--spc-player-controls-icon-color, #ffffff);
width: 100%;
--ha-icon-button-size: var(--spc-player-controls-icon-button-size, ${o(ge)});
--mdc-icon-size: var(--spc-player-controls-icon-size, ${o(Ae)});
}
*[hide] {
display: none;
}
`}}Ie([Ve({attribute:!1})],Xs.prototype,"player",void 0),Ie([Ve()],Xs.prototype,"slim",void 0),customElements.define("spc-player-volume",Xs);let Qs=class extends ai{render(){this.config=this.store.config,this.player=this.store.player;const e=this.player.isPoweredOffOrIdle();return U`
${this.alertError?U`${this.alertError}`:""}
${this.alertInfo?U`${this.alertInfo}`:""}
${(()=>e&&this.config.playerMinimizeOnIdle&&"fill"!=this.config.height?U`
`:1==(this.config.playerControlsHideFavorites||!1)?U``:"track"==this.player.attributes.sp_item_type?U`
`:"podcast"==this.player.attributes.sp_item_type?U`
`:"audiobook"==this.player.attributes.sp_item_type?U`
`:U`
`)()}
${(()=>e&&this.config.playerMinimizeOnIdle&&"fill"!=this.config.height||1==(this.config.playerControlsHidePlayQueue||!1)?U``:"track"==this.player.attributes.sp_item_type||"podcast"==this.player.attributes.sp_item_type||"audiobook"==this.player.attributes.sp_item_type?U`
`:U`
`)()}
`}static get styles(){return a`
.hoverable:focus,
.hoverable:hover {
color: var(--dark-primary-color);
}
.hoverable:active {
color: var(--primary-color);
}
.player-section-container {
display: grid;
grid-template-columns: 100%;
grid-template-rows: min-content auto min-content;
grid-template-areas:
'header'
'body'
'controls';
align-items: center;
background-position: center;
background-repeat: no-repeat;
background-size: var(--spc-player-background-size, var(--spc-player-background-size-default, 100% 100%)); /* PLAYER_BACKGROUND_IMAGE_SIZE_DEFAULT */
text-align: -webkit-center;
height: 100%;
width: 100%;
}
.player-section-header {
/* border: 1px solid red; /* FOR TESTING CONTROL LAYOUT CHANGES */
grid-area: header;
padding: 0.25rem 0.5rem 0rem 0.5rem;
box-sizing: border-box;
background: linear-gradient(180deg, var(--spc-player-header-bg-color, ${o(fe)}) 30%, transparent 100%);
background-repeat: no-repeat;
}
.player-section-body {
/* border: 1px solid orange; /* FOR TESTING CONTROL LAYOUT CHANGES */
grid-area: body;
height: 100%;
overflow: hidden;
padding: 0rem 0.5rem 0rem 0.5rem;
box-sizing: border-box;
background: transparent;
}
.player-section-body-content {
/* border: 1px solid yellow; /* FOR TESTING CONTROL LAYOUT CHANGES */
height: inherit;
background: transparent;
overflow: hidden;
display: none; /* don't display initially */
/* for fade-in, fade-out support */
transition: opacity 0.25s, display 0.25s;
transition-behavior: allow-discrete; /* Note: be sure to write this after the shorthand */
}
.player-section-body-queue {
/* border: 1px solid yellow; /* FOR TESTING CONTROL LAYOUT CHANGES */
height: inherit;
background: transparent;
overflow: hidden;
display: none; /* don't display initially */
/* for fade-in, fade-out support */
transition: opacity 0.25s, display 0.25s;
transition-behavior: allow-discrete; /* Note: be sure to write this after the shorthand */
}
.player-section-controls {
/* border: 1px solid blue; /* FOR TESTING CONTROL LAYOUT CHANGES */
grid-area: controls;
overflow-y: auto;
padding: 0rem 0.5rem 0.25rem 0.5rem;
box-sizing: border-box;
background: linear-gradient(0deg, var(--spc-player-controls-bg-color, ${o(fe)}) 30%, transparent 100%);
background-repeat: no-repeat;
}
/* have to set a background color for alerts due to parent background transparency. */
.player-alert-bgcolor {
background-color: rgba(var(--rgb-card-background-color), 0.92);
}
`}stylePlayerSection(){const e={},t=this.player.isPoweredOffOrUnknown(),i=this.player.isIdle();let s,r=!1;const o=this.config.customImageUrls?.default,a=this.config.customImageUrls?.playerBackground,n=this.config.customImageUrls?.playerIdleBackground,l=this.config.customImageUrls?.playerOffBackground;let c,d;this.store.player&&(c=this.store.player.attributes.media_content_id,d=this.store.player.attributes.entity_picture||this.store.player.attributes.entity_picture_local,d&&(d=this.store.hass.hassUrl(d))),this.config.playerBackgroundImageSize?e["--spc-player-background-size"]=`${this.config.playerBackgroundImageSize}`:"fill"==this.config.width&&(e["--spc-player-background-size-default"]="contain");const h=this.config.playerControlsMaxWidth;h&&(e["--spc-player-controls-max-width"]=`${h}`);const p=this.config.playerControlsIconJustifyContent;p&&(e["--spc-player-controls-icon-justify-content"]=`${p}`),t?(this.store.card.playerMediaContentId="configImagePlayerBgOff","none"==(l||"").toLowerCase()?e["background-image"]=void 0:l?(e["background-image"]=`url(${l})`,s=l):this.config.playerMinimizeOnIdle?e["background-image"]="var(--spc-player-background-image-off)":(e["background-image"]=`var(--spc-player-background-image-off, url(${ue}))`,e["--spc-player-background-size-default"]=`${me}`,r=!0),this.config.playerBackgroundImageSize&&(e["--spc-player-background-size"]=`${this.config.playerBackgroundImageSize}`)):i?(this.store.card.playerMediaContentId="configImagePlayerBgIdle","none"==(n||"").toLowerCase()?e["background-image"]=void 0:n?(e["background-image"]=`url(${n})`,s=n):this.config.playerMinimizeOnIdle?e["background-image"]="var(--spc-player-background-image-off)":(e["background-image"]=`var(--spc-player-background-image-off, url(${ue}))`,e["--spc-player-background-size-default"]=`${me}`,r=!0),this.config.playerBackgroundImageSize&&(e["--spc-player-background-size"]=`${this.config.playerBackgroundImageSize}`)):a?(this.store.card.playerMediaContentId="configImagePlayerBg","none"==(a||"").toLowerCase()?e["background-image"]=void 0:a&&(e["background-image"]=`url(${a})`,s=a)):d?(this.store.card.playerMediaContentId=c,s=d,e["background-image"]=`var(--spc-player-background-image, url(${d}))`):o?(this.store.card.playerMediaContentId="configImageDefault",s=o,e["background-image"]=`url(${o}`):(this.store.card.playerMediaContentId="BRAND_LOGO_IMAGE_BASE64",this.config.playerMinimizeOnIdle?e["background-image"]="var(--spc-player-background-image-off)":(e["background-image"]=`var(--spc-player-background-image-off, url(${ue}))`,e["--spc-player-background-size-default"]=`${me}`,r=!0),this.config.playerBackgroundImageSize&&(e["--spc-player-background-size"]=`${this.config.playerBackgroundImageSize}`));let u=this.config.playerControlsBackgroundColor;const m=this.config.playerControlsColor,v=this.config.playerControlsIconSize;let f=this.config.playerControlsIconColor;const g=this.config.playerControlsIconToggleColor;let A=this.config.playerHeaderBackgroundColor,y=this.config.playerHeaderTitle1Color;const b=this.config.playerHeaderTitle1FontSize;let w=this.config.playerHeaderTitle2Color;const C=this.config.playerHeaderTitle2FontSize;let S=this.config.playerHeaderTitle3Color;const I=this.config.playerHeaderTitle3FontSize,T=this.config.playerMinimizedTitleColor,k=this.config.playerMinimizedTitleFontSize,E=this.config.playerProgressSliderColor,_=this.config.playerProgressLabelColor,$=this.config.playerProgressLabelFontSize,P=this.config.playerProgressLabelPaddingLR,F=this.config.playerVolumeSliderColor,R=this.config.playerVolumeSliderThickness;let L=this.config.playerVolumeLabelColor;const O=this.config.playerVolumeLabelFontSize;return r&&(u=u||"transparent",f=f||"var(--primary-text-color, PLAYER_CONTROLS_BACKGROUND_COLOR_DEFAULT)",A=A||"transparent",y=y||"var(--primary-text-color, PLAYER_CONTROLS_BACKGROUND_COLOR_DEFAULT)",w=w||"var(--primary-text-color, PLAYER_CONTROLS_BACKGROUND_COLOR_DEFAULT)",S=S||"var(--primary-text-color, PLAYER_CONTROLS_BACKGROUND_COLOR_DEFAULT)",L=L||"var(--primary-text-color, PLAYER_CONTROLS_BACKGROUND_COLOR_DEFAULT)"),this.store.card.playerImage=s,u&&(e["--spc-player-controls-bg-color"]=`${u} `),m&&(e["--spc-player-controls-color"]=`${m}`),g&&(e["--spc-player-controls-icon-toggle-color"]=`${g}`),f&&(e["--spc-player-controls-icon-color"]=`${f}`),v&&(e["--spc-player-controls-icon-size"]=`${v}`,e["--spc-player-controls-icon-button-size"]=`var(--spc-player-controls-icon-size, ${v})`),A&&(e["--spc-player-header-bg-color"]=`${A}`),y&&(e["--spc-player-header-title1-color"]=`${y}`),b&&(e["--spc-player-header-title1-font-size"]=`${b}`),w&&(e["--spc-player-header-title2-color"]=`${w}`),C&&(e["--spc-player-header-title2-font-size"]=`${C}`),S&&(e["--spc-player-header-title3-color"]=`${S}`),I&&(e["--spc-player-header-title3-font-size"]=`${I}`),T&&(e["--spc-player-minimized-title-color"]=`${T}`),k&&(e["--spc-player-minimized-title-font-size"]=`${k}`),_&&(e["--spc-player-progress-label-color"]=`${_}`),$&&(e["--spc-player-progress-label-font-size"]=`${$}`),P&&(e["--spc-player-progress-label-padding-lr"]=`${P}`),E&&(e["--spc-player-progress-slider-color"]=`${E}`),L&&(e["--spc-player-volume-label-color"]=`${L}`),O&&(e["--spc-player-volume-label-font-size"]=`${O}`),F&&(e["--spc-player-volume-slider-color"]=`${F}`),R&&(e["--spc-player-volume-slider-thickness"]=`${R}`),xe(e)}stylePlayerHeader(){const e={};return this.config.playerHeaderHide&&(e.display="none"),this.config.playerMinimizeOnIdle&&this.store.player.isPoweredOffOrIdle()&&"fill"!=this.config.height&&(e.display="none"),xe(e)}stylePlayerControls(){const e={};return this.config.playerControlsHide&&(e.display="none"),this.config.playerMinimizeOnIdle&&this.store.player.isPoweredOffOrIdle()&&"fill"!=this.config.height&&(e["justify-items"]="flex-start",e["padding-left"]="0px"),xe(e)}};Ie([Ve({attribute:!1})],Qs.prototype,"mediaContentId",void 0),Ie([De()],Qs.prototype,"config",void 0),Qs=Ie([Be("spc-player")],Qs);let er=class extends Zi{constructor(){super(et.PLAYLIST_FAVORITES),this.filterCriteriaPlaceholder="filter by playlist name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.playlistFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.playlistFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.shuffleOnPlay=this.config.playlistFavBrowserShuffleOnPlay||!1,this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.playlistFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.playlistFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.playlistFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.playlistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetPlaylistFavorites(e,0,0,s,r).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Playlist Followed failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Playlist followed refresh failed: "+yt(e)),!0}}};var tr;er=Ie([Be("spc-playlist-fav-browser")],er),function(e){e.AlbumCopyPresetToClipboard="AlbumCopyPresetToClipboard",e.AlbumCopyPresetJsonToClipboard="AlbumCopyPresetJsonToClipboard",e.AlbumCopyUriToClipboard="AlbumCopyUriToClipboard",e.AlbumFavoriteAdd="AlbumFavoriteAdd",e.AlbumFavoriteRemove="AlbumFavoriteRemove",e.AlbumFavoriteUpdate="AlbumFavoriteUpdate",e.AlbumPlayTrackFavorites="AlbumPlayTrackFavorites",e.AlbumSearchRadio="AlbumSearchRadio",e.AlbumShowTracks="AlbumShowTracks",e.AlbumUserPresetAdd="AlbumUserPresetAdd",e.ArtistCopyPresetToClipboard="ArtistCopyPresetToClipboard",e.ArtistCopyPresetJsonToClipboard="ArtistCopyPresetJsonToClipboard",e.ArtistCopyUriToClipboard="ArtistCopyUriToClipboard",e.ArtistFavoriteAdd="ArtistFavoriteAdd",e.ArtistFavoriteRemove="ArtistFavoriteRemove",e.ArtistFavoriteUpdate="ArtistFavoriteUpdate",e.ArtistPlayTrackFavorites="ArtistPlayTrackFavorites",e.ArtistSearchPlaylists="ArtistSearchPlaylists",e.ArtistSearchRadio="ArtistSearchRadio",e.ArtistSearchTracks="ArtistSearchTracks",e.ArtistShowAlbums="ArtistShowAlbums",e.ArtistShowAlbumsAppearsOn="ArtistShowAlbumsAppearsOn",e.ArtistShowAlbumsCompilation="ArtistShowAlbumsCompilation",e.ArtistShowAlbumsSingle="ArtistShowAlbumsSingle",e.ArtistShowRelatedArtists="ArtistShowRelatedArtists",e.ArtistShowTopTracks="ArtistShowTopTracks",e.ArtistUserPresetAdd="ArtistUserPresetAdd",e.TrackCopyPresetToClipboard="TrackCopyPresetToClipboard",e.TrackCopyPresetJsonToClipboard="TrackCopyPresetJsonToClipboard",e.TrackCopyUriToClipboard="TrackCopyUriToClipboard",e.TrackFavoriteAdd="TrackFavoriteAdd",e.TrackFavoriteRemove="TrackFavoriteRemove",e.TrackFavoriteUpdate="TrackFavoriteUpdate",e.TrackPlayQueueAdd="TrackPlayQueueAdd",e.TrackPlayTrackFavorites="TrackPlayTrackFavorites",e.TrackSearchPlaylists="TrackSearchPlaylists",e.TrackSearchRadio="TrackSearchRadio",e.TrackUserPresetAdd="TrackUserPresetAdd"}(tr||(tr={}));class ir extends li{constructor(){super(et.TRACK_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(tr.ArtistFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(tr.ArtistFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
this.onClickAction(tr.AlbumFavoriteAdd)}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(tr.AlbumFavoriteRemove)}
slot="icon-button-small-selected"
>
`,r=U`
this.onClickAction(tr.TrackFavoriteAdd)}
slot="icon-button-small"
>
`,o=U`
this.onClickAction(tr.TrackFavoriteRemove)}
slot="icon-button-small-selected"
>
`,a=U`
Tt(this.mediaItem.artists[0].external_urls.spotify||"")}
slot="icon-button-small"
>
`,n=U`
Tt(this.mediaItem.album.external_urls.spotify||"")}
slot="icon-button-small"
>
`,l=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,c=U`
this.onClickAction(tr.TrackSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Track
this.onClickAction(tr.TrackSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Track Radio
this.onClickAction(tr.TrackPlayQueueAdd)}>
Add Track to Play Queue
this.onClickAction(tr.TrackPlayTrackFavorites)}>
Play All Track Favorites
this.onClickAction(tr.TrackUserPresetAdd)}>
Add Track to User Presets
this.onClickAction(tr.TrackCopyPresetToClipboard)}>
Copy Track Preset Info to Clipboard
this.onClickAction(tr.TrackCopyPresetJsonToClipboard)}>
Copy Track Preset JSON to Clipboard
this.onClickAction(tr.TrackCopyUriToClipboard)}>
Copy Track URI to Clipboard
`,d=U`
this.onClickAction(tr.AlbumPlayTrackFavorites)}>
Play Favorite Tracks from this Album
this.onClickAction(tr.AlbumShowTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Album Tracks
this.onClickAction(tr.AlbumSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Album Radio
this.onClickAction(tr.AlbumUserPresetAdd)}>
Add Album to User Presets
this.onClickAction(tr.AlbumCopyPresetToClipboard)}>
Copy Album Preset Info to Clipboard
this.onClickAction(tr.AlbumCopyPresetJsonToClipboard)}>
Copy Album Preset JSON to Clipboard
this.onClickAction(tr.AlbumCopyUriToClipboard)}>
Copy Album URI to Clipboard
`,h=U`
this.onClickAction(tr.ArtistPlayTrackFavorites)}>
Play Favorite Tracks from this Artist
this.onClickAction(tr.ArtistSearchPlaylists)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search Playlists for Artist
this.onClickAction(tr.ArtistSearchTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Search Tracks for Artist
this.onClickAction(tr.ArtistSearchRadio)} hide=${this.hideSearchType(Et.PLAYLISTS)}>
Search for Artist Radio
this.onClickAction(tr.ArtistShowTopTracks)} hide=${this.hideSearchType(Et.TRACKS)}>
Show Artist Top Tracks
this.onClickAction(tr.ArtistShowAlbums)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums
this.onClickAction(tr.ArtistShowAlbumsCompilation)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Compilations
this.onClickAction(tr.ArtistShowAlbumsSingle)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums Singles
this.onClickAction(tr.ArtistShowAlbumsAppearsOn)} hide=${this.hideSearchType(Et.ALBUMS)}>
Show Artist Albums AppearsOn
this.onClickAction(tr.ArtistShowRelatedArtists)} hide=${this.hideSearchType(Et.ARTISTS)}>
Show Related Artists
this.onClickAction(tr.ArtistUserPresetAdd)}>
Add Artist to User Presets
this.onClickAction(tr.ArtistCopyPresetToClipboard)}>
Copy Artist Preset Info to Clipboard
this.onClickAction(tr.ArtistCopyPresetJsonToClipboard)}>
Copy Artist Preset JSON to Clipboard
this.onClickAction(tr.ArtistCopyUriToClipboard)}>
Copy Artist URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.track-info-grid {
grid-template-columns: auto auto 30px auto auto 30px auto auto;
justify-content: left;
}
.track-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.colspan-r3-c2 {
grid-row: 3 / 3; /* grid row 3 */
grid-column: 2 / 9; /* grid columns 2 thru 8 */
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{if(e==tr.AlbumCopyPresetToClipboard)return st($i(this.mediaItem.album,this.mediaItem.album.artists[0].name)),this.alertInfoSet(we),!0;if(e==tr.AlbumCopyPresetJsonToClipboard)return st(Pi(this.mediaItem.album,this.mediaItem.album.artists[0].name)),this.alertInfoSet(Ce),!0;if(e==tr.AlbumCopyUriToClipboard)return st(this.mediaItem.album.uri),!0;if(e==tr.AlbumSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.album.name+ve+this.mediaItem.artists[0].name)),!0;if(e==tr.AlbumShowTracks)return this.dispatchEvent(hi(Et.ALBUM_TRACKS,this.mediaItem.album.name+"; "+this.mediaItem.artists[0].name,this.mediaItem.album.name,this.mediaItem.album.uri,null,this.mediaItem.album)),!0;if(e==tr.ArtistCopyPresetToClipboard)return st($i(this.mediaItem.artists[0])),this.alertInfoSet(we),!0;if(e==tr.ArtistCopyPresetJsonToClipboard)return st(Pi(this.mediaItem.artists[0])),this.alertInfoSet(Ce),!0;if(e==tr.ArtistCopyUriToClipboard)return st(this.mediaItem.artists[0].uri),!0;if(e==tr.ArtistSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.artists[0].name)),!0;if(e==tr.ArtistSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.artists[0].name+ve)),!0;if(e==tr.ArtistShowAlbums)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistShowAlbumsAppearsOn)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_APPEARSON,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistShowAlbumsCompilation)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_COMPILATION,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistShowAlbumsSingle)return this.dispatchEvent(hi(Et.ARTIST_ALBUMS_SINGLE,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistShowRelatedArtists)return this.dispatchEvent(hi(Et.ARTIST_RELATED_ARTISTS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistShowTopTracks)return this.dispatchEvent(hi(Et.ARTIST_TOP_TRACKS,this.mediaItem.artists[0].name,this.mediaItem.artists[0].name,this.mediaItem.artists[0].uri)),!0;if(e==tr.ArtistSearchTracks)return this.dispatchEvent(hi(Et.TRACKS,this.mediaItem.artists[0].name)),!0;if(e==tr.TrackCopyPresetToClipboard)return st($i(this.mediaItem,this.mediaItem.artists[0].name)),this.alertInfoSet(we),!0;if(e==tr.TrackCopyPresetJsonToClipboard)return st(Pi(this.mediaItem,this.mediaItem.artists[0].name)),this.alertInfoSet(Ce),!0;if(e==tr.TrackCopyUriToClipboard)return st(this.mediaItem.uri),!0;if(e==tr.TrackSearchPlaylists)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.name+" "+this.mediaItem.artists[0].name)),!0;if(e==tr.TrackSearchRadio)return this.dispatchEvent(hi(Et.PLAYLISTS,this.mediaItem.name+ve+this.mediaItem.artists[0].name)),!0;if(this.progressShow(),e==tr.AlbumUserPresetAdd)this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide();else if(e==tr.AlbumFavoriteAdd)await this.spotifyPlusService.SaveAlbumFavorites(this.player,this.mediaItem.album.id),this.updateActions(this.player,[tr.AlbumFavoriteUpdate]);else if(e==tr.AlbumFavoriteRemove)await this.spotifyPlusService.RemoveAlbumFavorites(this.player,this.mediaItem.album.id),this.updateActions(this.player,[tr.AlbumFavoriteUpdate]);else if(e==tr.AlbumPlayTrackFavorites){const e=this.store.config.albumFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,null,this.mediaItem.album.uri),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else if(e==tr.ArtistFavoriteAdd)await this.spotifyPlusService.FollowArtists(this.player,this.mediaItem.artists[0].id),this.updateActions(this.player,[tr.ArtistFavoriteUpdate]);else if(e==tr.ArtistFavoriteRemove)await this.spotifyPlusService.UnfollowArtists(this.player,this.mediaItem.artists[0].id),this.updateActions(this.player,[tr.ArtistFavoriteUpdate]);else if(e==tr.ArtistPlayTrackFavorites){const e=this.store.config.artistFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,999,this.mediaItem.artists[0].uri,null),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else if(e==tr.ArtistUserPresetAdd)this.mediaItem.artists[0].image_url=this.mediaItem.album.image_url,this.store.config.userPresets?.unshift(_i(this.mediaItem.artists[0])),await Di(this.store.config),this.progressHide();else if(e==tr.TrackUserPresetAdd)this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide();else if(e==tr.TrackFavoriteAdd)await this.spotifyPlusService.SaveTrackFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[tr.TrackFavoriteUpdate]);else if(e==tr.TrackFavoriteRemove)await this.spotifyPlusService.RemoveTrackFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[tr.TrackFavoriteUpdate]);else if(e==tr.TrackPlayQueueAdd)await this.spotifyPlusService.AddPlayerQueueItems(this.player,this.mediaItem.uri),this.progressHide();else if(e==tr.TrackPlayTrackFavorites){const e=this.store.config.trackFavBrowserShuffleOnPlay;await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e,null,!1,this.store.config.trackFavBrowserItemsLimit||200),this.progressHide(),this.store.card.SetSection(et.PLAYER)}else this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(tr.AlbumFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckAlbumFavorites(e,this.mediaItem.album.id).then((e=>{this.isAlbumFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isAlbumFavorite=void 0,this.alertErrorSet("Check Album Favorite failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(tr.ArtistFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckArtistsFollowing(e,this.mediaItem.artists[0].id).then((e=>{this.isArtistFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isArtistFavorite=void 0,this.alertErrorSet("Check Artist Following failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(tr.TrackFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{let s=this.mediaItem.id;this.mediaItem.is_linked_from&&(s=this.mediaItem.id+","+this.mediaItem.id_origin),this.spotifyPlusService.CheckTrackFavorites(e,s).then((e=>{const i=Object.keys(e);this.isTrackFavorite=e[i[0]],i.length>1&&(this.isTrackFavorite=e[i[0]]||e[i[1]]),t(!0)})).catch((e=>{this.isTrackFavorite=void 0,this.alertErrorSet("Check Track Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Track actions refresh failed: "+yt(e)),!0}}}function sr(e){const t=new Array;if(e)for(const i of e.items||[])t.push(i.track);return t}Ie([Ve({attribute:!1})],ir.prototype,"mediaItem",void 0),Ie([De()],ir.prototype,"isAlbumFavorite",void 0),Ie([De()],ir.prototype,"isArtistFavorite",void 0),Ie([De()],ir.prototype,"isTrackFavorite",void 0),customElements.define("spc-track-actions",ir);const rr=Fe(ce+":recent-browser");let or=class extends Zi{constructor(){super(et.RECENTS),this.filterCriteriaPlaceholder="filter by name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.recentBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.recentBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.recentBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.recentBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}onItemSelected(e){rr.enabled&&rr("onItemSelected - media item selected:\n%s",JSON.stringify(e.detail,null,2));try{if(this.progressShow(),!this.player.isUserProductPremium()&&!this.player.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const t=e.detail,{uris:i}=kt(this.mediaList||[],t);this.spotifyPlusService.PlayerMediaPlayTracks(this.player,i.join(","),null,null,null,!1),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not play media item. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.LIMIT_TOTAL_MAX;this.spotifyPlusService.GetPlayerRecentTracks(e,0,0,0,s).then((e=>{this.mediaList=sr(e),this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Player Recent Tracks failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Recently Played items refresh failed: "+yt(e)),!0}}};var ar;or=Ie([Be("spc-recent-browser")],or),function(e){e.ShowCopyPresetToClipboard="ShowCopyPresetToClipboard",e.ShowCopyPresetJsonToClipboard="ShowCopyPresetJsonToClipboard",e.ShowCopyUriToClipboard="ShowCopyUriToClipboard",e.ShowEpisodesUpdate="ShowEpisodesUpdate",e.ShowFavoriteAdd="ShowFavoriteAdd",e.ShowFavoriteRemove="ShowFavoriteRemove",e.ShowFavoriteUpdate="ShowFavoriteUpdate",e.ShowSearchEpisodes="ShowSearchEpisodes",e.ShowUserPresetAdd="ShowUserPresetAdd"}(ar||(ar={}));class nr extends li{constructor(){super(et.SHOW_FAVORITES)}render(){super.render();const e=U`
this.onClickAction(ar.ShowFavoriteAdd)}
slot="icon-button-small"
>
`,t=U`
this.onClickAction(ar.ShowFavoriteRemove)}
slot="icon-button-small-selected"
>
`,i=U`
Tt(this.mediaItem.external_urls.spotify||"")}
slot="icon-button-small"
>
`,s=U`
this.onClickAction(ar.ShowSearchEpisodes)} hide=${this.hideSearchType(Et.EPISODES)}>
Search for Show Episodes
this.onClickAction(ar.ShowUserPresetAdd)}>
Add Show to User Presets
this.onClickAction(ar.ShowCopyPresetToClipboard)}>
Copy Show Preset Info to Clipboard
this.onClickAction(ar.ShowCopyPresetJsonToClipboard)}>
Copy Show Preset JSON to Clipboard
this.onClickAction(ar.ShowCopyUriToClipboard)}>
Copy Show URI to Clipboard
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.show-info-grid {
grid-template-columns: auto auto;
justify-content: left;
}
.show-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
/* style episodes container and grid */
.episodes-grid {
grid-template-columns: 40px auto auto auto;
margin-top: 1.0rem;
}
/* style ha-icon-button controls in tracks grid: icon size, title text */
.episodes-grid > ha-icon-button[slot="icon-button"] {
--ha-icon-button-size: 24px;
--ha-icon-size: 20px;
vertical-align: top;
padding: 0px;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{return e==ar.ShowCopyPresetToClipboard?(st($i(this.mediaItem,"Podcast")),this.alertInfoSet(we),!0):e==ar.ShowCopyPresetJsonToClipboard?(st(Pi(this.mediaItem,"Podcast")),this.alertInfoSet(Ce),!0):e==ar.ShowCopyUriToClipboard?(st(this.mediaItem.uri),!0):e==ar.ShowSearchEpisodes?(this.dispatchEvent(hi(Et.SHOW_EPISODES,this.mediaItem.name,this.mediaItem.name,this.mediaItem.uri)),!0):(this.progressShow(),e==ar.ShowUserPresetAdd?(this.store.config.userPresets?.unshift(_i(this.mediaItem)),await Di(this.store.config),this.progressHide()):e==ar.ShowFavoriteAdd?(await this.spotifyPlusService.SaveShowFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[ar.ShowFavoriteUpdate])):e==ar.ShowFavoriteRemove?(await this.spotifyPlusService.RemoveShowFavorites(this.player,this.mediaItem.id),this.updateActions(this.player,[ar.ShowFavoriteUpdate])):this.progressHide(),!0)}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{const i=new Array;if(-1!=t.indexOf(ar.ShowEpisodesUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.GetShowEpisodes(e,this.mediaItem.id,0,0,null,20).then((e=>{this.showEpisodes=e,t(!0)})).catch((e=>{this.showEpisodes=void 0,this.alertErrorSet("Get Show Episodes failed: "+yt(e)),i(e)}))}));i.push(t)}if(-1!=t.indexOf(ar.ShowFavoriteUpdate)||0==t.length){const t=new Promise(((t,i)=>{this.spotifyPlusService.CheckShowFavorites(e,this.mediaItem.id).then((e=>{this.isShowFavorite=e[Object.keys(e)[0]],t(!0)})).catch((e=>{this.isShowFavorite=void 0,this.alertErrorSet("Check Show Favorites failed: "+yt(e)),i(e)}))}));i.push(t)}return this.progressShow(),Promise.allSettled(i).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),this.alertErrorSet("Show actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],nr.prototype,"mediaItem",void 0),Ie([De()],nr.prototype,"showEpisodes",void 0),Ie([De()],nr.prototype,"isShowFavorite",void 0),customElements.define("spc-show-actions",nr);const lr=Fe(ce+":search-media-browser"),cr="_searchmediatype",dr="_searcheventargs",hr="Search for ",pr=[Et.ALBUMS,Et.ARTISTS,Et.AUDIOBOOKS,Et.EPISODES,Et.PLAYLISTS,Et.SHOWS,Et.TRACKS];let ur=class extends Zi{constructor(){super(et.SEARCH_MEDIA),this.filterCriteriaPlaceholder="search by name"}render(){super.render();const e=It(this.config.searchMediaBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList),t=It(this.config.searchMediaBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList),i=this.searchMediaType;this.favBrowserItemsPerRow=this.config.searchMediaBrowserItemsPerRow||4,this.config.searchMediaBrowserUseDisplaySettings||(i==Et.ALBUMS?this.favBrowserItemsPerRow=this.config.albumFavBrowserItemsPerRow||4:i==Et.ARTISTS?this.favBrowserItemsPerRow=this.config.artistFavBrowserItemsPerRow||4:i==Et.AUDIOBOOKS?this.favBrowserItemsPerRow=this.config.audiobookFavBrowserItemsPerRow||4:i==Et.EPISODES?this.favBrowserItemsPerRow=this.config.episodeFavBrowserItemsPerRow||4:i==Et.PLAYLISTS?this.favBrowserItemsPerRow=this.config.playlistFavBrowserItemsPerRow||4:i==Et.SHOWS?this.favBrowserItemsPerRow=this.config.showFavBrowserItemsPerRow||4:i==Et.TRACKS?this.favBrowserItemsPerRow=this.config.trackFavBrowserItemsPerRow||4:i==Et.ALBUM_TRACKS?(this.favBrowserItemsPerRow=this.config.trackFavBrowserItemsPerRow||4,this.isFilterCriteriaReadOnly=!0):i==Et.ARTIST_ALBUMS||i==Et.ARTIST_ALBUMS_APPEARSON||i==Et.ARTIST_ALBUMS_COMPILATION||i==Et.ARTIST_ALBUMS_SINGLE?(this.favBrowserItemsPerRow=this.config.albumFavBrowserItemsPerRow||4,this.isFilterCriteriaReadOnly=!0):i==Et.ARTIST_RELATED_ARTISTS?(this.favBrowserItemsPerRow=this.config.artistFavBrowserItemsPerRow||4,this.isFilterCriteriaReadOnly=!0):i==Et.ARTIST_TOP_TRACKS?(this.favBrowserItemsPerRow=this.config.trackFavBrowserItemsPerRow||4,this.isFilterCriteriaReadOnly=!0):(i==Et.AUDIOBOOK_EPISODES||i==Et.SHOW_EPISODES)&&(this.favBrowserItemsPerRow=this.config.episodeFavBrowserItemsPerRow||4,this.isFilterCriteriaReadOnly=!0)),!this.isFilterCriteriaReadOnly&&this.config.searchMediaBrowserSearchTypes&&this.config.searchMediaBrowserSearchTypes.length>0&&(this.config.searchMediaBrowserSearchTypes?.includes(this.searchMediaType)||(this.searchMediaType=this.config.searchMediaBrowserSearchTypes[0],this.searchMediaTypeTitle=hr+this.searchMediaType,this.mediaList=void 0,this.mediaListLastUpdatedOn=0,this.scrollTopSaved=0));const s=(this.searchEventArgs?.uri||"").indexOf(":album:")>-1,r=(this.searchEventArgs?.uri||"").indexOf(":artist:")>-1,o=(this.searchEventArgs?.uri||"").indexOf(":show:")>-1&&"audiobook"==this.searchEventArgs?.subtype,a=(this.searchEventArgs?.uri||"").indexOf(":show:")>-1&&"podcast"==this.searchEventArgs?.subtype,n=s||r||o||a,l=U`
${Et.ALBUMS}
${Et.ARTISTS}
${Et.AUDIOBOOKS}
${Et.EPISODES}
${Et.PLAYLISTS}
${Et.SHOWS}
${Et.TRACKS}
${Et.ALBUM_TRACKS}
${Et.ARTIST_TOP_TRACKS}
${Et.ARTIST_ALBUMS}
${Et.ARTIST_ALBUMS_COMPILATION}
${Et.ARTIST_ALBUMS_SINGLE}
${Et.ARTIST_ALBUMS_APPEARSON}
${Et.ARTIST_RELATED_ARTISTS}
${Et.AUDIOBOOK_EPISODES}
${Et.SHOW_EPISODES}
`;return this.setScrollPosition(),U`
`}static get styles(){return[Gi,a`
/* extra styles not defined in sharedStylesFavBrowser would go here. */
.search-media-browser-controls {
margin-top: 0.5rem;
margin-left: 0.5rem;
margin-right: 0.5rem;
margin-bottom: 0rem;
white-space: nowrap;
align-items: left;
--ha-select-height: 2.5rem; /* ha dropdown control height */
--mdc-menu-item-height: 2.5rem; /* mdc dropdown list item height */
--ha-icon-button-size: 2.5rem; /* mdc icon button size */
--md-menu-item-top-space: 0.5rem; /* top spacing between items */
--md-menu-item-bottom-space: 0.5rem; /* bottom spacing between items */
--md-menu-item-one-line-container-height: 2.0rem; /* menu item height */
display: inline-flex;
flex-direction: row;
justify-content: space-between;
}
.search-media-browser-actions {
height: 100%;
}
/* related styles */
ha-assist-chip {
--ha-assist-chip-container-shape: 10px; /* 0px=square corner, 10px=rounded corner */
--ha-assist-chip-container-color: var(--card-background-color);
}
.selection-bar {
background: rgba(var(--rgb-primary-color), 0.1);
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 12px;
box-sizing: border-box;
font-size: 14px;
--ha-assist-chip-container-color: var(--card-background-color);
}
.selection-controls {
display: flex;
align-items: center;
gap: 8px;
}
.selection-controls p {
margin-left: 8px;
margin-inline-start: 8px;
margin-inline-end: initial;
}
.center-vertical {
display: flex;
align-items: center;
gap: 8px;
}
.relative {
position: relative;
}
*[hide="true"] {
display: none;
}
*[hide="false"] {
display: flex;
}
`]}onItemSelected(e){lr.enabled&&lr("onItemSelected - search media item selected:\n%s",JSON.stringify(e.detail,null,2));const t=e.detail;!this.config.searchMediaBrowserQueueSelection||"track"!=t.type&&"episode"!=t.type?this.PlayMediaItem(t):this.QueueMediaItem(t)}hideSearchType(e){return!!(this.config.searchMediaBrowserSearchTypes&&this.config.searchMediaBrowserSearchTypes.length>0)&&(!this.config.searchMediaBrowserSearchTypes?.includes(e)&&(!this.searchEventArgs||this.searchEventArgs?.searchCriteria!=e))}searchExecute(e){lr.enabled&&lr("searchExecute - searching Spotify media:\n%s",JSON.stringify(e,null,2)),this.initSearchValues(e.searchType),this.filterCriteria=e.searchCriteria,this.searchMediaType=e.searchType,pr.includes(e.searchType)?this.searchEventArgs=null:this.searchEventArgs=e,this.updateMediaList(this.player)}storageValuesLoad(){super.storageValuesLoad();let e=Et.PLAYLISTS;this.isFilterCriteriaReadOnly||this.config.searchMediaBrowserSearchTypes&&this.config.searchMediaBrowserSearchTypes.length>0&&(this.config.searchMediaBrowserSearchTypes.includes(e)||(e=this.config?.searchMediaBrowserSearchTypes[0]||"")),this.searchMediaType=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+cr,e),this.searchEventArgs=Ji.getStorageValue(this.cacheKeyBase+this.mediaType+dr,e),this.searchMediaTypeTitle=hr+this.searchMediaType,lr.enabled&&lr("storageValuesLoad - parameters loaded from cache: searchMediaType, searchEventArgs")}storageValuesSave(){super.storageValuesSave(),Ji.setStorageValue(this.cacheKeyBase+this.mediaType+cr,this.searchMediaType),Ji.setStorageValue(this.cacheKeyBase+this.mediaType+dr,this.searchEventArgs),lr.enabled&&lr("storageValuesSave - parameters saved to cache: searchMediaType, searchEventArgs")}onSearchMediaTypeChanged(e){this.initSearchValues(e.currentTarget.value);const t=e.currentTarget.value;lr.enabled&&lr("onSearchMediaTypeChanged - selected value = %s ",JSON.stringify(t)),pr.includes(t)?this.searchEventArgs=null:this.searchEventArgs?(this.searchEventArgs.searchType=t,this.updateMediaList(this.player)):lr("%conSearchMediaTypeChanged - searchEventArgs not set; event ignored!","color:red")}initSearchValues(e){this.searchMediaType!=e&&(lr.enabled&&lr("initSearchValues - preparing to search for type: %s",JSON.stringify(e)),this.searchMediaType=e,this.searchMediaTypeTitle=hr+this.searchMediaType,this.mediaList=void 0,this.mediaListLastUpdatedOn=0,this.scrollTopSaved=0,this.alertClear(),this.isActionsVisible&&(this.isActionsVisible=!1))}updateMediaList(e){if(!this.searchMediaType)return this.alertErrorSet("Please select the type of content to search for"),this.searchMediaTypeElement.focus(),!1;if(!this.isFilterCriteriaReadOnly&&!this.filterCriteria)return this.alertErrorSet("Please enter criteria to search for"),this.filterCriteriaElement.focus(),!1;if(!super.updateMediaList(e))return!1;try{const t=new Array;if(lr.enabled&&lr("%cupdateMediaList\n- mediaType = %s\n- searchMediaType = %s\n- searchEventArgs = %s","color:green",JSON.stringify(this.mediaType),JSON.stringify(this.searchMediaType),JSON.stringify(this.searchEventArgs,null,2)),pr.includes(this.searchMediaType)){const i=new Promise(((t,i)=>{this.alertInfo="Searching Spotify "+this.searchMediaType+' catalog for "'+this.filterCriteria+'" ...';const s=this.config.searchMediaBrowserSearchLimit||50;this.spotifyPlusService.Search(this.searchMediaType,e,this.filterCriteria||"",0,0,null,null,s).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ALBUM_TRACKS){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50;this.spotifyPlusService.GetAlbumTracks(e,s,0,0,null,r).then((e=>{lr.enabled&&lr("%cupdateMediaList - Appending album to SearchMediaTypes.ALBUM_TRACKS items.\n- Album parentMediaItem:\n%s","color.red",JSON.stringify(this.searchEventArgs?.parentMediaItem,null,2)),e.items.forEach((e=>{const t=e;t.album=this.searchEventArgs?.parentMediaItem,t.album&&(t.image_url=t.album.image_url)})),this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_ALBUMS){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50,o=this.config.artistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistAlbums(e,s,"album",0,0,null,r,o).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_ALBUMS_APPEARSON){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50,o=this.config.artistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistAlbums(e,s,"appears_on",0,0,null,r,o).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_ALBUMS_COMPILATION){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50,o=this.config.artistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistAlbums(e,s,"compilation",0,0,null,r,o).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_ALBUMS_SINGLE){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50,o=this.config.artistFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistAlbums(e,s,"single",0,0,null,r,o).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_RELATED_ARTISTS){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistRelatedArtists(e,s,r).then((e=>{this.mediaList=e,this.mediaListLastUpdatedOn=nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.ARTIST_TOP_TRACKS){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserItemsSortTitle||!1;this.spotifyPlusService.GetArtistTopTracks(e,s,null,r).then((e=>{this.mediaList=e,this.mediaListLastUpdatedOn=nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else if(this.searchMediaType==Et.SHOW_EPISODES){const i=new Promise(((t,i)=>{this.alertInfo="Searching "+this.searchMediaType+' for "'+this.searchEventArgs?.title+'" ...';const s=Ti(this.searchEventArgs?.uri),r=this.config.searchMediaBrowserSearchLimit||50;this.spotifyPlusService.GetShowEpisodes(e,s,0,0,null,r).then((e=>{this.mediaList=e.items,this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),this.alertInfo?.startsWith("Searching ")&&this.alertInfoClear(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),i(e)}))}));t.push(i)}else this.isUpdateInProgress=!1,console.log("%cSpotifyPlus Card: updateMediaList - searchMediaType was not processed:\n- mediaType = %s\n- searchMediaType = %s\n- searchEventArgs = %s","color:red",JSON.stringify(this.mediaType),JSON.stringify(this.searchMediaType),JSON.stringify(this.searchEventArgs,null,2));return this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Spotify "+this.searchMediaType+" search failed: "+yt(e)),!0}}};Ie([De()],ur.prototype,"searchMediaType",void 0),Ie([De()],ur.prototype,"searchMediaTypeTitle",void 0),Ie([De()],ur.prototype,"searchEventArgs",void 0),Ie([qe("#searchMediaType",!1)],ur.prototype,"searchMediaTypeElement",void 0),ur=Ie([Be("spc-search-media-browser")],ur);let mr=class extends Zi{constructor(){super(et.SHOW_FAVORITES),this.filterCriteriaPlaceholder="filter by show name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.showFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.showFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.showFavBrowserItemsPerRow||4),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.showFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.showFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.showFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetShowFavorites(e,0,0,s,r,!0).then((e=>{this.mediaList=function(e){const t=new Array;if(e)for(const i of e.items||[])t.push(i.show);return t}(e),this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Show Favorites failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Show favorites refresh failed: "+yt(e)),!0}}};mr=Ie([Be("spc-show-fav-browser")],mr);const vr=Fe(ce+":track-fav-browser");let fr=class extends Zi{constructor(){super(et.TRACK_FAVORITES),this.filterCriteriaPlaceholder="filter by track name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name.toLocaleLowerCase().indexOf(t)||-1!==e.artists[0].name.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.trackFavBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.trackFavBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.shuffleOnPlay=this.config.trackFavBrowserShuffleOnPlay||!1,this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.trackFavBrowserItemsPerRow||4,vr.enabled&&vr("render - loaded favBrowserItemsPerRow, value = %s",JSON.stringify(this.favBrowserItemsPerRow))),U`
`}firstUpdated(e){this.isCardInEditPreview||(this.isMediaListRefreshedOnSectionEntry=this.config.trackFavBrowserItemsRefreshOnEntry||!1),super.firstUpdated(e)}onItemSelected(e){vr.enabled&&vr("onItemSelected - media item selected:\n%s",JSON.stringify(e.detail,null,2));try{if(this.progressShow(),!this.player.isUserProductPremium()&&!this.player.attributes.sp_user_has_web_player_credentials)throw new Error(Se);const t=e.detail,{uris:i}=kt(this.mediaList||[],t);this.spotifyPlusService.PlayerMediaPlayTracks(this.player,i.join(","),null,null,null,!1),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not play media item. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{const t=new Array,i=new Promise(((t,i)=>{const s=this.config.trackFavBrowserItemsLimit||this.LIMIT_TOTAL_MAX,r=this.config.trackFavBrowserItemsSortTitle||!1;this.spotifyPlusService.GetTrackFavorites(e,0,0,null,s,r).then((e=>{this.mediaList=sr(e),this.mediaListLastUpdatedOn=e.date_last_refreshed||nt(),super.updatedMediaListOk(),t(!0)})).catch((e=>{this.mediaList=void 0,this.mediaListLastUpdatedOn=0,super.updatedMediaListError("Get Track Favorites failed: "+yt(e)),i(e)}))}));return t.push(i),this.progressShow(),Promise.allSettled(t).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("Track favorites refresh failed: "+yt(e)),!0}}};var gr;fr=Ie([Be("spc-track-fav-browser")],fr),function(e){e.UserPresetRemove="UserPresetRemove"}(gr||(gr={}));class Ar extends li{constructor(){super(et.USERPRESETS)}render(){super.render();const e=U`
this.onClickAction(gr.UserPresetRemove)}>
Remove User Preset Item
`;return U`
${this.alertError?U`
${this.alertError}`:""}
${this.alertInfo?U`
${this.alertInfo}`:""}
st(this.mediaItem.image_url||"")}>
`}static get styles(){return[ti,ii,si,a`
.userpreset-info-grid {
grid-template-columns: auto auto;
justify-content: left;
}
.userpreset-actions-container {
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.pad-top {
padding-top: 0.50rem;
}
`]}async onClickAction(e){if(this.isCardInEditPreview)return!0;try{if(this.progressShow(),e==gr.UserPresetRemove){if("card config"!=this.mediaItem.origin)return this.progressHide(),this.alertInfoSet("JSON File preset items must be removed via a file editor, since they may affect other card configurations."),!0;const e=this.store.config.userPresets||[];for(let t=e.length-1;t>=0;t--)if(e[t].name==this.mediaItem.name&&e[t].subtitle==this.mediaItem.subtitle&&(e[t].image_url||"")==(this.mediaItem.image_url||"")){e.splice(t,1);break}this.store.config.userPresets=e,await Di(this.store.config),this.progressHide(),Ui.selectedConfigArea=tt.USERPRESET_BROWSER,this.alertInfoSet('User Preset was removed: "'+this.mediaItem.name+'".')}else this.progressHide();return!0}catch(e){return this.progressHide(),this.alertErrorSet("Action failed: "+yt(e)),!0}}updateActions(e,t){if(!super.updateActions(e,t))return!1;try{return!0}catch(e){return this.progressHide(),this.alertErrorSet("UserPreset actions refresh failed: "+yt(e)),!0}}}Ie([Ve({attribute:!1})],Ar.prototype,"mediaItem",void 0),customElements.define("spc-userpreset-actions",Ar);const yr=ne+"-card-category-display";class br{constructor(e=null,t=null,i=null){this.filterCriteria=e||"",this.title=t||"",this.uri=i||""}}const wr=ne+"-card-filter-section-media";class Cr{constructor(e,t=null){this.section=e||"",this.filterCriteria=t||""}}const Sr=Fe(ce+":userpreset-browser");let Ir=class extends Zi{constructor(){super(et.USERPRESETS),this.filterCriteriaPlaceholder="filter by preset name"}render(){let e;if(super.render(),!this.isActionsVisible){const t=(this.filterCriteria||"").toLocaleLowerCase();e=this.mediaList?.filter((e=>-1!==e.name?.toLocaleLowerCase().indexOf(t)||-1!==e.subtitle?.toLocaleLowerCase().indexOf(t))),this.filterItemCount=e?.length}const t=It(this.config.userPresetBrowserTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e),i=It(this.config.userPresetBrowserSubTitle,this.config,this.player,this.mediaListLastUpdatedOn,this.mediaList,e);return this.favBrowserItemsPerRow||(this.favBrowserItemsPerRow=this.config.userPresetBrowserItemsPerRow||4),U`
`}onItemSelected(e){if(Sr.enabled&&Sr("onItemSelected - media item selected:\n%s",JSON.stringify(e.detail,null,2)),"recommendations"==e.detail.type){const t=e.detail;this.PlayTrackRecommendations(t)}else if("filtersection"==e.detail.type){const t=e.detail;if(!Object.values(et).includes(t.filter_section||""))return void this.alertErrorSet('Preset filter_section "'+t.filter_section+'" is not a valid section identifier.');this.dispatchEvent(function(e,t){const i=new Cr(e);return i.filterCriteria=(t||"").trim(),new CustomEvent(wr,{bubbles:!0,composed:!0,detail:i})}(t.filter_section,t.filter_criteria))}else if("category"==e.detail.type){const t=e.detail;this.dispatchEvent(function(e,t=null,i=null){const s=new br;return s.filterCriteria=(e||"").trim(),s.title=t||"",s.uri=i||"",new CustomEvent(yr,{bubbles:!0,composed:!0,detail:s})}(t.subtitle,t.name,t.uri))}else if("trackfavorites"==e.detail.type){const t=e.detail;this.PlayTrackFavorites(t)}else super.onItemSelected(e)}onItemSelectedWithHold(e){""==(e.detail.uri||"")&&(e.detail.uri="unknown"),super.onItemSelectedWithHold(e)}async PlayTrackRecommendations(e){try{if(!this.player.isUserProductPremium()&&!this.player.attributes.sp_user_has_web_player_credentials)throw new Error(Se);this.progressShow(),this.alertInfo="Searching for track recommendations ...",this.requestUpdate();const t=50,i=await this.spotifyPlusService.GetTrackRecommendations(this.player,e.recommendations,t,null),s=new Array;if(i.tracks.forEach((e=>{s.push(e.uri)})),0==s.length)return void(this.alertInfo="No recommended tracks were found for the preset criteria; adjust the preset criteria settings and try again.");this.alertInfo="Playing recommended tracks ...",this.requestUpdate(),this.spotifyPlusService.PlayerMediaPlayTracks(this.player,s.join(","),null,null,null,!1),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not get track recommendations for user preset. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}async PlayTrackFavorites(e){try{if(!this.player.isUserProductPremium()&&!this.player.attributes.sp_user_has_web_player_credentials)throw new Error(Se);this.progressShow(),this.alertInfo="Playing track favorites ...",this.requestUpdate(),await this.spotifyPlusService.PlayerMediaPlayTrackFavorites(this.player,null,e.shuffle,null,!0,this.config.trackFavBrowserItemsLimit||200),this.store.card.SetSection(et.PLAYER)}catch(e){this.alertErrorSet("Could not play track favorites for user preset. "+yt(e)),this.mediaBrowserContentElement.scrollTop=0}finally{this.progressHide()}}updateMediaList(e){if(!super.updateMediaList(e))return!1;try{this.mediaListLastUpdatedOn=nt(),this.mediaList=new Array;const e=new Array,t=new Promise(((e,t)=>{try{const t=JSON.parse(JSON.stringify(this.config.userPresets||[]));if(t){const e="nocache="+nt();t.forEach((t=>{t.origin="card config",t.image_url=(t.image_url||"").replace("{nocache}",e)})),(this.mediaList||[]).push(...t)}e(!0)}catch(e){super.updatedMediaListError("Load User Presets from config failed: "+yt(e)),t(e)}}));if(e.push(t),this.config.userPresetsFile){const t=new Promise(((e,t)=>{fetch(this.config.userPresetsFile+"?nocache="+Date.now()).then((e=>{if(!e.ok)throw new Error("server response: "+e.status+" "+e.statusText);return e.json()})).then((t=>{const i=t;if(i){const e="nocache="+nt();i.forEach((t=>{t.origin=this.config.userPresetsFile,t.image_url=(t.image_url||"").replace("{nocache}",e)})),(this.mediaList||[]).push(...i)}e(!0)})).catch((e=>{super.updatedMediaListError("Could not fetch data from configuration `userPresetsFile` ("+this.config.userPresetsFile+"); "+yt(e)),t(e)}))}));e.push(t)}return this.progressShow(),Promise.allSettled(e).then((e=>{})).finally((()=>{this.progressHide()})),!0}catch(e){return this.progressHide(),super.updatedMediaListError("User Presets favorites refresh failed: "+yt(e)),!0}}};Ir=Ie([Be("spc-userpreset-browser")],Ir);let Tr=class extends re{render(){return U`
this.onSectionClick(et.PLAYER)}
selected=${this.getSectionSelected(et.PLAYER)}
hide=${this.getSectionEnabled(et.PLAYER)}
>
this.onSectionClick(et.DEVICES)}
selected=${this.getSectionSelected(et.DEVICES)}
hide=${this.getSectionEnabled(et.DEVICES)}
>
this.onSectionClick(et.USERPRESETS)}
selected=${this.getSectionSelected(et.USERPRESETS)}
hide=${this.getSectionEnabled(et.USERPRESETS)}
>
this.onSectionClick(et.RECENTS)}
selected=${this.getSectionSelected(et.RECENTS)}
hide=${this.getSectionEnabled(et.RECENTS)}
>
this.onSectionClick(et.CATEGORYS)}
selected=${this.getSectionSelected(et.CATEGORYS)}
hide=${this.getSectionEnabled(et.CATEGORYS)}
>
this.onSectionClick(et.PLAYLIST_FAVORITES)}
selected=${this.getSectionSelected(et.PLAYLIST_FAVORITES)}
hide=${this.getSectionEnabled(et.PLAYLIST_FAVORITES)}
>
this.onSectionClick(et.ALBUM_FAVORITES)}
selected=${this.getSectionSelected(et.ALBUM_FAVORITES)}
hide=${this.getSectionEnabled(et.ALBUM_FAVORITES)}
>
this.onSectionClick(et.ARTIST_FAVORITES)}
selected=${this.getSectionSelected(et.ARTIST_FAVORITES)}
hide=${this.getSectionEnabled(et.ARTIST_FAVORITES)}
>
this.onSectionClick(et.TRACK_FAVORITES)}
selected=${this.getSectionSelected(et.TRACK_FAVORITES)}
hide=${this.getSectionEnabled(et.TRACK_FAVORITES)}
>
this.onSectionClick(et.AUDIOBOOK_FAVORITES)}
selected=${this.getSectionSelected(et.AUDIOBOOK_FAVORITES)}
hide=${this.getSectionEnabled(et.AUDIOBOOK_FAVORITES)}
>
this.onSectionClick(et.SHOW_FAVORITES)}
selected=${this.getSectionSelected(et.SHOW_FAVORITES)}
hide=${this.getSectionEnabled(et.SHOW_FAVORITES)}
>
this.onSectionClick(et.EPISODE_FAVORITES)}
selected=${this.getSectionSelected(et.EPISODE_FAVORITES)}
hide=${this.getSectionEnabled(et.EPISODE_FAVORITES)}
>
this.onSectionClick(et.SEARCH_MEDIA)}
selected=${this.getSectionSelected(et.SEARCH_MEDIA)}
hide=${this.getSectionEnabled(et.SEARCH_MEDIA)}
>
`}static get styles(){return a`
:host > * {
color: var(--spc-footer-icon-color, inherit);
}
:host > *[selected] {
color: var(--spc-footer-icon-color-selected, var(--dark-primary-color));
}
:host > *[hide] {
display: none;
}
`}onSectionClick(e){this.dispatchEvent(ot(pe,e))}getSectionSelected(e){return this.section===e||V}getSectionEnabled(e){return this.config.sections&&!this.config.sections?.includes(e)||V}};Ie([Ve({attribute:!1})],Tr.prototype,"config",void 0),Ie([Ve()],Tr.prototype,"section",void 0),Tr=Ie([Be("spc-footer")],Tr);const kr=ne+"-card-editor-config-area-selected";class Er{constructor(e){this.section=e||et.UNDEFINED}}function _r(e){const t=new Er;return t.section=e,new CustomEvent(kr,{bubbles:!0,composed:!0,detail:t})}class $r extends re{constructor(){super()}static get styles(){return a`
ha-svg-icon {
margin: 5px;
}
ha-control-button {
white-space: nowrap;
}
ha-control-button-group {
margin: 5px;
}
div {
margin-top: 20px;
}
`}setConfig(e){const t=JSON.parse(JSON.stringify(e));t.sections&&0!==t.sections.length||(t.sections=[et.PLAYER],Ui.selectedConfigArea=tt.GENERAL),this.config=t}configChanged(e=void 0){let t={};e&&(t=vt(this.config,e),this.config={...this.config,...e});const i=ht(Ui.selectedConfigArea);this.section!=i&&(this.section=i,this.store.section=this.section,document.dispatchEvent(_r(this.section))),((e,t,i,s)=>{s=s||{},i=null==i?{}:i;const r=new Event(t,{bubbles:void 0===s.bubbles||s.bubbles,cancelable:Boolean(s.cancelable),composed:void 0===s.composed||s.composed});r.detail=i,e.dispatchEvent(r)})(this,"config-changed",{config:this.config}),super.requestUpdate(),function(e,t){const i=ot(e,t);document.dispatchEvent(i)}("spc-dispatch-event-config-updated",t)}dispatchClose(){return super.dispatchEvent(new CustomEvent("closed"))}createStore(){if(this.store)return;const e=ht(Ui.selectedConfigArea);this.config.sections&&0!==this.config.sections.length||(this.config.sections=[et.PLAYER],Ui.selectedConfigArea=tt.GENERAL),this.store=new Ui(this.hass,this.config,this,e),this.player=this.store.player,this.section=this.store.section}SetSection(e){(!this.config.sections||this.config.sections.indexOf(e)>-1)&&(this.section=e,this.store.section=this.section,super.requestUpdate())}}Ie([Ve({attribute:!1})],$r.prototype,"hass",void 0),Ie([Ve({attribute:!1})],$r.prototype,"config",void 0),Ie([Ve({attribute:!1})],$r.prototype,"store",void 0),Ie([Ve({attribute:!0})],$r.prototype,"section",void 0),Ie([Ve({attribute:!1})],$r.prototype,"footerBackgroundColor",void 0),Ie([De()],$r.prototype,"playerImage",void 0),Ie([De()],$r.prototype,"playerMediaContentId",void 0),Ie([De()],$r.prototype,"vibrantImage",void 0),Ie([De()],$r.prototype,"vibrantMediaContentId",void 0);class Pr extends $r{render(){return this._styleRenderRootElements(),U`
`}static get styles(){return a`
`}firstUpdated(e){super.firstUpdated(e),this.isRenderRootStylesUpdated||this.requestUpdate()}onValueChanged(e){const t=e.detail.value;this.configChanged(t)}_styleRenderRootElements(){if(this.isRenderRootStylesUpdated)return;if(!this._elmHaForm)return void this.requestUpdate();if(!this._elmHaForm.shadowRoot)return void this.requestUpdate();if(!this._elmHaForm?.updateComplete)return void this.requestUpdate();if(!this.hasUpdated)return void this.requestUpdate();const e=this._elmHaForm.renderRoot.querySelector(".root");if(e){for(let t=0;t{this._styleRenderRootElements(),this.isRenderRootStylesUpdated=!0}),50),this._elmHaForm.requestUpdate()}else;}}function Fr({help:e,label:t,name:i}){if(t)return t+(e?` (${e})`:"");let s=i.replace(/([A-Z])/g," $1");return s=s.charAt(0).toUpperCase()+s.slice(1),s+(e?` (${e})`:"")}Ie([Ve({attribute:!1})],Pr.prototype,"schema",void 0),Ie([Ve({attribute:!1})],Pr.prototype,"data",void 0),Ie([Ve()],Pr.prototype,"changed",void 0),Ie([Ve()],Pr.prototype,"isRenderRootStylesUpdated",void 0),Ie([qe("#elmHaForm")],Pr.prototype,"_elmHaForm",void 0),customElements.define("spc-editor-form",Pr);const Rr=[{name:"sections",label:"Card sections to enable",help:"unchecked items will not be shown",required:!1,type:"multi_select",options:{player:"Player",albumfavorites:"Album Favorites",artistfavorites:"Artist Favorites",audiobookfavorites:"Audiobook Favorites",categorys:"Categorys",devices:"Devices",episodefavorites:"Episode Favorites",playlistfavorites:"Playlist Favorites",recents:"Recently Played",searchmedia:"Search Media",showfavorites:"Show Favorites",trackfavorites:"Track Favorites",userpresets:"User Presets"}},{name:"entity",label:"SpotifyPlus media player entity to retrieve data from",help:"required",required:!0,selector:{entity:{multiple:!1,filter:{domain:le,integration:ne}}}},{name:"title",label:"Card title text",help:"displayed at the top of the card above the section",required:!1,type:"string"},{name:"width",label:"Width of the card",help:'in rem units; or "fill" for 100% width',required:!1,type:"string",default:35.15},{name:"height",label:"Height of the card",help:'in rem units; or "fill" for 100% height',required:!1,type:"string",default:35.15},{name:"sectionDefault",label:"Default card section to display",required:!1,type:"select",options:[["player","Player"],["albumfavorites","Album Favorites"],["artistfavorites","Artist Favorites"],["audiobookfavorites","Audiobook Favorites"],["categorys","Categorys"],["devices","Devices"],["episodefavorites","Episode Favorites"],["playlistfavorites","Playlist Favorites"],["recents","Recently Played"],["searchmedia","Search Media"],["showfavorites","Show Favorites"],["trackfavorites","Track Favorites"],["userpresets","User Presets"]]},{name:"touchSupportDisabled",label:"Disable touch event support",help:"force mouse events",required:!1,selector:{boolean:{}}}];customElements.define("spc-general-editor",class extends $r{render(){return super.createStore(),U`
Settings that control overall look of card - version ${ae}
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}});const Lr=[{name:"playerBackgroundImageSize",label:"Size of the player background image",help:'default is "100% 100%"',required:!1,type:"string"},{name:"playerMinimizeOnIdle",label:"Minimize player height when state is off / idle",help:'if height not "fill"',required:!1,selector:{boolean:{}}}];customElements.define("spc-player-general-editor",class extends $r{render(){return super.createStore(),U`
Player General area settings
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
`}});const Or=[{name:"playerHeaderTitle",label:"Section title text displayed in the header area",required:!1,type:"string"},{name:"playerHeaderArtistTrack",label:"Artist and Track info displayed in the header area",required:!1,type:"string"},{name:"playerHeaderAlbum",label:"Album info displayed in the header area",required:!1,type:"string"},{name:"playerHeaderNoMediaPlayingText",label:"Text to display in the header area when no media is currently playing",required:!1,type:"string"},{name:"playerHeaderBackgroundColor",label:'Color value (e.g. "#hhrrggbb") for header area background gradient',help:"'transparent' to disable",required:!1,type:"string",default:fe},{name:"playerHeaderHideProgressBar",label:"Hide progress bar in the header area",required:!1,selector:{boolean:{}}},{name:"playerHeaderHide",label:"Hide header area of the Player section form",required:!1,selector:{boolean:{}}}];customElements.define("spc-player-header-editor",class extends $r{render(){return super.createStore(),U`
Player Header Status area settings
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
`}});const Mr=[{name:"playerControlsIconSize",label:"Size of the icons in the Player controls area.",help:'default is "'+Ae+'"',required:!1,type:"string",default:Ae},{name:"playerControlsHideFavorites",label:"Hide favorite actions control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHideShuffle",label:"Hide shuffle control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHideTrackPrev",label:"Hide previous track control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHidePlayPause",label:"Hide play / pause control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHideTrackNext",label:"Hide next track control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHideRepeat",label:"Hide repeat control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHidePlayQueue",label:"Hide play queue control button in the controls area",required:!1,selector:{boolean:{}}},{name:"playerControlsHide",label:"Hide controls area of the Player section form",required:!1,selector:{boolean:{}}}];customElements.define("spc-player-controls-editor",class extends $r{render(){return super.createStore(),U`
Player Media Control area settings
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
`}});const xr=[{name:"playerControlsBackgroundColor",label:'Color value (e.g. "#hhrrggbb") for controls area background gradient',help:"'transparent' to disable",required:!1,type:"string",default:fe},{name:"playerVolumeMaxValue",label:"Maximum volume value allowed via card UI",help:"range 10 - 100",required:!0,type:"integer",default:100,valueMin:10,valueMax:100},{name:"playerVolumeStepValue",label:"Amount used to adjust volume when step buttons are used",help:"range 1 - 30",required:!0,type:"integer",default:10,valueMin:1,valueMax:30},{name:"playerVolumeControlsHideMute",label:"Hide mute button in the volume controls area",required:!1,selector:{boolean:{}}},{name:"playerVolumeControlsHidePower",label:"Hide power button in the volume controls area",required:!1,selector:{boolean:{}}},{name:"playerVolumeControlsHideSlider",label:"Hide volume slider and levels in the volume controls area",required:!1,selector:{boolean:{}}},{name:"playerVolumeControlsShowPlusMinus",label:"Show plus / minus buttons in the volume controls area",required:!1,selector:{boolean:{}}},{name:"playerVolumeControlsHideLevels",label:"Hide volume level numbers / %'s in the volume controls area",required:!1,selector:{boolean:{}}}];var Br;customElements.define("spc-player-volume-editor",class extends $r{render(){return super.createStore(),U`
Player Volume Control area settings
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
`}}),function(e){e.GENERAL="General",e.HEADER="Header",e.CONTROLS="Controls",e.VOLUME="Volume"}(Br||(Br={}));const{GENERAL:Ur,HEADER:Hr,CONTROLS:Vr,VOLUME:Dr}=Br;class Nr extends $r{constructor(){super(...arguments),this.configArea=Ur}render(){return super.createStore(),U`
Settings that control the Player section look and feel
${[Ur,Hr,Vr,Dr].map((e=>U`
this.onConfigPlayerSectionClick(e)}
>
${e}
`))}
${this.subEditor()}
`}subEditor(){return Je(this.configArea,[[Ur,()=>U``],[Hr,()=>U``],[Vr,()=>U``],[Dr,()=>U``]])}onConfigPlayerSectionClick(e){this.configArea=e}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
ha-control-button[selected] {
--control-button-background-color: var(--primary-color);
}
`}}Ie([De()],Nr.prototype,"configArea",void 0),customElements.define("spc-player-editor",Nr);const qr=[{name:"albumFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"albumFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"albumFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"albumFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"albumFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"albumFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"albumFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"albumFavBrowserShuffleOnPlay",label:"Enable shuffle prior to starting play",required:!1,selector:{boolean:{}}},{name:"albumFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-album-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Album Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Gr=[{name:"artistFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"artistFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"artistFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"artistFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"artistFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"artistFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"artistFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"artistFavBrowserShuffleOnPlay",label:"Enable shuffle prior to starting play",required:!1,selector:{boolean:{}}},{name:"artistFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-artist-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Artist Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Jr=[{name:"audiobookFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"audiobookFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"audiobookFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"audiobookFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"audiobookFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"audiobookFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"audiobookFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"audiobookFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-audiobook-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Audiobook Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Wr=[{name:"categoryBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"categoryBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"categoryBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"categoryBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"categoryBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"categoryBrowserItemsSortTitle",label:"Sort Playlist items by Title",required:!1,selector:{boolean:{}}}];customElements.define("spc-category-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Category section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const zr=[{name:"deviceBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"deviceBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"deviceDefaultId",label:"Device name / id to use for all SpotifyPlus service calls",help:"e.g. Office Speaker",required:!1,type:"string"},{name:"deviceBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"deviceBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"deviceBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"deviceBrowserItemsShowHiddenDevices",label:"Show SpotifyPlus configured hidden devices in Device browser",required:!1,selector:{boolean:{}}},{name:"deviceControlByName",label:"Control the device by its name instead of ID",required:!1,selector:{boolean:{}}}];customElements.define("spc-device-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Sources section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}});const jr=[{name:"episodeFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"episodeFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"episodeFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"episodeFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"episodeFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"episodeFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"episodeFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"episodeFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-episode-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Episode Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Yr=[{name:"playlistFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"playlistFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"playlistFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"playlistFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"playlistFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"playlistFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"playlistFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"playlistFavBrowserShuffleOnPlay",label:"Enable shuffle prior to starting play",required:!1,selector:{boolean:{}}},{name:"playlistFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-playlist-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Playlist Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Kr=[{name:"recentBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"recentBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"recentBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"recentBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"recentBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"recentBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-recent-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Recently Played Browser section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}});const Zr=[{name:"searchMediaBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"searchMediaBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"searchMediaBrowserSearchTypes",label:"Search media types to enable",help:"unchecked items will not be shown; all enabled if none checked",required:!1,type:"multi_select",options:{Albums:"Albums",Artists:"Artists",AudioBooks:"AudioBooks",Episodes:"Episodes",Playlists:"Playlists",Shows:"Shows",Tracks:"Tracks"}},{name:"searchMediaBrowserSearchLimit",label:"Maximum # of items to return by the search",required:!1,type:"integer",default:50,valueMin:25,valueMax:500},{name:"searchMediaBrowserUseDisplaySettings",label:"Use search display settings when displaying results:",required:!1,selector:{boolean:{}}},{name:"searchMediaBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"searchMediaBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"searchMediaBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"searchMediaBrowserQueueSelection",label:"Queue track / episode when selected",help:"otherwise play immediately",required:!1,selector:{boolean:{}}}];customElements.define("spc-search-media-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Search Media section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Xr=[{name:"showFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"showFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"showFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"showFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"showFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"showFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"showFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"showFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-show-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Show Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const Qr=[{name:"trackFavBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"trackFavBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"trackFavBrowserItemsLimit",label:"Maximum # of favorite items to return",help:"1000 max, 200 default",required:!1,type:"integer",default:200,valueMin:1,valueMax:1e3},{name:"trackFavBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"trackFavBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"trackFavBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}},{name:"trackFavBrowserItemsSortTitle",label:"Sort items by Title",required:!1,selector:{boolean:{}}},{name:"trackFavBrowserShuffleOnPlay",label:"Enable shuffle prior to starting play of favorites",required:!1,selector:{boolean:{}}},{name:"trackFavBrowserItemsRefreshOnEntry",label:"Enable refresh of items on initial section display",required:!1,selector:{boolean:{}}}];customElements.define("spc-track-fav-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the Track Favorites section look and feel
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}onValueChanged(e){}});const eo=[{name:"userPresetBrowserTitle",label:"Section title text",help:"displayed at the top of the section",required:!1,type:"string"},{name:"userPresetBrowserSubTitle",label:"Section sub-title text",help:"displayed below the section title",required:!1,type:"string"},{name:"userPresetsFile",label:"File that contains user-defined preset items",help:'e.g. "/local/spotifyplus/userpresets.json"',required:!1,type:"string"},{name:"userPresetBrowserItemsPerRow",label:"# of items to display per row",help:"use 1 for list format",required:!0,type:"integer",default:4,valueMin:1,valueMax:12},{name:"userPresetBrowserItemsHideTitle",label:"Hide item row title text",required:!1,selector:{boolean:{}}},{name:"userPresetBrowserItemsHideSubTitle",label:"Hide item row sub-title text",help:"if Title visible",required:!1,selector:{boolean:{}}}];customElements.define("spc-userpreset-browser-editor",class extends $r{render(){return super.createStore(),U`
Settings that control the User Preset Browser section look and feel
User Preset items must be defined manually in the configuration code editor.
Please refer to the
wiki documentation for more details and examples.
`}static get styles(){return a`
.schema-title {
margin: 0.4rem 0;
text-align: left;
font-size: 1rem;
color: var(--secondary-text-color);
}
/* control the look and feel of the HA-FORM element. */
.spc-editor-form {
}
`}});const to=Fe(ce+":editor");class io extends $r{constructor(){super(...arguments),this.configArea=tt.GENERAL,this.onFooterShowSection=e=>{const t=pt(e.detail);this.configArea=t,Ui.selectedConfigArea=this.configArea}}render(){return this.hass&&this.config?(super.createStore(),U`
${[tt.GENERAL,tt.PLAYER,tt.DEVICE_BROWSER,tt.USERPRESET_BROWSER,tt.RECENT_BROWSER].map((e=>U`
this.onConfigSectionClick(e)}
>
${e}
`))}
${[tt.PLAYLIST_FAVORITES,tt.ALBUM_FAVORITES,tt.ARTIST_FAVORITES,tt.TRACK_FAVORITES,tt.AUDIOBOOK_FAVORITES].map((e=>U`
this.onConfigSectionClick(e)}
>
${e}
`))}
${[tt.EPISODE_FAVORITES,tt.SHOW_FAVORITES,tt.CATEGORY_BROWSER,tt.SEARCH_MEDIA_BROWSER].map((e=>U`
this.onConfigSectionClick(e)}
>
${e}
`))}
${this.subEditor()}
`):U``}static get styles(){return a`
.spc-card-editor {
/* control the look and feel of the HA-FORM element. */
--ha-form-style-integer-margin-bottom: 0.5rem;
--ha-form-style-multiselect-margin-bottom: 0.5rem;
--ha-form-style-selector-margin-bottom: 0.5rem;
--ha-form-style-selector-boolean-min-height: 28px;
--ha-form-style-string-margin-bottom: 0.5rem;
}
ha-control-button-group {
margin-bottom: 8px;
}
ha-control-button[selected] {
--control-button-background-color: var(--primary-color);
}
`}subEditor(){return Je(this.configArea,[[tt.ALBUM_FAVORITES,()=>U``],[tt.ARTIST_FAVORITES,()=>U``],[tt.AUDIOBOOK_FAVORITES,()=>U``],[tt.CATEGORY_BROWSER,()=>U``],[tt.DEVICE_BROWSER,()=>U``],[tt.EPISODE_FAVORITES,()=>U``],[tt.GENERAL,()=>U``],[tt.PLAYER,()=>U``],[tt.PLAYLIST_FAVORITES,()=>U``],[tt.RECENT_BROWSER,()=>U``],[tt.SEARCH_MEDIA_BROWSER,()=>U``],[tt.SHOW_FAVORITES,()=>U``],[tt.TRACK_FAVORITES,()=>U``],[tt.USERPRESET_BROWSER,()=>U``]])}onConfigSectionClick(e){const t=ht(e);Ui.selectedConfigArea=e,this.configArea=e,this.section=t,this.store.section=t,document.dispatchEvent(_r(this.section))}connectedCallback(){super.connectedCallback(),window.addEventListener(pe,this.onFooterShowSection)}disconnectedCallback(){window.removeEventListener(pe,this.onFooterShowSection),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),to.enabled&&to("firstUpdated (editor) - 1st render complete - changedProperties keys:\n%s",JSON.stringify(Array.from(e.keys())));let t=pt(this.section);this.config&&(this.config.entity||(t=tt.GENERAL)),this.configArea=t,Ui.selectedConfigArea=this.configArea,super.requestUpdate()}}Ie([De()],io.prototype,"configArea",void 0),customElements.define("spc-editor",io);const so=Fe(ce+":card"),ro="100%";let oo=class extends ai{constructor(){super(),this.isFirstTimeSetup=!0,this.onEditorConfigAreaSelectedEventHandler=e=>{const t=e.detail;this.config.sections?.includes(t.section)?(so.enabled&&so("onEditorConfigAreaSelectedEventHandler - set section reference for selected ConfigArea and display the section\n- OLD section=%s\n- NEW section=%s",JSON.stringify(this.section),JSON.stringify(t.section)),this.SetSection(t.section)):so.enabled&&so("onEditorConfigAreaSelectedEventHandler - section is not active: %s",JSON.stringify(t.section))},this.onFooterShowSection=e=>{const t=e.detail;(!this.config.sections||this.config.sections.indexOf(t)>-1)&&(this.section=t,this.store.section=this.section,super.requestUpdate())},this.onMediaListItemSelected=()=>{},this.onProgressEndedEventHandler=()=>{this.cancelLoader=!0;const e=Date.now()-this.loaderTimestamp;this.showLoader&&(e<1e3?setTimeout((()=>this.showLoader=!1),1e3-e):this.showLoader=!1)},this.onProgressStartedEventHandler=()=>{this.showLoader||(this.cancelLoader=!1,setTimeout((()=>{this.cancelLoader||(this.showLoader=!0,this.loaderTimestamp=Date.now())}),250))},this.onFilterSectionMediaEventHandler=e=>{const t=e.detail;Object.values(et).includes(t.section||"")||so("%conFilterSectionMediaEventHandler - Ignoring Filter request; section is not a valid Section enum value:\n%s","color:red",JSON.stringify(t,null,2)),this.config.sections?.includes(t.section)?(this.section=t.section,this.store.section=this.section,setTimeout((()=>{let e;if(so.enabled&&so("onFilterSectionMediaEventHandler - executing filter:\n%s",JSON.stringify(t,null,2)),t.section==et.ALBUM_FAVORITES)e=this.elmAlbumFavBrowserForm;else if(t.section==et.ARTIST_FAVORITES)e=this.elmArtistFavBrowserForm;else if(t.section==et.AUDIOBOOK_FAVORITES)e=this.elmAudiobookFavBrowserForm;else if(t.section==et.DEVICES)e=this.elmDeviceBrowserForm;else if(t.section==et.EPISODE_FAVORITES)e=this.elmEpisodeFavBrowserForm;else if(t.section==et.PLAYLIST_FAVORITES)e=this.elmPlaylistFavBrowserForm;else if(t.section==et.RECENTS)e=this.elmRecentBrowserForm;else if(t.section==et.SHOW_FAVORITES)e=this.elmShowFavBrowserForm;else if(t.section==et.TRACK_FAVORITES)e=this.elmTrackFavBrowserForm;else{if(t.section!=et.USERPRESETS)return;e=this.elmUserPresetBrowserForm}e.filterSectionMedia(t)}),50)):so("%onFilterSectionMediaEventHandler - Filter section is not enabled; ignoring filter request:\n%s","color:red",JSON.stringify(t,null,2))},this.onSearchMediaEventHandler=e=>{const t=e.detail;this.config.sections?.includes(et.SEARCH_MEDIA)?(this.section=et.SEARCH_MEDIA,this.store.section=this.section,setTimeout((()=>{so.enabled&&so("onSearchMediaEventHandler - executing search:\n%s",JSON.stringify(t,null,2)),this.elmSearchMediaBrowserForm.searchExecute(t)}),250)):(so("%conSearchMediaEventHandler - Search section is not enabled; ignoring search request:\n%s","color:red",JSON.stringify(t,null,2)),this.alertInfoSet("Search section is not enabled; ignoring search request."))},this.onCategoryDisplayEventHandler=e=>{const t=e.detail;this.config.sections?.includes(et.CATEGORYS)?(this.section=et.CATEGORYS,this.store.section=this.section,setTimeout((()=>{so.enabled&&so("onCategoryDisplayEventHandler - displaying category:\n%s",JSON.stringify(t,null,2)),this.elmCategoryBrowserForm.displayCategory(t)}),250)):so("%conCategoryDisplayEventHandler - Category section is not enabled; ignoring display request:\n%s","color:red",JSON.stringify(t,null,2))},this.showLoader=!1,this.cancelLoader=!1,this.loaderTimestamp=0}render(){if(!this.hass)return U``;this.createStore(),this.config.sections&&0!==this.config.sections.length||(this.config.sections=[et.PLAYER],Ui.selectedConfigArea=tt.GENERAL);const e=this.config.sections,t=!e||e.length>1,i=It(this.config.title,this.config,this.store.player);return this.checkForBackgroundImageChange(),U`
${i?U``:""}
${this.alertError?U`${this.alertError}`:""}
${this.alertInfo?U`${this.alertInfo}`:""}
${""!=this.store.player.id?Je(this.section,[[et.ALBUM_FAVORITES,()=>U`
`],[et.ARTIST_FAVORITES,()=>U`
`],[et.AUDIOBOOK_FAVORITES,()=>U`
`],[et.CATEGORYS,()=>U`
`],[et.DEVICES,()=>U`
`],[et.EPISODE_FAVORITES,()=>U`
`],[et.PLAYER,()=>U`
`],[et.PLAYLIST_FAVORITES,()=>U`
`],[et.RECENTS,()=>U`
`],[et.SEARCH_MEDIA,()=>U``],[et.SHOW_FAVORITES,()=>U``],[et.TRACK_FAVORITES,()=>U``],[et.USERPRESETS,()=>U``],[et.UNDEFINED,()=>U`SpotifyPlus card configuration error.
Please configure section(s) to display.
`]]):U`
Welcome to the SpotifyPlus media player card.
Start by editing the card configuration media player "entity" value.
${this.store.player.attributes.sp_config_state}
`}
${We(t,(()=>U``))}
`}static get styles(){return a`
:host {
display: block;
width: 100% !important;
height: 100% !important;
}
* {
margin: 0;
}
html,
body {
height: 100%;
margin: 0;
}
spotifyplus-card {
display: block;
height: 100% !important;
width: 100% !important;
}
hui-card-preview {
min-height: 10rem;
height: 40rem;
min-width: 10rem;
width: 40rem;
}
.spc-card {
--spc-card-header-height: ${2}rem;
--spc-card-footer-height: ${4}rem;
--spc-card-edit-tab-height: 0px;
--spc-card-edit-bottom-toolbar-height: 0px;
box-sizing: border-box;
padding: 0rem;
display: flex;
flex-direction: column;
overflow: hidden;
height: calc(100vh - var(--spc-card-footer-height) - var(--spc-card-edit-tab-height) - var(--spc-card-edit-bottom-toolbar-height));
min-width: 20rem;
width: calc(100vw - var(--mdc-drawer-width));
color: var(--secondary-text-color);
}
.spc-card-header {
box-sizing: border-box;
padding: 0.2rem;
display: flex;
align-self: flex-start;
align-items: center;
justify-content: space-around;
width: 100%;
font-weight: bold;
font-size: 1.2rem;
color: var(--secondary-text-color);
}
.spc-card-content-section {
margin: var(--spc-card-content-margin, ${o("0.0rem")});
flex-grow: 1;
flex-shrink: 0;
height: 1vh;
overflow: hidden;
}
.spc-card-footer-container {
width: 100%;
display: flex;
align-items: center;
background-repeat: no-repeat;
background-color: var(--spc-footer-background-color, var(--spc-player-footer-bg-color, var(--card-background-color, transparent)));
background-image: var(--spc-footer-background-image, linear-gradient(rgba(0, 0, 0, 0.6), rgb(0, 0, 0)));
}
.spc-card-footer {
margin: 0.2rem;
display: flex;
align-self: flex-start;
align-items: center;
justify-content: space-around;
flex-wrap: wrap;
width: 100%;
--ha-icon-button-size: var(--spc-footer-icon-button-size, 2.5rem);
--mdc-icon-size: var(--spc-footer-icon-size, 1.75rem);
--mdc-ripple-top: 0px;
--mdc-ripple-left: 0px;
--mdc-ripple-fg-size: 10px;
}
.spc-loader {
position: absolute;
z-index: 1000;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
--ha-spinner-indicator-color: var(--spc-card-wait-progress-slider-color, var(--dark-primary-color, ${o(ye)}));
}
.spc-not-configured {
text-align: center;
margin: 1rem;
color: #fa2643;
}
.spc-initial-config {
text-align: center;
margin-top: 1rem;
}
ha-icon-button {
padding-left: 1rem;
padding-right: 1rem;
}
`}createStore(){if(this.store=new Ui(this.hass,this.config,this,this.section),this.isCardInEditPreview=ut(this),this.playerId||(this.playerId=this.config.entity),this.isFirstTimeSetup&&this.playerId){so("createStore - isFirstTimeSetup logic invoked; creating store area");const e=this.store.config.playerVolumeStepValue||0;e>0&&10!=e&&(so("createStore - isFirstTimeSetup is setting media player volume step level"),this.store.spotifyPlusService.VolumeSetStepLevel(this.store.player,e)),this.config.sections&&0!=this.config.sections.length?this.config.sectionDefault?(so("createStore - isFirstTimeSetup defaulting section to config.sectionDefault (%s)",JSON.stringify(this.config.sectionDefault)),this.SetSection(this.config.sectionDefault)):this.section||(so("createStore - isFirstTimeSetup defaulting section to Store.selectedConfigArea (%s)",JSON.stringify(Ui.selectedConfigArea)),this.SetSection(ht(Ui.selectedConfigArea))):(so("createStore - isFirstTimeSetup defaulting section to PLAYER"),this.config.sections=[et.PLAYER],Ui.selectedConfigArea=tt.GENERAL,this.SetSection(et.PLAYER)),this.isFirstTimeSetup=!1}}SetSection(e){!this.config.sections||this.config.sections.indexOf(e)>-1?(so.enabled&&so("SetSection - set section reference and display the section\n- OLD section=%s\n- NEW section=%s",JSON.stringify(this.section),JSON.stringify(e)),this.section=e,this.store.section=this.section,super.requestUpdate()):so.enabled&&so("SetSection - section is not active: %s",JSON.stringify(e))}connectedCallback(){super.connectedCallback(),this.addEventListener(ri,this.onProgressEndedEventHandler),this.addEventListener(oi,this.onProgressStartedEventHandler),this.addEventListener(ci,this.onSearchMediaEventHandler),this.addEventListener(yr,this.onCategoryDisplayEventHandler),this.addEventListener(wr,this.onFilterSectionMediaEventHandler),document.addEventListener(kr,this.onEditorConfigAreaSelectedEventHandler)}disconnectedCallback(){this.removeEventListener(ri,this.onProgressEndedEventHandler),this.removeEventListener(oi,this.onProgressStartedEventHandler),this.removeEventListener(ci,this.onSearchMediaEventHandler),this.removeEventListener(yr,this.onCategoryDisplayEventHandler),this.removeEventListener(wr,this.onFilterSectionMediaEventHandler),document.removeEventListener(kr,this.onEditorConfigAreaSelectedEventHandler),super.disconnectedCallback()}firstUpdated(e){super.firstUpdated(e),so.enabled&&so("firstUpdated (card) - 1st render complete - changedProperties keys:\n%s",JSON.stringify(Array.from(e.keys())));const t=this.config.sections||[];if(t.includes(this.section))this.isCardInEditPreview&&super.requestUpdate();else{let e=et.PLAYER;t.includes(et.PLAYER)?e=et.PLAYER:t.includes(et.DEVICES)?e=et.DEVICES:t.includes(et.USERPRESETS)?e=et.USERPRESETS:t.includes(et.RECENTS)?e=et.RECENTS:t.includes(et.CATEGORYS)?e=et.CATEGORYS:t.includes(et.PLAYLIST_FAVORITES)?e=et.PLAYLIST_FAVORITES:t.includes(et.ALBUM_FAVORITES)?e=et.ALBUM_FAVORITES:t.includes(et.ARTIST_FAVORITES)?e=et.ARTIST_FAVORITES:t.includes(et.TRACK_FAVORITES)?e=et.TRACK_FAVORITES:t.includes(et.AUDIOBOOK_FAVORITES)?e=et.AUDIOBOOK_FAVORITES:t.includes(et.SHOW_FAVORITES)?e=et.SHOW_FAVORITES:t.includes(et.EPISODE_FAVORITES)?e=et.EPISODE_FAVORITES:t.includes(et.SEARCH_MEDIA)&&(e=et.SEARCH_MEDIA),Ui.selectedConfigArea=pt(e),this.section=e,this.store.section=e,super.requestUpdate()}}setConfig(e){const t=JSON.parse(JSON.stringify(e));for(const[e,i]of Object.entries(t))Array.isArray(i)&&0===i.length&&delete t[e];const i={};for(const e in t.customImageUrls){const s=wt(e);let r=t.customImageUrls[e];r=r?.replace(" ","%20"),i[s]=r}t.customImageUrls=i,t.sections&&0!==t.sections.length||(t.sections=[et.PLAYER],Ui.selectedConfigArea=tt.GENERAL),this.config=t,so("%csetConfig - Configuration reference set\n%s","color:orange",JSON.stringify(t,null,2))}getCardSize(){return 3}static getConfigElement(){return Ui.selectedConfigArea=tt.GENERAL,Ui.hasCardEditLoadedMediaList={},document.createElement("spc-editor")}static getStubConfig(){return{cardUniqueId:Ze(),sections:[et.PLAYER,et.ALBUM_FAVORITES,et.ARTIST_FAVORITES,et.PLAYLIST_FAVORITES,et.RECENTS,et.DEVICES,et.TRACK_FAVORITES,et.USERPRESETS,et.AUDIOBOOK_FAVORITES,et.SHOW_FAVORITES,et.EPISODE_FAVORITES,et.SEARCH_MEDIA],entity:"",playerHeaderTitle:"{player.source}",playerHeaderArtistTrack:"{player.media_artist} - {player.media_title}",playerHeaderAlbum:"{player.media_album_name} {player.sp_playlist_name_title}",playerHeaderNoMediaPlayingText:'"{player.name}" state is "{player.state}"',albumFavBrowserTitle:"Album Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",albumFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",albumFavBrowserItemsPerRow:4,albumFavBrowserItemsHideTitle:!1,albumFavBrowserItemsHideSubTitle:!1,albumFavBrowserItemsSortTitle:!0,artistFavBrowserTitle:"Artist Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",artistFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",artistFavBrowserItemsPerRow:4,artistFavBrowserItemsHideTitle:!1,artistFavBrowserItemsHideSubTitle:!0,artistFavBrowserItemsSortTitle:!0,audiobookFavBrowserTitle:"Audiobook Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",audiobookFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",audiobookFavBrowserItemsPerRow:4,audiobookFavBrowserItemsHideTitle:!1,audiobookFavBrowserItemsHideSubTitle:!1,audiobookFavBrowserItemsSortTitle:!0,categoryBrowserTitle:"Categorys for {player.sp_user_display_name} ({medialist.filteritemcount} items)",categoryBrowserSubTitle:"click a tile item to view the content; click-hold for actions",categoryBrowserItemsPerRow:4,categoryBrowserItemsHideTitle:!1,categoryBrowserItemsHideSubTitle:!0,categoryBrowserItemsSortTitle:!0,deviceBrowserTitle:"Spotify Connect Devices ({medialist.filteritemcount} items)",deviceBrowserSubTitle:"click an item to select the device; click-hold for device info",deviceBrowserItemsPerRow:1,deviceBrowserItemsHideTitle:!1,deviceBrowserItemsHideSubTitle:!0,episodeFavBrowserTitle:"Episode Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",episodeFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",episodeFavBrowserItemsPerRow:4,episodeFavBrowserItemsHideTitle:!1,episodeFavBrowserItemsHideSubTitle:!1,episodeFavBrowserItemsSortTitle:!0,playlistFavBrowserTitle:"Playlist Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",playlistFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",playlistFavBrowserItemsPerRow:4,playlistFavBrowserItemsHideTitle:!1,playlistFavBrowserItemsHideSubTitle:!1,playlistFavBrowserItemsSortTitle:!0,recentBrowserTitle:"Recently Played by {player.sp_user_display_name} ({medialist.filteritemcount} items)",recentBrowserSubTitle:"click a tile item to play the content; click-hold for actions",recentBrowserItemsPerRow:4,recentBrowserItemsHideTitle:!1,recentBrowserItemsHideSubTitle:!1,searchMediaBrowserTitle:"Search Media for {player.sp_user_display_name} ({medialist.filteritemcount} items)",searchMediaBrowserSubTitle:"click a tile item to play the content; click-hold for actions",searchMediaBrowserUseDisplaySettings:!1,searchMediaBrowserItemsPerRow:4,searchMediaBrowserItemsHideTitle:!1,searchMediaBrowserItemsHideSubTitle:!0,searchMediaBrowserItemsSortTitle:!1,searchMediaBrowserSearchLimit:50,searchMediaBrowserSearchTypes:[Et.ALBUMS,Et.ARTISTS,Et.PLAYLISTS,Et.TRACKS,Et.AUDIOBOOKS,Et.SHOWS,Et.EPISODES],showFavBrowserTitle:"Show Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",showFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",showFavBrowserItemsPerRow:4,showFavBrowserItemsHideTitle:!1,showFavBrowserItemsHideSubTitle:!0,showFavBrowserItemsSortTitle:!0,trackFavBrowserTitle:"Track Favorites for {player.sp_user_display_name} ({medialist.filteritemcount} items)",trackFavBrowserSubTitle:"click a tile item to play the content; click-hold for actions",trackFavBrowserItemsPerRow:4,trackFavBrowserItemsHideTitle:!1,trackFavBrowserItemsHideSubTitle:!1,trackFavBrowserItemsSortTitle:!1,userPresetBrowserTitle:"User Presets for {player.sp_user_display_name} ({medialist.filteritemcount} items)",userPresetBrowserSubTitle:"click a tile item to play the content; click-hold for actions",userPresetBrowserItemsPerRow:4,userPresetBrowserItemsHideTitle:!1,userPresetBrowserItemsHideSubTitle:!1,userPresets:[{name:"Daily Mix 1",subtitle:"Various Artists",image_url:"https://dailymix-images.scdn.co/v2/img/ab6761610000e5ebcd3f796bd7ea49ed7615a550/1/en/default",uri:"spotify:playlist:37i9dQZF1E39vTG3GurFPW",type:"playlist"},{name:"My Track Favorites",subtitle:"Shuffled",image_url:"https://t.scdn.co/images/728ed47fc1674feb95f7ac20236eb6d7.jpeg",shuffle:!0,type:"trackfavorites"}],customImageUrls:{X_default:"/local/images/spotifyplus_card_customimages/default.png","X_empty preset":"/local/images/spotifyplus_card_customimages/empty_preset.png","X_Daily Mix 1":"https://brands.home-assistant.io/spotifyplus/icon.png",X_playerBackground:"/local/images/spotifyplus_card_customimages/playerBackground.png",X_playerIdleBackground:"/local/images/spotifyplus_card_customimages/playerIdleBackground.png",X_playerOffBackground:"/local/images/spotifyplus_card_customimages/playerOffBackground.png"}}}styleCard(){const e={};let t="0px",i="0px";const s=this.config.cardWaitProgressSliderColor,r=this.config.cardContentMargin;return s&&(e["--spc-card-wait-progress-slider-color"]=`${s}`),r&&(e["--spc-card-content-margin"]=`${r}`),""==(this.playerId||"")&&(e["background-repeat"]="no-repeat",e["background-position"]="center",e["background-image"]=`url(${ue})`,e["background-size"]=`${me}`),this.isCardInEditPreview?(e["--spc-card-edit-tab-height"]=`${t}`,e["--spc-card-edit-bottom-toolbar-height"]=`${i}`,e.height="42rem",e.width="100%",this.config.playerMinimizeOnIdle&&this.section==et.PLAYER&&this.store.player.isPoweredOffOrIdle()&&"fill"!=this.config.height&&(e.height="unset !important",e["min-height"]="unset !important"),xe(e)):function(e){let t,i,s;if(e){const r=e.parentElement;if(r){t=(r.className||"").trim();const e=r.parentElement;if(e){i=(e.className||"").trim();const t=e.parentElement;t&&(s=(t.className||"").trim())}}}let r=!1;return"preview"===t&&"card"===i&&"cards-container"===s&&(r=!0),r}(this)?(e["--spc-card-edit-tab-height"]=`${t}`,e["--spc-card-edit-bottom-toolbar-height"]=`${i}`,e.height="100%",e.width=`${ro}`,e["min-height"]="22rem",e["min-width"]=`${ro}`,xe(e)):(function(){const e=window.location.search;let t=!1;return"1"==new URLSearchParams(e).get("edit")&&(t=!0),t}()&&(t="48px",i="59px"),"fill"==this.config.width?e.width="100%":mt(String(this.config.width))?e.width=String(this.config.width)+"rem":e.width="35.15rem","fill"==this.config.height?e.height="calc(100vh - var(--spc-card-footer-height) - var(--spc-card-edit-tab-height) - var(--spc-card-edit-bottom-toolbar-height))":mt(String(this.config.height))?e.height=String(this.config.height)+"rem":e.height="35.15rem",this.config.playerMinimizeOnIdle&&this.section==et.PLAYER&&this.store.player.isPoweredOffOrIdle()&&"fill"!=this.config.height&&(e.height="unset !important",e["min-height"]="unset !important"),e["--spc-card-edit-tab-height"]=`${t}`,e["--spc-card-edit-bottom-toolbar-height"]=`${i}`,e["--spc-player-palette-vibrant"]=`${this.vibrantColorVibrant}`,e["--spc-player-palette-muted"]=`${this.vibrantColorMuted}`,e["--spc-player-palette-darkvibrant"]=`${this.vibrantColorDarkVibrant}`,e["--spc-player-palette-darkmuted"]=`${this.vibrantColorDarkMuted}`,e["--spc-player-palette-lightvibrant"]=`${this.vibrantColorLightVibrant}`,e["--spc-player-palette-lightmuted"]=`${this.vibrantColorLightMuted}`,xe(e))}styleCardHeader(){const e={};return this.section==et.PLAYER&&this.footerBackgroundColor&&(e["--spc-player-footer-bg-color"]=`${this.footerBackgroundColor||"transparent"}`,e["background-color"]="var(--spc-player-footer-bg-color)",e["background-image"]="linear-gradient(rgba(0, 0, 0, 1.6), rgba(0, 0, 0, 0.6))"),xe(e)}styleCardContent(){const e={};return this.config.playerMinimizeOnIdle&&this.section==et.PLAYER&&this.store.player.isPoweredOffOrIdle()&&"fill"!=this.config.height&&(e.height="unset !important"),xe(e)}styleCardFooter(){const e={};this.config.playerMinimizeOnIdle&&(this.alertError||this.store.player.isPoweredOffOrIdle()&&(this.config.sections||[]).indexOf(et.PLAYER)>-1&&this.section==et.PLAYER&&(e.display="none",this.section=et.PLAYER,Ui.selectedConfigArea=tt.PLAYER));const t=this.config.footerBackgroundColor,i=this.config.footerBackgroundImage,s=this.config.footerIconColor,r=this.config.footerIconColorSelected,o=this.config.footerIconSize;return s&&(e["--spc-footer-icon-color"]=`${s}`),r&&(e["--spc-footer-icon-color-selected"]=`${r}`),o&&(e["--spc-footer-icon-size"]=`${o}`,e["--spc-footer-icon-button-size"]=`var(--spc-footer-icon-size, ${o})`),i&&(e["--spc-footer-background-image"]=`${i}`),t?e["--spc-footer-background-color"]=`${t}`:this.section==et.PLAYER&&this.vibrantColorVibrant?e["--spc-player-footer-bg-color"]=`${this.footerBackgroundColor||"transparent"}`:e.background="unset",xe(e)}checkForBackgroundImageChange(){try{if(this.isUpdateInProgressAsync)return;this.isUpdateInProgressAsync=!0;const e=this.playerImage,t=this.playerMediaContentId;if(this.isCardInEditPreview)return this.isUpdateInProgressAsync=!1,void(this.footerBackgroundColor=void 0);if(this.vibrantMediaContentId===t)return void(this.isUpdateInProgressAsync=!1);if(null==e||""==e||"BRAND_LOGO_IMAGE_BASE64"==t)return this.vibrantImage=e,this.vibrantMediaContentId=t,this.vibrantColorVibrant=void 0,this.footerBackgroundColor=this.vibrantColorVibrant,void(this.isUpdateInProgressAsync=!1);so.enabled&&so("checkForBackgroundImageChange - player content changed:\n- OLD vibrantMediaContentId = %s\n- NEW playerMediaContentId = %s\n- OLD vibrantImage = %s\n- NEW playerImage = %s\n- isCardInEditPreview = %s\n- footerBackgroundColor = %s",JSON.stringify(this.vibrantMediaContentId),JSON.stringify(t),JSON.stringify(this.vibrantImage),JSON.stringify(e),JSON.stringify(this.isCardInEditPreview),JSON.stringify(this.footerBackgroundColor));const i=new Array,s=new Promise(((i,s)=>{const r=new Image;r.crossOrigin="Anonymous",r.src=e+"?not-from-cache-please";new it(r,{colorCount:64,quality:3}).getPalette().then((s=>{so.enabled&&so("%ccheckForBackgroundImageChange - colors found by getPalette:\n- Vibrant = %s\n- Muted = %s\n- DarkVibrant = %s\n- DarkMuted = %s\n- LightVibrant = %s\n- LightMuted = %s","color:orange",s.Vibrant?.hex||"undefined",s.Muted?.hex||"undefined",s.DarkVibrant?.hex||"undefined",s.DarkMuted?.hex||"undefined",s.LightVibrant?.hex||"undefined",s.LightMuted?.hex||"undefined"),this.vibrantColorVibrant=s.Vibrant?.hex||void 0,this.vibrantColorMuted=s.Muted?.hex||void 0,this.vibrantColorDarkVibrant=s.DarkVibrant?.hex||void 0,this.vibrantColorDarkMuted=s.DarkMuted?.hex||void 0,this.vibrantColorLightVibrant=s.LightVibrant?.hex||void 0,this.vibrantColorLightMuted=s.LightMuted?.hex||void 0,this.vibrantImage=e,this.vibrantMediaContentId=t,this.footerBackgroundColor=this.vibrantColorVibrant,this.isUpdateInProgressAsync=!1,i(!0)})).catch((i=>{so.enabled&&so("%ccheckForBackgroundImageChange - Could not retrieve color palette info for player background image\nreason = %s",JSON.stringify(yt(i))),this.vibrantColorVibrant=void 0,this.vibrantColorMuted=void 0,this.vibrantColorDarkVibrant=void 0,this.vibrantColorDarkMuted=void 0,this.vibrantColorLightVibrant=void 0,this.vibrantColorLightMuted=void 0,this.vibrantImage=e,this.vibrantMediaContentId=t,this.footerBackgroundColor=this.vibrantColorVibrant,this.isUpdateInProgressAsync=!1,this.checkForBackgroundImageChangeError("Vibrant getPalette method failed: "+yt(i)),s(i)}))}));return i.push(s),void Promise.allSettled(i).finally((()=>{this.progressHide()}))}catch(e){return void this.checkForBackgroundImageChangeError("Background Image processing error: "+yt(e))}}checkForBackgroundImageChangeError(e=null){this.alertInfoClear(),so.enabled&&so("%ccheckForBackgroundImageChangeError - error processing background image:\n %s","color:red",JSON.stringify(e)),this.alertErrorSet(e||"Unknown Error")}};Ie([Ve({attribute:!1})],oo.prototype,"hass",void 0),Ie([Ve({attribute:!1})],oo.prototype,"config",void 0),Ie([Ve({attribute:!1})],oo.prototype,"footerBackgroundColor",void 0),Ie([De()],oo.prototype,"section",void 0),Ie([De()],oo.prototype,"showLoader",void 0),Ie([De()],oo.prototype,"loaderTimestamp",void 0),Ie([De()],oo.prototype,"cancelLoader",void 0),Ie([De()],oo.prototype,"playerId",void 0),Ie([De()],oo.prototype,"playerImage",void 0),Ie([De()],oo.prototype,"playerMediaContentId",void 0),Ie([De()],oo.prototype,"vibrantImage",void 0),Ie([De()],oo.prototype,"vibrantMediaContentId",void 0),Ie([De()],oo.prototype,"vibrantColorVibrant",void 0),Ie([De()],oo.prototype,"vibrantColorMuted",void 0),Ie([De()],oo.prototype,"vibrantColorDarkVibrant",void 0),Ie([De()],oo.prototype,"vibrantColorDarkMuted",void 0),Ie([De()],oo.prototype,"vibrantColorLightVibrant",void 0),Ie([De()],oo.prototype,"vibrantColorLightMuted",void 0),Ie([qe("#elmSearchMediaBrowserForm",!1)],oo.prototype,"elmSearchMediaBrowserForm",void 0),Ie([qe("#elmCategoryBrowserForm",!1)],oo.prototype,"elmCategoryBrowserForm",void 0),Ie([qe("#elmAlbumFavBrowserForm",!1)],oo.prototype,"elmAlbumFavBrowserForm",void 0),Ie([qe("#elmArtistFavBrowserForm",!1)],oo.prototype,"elmArtistFavBrowserForm",void 0),Ie([qe("#elmAudiobookFavBrowserForm",!1)],oo.prototype,"elmAudiobookFavBrowserForm",void 0),Ie([qe("#elmDeviceBrowserForm",!1)],oo.prototype,"elmDeviceBrowserForm",void 0),Ie([qe("#elmEpisodeFavBrowserForm",!1)],oo.prototype,"elmEpisodeFavBrowserForm",void 0),Ie([qe("#elmPlaylistFavBrowserForm",!1)],oo.prototype,"elmPlaylistFavBrowserForm",void 0),Ie([qe("#elmRecentBrowserForm",!1)],oo.prototype,"elmRecentBrowserForm",void 0),Ie([qe("#elmShowFavBrowserForm",!1)],oo.prototype,"elmShowFavBrowserForm",void 0),Ie([qe("#elmTrackFavBrowserForm",!1)],oo.prototype,"elmTrackFavBrowserForm",void 0),Ie([qe("#elmUserPresetBrowserForm",!1)],oo.prototype,"elmUserPresetBrowserForm",void 0),oo=Ie([Be("spotifyplus-card")],oo);
/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */
let ao="";function no(e){ao=e}async function lo(e){const t=e instanceof Element?e.tagName.toLowerCase():"",i=t?.startsWith("wa-"),s=[...e.querySelectorAll(":not(:defined)")].map((e=>e.tagName.toLowerCase())).filter((e=>e.startsWith("wa-")));i&&!customElements.get(t)&&s.push(t);const r=[...new Set(s)],o=await Promise.allSettled(r.map((e=>function(e){if(customElements.get(e))return Promise.resolve();const t=e.replace(/^wa-/i,""),i=function(e=""){if(!ao){const e=document.querySelector("[data-webawesome]");if(e?.hasAttribute("data-webawesome"))no(new URL(e.getAttribute("data-webawesome")??"",window.location.href).pathname);else{const e=[...document.getElementsByTagName("script")].find((e=>e.src.endsWith("webawesome.js")||e.src.endsWith("webawesome.loader.js")||e.src.endsWith("webawesome.ssr-loader.js")));e&&no(String(e.getAttribute("src")).split("/").slice(0,-1).join("/"))}}return ao.replace(/\/$/,"")+(e?`/${e.replace(/^\//,"")}`:"")}
/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */(`components/${t}/${t}.js`);return new Promise(((t,s)=>{import(i).then((()=>t())).catch((()=>s(new Error(`Unable to autoload <${e}> from ${i}`))))}))}(e))));for(const e of o)"rejected"===e.status&&console.warn(e.reason);await new Promise(requestAnimationFrame),e.dispatchEvent(new CustomEvent("wa-discovery-complete",{bubbles:!1,cancelable:!1,composed:!0}))}new MutationObserver((e=>{for(const{addedNodes:t}of e)for(const e of t)e.nodeType===Node.ELEMENT_NODE&&lo(e)}));const co=new Set,ho=new Map,po="undefined"!=typeof MutationObserver&&"undefined"!=typeof document&&void 0!==document.documentElement;if(po){const e=new MutationObserver(mo);document.documentElement.dir,document.documentElement.lang||navigator.language,e.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","lang"]})}function uo(...e){e.map((e=>{const t=e.$code.toLowerCase();ho.has(t)?ho.set(t,Object.assign(Object.assign({},ho.get(t)),e)):ho.set(t,e)})),mo()}function mo(){po&&(document.documentElement.dir,document.documentElement.lang||navigator.language),[...co.keys()].map((e=>{"function"==typeof e.requestUpdate&&e.requestUpdate()}))}
/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */const vo={$code:"en",$name:"English",$dir:"ltr",carousel:"Carousel",clearEntry:"Clear entry",close:"Close",copied:"Copied",copy:"Copy",currentValue:"Current value",dropFileHere:"Drop file here or click to browse",decrement:"Decrement",dropFilesHere:"Drop files here or click to browse",error:"Error",goToSlide:(e,t)=>`Go to slide ${e} of ${t}`,hidePassword:"Hide password",increment:"Increment",loading:"Loading",nextSlide:"Next slide",numOptionsSelected:e=>0===e?"No options selected":1===e?"1 option selected":`${e} options selected`,pauseAnimation:"Pause animation",playAnimation:"Play animation",previousSlide:"Previous slide",progress:"Progress",remove:"Remove",resize:"Resize",scrollableRegion:"Scrollable region",scrollToEnd:"Scroll to end",scrollToStart:"Scroll to start",selectAColorFromTheScreen:"Select a color from the screen",showPassword:"Show password",slideNum:e=>`Slide ${e}`,toggleColorFormat:"Toggle color format",zoomIn:"Zoom in",zoomOut:"Zoom out"};uo(vo),
/*! Copyright 2026 Fonticons, Inc. - https://webawesome.com/license */
uo(vo),console.groupCollapsed(`%cSPOTIFYPLUS-CARD ${ae} IS INSTALLED`,"color: green; font-weight: bold"),console.log("SpotifyPlus Card Wiki Docs:","https://github.com/thlucas1/spotifyplus_card/wiki/Configuration-Options"),console.log("SpotifyPlus Integration Wiki Docs:","https://github.com/thlucas1/homeassistantcomponent_spotifyplus/wiki"),console.log("SpotifyPlus Card Debug Logging Console Commands:\n","- enable: localStorage.setItem('debug', 'spotifyplus-card:*');\n","- disable: localStorage.setItem('debug', '');"),console.groupEnd(),window.customCards.push({type:"spotifyplus-card",name:"SpotifyPlus Card",description:"Home Assistant UI card that supports features unique to the SpotifyPlus custom integration",preview:!0});
//# sourceMappingURL=spotifyplus_card.js.map