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