const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-Gm5M1tJf.js","./index-KAtljJVt.js","./envs-CSqIi4cL.js","./index-COCbPj4S.css","./RecallRemove-Dq0GUqdz.js","./DashboardFeatureWrapper-iw7H46wQ.js","./Feature-B1aHJEJ-.js","./DisplayValue-BbeFDe0l.js","./isObject--vsEa_js.js","./_createCompounder-CDGep--y.js","./isObjectLike-CdeenLLY.js","./index-B-QDvwG_.js","./InputField-D4fq1Htu.js","./extends-CF3RwP-h.js","./react-select.esm-DL84IisZ.js","./defineProperty-CegpTSss.js","./floating-ui.dom-I8hrORoS.js","./DevicePicker-D5lrfSSh.js","./EndpointPicker-Cjgep8ml.js","./SelectField-wRS87yKs.js","./useColumnCount-SLc5fbFS.js","./DeviceCard-NfElU8a8.js","./LastSeen-CHI_R8WJ.js","./TimeAgo-CaEbEHPa.js","./Lqi-1-mXdfEK.js","./PowerSource-COQAARG3.js","./snakeCase-DfUuCAP-.js","./DeviceImage-BIyKFxKY.js","./index-B0hOIgnO.js","./GroupSettings-BPHAb2b_.js","./InfoAlert-BDXiwj6e.js","./SettingsList-B3K-wAVh.js","./CheckboxField-DhE3iyQ3.js","./NumberField-CpqFpk71.js"])))=>i.map(i=>d[i]);
import{r as m,u as _,a as v,x as j,A as h,j as e,S as p,y as S,z as N,C as $,D as E,N as y,E as g,F as x,U as A,O as T,_ as b}from"./index-KAtljJVt.js";import{S as C}from"./react-select.esm-DL84IisZ.js";import"./envs-CSqIi4cL.js";import"./defineProperty-CegpTSss.js";import"./extends-CF3RwP-h.js";import"./floating-ui.dom-I8hrORoS.js";const w=m.memo(({currentSourceIdx:t,currentGroup:n,tab:o="devices"})=>{const{t:r}=_("common"),c=v(s=>s.groups),l=j(),u=m.useCallback(s=>{s&&l(s.link)},[l]),d=m.useMemo(()=>{const s=[];for(let a=0;a<h.length;a++)for(const i of c[a])a===t&&i.id===n?.id||s.push({value:i.friendly_name,label:e.jsxs(e.Fragment,{children:[e.jsx(p,{idx:a,autoHide:!0,namePostfix:" – "})," ",i.friendly_name]}),name:`${a} ${i.friendly_name}`,link:`/group/${a}/${i.id}/${o}`});return s.sort((a,i)=>a.name.localeCompare(i.name)),s},[c,t,n,o]);return e.jsx(C,{unstyled:!0,placeholder:n&&t!==void 0?e.jsxs(e.Fragment,{children:[e.jsx(p,{idx:t,autoHide:!0,namePostfix:" – "})," ",n.friendly_name]}):r(s=>s.select_group),"aria-label":r(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 b(()=>import("./Devices-Gm5M1tJf.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,26,27,28]),import.meta.url)),P=m.lazy(async()=>await b(()=>import("./GroupSettings-BPHAb2b_.js"),__vite__mapDeps([29,1,2,3,30,31,32,12,33,19]),import.meta.url));function k(t,n,o){const r=`${t}-${o.id}`;switch(n){case"devices":return e.jsx(I,{sourceIdx:t,group:o},r);case"settings":return e.jsx(P,{sourceIdx:t,group:o},r)}}const f=({isActive:t})=>t?"tab tab-active":"tab";function z(){const t=j(),{t:n}=_(["groups","common"]),{sourceIdx:o,groupId:r,tab:c}=N(),[l,u]=$(o),d=Number.parseInt(r,10),s=v(E(a=>r?a.groups[l].find(i=>i.id===d):void 0));return m.useEffect(()=>{o&&u&&s?c||t(`/group/${o}/${s.id}/devices`,{replace:!0}):t("/groups",{replace:!0})},[o,u,c,s,t]),e.jsxs(e.Fragment,{children:[e.jsx(y,{children:e.jsx(w,{currentSourceIdx:l,currentGroup:s,tab:c})}),e.jsxs("div",{className:"tabs tabs-border mt-2",children:[e.jsxs(g,{to:`/group/${l}/${r}/devices`,className:f,children:[e.jsx(x,{icon:A,className:"me-2"}),n(a=>a.devices,{ns:"common"})]}),e.jsxs(g,{to:`/group/${l}/${r}/settings`,className:f,children:[e.jsx(x,{icon:T,className:"me-2"}),n(a=>a.settings)]})]}),e.jsx("div",{className:"tab-content block h-full bg-base-100 p-3",children:c&&s?k(l,c,s):e.jsx("div",{className:"flex-auto justify-center items-center",children:n(a=>a.unknown_group,{ns:"common"})})})]})}export{z as default};
