import{a1 as D,a6 as V,u as N,r as o,j as e,a7 as G,B as v,F as j,a8 as H,a as f,I as h,s as b,L as g,an as B,aj as y,b3 as J,b4 as S,b1 as W,M as K,t as Q,S as C,A as Z,b2 as E}from"./index-a36IMXuN.js";import{s as X}from"./snakeCase-BMb4_GjJ.js";import{O as Y,a as ee,A as se,D as te}from"./oui-B7Gqtu1L.js";import{T as ne}from"./TextareaField-DTp8LLQE.js";import{D as ae}from"./DeviceImage-DIhbuI22.js";import{h as ie}from"./index-CsCgDwc5.js";import{f as oe,b as re}from"./OtaControlGroup-D_De-Lbp.js";import{D as le,V as ce}from"./VendorLink-CPWZg0eW.js";import{D as de}from"./DisplayValue-D9Ja0Su_.js";import{L as me}from"./LastSeen-sm0titIc.js";import{P as pe}from"./PowerSource-CSWJpU_d.js";import"./envs-CRUy-_iG.js";import"./_createCompounder-BuXEc9F7.js";import"./isObjectLike-BQssIl0N.js";import"./RemoveDeviceModal-BAMdW2gO.js";import"./CheckboxField-CwZ6yoAm.js";import"./InputField-IMyvy6Mz.js";import"./defineProperty-CegpTSss.js";import"./floating-ui.react-BC-AM6K8.js";import"./floating-ui.dom-DbzrgdRQ.js";import"./SelectField-BQBsNhlB.js";import"./TimeAgo-DVPpOI6f.js";const be=D.create(({device:n,setDeviceDescription:s})=>{const a=V(),{t:i}=N(["zigbee","common"]),[r,m]=o.useState(n.description||"");return o.useEffect(()=>{m(n.description||"")},[n.description]),o.useEffect(()=>{const c=u=>{u.key==="Escape"&&(u.preventDefault(),a.remove())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(G,{isOpen:a.visible,title:`${i(c=>c.update_description)} ${n.friendly_name}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(v,{className:"btn btn-neutral",onClick:a.remove,children:i(c=>c.cancel,{ns:"common"})}),e.jsx(v,{className:"btn btn-primary ms-1",onClick:async()=>{a.remove(),await s(n.ieee_address,r)},children:i(c=>c.save_description)})]}),children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(ne,{label:i(c=>c.description),name:"update_description",onChange:c=>m(c.target.value),rows:3,value:r})})})}),ue=o.memo(({device:n,setDeviceDescription:s})=>{const{t:a}=N("zigbee");return e.jsx(v,{className:`btn btn-link btn-md ${n.description?"btn-square":""} tooltip-bottom`,onClick:async()=>await D.show(be,{device:n,setDeviceDescription:s}),title:a(i=>i.edit_description),children:n.description?e.jsx(j,{icon:H}):a(i=>i.edit_description)})}),xe=/\[(.*?)]\((.*?)\)/,fe={native:"badge-success",external:"badge-info",generated:"badge-warning"},he=(n,s)=>{if(!(n==="bindings"||n==="configured_reportings"||n==="scenes"))return s},_e=o.memo(({sourceIdx:n,device:s})=>{const{t:a}=N("zigbee"),i=f(h(m=>m.bridgeInfo[n])),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,he)}
\`\`\``};return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(r).toString()}`,className:"link link-hover",children:a(m=>m.submit_converter)})}),je=o.memo(({sourceIdx:n,device:s})=>{const{t:a}=N("zigbee"),i=f(h(d=>d.bridgeInfo[n])),r=f(h(d=>d.bridgeHealth[n])),m=s.definition;if(!m)return null;const c=m.model!==s.model_id?` (${m.model})`:"",u={template:"problem_report.yaml",title:`[${s.model_id}${c} / ${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&&(u.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(u).toString()}`,className:"btn btn-ghost",children:a(d=>d.report_problem)})});function ze({sourceIdx:n,device:s}){const{t:a}=N(["zigbee","availability","common","ota"]),i=f(h(t=>t.deviceStates[n])),r=f(h(t=>t.bridgeInfo[n].config)),m=f(h(t=>t.availability[n])),c=f(h(t=>t.recentActivity[n])),u=r.homeassistant.enabled,d=i[s.friendly_name]??{},w=c[s.friendly_name],O=o.useMemo(()=>ie(s),[s]),_=o.useMemo(()=>oe(d.update?.installed_version),[d.update?.installed_version]),L=o.useMemo(()=>Y.get(s.ieee_address.slice(2,8))??"?",[s.ieee_address]),U=o.useCallback(async(t,l)=>{await b(n,"bridge/request/device/options",{id:t,options:{description:l}})},[n]),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})},[]),I=o.useCallback(async([t,l])=>{await b(t,"bridge/request/device/interview",{id:l})},[]),P=o.useCallback(async(t,l,p,x)=>{await b(t,"bridge/request/device/remove",{id:l,force:p,block:x})},[]),q=o.useCallback(async({sourceIdx:t,ieee:l,...p})=>await b(t,"bridge/request/device/ota_update/check",{id:l,...p}),[]),A=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}),[]),$=r.devices[s.ieee_address]?.availability,T=o.useMemo(()=>{const t=s.definition?.description?xe.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 y.Pending:return e.jsx(j,{icon:S,className:"text-info"});case y.InProgress:return e.jsx(j,{icon:S,spin:!0,className:"text-info"});case y.Successful:return e.jsx(j,{icon:J,className:"text-success"});default:return e.jsx(j,{icon:B,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(ae,{device:s,otaState:d.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(ee,{sourceIdx:n,name:s.friendly_name,renameDevice:k,homeassistantEnabled:u,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?fe[s.definition.source]:""}`,children:[e.jsx(de,{name:"supported",value:s.supported}),s.definition?`: ${s.definition.source}`:""]}),!s.supported&&e.jsx("span",{className:"badge",children:e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:W,className:"link link-hover",children:a(t=>t.how_to_add_support)})}),s.definition?.source==="external"&&e.jsx("span",{className:"badge",children:e.jsx(_e,{sourceIdx:n,device:s})}),e.jsxs("span",{className:"badge opacity-70 tooltip tooltip-bottom","data-tip":s.interview_state,children:[a(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(ue,{device:s,setDeviceDescription:U})]}),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:a(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":a(t=>t[X(s.power_source||"unknown")]),e.jsx("span",{className:"ms-3",children:e.jsx(pe,{showLevel:!0,device:s,batteryPercent:d.battery,batteryState:d.battery_state,batteryLow:d.battery_low})})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:a(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: ",L]})})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:a(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":a(t=>t.network_address_hex),children:e.jsx("span",{className:"font-mono",children:Q(s.network_address)})})}),e.jsxs("p",{className:"text-base-content/50",children:[a(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:a(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:s.manufacturer})]}),e.jsxs("div",{className:"font-semibold text-base-content/70",children:[a(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(le,{modelId:s.model_id,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(ce,{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:a(t=>t.firmware_id)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:s.software_build_id||"N/A"}),e.jsx("p",{className:"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:a(t=>t.firmware_version,{ns:"ota"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold",children:[d.update?.installed_version??a(t=>t.unknown),e.jsx("span",{className:"ms-3",children:e.jsx(re,{sourceIdx:n,device:s,otaSettings:r.ota,state:d.update,onCheckClick:q,onUpdateClick:A,onScheduleClick:R,onUnscheduleClick:F})})]}),_?e.jsxs("p",{className:"text-base-content/50",children:[a(t=>t.app,{ns:"ota"}),": ",`${_[0]} build ${_[1]}`," | ",a(t=>t.stack,{ns:"ota"}),": ",`${_[2]} build ${_[3]}`]}):null]})]}):null,e.jsx("div",{className:"font-semibold text-base-content/70",children:a(t=>t.last_seen)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(me,{config:r.advanced.last_seen,lastSeen:d.last_seen,fallback:a(t=>t.disabled,{ns:"common"})})}),e.jsxs("p",{className:"text-base-content/50",children:[a(t=>t.availability,{ns:"availability"}),": ",e.jsx(se,{availability:m[s.friendly_name]?.state??"offline",disabled:s.disabled,availabilityFeatureEnabled:r.availability.enabled,availabilityEnabledForDevice:$!=null?!!$:void 0})]})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:a(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(C,{idx:n,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:"-"})]}),K&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:a(t=>t.source,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(C,{idx:n,alwaysShowName:!0})}),e.jsx("p",{className:"text-base-content/50",children:Z[n]})]})]})]}),e.jsxs("div",{className:"card-actions justify-center md:justify-end mt-2 me-4",children:[s.supported&&e.jsx(je,{sourceIdx:n,device:s}),e.jsx(te,{sourceIdx:n,device:s,otaState:d.update?.state,homeassistantEnabled:u,renameDevice:k,configureDevice:M,interviewDevice:I,removeDevice:P})]})]})]})}export{ze as default};
