import{u as j,l as x,j as a,r as w,L as C,g as h,d as g,c as k,a as S,w as H,R as E,i as L}from"./index-a77bd902.js";import{V as T,M as q}from"./vendor-links-02c94b52.js";import{L as F,D as M,P as N}from"./index-6ddbc65b.js";import{i as P,A,D as I}from"./Availability-cc85c92c.js";import{T as R}from"./ReactTableCom-601a3beb.js";import{D as V}from"./DeviceImage-3bec68ff.js";import{D as B}from"./DEVICES_GLOBAL_NAME-6620c611.js";import"./powerSourceTypeToTranslationKey-452dac81.js";import"./persist-4349f4e2.js";import"./index-f7288b4b.js";const $={"action-column":"_action-column_1729o_1","device-pic":"_device-pic_1729o_8","device-image":"_device-image_1729o_14"};function z(t){const{data:l,lastSeenType:o,availabilityFeatureEnabled:n,homeassistantEnabled:d,setDeviceDescription:y}=t,{renameDevice:c,removeDevice:m,configureDevice:v,interviewDevice:b}=t,{t:r}=j(["zigbee","common","avaliability"]),u=o!=="disable"?[{id:"last_seen",Header:r("last_seen"),accessor:({state:e})=>{var i;return(i=x(e,o))==null?void 0:i.getTime()},Cell:({row:{original:{state:e}}})=>a.jsx(F,{state:e,lastSeenType:o})}]:[],_=n?[{id:"availability",Header:r("avaliability:avaliability"),accessor:({availabilityState:e})=>P(e)?e:e.state,Cell:({row:{original:{availabilityState:e,availabilityEnabledForDevice:i,disabled:s}}})=>a.jsx(A,{disabled:s,availability:e,availabilityEnabledForDevice:i})}]:[],p=w.useMemo(()=>[{id:"pic",Header:r("pic"),Cell:({row:{original:{device:e,state:i,disabled:s}}})=>a.jsx(V,{className:$["device-image"],device:e,deviceStatus:i,disabled:s}),accessor:e=>e,disableSortBy:!0},{id:"friendly_name",Header:r("friendly_name"),accessor:({device:e})=>[e.friendly_name,e.description].join(" "),Cell:({row:{original:{device:e}}})=>a.jsxs(a.Fragment,{children:[a.jsx(C,{to:h(e.ieee_address),children:e.friendly_name}),a.jsx("small",{className:"d-block",children:e.description})]})},{id:"ieee_address",Header:r("ieee_address"),accessor:({device:e})=>[e.ieee_address,g(e.network_address,4)].join(" "),Cell:({row:{original:{device:e}}})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{children:e.ieee_address}),a.jsx("div",{children:a.jsxs("abbr",{title:`${r("network_address_hex")} (${r("network_address_dec")}: ${e.network_address})`,children:["(",g(e.network_address,4),")"]})})]})},{id:"manufacturer",Header:r("manufacturer"),accessor:({device:e})=>{var i;return[(i=e.definition)==null?void 0:i.vendor,e.manufacturer].join(" ")},Cell:({row:{original:{device:e}}})=>a.jsx(T,{device:e})},{id:"model",Header:r("model"),accessor:({device:e})=>{var i;return[(i=e.definition)==null?void 0:i.model,e.model_id].join(" ")},Cell:({row:{original:{device:e}}})=>a.jsx(q,{device:e})},{id:"lqi",Header:r("lqi"),accessor:({state:e})=>e.linkquality,Cell:({row:{original:{state:e}}})=>a.jsx(M,{value:e.linkquality,name:"linkquality"})},...u,..._,{id:"power",Header:r("power"),accessor:({state:e,device:i})=>{var s;return[e.battery,(s=i.definition)==null?void 0:s.power].join(" ")},Cell:({row:{original:{state:e,device:i}}})=>a.jsx(N,{device:i,deviceState:e})},{id:"controls",Header:"",Cell:({row:{original:{device:e,state:i}}})=>a.jsx(I,{device:e,state:i,homeassistantEnabled:d,renameDevice:c,removeDevice:m,configureDevice:v,setDeviceDescription:y,interviewDevice:b}),disableSortBy:!0}],[u,_,r,d,c,m,v,b]);return a.jsx("div",{className:"card",children:a.jsx("div",{className:"table-responsive",children:a.jsx(R,{id:B,columns:p,data:l})})})}function G(t){var e,i;const{devices:l,deviceStates:o,bridgeInfo:{config:n},availability:d}=t,{renameDevice:y,removeDevice:c,configureDevice:m,setDeviceDescription:v,interviewDevice:b}=t,r=!!((e=n.availability)!=null&&e.enabled),u=!!((i=n==null?void 0:n.homeassistant)!=null&&i.enabled),_=()=>Object.values(l).filter(s=>s.type!=="Coordinator").map(s=>{var f;const D=o[s.friendly_name]??{};return{id:s.friendly_name,disabled:L(s,n),device:s,state:D,availabilityState:d[s.friendly_name]??"offline",availabilityEnabledForDevice:((f=n.devices[s.ieee_address])==null?void 0:f.availability)!==!1}}),p=E.useMemo(()=>_(),[l,o]);return a.jsx(z,{data:p,lastSeenType:n.advanced.last_seen,availabilityFeatureEnabled:r,homeassistantEnabled:u,renameDevice:y,removeDevice:c,configureDevice:m,setDeviceDescription:v,interviewDevice:b})}const O=["devices","deviceStates","bridgeInfo","availability"],ae=k(O,S)(H(["zigbee","common"])(G));export{ae as ConnectedZigbeePage};
