import{E as e,G as t,N as n,O as r,Q as i,Rt as a,S as o,Vt as s,W as c,b as l,dt as u,ft as d,kt as f,n as ee,ot as p,p as m,q as h,x as g,y as _}from"./vue-i18n-Bp4YYb-2.js";import{C as v,E as y,Lt as b,ar as x,ca as S,ia as C,ir as w,na as T,oa as te,ra as E,ri as D}from"./index-BOiiIZox.js";import{t as O}from"./select-DzqiXWJ_.js";import{t as k}from"./es-CCfg6HOm.js";import{t as A}from"./EntityTitleRename-Bzt7LwIE.js";import{n as j,r as M,t as N}from"./AxisOptions-PW0IEnod.js";var P=s(x()),F={id:`control-panel`,class:`flex border-b-4 border-border-one items-center justify-between`},I={class:`flex flex-wrap gap-x-1 justify-end`},L={key:0,class:`p-2 flex leading-none items-center`},R={key:1,class:`p-2 pr-0 flex flex-row`},z={class:`p-2`},B=1,V=60,H=r({__name:`SingleDashboardView`,props:{deviceUID:{},channelName:{}},setup(r){let s=r,{t:x}=ee(),H=n(`emitter`),U=b(),W=w(),G=f(W.allUIDeviceSettings.get(s.deviceUID)?.sensorsAndChannels.get(s.channelName)?.name??s.channelName),K=f(W.allUIDeviceSettings.get(s.deviceUID).sensorsAndChannels.get(s.channelName).channelDashboard??(()=>{let e=new E(G.value);return e.timeRangeSeconds=300,e.dataTypes=[],e.deviceChannelNames.push(new C(s.deviceUID,s.channelName)),W.allUIDeviceSettings.get(s.deviceUID).sensorsAndChannels.get(s.channelName).channelDashboard=e,e})());K.value.dataTypes.length>0&&(K.value.dataTypes=[]);let q=[...k(T).values()].map(e=>({value:e,text:te(e)})),J=f(K.value.timeRangeSeconds/60),Y=e=>{e.deltaY<0?J.value<V&&(J.value+=1):J.value>B&&--J.value},X=()=>{document?.querySelector(`.chart-minutes`)?.addEventListener(`wheel`,Y)},Z=e=>{K.value.timeRangeSeconds=e*60},Q=()=>{let e=document.getElementById(`u-plot-chart`),t=document.getElementById(`control-panel`);if(e!=null&&t!=null){let n=t.getBoundingClientRect().height;n>77?e.style.height=`calc(100vh - (${n}px + 2rem))`:e.style.height=`calc(100vh - 5.75rem)`}},$=f(S()),ne=async e=>(e.length>0?(W.allUIDeviceSettings.get(s.deviceUID).sensorsAndChannels.get(s.channelName).userName=e,G.value=e,H.emit(`device-sensor-name-update`,{deviceUID:s.deviceUID,sensorId:s.channelName,name:e})):(W.allUIDeviceSettings.get(s.deviceUID).sensorsAndChannels.get(s.channelName).userName=void 0,G.value=W.allUIDeviceSettings.get(s.deviceUID)?.sensorsAndChannels.get(s.channelName)?.name??s.channelName,H.emit(`device-sensor-name-update`,{deviceUID:s.deviceUID,sensorId:s.channelName,name:G.value})),!0);return c(async()=>{window.addEventListener(`resize`,Q),setTimeout(Q),X(),p(J,e=>{Z(e)}),p(W.allUIDeviceSettings,P.default.debounce(()=>$.value=S(),400,{leading:!0}))}),t(()=>{window.removeEventListener(`resize`,Q)}),(t,n)=>{let r=i(`tooltip`);return h(),o(m,null,[_(`div`,F,[e(A,{"current-name":G.value,"save-name-function":ne},null,8,[`current-name`]),_(`div`,I,[K.value.chartType==a(T).TIME_CHART?d((h(),o(`div`,L,[e(v,{type:`mdi`,path:a(D),size:a(U).getREMSize(1.25)},null,8,[`path`,`size`])])),[[r,a(x)(`views.singleDashboard.chartMouseActions`),void 0,{top:!0}]]):g(``,!0),K.value.chartType==a(T).TIME_CHART?(h(),o(`div`,R,[d((h(),l(a(y),{placeholder:`Minutes`,"input-id":`chart-minutes`,modelValue:J.value,"onUpdate:modelValue":n[0]||(n[0]=e=>J.value=e),class:`h-[2.375rem] chart-minutes`,suffix:` `+a(x)(`views.singleDashboard.minutes`),"show-buttons":``,"use-grouping":!1,step:1,min:B,max:V,"button-layout":`horizontal`,"allow-empty":!1,"input-style":{width:`5rem`}},{incrementbuttonicon:u(()=>[...n[2]||(n[2]=[_(`span`,{class:`pi pi-plus`},null,-1)])]),decrementbuttonicon:u(()=>[...n[3]||(n[3]=[_(`span`,{class:`pi pi-minus`},null,-1)])]),_:1},8,[`modelValue`,`suffix`])),[[r,a(x)(`views.singleDashboard.timeRange`),void 0,{top:!0}]]),e(N,{class:`h-[2.375rem] ml-3`,dashboard:K.value},null,8,[`dashboard`])])):g(``,!0),_(`div`,z,[d(e(a(O),{modelValue:K.value.chartType,"onUpdate:modelValue":n[1]||(n[1]=e=>K.value.chartType=e),options:a(q),placeholder:a(x)(`views.dashboard.selectChartType`),class:`h-[2.375rem] w-32`,checkmark:``,"dropdown-icon":`pi pi-chart-bar`,"scroll-height":`400px`,"option-label":`text`,"option-value":`value`},null,8,[`modelValue`,`options`,`placeholder`]),[[r,a(x)(`views.singleDashboard.chartType`),void 0,{top:!0}]])])])]),K.value.chartType==a(T).TIME_CHART?(h(),l(M,{dashboard:K.value,key:$.value},null,8,[`dashboard`])):K.value.chartType==a(T).TABLE?(h(),l(j,{dashboard:K.value,key:`table`+$.value},null,8,[`dashboard`])):g(``,!0)],64)}}});export{H as default};