import{r as f,u as y,j as s,L as u,S as w,F as N,bl as L}from"./index-ClCsMWbS.js";import{F}from"./Feature-C2pFQwpi.js";import{g as $}from"./index-CQLnbJQy.js";import{L as _}from"./LastSeen-BOY7jIoe.js";import{L as v}from"./Lqi-B1ebT_rM.js";import{P as D}from"./PowerSource--PK2quZc.js";import{D as P}from"./DeviceImage-Bs0M9j-k.js";const K=f.memo(({onChange:m,onRead:c,sourceIdx:n,hideSourceDot:j,device:e,endpoint:o,deviceState:t,lastSeenConfig:b,features:x,featureWrapperClass:d,children:h})=>{const{t:l}=y(["zigbee","devicePage"]),i=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===i)&&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},[i,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(P,{disabled:!1,device:e,otaState:t.update?.state})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs(u,{to:`/device/${n}/${e.ieee_address}/info`,className:"link link-hover font-semibold",children:[e.friendly_name,o!=null?` (${l(a=>a.endpoint)}: ${i?`${i} / `:""}${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:n,autoHide:!0})})]})]}),s.jsx("div",{className:"text-sm w-full p-2 max-h-125 overflow-y-auto",style:{scrollbarWidth:"thin"},children:g}),s.jsx("div",{className:"flex flex-row justify-end mb-2",children:s.jsxs(u,{to:`/device/${n}/${e.ieee_address}/exposes`,className:"btn btn-xs",children:[l(a=>a.exposes,{ns:"devicePage"})," ",s.jsx(N,{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(v,{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{K as D};
