import{r as f,u as N,j as s,L as u,S as w,F as y,dm as L}from"./index-a36IMXuN.js";import{F}from"./startCase-K7WbZvzP.js";import{g as $}from"./index-CCf1BEwD.js";import{L as _}from"./LastSeen-sm0titIc.js";import{L as D}from"./Lqi-BErKiqkS.js";import{P as k}from"./PowerSource-CSWJpU_d.js";import{D as q}from"./DeviceImage-DIhbuI22.js";const K=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(F,{feature:r,device:e,deviceState:t,onChange:m,onRead:c,featureWrapperClass:d,minimal:!0,parentFeatures:[],endpointSpecific:p},$(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(D,{value:t.linkquality})}),s.jsx("span",{className:"badge badge-soft badge-ghost cursor-default tooltip","data-tip":l(a=>a.power),children:s.jsx(k,{device:e,batteryPercent:t.battery,batteryState:t.battery_state,batteryLow:t.battery_low,showLevel:!0})}),h]})]})});export{K as D};
