import{N as v,e as j,u as d,r as x,j as e,M as y,k as g,m as p,n as k,B as u,b as h,v as _,K as C,x as D,O as w}from"./index-6a654fd1.js";const S=v.create(s=>{const a=j(),{t:n}=d(["zigbee","common"]),{device:i,removeDevice:l}=s,[t,c]=x.useState({block:!1,force:!1}),b=[{label:n("force_remove"),name:"force",value:t.force},{label:n("block_join"),name:"block",value:t.block}],f=r=>{const{checked:o,name:N}=r.target;c({...t,[N]:o})},m=()=>{l(i.friendly_name,t.force,t.block),a.remove()};return e.jsxs(y,{isOpen:a.visible,children:[e.jsxs(g,{children:[e.jsx("h3",{children:n("remove_device")}),e.jsx("small",{children:i.friendly_name})]}),e.jsx(p,{children:b.map(r=>{const o=`${r.name}${i.ieee_address}`;return e.jsxs("div",{className:"form-check form-switch",children:[e.jsx("input",{className:"form-check-input",name:r.name,checked:r.value,type:"checkbox",id:o,onChange:f}),e.jsx("label",{className:"form-check-label",htmlFor:o,children:r.label})]},r.name)})}),e.jsxs(k,{children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:a.remove,children:n("common:close")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:m,children:n("common:delete")})]})]})}),E=v.create(s=>{const a=j(),{homeassistantEnabled:n,device:i,renameDevice:l}=s,[t,c]=x.useState(!1),[b,f]=x.useState(i.friendly_name),{t:m}=d(["zigbee","common"]),r=async()=>{await l(i.friendly_name,b,t),a.remove()};return e.jsxs(y,{isOpen:a.visible,children:[e.jsxs(g,{children:[e.jsx("h3",{children:m("rename_device")}),e.jsx("small",{children:i.friendly_name})]}),e.jsx(p,{children:e.jsx("div",{className:"card",children:e.jsxs("div",{className:"card-body",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"form-label",children:m("friendly_name")}),e.jsx("input",{onChange:o=>f(o.target.value),type:"text",className:"form-control",value:b})]}),n?e.jsxs("div",{className:"form-check form-switch",children:[e.jsx("input",{className:"form-check-input",checked:t,type:"checkbox",id:`hass${i.ieee_address}`,onChange:o=>c(o.target.checked)}),e.jsx("label",{className:"form-check-label",htmlFor:`hass${i.ieee_address}`,children:m("update_Home_assistant_entity_id")})]}):null]})})}),e.jsxs(k,{children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:a.remove,children:m("common:close")}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:r,children:m("zigbee:rename_device")})]})]})}),M=s=>{const{homeassistantEnabled:a,device:n,renameDevice:i,style:l}=s,{t}=d(["zigbee","common"]);return e.jsx(u,{className:`btn btn-${l} btn-sm d-md-inline-block mx-1`,onClick:()=>v.show(E,{device:n,renameDevice:i,homeassistantEnabled:a}),title:t("rename_device"),children:e.jsx("i",{className:"fa fa-edit"})})};function B(s){const{device:a,configureDevice:n,removeDevice:i,interviewDevice:l}=s,{t}=d(["zigbee","common"]);return e.jsxs("div",{className:"btn-group btn-group-sm",role:"group",children:[e.jsx(M,{device:a,renameDevice:s.renameDevice,homeassistantEnabled:s.homeassistantEnabled,style:"primary"}),e.jsx(u,{className:"btn btn-warning",onClick:n,item:a.friendly_name,title:t("reconfigure"),prompt:!0,children:e.jsx("i",{className:h("fa","fa-retweet")})}),e.jsx(u,{className:"btn btn-info",onClick:l,item:a.friendly_name,title:t("interview"),prompt:!0,children:e.jsx("i",{className:h("fa","fa-info")})}),e.jsx("button",{onClick:()=>v.show(S,{device:a,removeDevice:i}),className:"btn btn-danger",title:t("remove_device"),children:e.jsx("i",{className:h("fa","fa-trash")})})]})}var R=C,F=D,z=w,A="[object String]";function $(s){return typeof s=="string"||!F(s)&&z(s)&&R(s)==A}var O=$;const H=_(O);function G(s){const{t:a}=d(["avaliability"]),{availability:n,availabilityFeatureEnabled:i,availabilityEnabledForDevice:l,disabled:t}=s;let c;return H(n)?c=n:c=n.state,c=c.toLowerCase(),t?e.jsx("span",{children:a("disabled")}):l??i?e.jsx("span",{className:h({"text-danger animation-blinking":c==="offline","text-success":n==="online"}),children:a(c)}):e.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://www.zigbee2mqtt.io/guide/configuration/device-availability.html#availability-advanced-configuration",children:a("disabled")})}export{G as A,B as D,M as a,H as i};
