import{r as p,b as v,j as o}from"./index-vDL8KyrI.js";import{S as _}from"./SelectField-apZm61cq.js";const D=p.memo(m=>{const{t:r}=v("common"),{devices:l,value:u,label:h,onChange:a,groups:n=[],...f}=m,x=t=>{const{value:i}=t.target;if(i.startsWith("0x"))a(l.find(e=>e.ieee_address===i));else{const e=Number.parseInt(i,10);a(n.find(s=>e===s.id))}},j=p.useMemo(()=>{const t=[],i=l.map(e=>{var s,d,c;return o.jsxs("option",{title:(s=e.definition)==null?void 0:s.description,value:e.ieee_address,children:[e.friendly_name," ",(d=e.definition)!=null&&d.model?`(${(c=e.definition)==null?void 0:c.model})`:""]},e.ieee_address)});if(n!=null&&n.length){const e=n.map(s=>o.jsx("option",{value:s.id,children:s.friendly_name},s.id));t.push(o.jsx("optgroup",{label:r("groups"),children:e},"Groups")),t.push(o.jsx("optgroup",{label:r("devices"),children:i},"Devices"))}else t.push(...i);return t},[l,n,r]);return o.jsxs(_,{name:"device_picker",label:h,value:u,onChange:x,...f,children:[o.jsx("option",{value:"",disabled:!0,children:r("select_device")}),j]})});export{D};
