const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Devices-CKrLjR7l.js","./index-ClCsMWbS.js","./envs-CSqIi4cL.js","./index-uKtJ6Klq.css","./RecallRemove-CnNFF1IW.js","./DashboardFeatureWrapper-DSvHZUwh.js","./Feature-C2pFQwpi.js","./DisplayValue-qZ7xyN8v.js","./isObject--vsEa_js.js","./_createCompounder-CDQ_1ElC.js","./isObjectLike-D4auEUP9.js","./index-CQLnbJQy.js","./InputField-CqTVHKf8.js","./SelectField-WiB6Edsu.js","./DevicePicker-0T64KBIx.js","./EndpointPicker-xjSURnYy.js","./useColumnCount-BIzxc4Aw.js","./DeviceCard-C89jjCiz.js","./LastSeen-BOY7jIoe.js","./TimeAgo-55eetS_D.js","./Lqi-B1ebT_rM.js","./PowerSource--PK2quZc.js","./snakeCase-D0nOJtgb.js","./DeviceImage-Bs0M9j-k.js","./index-C8QGyin-.js","./GroupSettings-BGUugnNe.js","./InfoAlert-DaX4x_1T.js","./SettingsList-B14Dp6bl.js","./CheckboxField-BxtT6ttj.js","./NumberField-Bv80Uoa9.js"])))=>i.map(i=>d[i]);
import{r as d,u as j,a as _,A as b,j as e,L as y,S as x,D as N,F as g,x as $,y as S,z as w,C as T,E as k,N as D,G as f,V as I,P as C,_ as v}from"./index-ClCsMWbS.js";import{u as E}from"./useSearch-BeB1_fQX.js";import{D as P}from"./DebouncedInput-B8gvkj6A.js";import"./envs-CSqIi4cL.js";const A=d.memo(({currentSourceIdx:a,currentGroup:n,tab:t="devices"})=>{const[r,i,c]=E(),{t:u}=j("common"),p=_(s=>s.groups),l=d.useMemo(()=>{const s=[];for(let o=0;o<b.length;o++)for(const m of p[o])o===a&&m.id===n?.id||i.length>0&&!m.friendly_name.toLowerCase().includes(i)||s.push(e.jsx("li",{children:e.jsxs(y,{to:`/group/${o}/${m.id}/${t}`,onClick:()=>c(""),className:"dropdown-item",children:[e.jsx(x,{idx:o,autoHide:!0,namePostfix:" – "})," ",m.friendly_name]})},`${m.friendly_name}-${m.id}-${o}`));return s.sort((o,m)=>o.key.localeCompare(m.key)),s},[p,i,a,n,t,c]);return e.jsxs(N,{buttonChildren:e.jsxs(e.Fragment,{children:[a!==void 0&&e.jsx(x,{idx:a,autoHide:!0}),n?n.friendly_name:u(s=>s.unknown_group)]}),children:[e.jsxs("label",{className:"input min-h-10",children:[e.jsx(g,{icon:$}),e.jsx(P,{onChange:c,placeholder:u(s=>s.type_to_filter),value:r,title:u(s=>s.type_to_filter)})]},"search"),l]})}),L=d.lazy(async()=>await v(()=>import("./Devices-CKrLjR7l.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]),import.meta.url)),z=d.lazy(async()=>await v(()=>import("./GroupSettings-BGUugnNe.js"),__vite__mapDeps([25,1,2,3,26,27,28,12,29,13]),import.meta.url));function F(a,n,t){const r=`${a}-${t.id}`;switch(n){case"devices":return e.jsx(L,{sourceIdx:a,group:t},r);case"settings":return e.jsx(z,{sourceIdx:a,group:t},r)}}const h=({isActive:a})=>a?"tab tab-active":"tab";function O(){const a=S(),{t:n}=j(["groups","common"]),{sourceIdx:t,groupId:r,tab:i}=w(),[c,u]=T(t),p=Number.parseInt(r,10),l=_(k(s=>r?s.groups[c].find(o=>o.id===p):void 0));return d.useEffect(()=>{t&&u&&l?i||a(`/group/${t}/${l.id}/devices`,{replace:!0}):a("/groups",{replace:!0})},[t,u,i,l,a]),e.jsxs(e.Fragment,{children:[e.jsx(D,{children:e.jsx(A,{currentSourceIdx:c,currentGroup:l,tab:i})}),e.jsxs("div",{className:"tabs tabs-border mt-2",children:[e.jsxs(f,{to:`/group/${c}/${r}/devices`,className:h,children:[e.jsx(g,{icon:I,className:"me-2"}),n(s=>s.devices,{ns:"common"})]}),e.jsxs(f,{to:`/group/${c}/${r}/settings`,className:h,children:[e.jsx(g,{icon:C,className:"me-2"}),n(s=>s.settings)]})]}),e.jsx("div",{className:"tab-content block h-full bg-base-100 p-3",children:i&&l?F(c,i,l):e.jsx("div",{className:"flex-auto justify-center items-center",children:n(s=>s.unknown_group,{ns:"common"})})})]})}export{O as default};
