import{I as v}from"./ItemsListing-DK1RMxgz.js";import{I as g,_}from"./ProviderDetails.vue_vue_type_script_setup_true_lang-m_vY9uQw.js";import{Q as V,x as f,w as A,o as h,a4 as s,aV as D,b as B,Z as M,B as E,R as n,a9 as p,W as d,a0 as T,S as u}from"./index-C8Wvo59W.js";import{M as U}from"./MediaItemImages-DIG_tYiA.js";import"./MediaItemThumb-DDMb_9k9.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./ListItem-BDnoqXe8.js";import"./Button-C6-W0Jei.js";import"./VBtn-DmOE8ObX.js";import"./VCheckbox-aZKtlmJa.js";import"./VCheckboxBtn-DZffJlMk.js";import"./PanelviewItemCompact-sXEe4fxv.js";import"./VSpacer-CRNj-rDk.js";/* empty css              */import"./Container-D43lS1qQ.js";import"./VContainer-BR45fXaf.js";import"./Toolbar-Bk_KlFQ2.js";import"./VToolbar-COHqcQ5L.js";import"./VTextField-h2jTOaQT.js";import"./VInfiniteScroll-DzhHULOU.js";import"./layout-D5VA38eE.js";import"./VRow-DV7BqAoZ.js";import"./VVirtualScroll-ZleTOGra.js";import"./VAlert-DjHMaeFy.js";import"./marquee_text_sync-BM6bVYJL.js";import"./VDialog-BKEcjOuu.js";const ie=V({__name:"AlbumDetails",props:{itemId:{},provider:{}},setup(b){const i=b,e=f(),o=f(!1),y=async function(){o.value=!0,e.value=await s.getAlbum(i.itemId,i.provider),o.value=!1};A(()=>i.itemId,r=>{r&&y()},{immediate:!0}),h(()=>{const r=s.subscribe(D.MEDIA_ITEM_UPDATED,t=>{var m;const a=t.data;if(((m=e.value)==null?void 0:m.uri)==a.uri)o.value=!0,e.value=a,o.value=!1;else if("provider_mappings"in a){for(const l of a.provider_mappings)if(l.item_id==i.itemId&&[l.provider_instance,l.provider_domain].includes(i.provider)){o.value=!0,e.value=a,o.value=!1;break}}});B(r)});const c=async function(r){return await s.getAlbumTracks(i.itemId,i.provider,r.libraryOnly)},k=async function(r){return await s.getAlbumVersions(e.value.item_id,e.value.provider)},w=async function(){e.value&&(e.value=await s.sendCommand("music/albums/update",{item_id:e.value.item_id,update:e.value,overwrite:!0}))};return(r,t)=>{var a,m,l;return u(),M("section",null,[E(g,{item:e.value,"active-provider":r.provider},null,8,["item","active-provider"]),e.value?(u(),n(v,{key:0,itemtype:"albumtracks","parent-item":e.value,"show-provider":!0,"show-track-number":!0,"show-favorites-only-filter":!0,"show-library-only-filter":e.value.provider=="library"&&T(s).hasStreamingProviders.value,"show-refresh-button":!1,"allow-key-hooks":!0,"load-items":c,"sort-keys":["track_number","name","sort_name","duration","duration_desc"],title:r.$t("tracks")},null,8,["parent-item","show-library-only-filter","title"])):p("",!0),t[1]||(t[1]=d("br",null,null,-1)),e.value?(u(),n(v,{key:1,itemtype:"albumversions","parent-item":e.value,"show-provider":!0,"show-favorites-only-filter":!1,"show-refresh-button":!1,"load-items":k,"sort-keys":["provider","name","year"],title:r.$t("other_versions"),"hide-on-empty":!0},null,8,["parent-item","title"])):p("",!0),t[2]||(t[2]=d("br",null,null,-1)),((a=e.value)==null?void 0:a.provider)=="library"&&((l=(m=e.value)==null?void 0:m.metadata)!=null&&l.images)?(u(),n(U,{key:2,modelValue:e.value.metadata.images,"onUpdate:modelValue":[t[0]||(t[0]=I=>e.value.metadata.images=I),w]},null,8,["modelValue"])):p("",!0),t[3]||(t[3]=d("br",null,null,-1)),e.value?(u(),n(_,{key:3,"item-details":e.value},null,8,["item-details"])):p("",!0),t[4]||(t[4]=d("br",null,null,-1))])}}});export{ie as default};
