import{d as H,b as _,H as f,D as d,I as u,c as S,r as P,E as o,F,M as G,O as p,f as I,a1 as n,$,e as a,u as y,ad as K,G as W}from"./lucide-BsOfcLnq.js";import{C as X}from"./Container-D40_MO5w.js";import{L as T}from"./ListItem-_zvhSn9K.js";import{_ as V}from"./ProviderIcon.vue_vue_type_style_index_0_lang-CsLTxntn.js";import{b as Y}from"./MediaItemThumb-BvqlnbT6.js";import{T as J}from"./Toolbar-CTiACIvy.js";import{f as l,g as O,M as A,b as B,e as j,J as q,t as N}from"./index-CyXUjyDM.js";import{e as Q,b as Z,G as g,m as M,n as ee}from"./vuetify-DHCm6MV9.js";import{u as te}from"./vue-i18n-CXdnqGsF.js";const ie={style:{"margin-bottom":"10px"}},ae={key:0},se=["title","onClick"],oe=["title"],ne={class:"d-flex align-center ga-2"},be=H({__name:"ProviderDetails",props:{itemDetails:{}},setup(r){const c=r,{t:m}=te(),b=P(!1),h=P(!1),C=function(t){window.open(t,"_blank")},v=W({}),z=function(t){const i=`${t.provider_instance}.${t.item_id}`,e=v[i];if(e)e.load(),delete v[i];else{const s=new Audio(L(t.provider_instance,t.item_id));v[i]=s,s.play()}},L=function(t,i){return`${l.baseUrl}/preview?item_id=${encodeURIComponent(i)}&provider=${t}`},k=function(t){return`${t.provider_instance}://${c.itemDetails.media_type}/${t.item_id}`},U=async function(t){await q(t)?N.success(m("uri_copied")):N.error(m("uri_copy_failed"))},x=function(t){const i=l.getProvider(t.provider_instance);if(i)return i.name;const e=l.getProviderManifest(t.provider_domain);return e?`${e.name} (${t.provider_instance})`:t.provider_instance},w=function(){b.value=!b.value},D=function(t,i){const e=t,s=[{label:m("tooltip.copy_uri"),icon:"mdi-link",action:()=>{i&&U(k(i))}}];i.url&&!i.provider_domain.startsWith("file")&&s.push({label:m("tooltip.open_provider_link"),icon:"mdi-open-in-new",action:()=>{C(i.url)}}),B.isAdmin()&&l.providers[i.provider_instance]?.is_streaming_provider&&s.push({label:m("remove_provider_mapping"),icon:"mdi-delete",action:async()=>{confirm(m("remove_provider_mapping_confirm"))&&await l.sendCommand("music/remove_provider_mapping",{media_type:c.itemDetails.media_type,db_id:c.itemDetails.item_id,mapping:i})}}),j.emit("contextmenu",{items:s,posX:e.clientX,posY:e.clientY})},E=function(){confirm(m("search_all_providers_confirm"))&&(h.value=!0,l.sendCommand("music/match_providers",{media_type:c.itemDetails.media_type,db_id:c.itemDetails.item_id}).finally(()=>{h.value=!1}))},R=S(()=>[{label:"search_all_providers",icon:"mdi-database-search",action:E,overflowAllowed:!1,disabled:h.value,hide:c.itemDetails.provider!="library"||!l.hasStreamingProviders.value||!B.isAdmin()},{label:"tooltip.collapse_expand",icon:b.value?"mdi-chevron-up":"mdi-chevron-down",action:w,overflowAllowed:!1}]);return(t,i)=>(a(),_("section",ie,[f(J,{title:t.$t("mapped_providers"),"menu-items":R.value,onTitleClicked:w},null,8,["title","menu-items"]),f(Q),b.value?(a(),d(X,{key:0},{default:o(()=>[f(Z,null,{default:o(()=>[(a(!0),_(F,null,G(r.itemDetails?.provider_mappings,e=>(a(),d(T,{key:e.provider_instance,disabled:!e.available||!y(l).getProvider(e.provider_instance),"show-menu-btn":"",onMenu:p(s=>D(s,e),["stop"])},{prepend:o(()=>[f(V,{domain:e.provider_domain,size:30},null,8,["domain"])]),title:o(()=>[$(n(x(e))+" ",1),e.in_library?(a(),d(ee,{key:0,size:"x-small",density:"compact",class:"ml-2",title:t.$t("tooltip.in_provider_library")},{default:o(()=>[$(n(t.$t("library")),1)]),_:1},8,["title"])):u("",!0)]),subtitle:o(()=>[r.itemDetails.media_type==y(A).TRACK&&e.audio_format?(a(),_("span",ae,n(e.audio_format.content_type)+" | "+n(e.audio_format.sample_rate/1e3)+"kHz/"+n(e.audio_format.bit_depth)+" bits | ",1)):u("",!0),e.url&&!e.provider_domain.startsWith("file")?(a(),_("a",{key:1,style:{opacity:"0.4"},title:t.$t("tooltip.open_provider_link"),onClick:p(s=>C(e.url),["prevent"])},n(k(e)),9,se)):(a(),_("span",{key:2,style:{opacity:"0.4"},title:t.$t("copy_uri")},n(k(e)),9,oe))]),append:o(()=>[e.audio_format&&e.audio_format.bit_depth>16?(a(),d(g,{key:0,src:y(Y),width:"30",class:K(t.$vuetify.theme.current.dark?"hiresicondark":"hiresicon")},null,8,["src","class"])):u("",!0),I("div",ne,[y(O)("bp1")&&r.itemDetails.media_type==y(A).TRACK?(a(),d(M,{key:0,variant:"plain",icon:v[`${e.provider_instance}.${e.item_id}`]?"mdi-pause":"mdi-play-circle",title:t.$t("tooltip.play_sample"),onClick:s=>z(e)},null,8,["icon","title","onClick"])):u("",!0)])]),_:2},1032,["disabled","onMenu"]))),128)),r.itemDetails.provider=="library"?(a(),d(T,{key:0,"show-menu-btn":"",onMenu:i[0]||(i[0]=p(e=>D(e,{provider_instance:"library",provider_domain:"library",item_id:r.itemDetails.item_id,available:!0}),["stop"]))},{prepend:o(()=>[f(V,{domain:"library",size:30})]),title:o(()=>[$(n(t.$t("music_assistant_library")),1)]),subtitle:o(()=>[I("span",null,"library://"+n(r.itemDetails.media_type)+"/"+n(r.itemDetails.item_id),1)]),_:1})):u("",!0)]),_:1})]),_:1})):u("",!0)]))}});export{be as _};
