import{E as e,N as t,O as n,Q as r,Rt as i,S as a,T as o,W as s,_t as c,b as l,dt as u,ft as d,gt as f,kt as p,n as m,ot as h,p as g,q as _,v,y}from"./vue-i18n-Bp4YYb-2.js";import{C as b,Er as x,F as S,Lt as C,Vi as w,ir as T,oi as E,ri as D}from"./index-BOiiIZox.js";import{n as O,t as k}from"./column-Bqn4T3tI.js";import{t as A}from"./EntityTitleRename-Bzt7LwIE.js";var j={class:`flex h-[3.6rem] border-b-4 border-border-one items-center justify-between`},M={class:`flex flex-row overflow-hidden`},N={class:`px-4 py-2 flex flex-row leading-none items-center`},P={class:`p-2`},F={class:`h-full pb-14`},I={class:`flex leading-none items-center`},L={class:`mr-2`},R=!1,z=n({__name:`ModeView`,props:{modeUID:{}},setup(n){let z=n,{t:B}=m(),V=t(`emitter`),H=C(),U=T(),W=v(()=>U.modes.find(e=>e.uid===z.modeUID)),G=p([]),K=()=>{G.value.length=0;let e=new Map;for(let[t,n]of W.value.device_settings){let r=new Map;for(let e of n)r.set(e.channel_name,e);e.set(t,r)}for(let t of H.allDevices()){let n=U.allUIDeviceSettings.get(t.uid);if(!(n==null||t.info==null))for(let[r,i]of t.info.channels.entries()){let a=n.sensorsAndChannels.get(r);if(a==null)continue;let o=e.get(t.uid)?.get(r),s=`Unknown`,c=`Unknown`;if(i.speed_options!=null){if(o==null)continue;if(o.speed_fixed!=null)s=`Manual`,c=`${o.speed_fixed}%`;else if(o.profile_uid!=null){s=`Profile`;let e=U.profiles.find(e=>e.uid===o.profile_uid);c=e==null?o.profile_uid===`0`?B(`common.unmanaged`):`Unknown`:w(e)}}else if(i.lighting_modes.length>0){if(o==null)continue;s=`Lighting Mode`,c=`${o.lighting?.mode??`Unknown`} ; Colors: ${o.lighting?.colors.length??`Unknown`}`}else if(i.lcd_info!=null){if(o==null)continue;s=`LCD Mode`,c=o.lcd?.mode??`Unknown`}else continue;G.value.push({rowID:`${t.uid}-${r}`,deviceUID:t.uid,deviceName:t.name,channelID:r,channelColor:a.color,channelLabel:a.name,settingType:s,settingInfo:c})}}};K();let q=async()=>{await U.activateMode(z.modeUID)},J=async e=>e.length>0&&await U.updateModeName(W.value.uid,e)?(W.value.name=e,V.emit(`mode-name-update`,{modeUID:W.value.uid,name:e}),!0):!1;return s(async()=>{h(U.allUIDeviceSettings,()=>{K()})}),(t,n)=>{let s=r(`tooltip`);return _(),a(g,null,[y(`div`,j,[y(`div`,M,[e(A,{"current-name":W.value.name,"save-name-function":J},null,8,[`current-name`]),d((_(),a(`div`,N,[e(i(b),{type:`mdi`,path:i(D),size:i(H).getREMSize(1.25)},null,8,[`path`,`size`])])),[[s,i(B)(`views.mode.modeHint`),void 0,{top:!0}]])]),d((_(),a(`div`,P,[d((_(),l(i(S),{class:`bg-accent/80 hover:!bg-accent w-32 h-[2.375rem]`,label:`Save`,disabled:R,onClick:q},{default:u(()=>[e(i(b),{class:`outline-0`,type:`mdi`,path:i(x),size:i(H).getREMSize(1.5)},null,8,[`path`,`size`])]),_:1})),[[s,i(B)(`views.mode.activateMode`),void 0,{top:!0}]])])),[[s,{value:i(B)(`views.mode.currentlyActive`),disabled:!0},void 0,{top:!0}]])]),y(`div`,F,[e(i(O),{value:G.value,"row-group-mode":`rowspan`,"group-rows-by":[`deviceName`,`rowID`],scrollable:``,"scroll-height":`flex`,pt:{tableContainer:()=>({class:[`rounded-none border-0 border-border-one`]})}},{default:u(()=>[e(i(k),{field:`deviceName`,header:i(B)(`components.sensorTable.device`)},{body:u(t=>[y(`div`,I,[y(`div`,L,[e(i(b),{type:`mdi`,path:i(E),size:i(H).getREMSize(1.3)},null,8,[`path`,`size`])]),y(`div`,null,c(t.data.deviceName),1)])]),_:1},8,[`header`]),e(i(k),{field:`rowID`,header:i(B)(`components.sensorTable.channel`)},{body:u(e=>[y(`span`,{class:`pi pi-minus mr-2`,style:f({color:e.data.channelColor})},null,4),o(c(e.data.channelLabel),1)]),_:1},8,[`header`]),e(i(k),{field:`settingType`,header:i(B)(`components.modeTable.setting`)},{body:u(e=>[o(c(e.data.settingType),1)]),_:1},8,[`header`]),e(i(k),{field:`settingInfo`,header:``},{body:u(e=>[o(c(e.data.settingInfo),1)]),_:1})]),_:1},8,[`value`])])],64)}}});export{z as default};