const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-CtpIK4Ws.js","./index-B_eahVWI.js","./envs-CRUy-_iG.js","./index-BtdcwP6l.css","./RecallRemove-DB4u8g49.js","./DashboardFeatureWrapper-BxYtaGVm.js","./startCase-BlYkzI2K.js","./DisplayValue-8WlGubxH.js","./isObject--vsEa_js.js","./_createCompounder-KpkcgNnL.js","./isObjectLike-mS1hgzH9.js","./InputField-DBG-IjF8.js","./react-select.esm-BQis7zht.js","./floating-ui.dom-D02yrJtw.js","./DevicePicker-B6FgDjrJ.js","./EndpointPicker-D4BSoZaj.js","./SelectField-JWPpuidh.js","./useColumnCount-C5Hk15aM.js","./DeviceCard-CbiojlW6.js","./LastSeen-DuqkpiII.js","./TimeAgo-D8Qg455l.js","./Lqi-DzsgggAL.js","./PowerSource-C9PkIWWx.js","./snakeCase-CJzHmbbg.js","./DeviceImage-BuQphSNv.js","./index-CDoSh7QA.js","./Exposes-gQ_6exxj.js","./FeatureWrapper-CuGmNNoZ.js","./GroupSettings-BU-O0I-b.js","./InfoAlert-BYb1Ijsc.js","./SettingsList-BKLVWCQb.js","./CheckboxField-CzUa3ISp.js","./NumberField-Cft7S9El.js"])))=>i.map(i=>d[i]);
import{r as m,u as j,a as b,C as h,A as N,j as e,S as v,D as S,E as $,G as E,I as y,N as T,J as p,F as x,X as f,T as A,$ as _}from"./index-B_eahVWI.js";import{S as w}from"./react-select.esm-BQis7zht.js";import"./envs-CRUy-_iG.js";import"./floating-ui.dom-D02yrJtw.js";const C=m.memo(({currentSourceIdx:t,currentGroup:r,tab:o="devices"})=>{const{t:n}=j("common"),l=b(s=>s.groups),i=h(),u=m.useCallback(s=>{s&&i(s.link)},[i]),d=m.useMemo(()=>{const s=[];for(let a=0;a<N.length;a++)for(const c of l[a])a===t&&c.id===r?.id||s.push({value:c.friendly_name,label:e.jsxs(e.Fragment,{children:[e.jsx(v,{idx:a,autoHide:!0,namePostfix:" – "})," ",c.friendly_name]}),name:`${a} ${c.friendly_name}`,link:`/group/${a}/${c.id}/${o}`});return s.sort((a,c)=>a.name.localeCompare(c.name)),s},[l,t,r,o]);return e.jsx(w,{unstyled:!0,placeholder:r&&t!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(v,{idx:t,autoHide:!0,namePostfix:" – "})," ",r.friendly_name]}):n(s=>s.select_group),"aria-label":n(s=>s.select_group),options:d,isSearchable:!0,onChange:u,className:"min-w-48 sm:w-auto me-2",classNames:S})}),I=m.lazy(async()=>await _(()=>import("./Devices-CtpIK4Ws.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]),import.meta.url)),P=m.lazy(async()=>await _(()=>import("./Exposes-gQ_6exxj.js"),__vite__mapDeps([26,1,2,3,6,7,8,9,10,27]),import.meta.url)),L=m.lazy(async()=>await _(()=>import("./GroupSettings-BU-O0I-b.js"),__vite__mapDeps([28,1,2,3,29,30,31,11,32,16]),import.meta.url));function k(t,r,o){const n=`${t}-${o.id}`;switch(r){case"devices":return e.jsx(I,{sourceIdx:t,group:o},n);case"exposes":return e.jsx(P,{sourceIdx:t,group:o},n);case"settings":return e.jsx(L,{sourceIdx:t,group:o},n)}}const g=({isActive:t})=>t?"tab tab-active":"tab";function O(){const t=h(),{t:r}=j(["groups","common"]),{sourceIdx:o,groupId:n,tab:l}=$(),[i,u]=E(o),d=Number.parseInt(n,10),s=b(y(a=>n?a.groups[i].find(c=>c.id===d):void 0));return m.useEffect(()=>{o&&u&&s?l||t(`/group/${o}/${s.id}/devices`,{replace:!0}):t("/groups",{replace:!0})},[o,u,l,s,t]),e.jsxs(e.Fragment,{children:[e.jsx(T,{children:e.jsx(C,{currentSourceIdx:i,currentGroup:s,tab:l})}),e.jsxs("div",{className:"tabs tabs-border mt-2",children:[e.jsxs(p,{to:`/group/${i}/${n}/devices`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),r(a=>a.devices,{ns:"common"})]}),e.jsxs(p,{to:`/group/${i}/${n}/exposes`,className:g,children:[e.jsx(x,{icon:f,className:"me-2"}),r(a=>a.exposes,{ns:"common"})]}),e.jsxs(p,{to:`/group/${i}/${n}/settings`,className:g,children:[e.jsx(x,{icon:A,className:"me-2"}),r(a=>a.settings)]})]}),e.jsx("div",{className:"tab-content block h-full bg-base-100 p-3",children:l&&s?k(i,l,s):e.jsx("div",{className:"flex-auto justify-center items-center",children:r(a=>a.unknown_group,{ns:"common"})})})]})}export{O as default};
