import{a1 as D,a6 as B,u as N,r as o,j as e,a7 as H,B as y,F as _,a8 as J,a as u,I as h,s as b,L as g,ap as W,aj as v,b3 as K,b4 as S,aB as Q,b5 as Z,q as X,b1 as Y,M as ee,t as se,S as $,A as te,b2 as E}from"./index-CE-9RlbR.js";import{s as ne}from"./snakeCase-WwJ9QoNs.js";import{O as ae,a as ie,A as oe,D as re}from"./oui-BbVKsFAP.js";import{T as le}from"./TextareaField-Ba8vaWW5.js";import{D as ce}from"./DeviceImage-Bcp15E0n.js";import{h as de}from"./index-CDoSh7QA.js";import{f as me,b as pe}from"./OtaControlGroup-CqxAW8k1.js";import{D as be,V as fe}from"./VendorLink-CmTCsOtg.js";import{L as xe}from"./LastSeen-D1je17I0.js";import{P as ue}from"./PowerSource-Ch5TptQq.js";import"./envs-CRUy-_iG.js";import"./_createCompounder-pwnXEtry.js";import"./isObjectLike-BsEMHB57.js";import"./RemoveDeviceModal-1XiYlA7B.js";import"./CheckboxField-BPvsXluL.js";import"./InputField-DRmYNLGX.js";import"./floating-ui.react-BJkbBPAO.js";import"./floating-ui.dom-D02yrJtw.js";import"./SelectField-BPXpeItQ.js";import"./TimeAgo-D_O5nVVz.js";const he=D.create(({device:a,setDeviceDescription:s})=>{const n=B(),{t:i}=N(["zigbee","common"]),[r,m]=o.useState(a.description||"");return o.useEffect(()=>{m(a.description||"")},[a.description]),o.useEffect(()=>{const d=f=>{f.key==="Escape"&&(f.preventDefault(),n.remove())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),e.jsx(H,{isOpen:n.visible,title:`${i(d=>d.update_description)} ${a.friendly_name}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"btn btn-neutral",onClick:n.remove,children:i(d=>d.cancel,{ns:"common"})}),e.jsx(y,{className:"btn btn-primary ms-1",onClick:async()=>{n.remove(),await s(a.ieee_address,r)},children:i(d=>d.save_description)})]}),children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(le,{label:i(d=>d.description),name:"update_description",onChange:d=>m(d.target.value),rows:3,value:r})})})}),_e=o.memo(({device:a,setDeviceDescription:s})=>{const{t:n}=N("zigbee");return e.jsx(y,{className:`btn btn-link btn-md ${a.description?"btn-square":""} tooltip-bottom`,onClick:async()=>await D.show(he,{device:a,setDeviceDescription:s}),title:n(i=>i.edit_description),children:a.description?e.jsx(_,{icon:J}):n(i=>i.edit_description)})}),je=/\[(.*?)]\((.*?)\)/,Ne={native:"badge-success",external:"badge-info",generated:"badge-accent"},ge={native:X,external:Z,generated:Q},we=(a,s)=>{if(!(a==="bindings"||a==="configured_reportings"||a==="scenes"))return s},ve=o.memo(({sourceIdx:a,device:s})=>{const{t:n}=N("zigbee"),i=u(h(m=>m.bridgeInfo[a])),r={template:"external_converter.yaml",title:`[External Converter]: ${s.model_id} from ${s.manufacturer}`,z2m_version:`${i.version} (${i.commit})`,notes:`
software_build_id: \`${s.software_build_id}\`
date_code: \`${s.date_code}\`
endpoints:
\`\`\`json
${JSON.stringify(s.endpoints,we)}
\`\`\``};return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(r).toString()}`,className:"link link-hover",children:n(m=>m.submit_converter)})}),ye=o.memo(({sourceIdx:a,device:s})=>{const{t:n}=N("zigbee"),i=u(h(c=>c.bridgeInfo[a])),r=u(h(c=>c.bridgeHealth[a])),m=s.definition;if(!m)return null;const d=m.model!==s.model_id?` (${m.model})`:"",f={template:"problem_report.yaml",title:`[${s.model_id}${d} / ${s.manufacturer}] ???`,z2m_version:`${i.version} (${i.commit})`,adapter_fwversion:JSON.stringify(i.coordinator.meta),adapter:i.coordinator.type,setup:`os: \`${i.os.version}\`
node: \`${i.os.node_version}\`
ha: \`${i.config.homeassistant.enabled}\``,notes:`
#### Device
definition: \`${m.model}\` - \`${m.vendor}\` (\`v${m.version??"0.0.0"}\`)
software_build_id: \`${s.software_build_id}\`
date_code: \`${s.date_code}\`
endpoints:
\`\`\`json
${JSON.stringify(s.endpoints)}
\`\`\``};return r.response_time>0&&(f.notes+=`
##### Health
time: \`${new Date(r.response_time)}\`
os.load_average: \`${r.os.load_average.join(", ")}\`
os.memory_percent: \`${r.os.memory_percent}\`
process.memory_percent: \`${r.process.memory_percent}\`
process.uptime_sec: \`${Math.round(r.process.uptime_sec)}\`
\`\`\`json
${JSON.stringify(r.devices[s.ieee_address]??{})}
\`\`\`
`),e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(f).toString()}`,className:"btn btn-ghost",children:n(c=>c.report_problem)})});function Be({sourceIdx:a,device:s}){const{t:n}=N(["zigbee","availability","common","ota"]),i=u(h(t=>t.deviceStates[a])),r=u(h(t=>t.bridgeInfo[a].config)),m=u(h(t=>t.availability[a])),d=u(h(t=>t.recentActivity[a])),f=r.homeassistant.enabled,c=i[s.friendly_name]??{},w=d[s.friendly_name],O=o.useMemo(()=>de(s),[s]),j=o.useMemo(()=>me(c.update?.installed_version),[c.update?.installed_version]),U=o.useMemo(()=>ae.get(s.ieee_address.slice(2,8))??"?",[s.ieee_address]),L=o.useCallback(async(t,l)=>{await b(a,"bridge/request/device/options",{id:t,options:{description:l}})},[a]),k=o.useCallback(async(t,l,p,x)=>{await b(t,"bridge/request/device/rename",{from:l,to:p,homeassistant_rename:x,last:void 0})},[]),M=o.useCallback(async([t,l])=>{await b(t,"bridge/request/device/configure",{id:l})},[]),q=o.useCallback(async([t,l])=>{await b(t,"bridge/request/device/interview",{id:l})},[]),A=o.useCallback(async(t,l,p,x,G,V)=>{await b(t,"bridge/request/device/remove",{id:l,force:p,block:x,keep_config:G,clear_cache:V})},[]),I=o.useCallback(async({sourceIdx:t,ieee:l,...p})=>await b(t,"bridge/request/device/ota_update/check",{id:l,...p}),[]),P=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...x})=>await b(t,p?"bridge/request/device/ota_update/update/downgrade":"bridge/request/device/ota_update/update",{id:l,...x}),[]),R=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...x})=>await b(t,p?"bridge/request/device/ota_update/schedule/downgrade":"bridge/request/device/ota_update/schedule",{id:l,...x}),[]),F=o.useCallback(async({sourceIdx:t,ieee:l})=>await b(t,"bridge/request/device/ota_update/unschedule",{id:l}),[]),C=r.devices[s.ieee_address]?.availability,T=o.useMemo(()=>{const t=s.definition?.description?je.exec(s.definition?.description):void 0;if(t){const[,l,p]=t;return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:p,className:"link link-hover",children:l})}return e.jsx(e.Fragment,{children:s.definition?.description})},[s.definition]),z=o.useMemo(()=>{switch(s.interview_state){case v.Pending:return e.jsx(_,{icon:S,className:"text-info"});case v.InProgress:return e.jsx(_,{icon:S,spin:!0,className:"text-info"});case v.Successful:return e.jsx(_,{icon:K,className:"text-success"});default:return e.jsx(_,{icon:W,beat:!0,className:"text-error"})}},[s.interview_state]);return e.jsxs("div",{className:"card lg:card-side bg-base-100",children:[e.jsx("figure",{className:"w-64 h-64",style:{overflow:"visible"},children:e.jsx(ce,{device:s,otaState:c.update?.state,disabled:s.disabled,noIndicator:!0})}),e.jsxs("div",{className:"card-body py-0 px-3",children:[e.jsxs("h2",{className:"card-title",children:[s.friendly_name,e.jsx(ie,{sourceIdx:a,name:s.friendly_name,renameDevice:k,homeassistantEnabled:f,style:"btn-link btn-md btn-square"})]}),e.jsxs("div",{className:"flex flex-row flex-wrap gap-2",children:[e.jsxs("span",{className:`badge ${s.definition?Ne[s.definition.source]:""}`,children:[s.definition?e.jsx(_,{icon:ge[s.definition.source]}):null,n(t=>s.definition?t[s.definition.source]:t.unsupported)]}),!s.supported&&e.jsx("span",{className:"badge",children:e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:Y,className:"link link-hover",children:n(t=>t.how_to_add_support)})}),s.definition?.source==="external"&&e.jsx("span",{className:"badge",children:e.jsx(ve,{sourceIdx:a,device:s})}),e.jsxs("span",{className:"badge opacity-70 tooltip tooltip-bottom","data-tip":s.interview_state,children:[n(t=>t.interview_state),": ",z]})]}),e.jsxs("div",{className:"flex flex-row flex-wrap items-center text-wrap break-all text-base-content/70",children:[s.description||"",e.jsx(_e,{device:s,setDeviceDescription:L})]}),e.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-2 text-wrap",children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.type)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:s.type}),e.jsxs("p",{className:"text-base-content/50",children:[s.type==="GreenPower"?"GreenPower":n(t=>t[ne(s.power_source||"unknown")]),e.jsx("span",{className:"ms-3",children:e.jsx(ue,{showLevel:!0,device:s,batteryPercent:c.battery,batteryState:c.battery_state,batteryLow:c.battery_low})})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.ieee_address)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold font-mono",children:s.ieee_address}),e.jsx("p",{className:"text-base-content/50",children:e.jsxs("span",{className:"tooltip tooltip-bottom",children:[e.jsxs("span",{className:"tooltip-content",children:["Organizationally Unique Identifier",e.jsx("br",{}),"(IEEE Vendor Prefix)"]}),"OUI: ",U]})})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.network_address)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx("span",{className:"tooltip tooltip-bottom","data-tip":n(t=>t.network_address_hex),children:e.jsx("span",{className:"font-mono",children:se(s.network_address)})})}),e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.network_address_dec),": ",e.jsx("span",{className:"font-mono",children:s.network_address})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.zigbee_model)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold break-all",children:s.model_id}),e.jsx("p",{className:"text-base-content/50",children:e.jsx("span",{className:"tooltip tooltip-bottom","data-tip":n(t=>t.zigbee_manufacturer),children:s.manufacturer})})]}),e.jsxs("div",{className:"font-semibold text-base-content/70",children:[n(t=>t.definition,{ns:"common"})," (Zigbee2MQTT)"]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[e.jsx(be,{supported:s.supported,definitionModel:s.definition?.model,icon:!0}),s.definition?.version&&s.definition.version!=="0.0.0"?` (v${s.definition.version})`:null]}),e.jsxs("p",{className:"text-base-content/50",children:[T,e.jsx("br",{}),e.jsx(fe,{supported:s.supported,definitionVendor:s.definition?.vendor,icon:!0})]})]}),s.software_build_id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.firmware_id)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono font-semibold",children:s.software_build_id||"N/A"}),e.jsx("p",{className:"font-mono text-base-content/50",children:s.date_code||"N/A"})]})]}):null,O?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.firmware_version,{ns:"ota"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold",children:[c.update?.installed_version?e.jsx("span",{className:"font-mono",children:c.update.installed_version}):e.jsx("span",{children:n(t=>t.not_assessed,{ns:"common"})}),e.jsx("span",{className:"ms-3",children:e.jsx(pe,{sourceIdx:a,device:s,otaSettings:r.ota,state:c.update,onCheckClick:I,onUpdateClick:P,onScheduleClick:R,onUnscheduleClick:F})})]}),j?e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.app,{ns:"ota"}),": ",`${j[0]} build ${j[1]}`," | ",n(t=>t.stack,{ns:"ota"}),": ",`${j[2]} build ${j[3]}`]}):null]})]}):null,e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.last_seen)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xe,{config:r.advanced.last_seen,lastSeen:c.last_seen,fallback:n(t=>t.disabled,{ns:"common"})})}),e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.availability,{ns:"availability"}),": ",e.jsx(oe,{availability:m[s.friendly_name]?.state??"offline",disabled:s.disabled,availabilityFeatureEnabled:r.availability.enabled,availabilityEnabledForDevice:C!=null?!!C:void 0})]})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.recent_activity,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[e.jsx($,{idx:a,autoHide:!0}),w.desc]}),e.jsx("p",{className:"text-base-content/50",children:new Date(w.timestamp).toLocaleString()})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:"MQTT"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[r.mqtt.base_topic,"/",s.friendly_name]}),e.jsx("p",{className:"text-base-content/0",children:"-"})]}),ee&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.source,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx($,{idx:a,alwaysShowName:!0})}),e.jsx("p",{className:"text-base-content/50",children:te[a]})]})]})]}),e.jsxs("div",{className:"card-actions justify-center md:justify-end mt-2 me-4",children:[e.jsx(ye,{sourceIdx:a,device:s}),e.jsx(re,{sourceIdx:a,device:s,otaState:c.update?.state,homeassistantEnabled:f,renameDevice:k,configureDevice:M,interviewDevice:q,removeDevice:A})]})]})]})}export{Be as default};
