import{av as h,H as c,aL as t,b6 as w,a4 as B,r as M,bm as g,cs as _,aZ as V,J as N,aw as P,x as p,aB as d,bS as A,ax as s,ay as u,d as o,aD as y,az as r,bb as O,bc as v,aI as i,bd as f,cr as G,aQ as D,aA as R}from"./index-C-Ivu3jU.js";import{E as q}from"./EditConfig-Y1ATbenl.js";import{n as F}from"./index.browser-OxPLOBIU.js";import{V as j}from"./VTextField-Bkx949P5.js";import{V as Y}from"./VSwitch-BQ2ltI05.js";import"./VForm-BYcBSxOg.js";import"./VInput-CnrZS6Kh.js";import"./VExpansionPanels-BevVHr3H.js";import"./VAlert-B3qbTkCR.js";import"./VSlider-B7gznk4l.js";import"./VSelect-JgdoZi1R.js";import"./VVirtualScroll-C_Lzj3jv.js";import"./VCheckboxBtn-BmKOjEU4.js";import"./VDialog-BZuFHdVP.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const x={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},oe=h({__name:"EditPlayer",props:{playerId:{}},setup(S){const C=R(),e=c(),I=F(11),k=c(!1),m=S,b=c(!1);(async()=>{if(m.playerId)try{b.value=(await t.getDSPConfig(m.playerId)).enabled}catch(a){console.error("Error fetching DSP config:",a)}})();const T=t.subscribe(w.PLAYER_DSP_CONFIG_UPDATED,a=>{b.value=a.data.enabled});B(T);const $=M(()=>{if(!e.value)return[];const a=Object.values(e.value.values),l=t.players[e.value.player_id];return l&&l.type!==g.GROUP?a.push({key:"dsp_settings",type:_.DSP_SETTINGS,label:"",default_value:b.value,required:!1,category:"audio"}):l&&l.type===g.GROUP&&l.supported_features.includes(V.MULTI_DEVICE_DSP)?a.push({key:"dsp_note_multi_device_group",type:_.LABEL,label:"You can configure the DSP for each player individually.",default_value:null,required:!1,category:"audio"}):l&&l.type===g.GROUP&&!l.supported_features.includes(V.MULTI_DEVICE_DSP)&&a.push({key:"dsp_note_multi_device_group_not_supported",type:_.LABEL,label:"This group type does not support DSP when playing to multiple devices.",default_value:null,required:!1,category:"audio"}),a});N(()=>m.playerId,async a=>{a&&(e.value=await t.getPlayerConfig(a))},{immediate:!0});const L=async function(a){delete a.dsp_settings,a.enabled=e.value.enabled,a.name=e.value.name||null,t.savePlayerConfig(m.playerId,a),C.push({name:"playersettings"})},U=async function(a,l){k.value=!0;for(const n of Object.values(e.value.values))n.value!==void 0&&l[n.key]==null&&(l[n.key]=n.value);l.session_id=I,t.getPlayerConfigEntries(e.value.player_id,a,l).then(n=>{e.value.values={};for(const E of n)e.value.values[E.key]=E}).catch(n=>{alert(n)}).finally(()=>{k.value=!1})};return(a,l)=>(s(),P("section",null,[p(A,null,{default:d(()=>[e.value&&r(t).getProviderManifest(e.value.provider).domain in r(t).providerManifests?(s(),P("div",x,[p(O,null,{default:d(()=>[v(i(a.$t("settings.config_player",[e.value.name||r(t).players[e.value.player_id]?.name||e.value.default_name])),1)]),_:1}),p(f,null,{default:d(()=>[o("b",null,i(a.$t("settings.player_id"))+": ",1),v(i(e.value.player_id),1)]),_:1}),p(f,null,{default:d(()=>[o("b",null,i(a.$t("settings.player_provider"))+": ",1),v(i(r(t).getProviderManifest(e.value.provider)?.name)+" ",1),r(t).getProviderManifest(e.value.provider)?.documentation?(s(),P("a",{key:0,onClick:l[0]||(l[0]=n=>r(G)(r(t).getProviderManifest(e.value.provider)?.documentation))}," ["+i(a.$t("settings.check_docs"))+"]",1)):u("",!0)]),_:1}),r(t).players[e.value.player_id]?(s(),y(f,{key:0},{default:d(()=>[o("b",null,i(a.$t("settings.player_model"))+": ",1),v(i(r(t).players[e.value.player_id].device_info.manufacturer)+" / "+i(r(t).players[e.value.player_id].device_info.model),1)]),_:1})):u("",!0),r(t).players[e.value.player_id]?.device_info.ip_address?(s(),y(f,{key:1},{default:d(()=>[o("b",null,i(a.$t("settings.player_address"))+": ",1),v(i(r(t).players[e.value.player_id].device_info.ip_address),1)]),_:1})):u("",!0),r(t).players[e.value.player_id]?(s(),y(f,{key:2},{default:d(()=>[o("b",null,i(a.$t("settings.player_type_label"))+": ",1),v(i(a.$t(`player_type.${r(t).players[e.value.player_id].type}`)),1)]),_:1})):u("",!0),l[3]||(l[3]=o("br",null,null,-1)),p(D),l[4]||(l[4]=o("br",null,null,-1)),l[5]||(l[5]=o("br",null,null,-1)),"name"in e.value?(s(),y(j,{key:3,modelValue:e.value.name,"onUpdate:modelValue":l[1]||(l[1]=n=>e.value.name=n),placeholder:e.value?.name,label:a.$t("settings.player_name"),variant:"outlined",clearable:"",class:"configcolumnleft",style:{"margin-right":"25px"}},null,8,["modelValue","placeholder","label"])):u("",!0),"enabled"in e.value?(s(),y(Y,{key:4,modelValue:e.value.enabled,"onUpdate:modelValue":l[2]||(l[2]=n=>e.value.enabled=n),label:a.$t("settings.enable_player"),color:"primary",disabled:r(t).getProviderManifest(e.value.provider)?.builtin},null,8,["modelValue","label","disabled"])):u("",!0)])):u("",!0),l[6]||(l[6]=o("br",null,null,-1)),p(D),e.value?(s(),y(q,{key:1,disabled:!e.value.enabled,"config-entries":$.value,onSubmit:L,onAction:U},null,8,["disabled","config-entries"])):u("",!0)]),_:1})]))}});export{oe as default};
