import{c as st,a as g,d as ra,f as D,s as n}from"../chunks/DktbhmWA.js";import{f as na,p as ia,c as e,r as a,s as t,t as pe,a as va,u as rt,g as u,h as ea,b as S,d as oe}from"../chunks/CPWcrcMP.js";import{i as $}from"../chunks/0jvM7PZf.js";import{I as nt,h as it,c as i,g as ue,s as vt,a as h,A as aa,m as ct}from"../chunks/CNDZS43m.js";import{p as dt}from"../chunks/DICQ4t50.js";import"../chunks/DUxDMF0-.js";import{H as lt,b as ta,T as sa,D as ot,a as ut,S as pt}from"../chunks/D09EVxHf.js";import{G as _t}from"../chunks/DsiULKVq.js";import"../chunks/CvCfPjaJ.js";import{l as mt,s as gt}from"../chunks/DBypTyp2.js";import{T as bt}from"../chunks/B-q2MrrX.js";function xt(d,v){const s=mt(v,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.511.0 - ISC
 *
 * ISC License
 *
 * Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2022 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2022.
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 *
 */const b=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2"}]];nt(d,gt({name:"activity"},()=>s,{get iconNode(){return b},children:(_,m)=>{var p=st(),l=na(p);it(l,v,"default",{}),g(_,p)},$$slots:{default:!0}}))}var ft=(d,v)=>{var s;return(s=v.onAbort)==null?void 0:s.call(v)},ht=(d,v)=>{var s;return(s=v.onOk)==null?void 0:s.call(v)},Dt=D('<div class="modal modal-open"><div class="modal-box"><h3 class="text-lg font-bold"> </h3> <p class="py-4">Be sure the AHU is not running!</p> <div class="modal-action"><button class="btn rounded-full">Abort</button> <button class="btn btn-primary rounded-full">OK</button></div></div></div>');function St(d,v){ia(v,!0);var s=Dt(),b=e(s),_=e(b),m=e(_);a(_);var p=t(_,4),l=e(p);l.__click=[ft,v];var N=t(l,2);N.__click=[ht,v],a(p),a(b),a(s),pe(()=>n(m,`Are you sure you want to test damper ${v.damper??""}?`)),g(d,s),va()}ra(["click"]);var wt=d=>d.stopPropagation(),yt=D("<span><!> </span>"),At=(d,v)=>v("A"),$t=D('<button class="btn btn-primary btn-sm">Run test</button>'),Nt=(d,v)=>v("B"),Bt=D('<button class="btn btn-primary btn-sm">Run test</button>'),Tt=D("--> <!>",1),kt=D('<section><div class="container mx-auto"><div class="flex items-center sticky bg-base-100 z-40 pb-2" style="top:4.11rem"><!></div> <div class="card bg-base-200 shadow-sm border border-base-300 rounded-2xl"><div class="m-2 p-1"><div><div class="flex items-center justify-between"><h2 class="text-2xl font-semibold"> </h2> <a class="btn btn-primary btn-sm rounded-full"> </a></div> <div class="flex items-center gap-3 mt-2"><span class="badge badge-secondary"> </span> <span class="badge badge-secondary"> </span> <span><!> </span> <div class="flex items-center gap-4"><!></div></div> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3></div> <div class="grid grid-cols-1 xl:grid-cols-3 gap-4 mt-0"><div class="xl:col-span-2 grid grid-cols-1 lg:grid-cols-2 gap-4"><div class="card bg-base-100 border border-base-300 rounded-2xl mt-2"><div class="card-body p-4"><div class="flex items-center justify-between"><h3 class="badge badge-secondary">Damper A</h3> <span> </span></div> <h3 class="text-l">Name: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Supplies: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Description: <span class="text-gray-400"> </span></h3> <div class="flex items-center justify-between"><span>Teststatus: <span class="text-gray-400"> </span></span> <!></div></div></div> <div class="card bg-base-100 border border-base-300 rounded-2xl"><div class="card-body p-4"><div class="flex items-center justify-between"><h3 class="badge badge-secondary">Damper B</h3> <span> </span></div> <h3 class="text-l">Name: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Supplies: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Location: <span class="text-gray-400"> </span></h3> <h3 class="text-l">Description: <span class="text-gray-400"> </span></h3> <div class="flex items-center justify-between"><span>Teststatus: <span class="text-gray-400"> </span></span> <!></div></div></div></div> <div class="card bg-base-100 border border-base-300 rounded-2xl"><div class="card-body gap-2 p-4"><div class="space-y-3"><div class="flex items-start justify-between"><div><div class="text-sm">Digital Input: <span class="text-gray-400"> </span></div></div> <span> </span></div> <div class="flex items-start justify-between"><div><div class="text-sm">Digital Output: <span class="text-gray-400"> </span></div></div> <span> </span></div></div></div></div></div> <h3 class="text-xs mt-2">Serial Number: <span class="text-gray-400"> </span></h3></div></div> <!></div></section>');function Mt(d,v){ia(v,!0);let s=dt.params.id;const b=new i(`Devices/${s}/SerialNumber`),_=new i(`Devices/${s}/Settings/Name`),m=new i(`Devices/${s}/Settings/Zone`),p=new i(`Devices/${s}/Health`);let l=oe(null);const N=new i(`Devices/${s}/Settings/Location`),_e=new i(`Devices/${s}/Settings/DiName`),B=new i(`Devices/${s}/Settings/DiFunc`),x=new i(`Devices/${s}/DigitalInput`),me=new i(`Devices/${s}/Settings/DoName`),ge=new i(`Devices/${s}/Settings/DoFunc`),T=new i(`Devices/${s}/DigitalOutput`),k=new i(`Devices/${s}/DmpA/Status`),be=new i(`Devices/${s}/DmpA/TestStatus`),ca=new i(`Devices/${s}/Settings/DmpAName`),da=new i(`Devices/${s}/Settings/DmpADesc`),la=new i(`Devices/${s}/Settings/DmpALocation`),oa=new i(`Devices/${s}/Settings/DmpASupply`),ua=new i(`Devices/${s}/DmpB/Status`),xe=new i(`Devices/${s}/DmpB/TestStatus`),pa=new i(`Devices/${s}/Settings/DmpBName`),_a=new i(`Devices/${s}/Settings/DmpBDesc`),ma=new i(`Devices/${s}/Settings/DmpBLocation`),ga=new i(`Devices/${s}/Settings/DmpBSupply`);rt(()=>{parseInt(m.value)>0&&parseInt(m.value)<=100&&S(l,new i(`Zones/${m.value}/${s}/Status`),!0)});let w=oe(!1),H=oe("A");function fe(r){S(H,r,!0),S(w,!0)}function ba(){ct.publish(u(H)==="A"?be.topic:xe.topic,"2"),S(w,!1)}function xa(r){switch(r){case"1":return"badge-success";case"2":return"badge-warning";case"3":return"badge-error";default:return""}}function fa(r){if(r===void 0)return"badge badge-error";switch(r.value){case"1":return"badge badge-success";case"2":case"3":case"4":return"badge badge-error";default:return""}}function he(r){if(!r)return"badge";const c=Number(r);return c>=5?"badge badge-error":c===1?"badge badge-success":"badge badge-warning"}function ha(){switch(B.value){case"1":return"-";case"2":case"3":case"4":case"5":return o(x.value)?"Alarm":"Normal";case"6":case"7":return o(x.value)?"Test triggered":"Test untriggered";case"8":case"9":return o(x.value)?"AHU Running":"AHU Stopped";default:return"Error"}}function Da(){switch(B.value){case"1":return"-";case"2":case"3":case"4":case"5":return o(x.value)?"badge-error":"badge-ghost";case"6":case"7":return o(x.value)?"badge-success":"badge-ghost";case"8":case"9":return o(x.value)?"badge-success":"badge-ghost";default:return"badge-error"}}function De(){switch(ge.value){case"1":return"-";case"2":case"3":return o(T.value)?"Zone Alarm":"Zone Normal";case"4":case"5":return o(T.value)?"AHU Stop":"AHU Start";case"6":return o(T.value)?"Internal Error":"OK";default:return"Error"}}const o=r=>(r??"").toLowerCase()==="true",Sa=ea(()=>!aa.canEditDevices),Se=ea(()=>aa.canRunTests);var L=kt(),we=e(L),I=e(we),wa=e(I);_t(wa),a(I);var F=t(I,2),ye=e(F),j=e(ye),O=e(j),U=e(O),ya=e(U,!0);a(U);var y=t(U,2);y.__click=[wt];var Aa=e(y,!0);a(y),a(O);var C=t(O,2),Z=e(C),$a=e(Z);a(Z);var E=t(Z,2),Na=e(E);a(E);var A=t(E,2),Ae=e(A);xt(Ae,{class:"w-4 h-4 mr-1"});var Ba=t(Ae);a(A);var $e=t(A,2),Ta=e($e);{var ka=r=>{var c=yt(),f=e(c);bt(f,{class:"w-4 h-4 mr-1"});var de=t(f);a(c),pe(le=>{h(c,1,le),n(de,` ${pt[u(l).value??""]??"—"??""}`)},[()=>ue(fa(u(l)))]),g(r,c)};$(Ta,r=>{u(l)!==null&&r(ka)})}a($e),a(C);var Ne=t(C,2),Be=t(e(Ne)),Ha=e(Be,!0);a(Be),a(Ne),a(j);var R=t(j,2),M=e(R),z=e(M),Te=e(z),G=e(Te),K=t(e(G),2),La=e(K,!0);a(K),a(G);var P=t(G,2),ke=t(e(P)),Ia=e(ke,!0);a(ke),a(P);var q=t(P,2),He=t(e(q)),Fa=e(He,!0);a(He),a(q);var V=t(q,2),Le=t(e(V)),ja=e(Le,!0);a(Le),a(V);var J=t(V,2),Ie=t(e(J)),Oa=e(Ie,!0);a(Ie),a(J);var Fe=t(J,2),Q=e(Fe),je=t(e(Q)),Ua=e(je,!0);a(je),a(Q);var Ca=t(Q,2);{var Za=r=>{var c=$t();c.__click=[At,fe],g(r,c)};$(Ca,r=>{u(Se)&&r(Za)})}a(Fe),a(Te),a(z);var Oe=t(z,2),Ue=e(Oe),W=e(Ue),X=t(e(W),2),Ea=e(X,!0);a(X),a(W);var Y=t(W,2),Ce=t(e(Y)),Ra=e(Ce,!0);a(Ce),a(Y);var ee=t(Y,2),Ze=t(e(ee)),Ma=e(Ze,!0);a(Ze),a(ee);var ae=t(ee,2),Ee=t(e(ae)),za=e(Ee,!0);a(Ee),a(ae);var te=t(ae,2),Re=t(e(te)),Ga=e(Re,!0);a(Re),a(te);var Me=t(te,2),se=e(Me),ze=t(e(se)),Ka=e(ze,!0);a(ze),a(se);var Pa=t(se,2);{var qa=r=>{var c=Bt();c.__click=[Nt,fe],g(r,c)};$(Pa,r=>{u(Se)&&r(qa)})}a(Me),a(Ue),a(Oe),a(M);var Ge=t(M,2),Ke=e(Ge),Pe=e(Ke),re=e(Pe),ne=e(re),qe=e(ne),Ve=t(e(qe)),Va=e(Ve,!0);a(Ve),a(qe),a(ne);var ie=t(ne,2),Ja=e(ie,!0);a(ie),a(re);var Je=t(re,2),ve=e(Je),Qe=e(ve),We=t(e(Qe)),Qa=e(We,!0);a(We),a(Qe),a(ve);var ce=t(ve,2),Wa=e(ce,!0);a(ce),a(Je),a(Pe),a(Ke),a(Ge),a(R);var Xe=t(R,2),Ye=t(e(Xe)),Xa=e(Ye,!0);a(Ye),a(Xe),a(ye),a(F);var Ya=t(F,2);{var et=r=>{var c=Tt(),f=t(na(c));St(f,{get damper(){return u(H)},onAbort:()=>{S(w,!1)},onOk:()=>{ba()}}),g(r,c)};$(Ya,r=>{u(w)&&r(et)})}a(we),a(L),pe((r,c,f,de,le,at,tt)=>{n(ya,_.value),vt(y,"href","/devices/"+s+"/edit"),n(Aa,u(Sa)?"View details":"Edit"),n($a,`ID ${s??""}`),n(Na,`Zone ${m.value??""}`),h(A,1,r),n(Ba,` ${lt[p.value??""]??"Unknown"??""}`),n(Ha,N.value),h(K,1,c),n(La,ta[k.value??""]??"1"),n(Ia,ca.value),n(Fa,oa.value),n(ja,la.value),n(Oa,da.value),n(Ua,sa[be.value]),h(X,1,f),n(Ea,ta[k.value??""]??"1"),n(Ra,pa.value),n(Ma,ga.value),n(za,ma.value),n(Ga,_a.value),n(Ka,sa[xe.value]),n(Va,_e.value.length?_e.value:ot[B.value??""]??"—"),h(ie,1,de),n(Ja,le),n(Qa,me.value.length?me.value:ut[ge.value??""]??"—"),h(ce,1,at),n(Wa,tt),n(Xa,b.value)},[()=>"badge "+xa(p.value),()=>ue(he(k.value)),()=>ue(he(ua.value)),()=>"badge "+Da(),ha,()=>"badge "+De(),De]),g(d,L),va()}ra(["click"]);export{Mt as component};
