import{dq as f,dG as N,dm as s,x as u,a0 as w,o as y,ck as L}from"./index-DjbVAZHL.js";import{F as $}from"./startCase-SXH8nyJo.js";import{a as F}from"./index-RfvTmd0Z.js";import{L as _}from"./LastSeen-TlG8TNPK.js";import{L as k}from"./Lqi-_D0pWzA-.js";import{P as D}from"./PowerSource-DwoxK9gS.js";import{D as q}from"./DeviceImage-Bsu1Hk6P.js";const H=f.memo(({onChange:m,onRead:c,sourceIdx:i,hideSourceDot:j,device:e,endpoint:o,deviceState:t,lastSeenConfig:b,features:x,featureWrapperClass:d,children:h})=>{const{t:l}=N(["zigbee","common"]),n=o!=null?e.endpoints[o]?.name:void 0,g=f.useMemo(()=>{const a=[];for(const r of x){const p=o!=null&&!!r.endpoint;(!p||Number(r.endpoint)===o||r.endpoint===n)&&a.push(s.jsx($,{feature:r,device:e,deviceState:t,onChange:m,onRead:c,featureWrapperClass:d,minimal:!0,parentFeatures:[],endpointSpecific:p},F(r)))}return a},[n,e,o,t,x,d,m,c]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"card-body p-2",children:[s.jsxs("div",{className:"flex flex-row items-center gap-3 w-full",children:[s.jsx("div",{className:"flex-none h-11 w-11 overflow-visible",children:s.jsx(q,{disabled:!1,device:e,otaState:t.update?.state})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs(u,{to:`/device/${i}/${e.ieee_address}/info`,className:"link link-hover font-semibold",children:[e.friendly_name,o!=null?` (${l(a=>a.endpoint)}: ${n?`${n} / `:""}${o})`:""]}),e.description&&s.jsx("div",{className:"text-xs opacity-50 truncate",title:e.description,children:e.description}),s.jsx("div",{className:"text-xs opacity-50",children:s.jsx(_,{lastSeen:t.last_seen,config:b})}),!j&&s.jsx("span",{className:"absolute top-2 right-2",children:s.jsx(w,{idx:i,autoHide:!0})})]})]}),s.jsx("div",{className:"text-sm w-full p-2",children:g}),s.jsx("div",{className:"flex flex-row justify-end mb-2",children:s.jsxs(u,{to:`/device/${i}/${e.ieee_address}/exposes`,className:"btn btn-xs",children:[l(a=>a.exposes,{ns:"common"})," ",s.jsx(y,{icon:L,size:"lg"})]})})]}),s.jsxs("div",{className:"flex flex-row flex-wrap gap-1 mx-2 mb-2 justify-around items-center",children:[s.jsx("span",{className:"badge badge-soft badge-ghost cursor-default tooltip","data-tip":l(a=>a.lqi),children:s.jsx(k,{value:t.linkquality})}),s.jsx("span",{className:"badge badge-soft badge-ghost cursor-default tooltip","data-tip":l(a=>a.power),children:s.jsx(D,{device:e,batteryPercent:t.battery,batteryState:t.battery_state,batteryLow:t.battery_low,showLevel:!0})}),h]})]})});export{H as D};
