const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-CKgGVVRi.js","./index-CE-9RlbR.js","./envs-CRUy-_iG.js","./index-Bz12kIVH.css","./RecallRemove-DFcPL08D.js","./DashboardFeatureWrapper-BAseHpKP.js","./startCase-BwzMWzGM.js","./DisplayValue-eLtXORWe.js","./isObject--vsEa_js.js","./_createCompounder-pwnXEtry.js","./isObjectLike-BsEMHB57.js","./InputField-DRmYNLGX.js","./react-select.esm-CxImRSNQ.js","./floating-ui.dom-D02yrJtw.js","./DevicePicker-D9pe3MS2.js","./EndpointPicker-WNk50fpC.js","./SelectField-BPXpeItQ.js","./useColumnCount-CdMiuwHk.js","./DeviceCard-DkDt8Vgs.js","./LastSeen-D1je17I0.js","./TimeAgo-D_O5nVVz.js","./Lqi-0GAOTPeK.js","./PowerSource-Ch5TptQq.js","./snakeCase-WwJ9QoNs.js","./DeviceImage-Bcp15E0n.js","./index-CDoSh7QA.js","./Exposes-Bitd7-tL.js","./FeatureWrapper-CyVtzJVN.js","./GroupSettings-rB4LWKEG.js","./InfoAlert-AzL4ZLp4.js","./SettingsList-DXaUDCbO.js","./CheckboxField-BPvsXluL.js","./NumberField-XGSCkVuy.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-CE-9RlbR.js";import{S as w}from"./react-select.esm-CxImRSNQ.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-CKgGVVRi.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-Bitd7-tL.js"),__vite__mapDeps([26,1,2,3,6,7,8,9,10,27]),import.meta.url)),L=m.lazy(async()=>await _(()=>import("./GroupSettings-rB4LWKEG.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};
