import{h as y,i as b,r as n,j as s}from"./vendor-react-9M-xu2bR.js";import{C as j,s as L,u as N,t as C,v,G as w}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import"./vendor-ui-utils-3tkeUVaX.js";import{a as $,b as S}from"./index-CTBPkbPG.js";import{ai as R,b4 as M,b8 as P,b9 as _,ba as k,bb as z,a8 as A,L as E}from"./vendor-icons-ndICq8DC.js";import"./vendor-radix-C6qchjxv.js";import"./vendor-i18n-E3-WitRV.js";import"./vendor-charts-BLNOCZWl.js";import"./infrastructure-n1j_TN6w.js";import"./vendor-objectstack-YKtcdalX.js";import"./vendor-zod-DxQVy2_o.js";import"./plugins-core-qwgXbAqa.js";import"./vendor-dndkit-CX1oDZqy.js";import"./plugins-views-CveFN6PV.js";import"./data-adapter-rvE3xy2B.js";import"./ui-layout-C6KWQtRO.js";function Z(){const m=y(),{appName:r}=b(),t=r?`/apps/${r}`:"",a=$(),{apps:l}=S(),[i,u]=n.useState({apps:null,users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[p,c]=n.useState(!0),d=n.useCallback(async()=>{if(a){c(!0);try{const[e,o,h,f,x]=await Promise.all([a.find("sys_user").catch(()=>({data:[]})),a.find("sys_org").catch(()=>({data:[]})),a.find("sys_role").catch(()=>({data:[]})),a.find("sys_permission").catch(()=>({data:[]})),a.find("sys_audit_log").catch(()=>({data:[]}))]);u({apps:l?.length??0,users:e.data?.length??0,orgs:o.data?.length??0,roles:h.data?.length??0,permissions:f.data?.length??0,auditLogs:x.data?.length??0})}catch{}finally{c(!1)}}},[a,l]);n.useEffect(()=>{d()},[d]);const g=[{title:"Applications",description:"Manage all configured applications",icon:R,href:`${t}/system/apps`,countLabel:"apps",count:i.apps},{title:"Users",description:"Manage system users and accounts",icon:M,href:`${t}/system/users`,countLabel:"users",count:i.users},{title:"Organizations",description:"Manage organizations and teams",icon:P,href:`${t}/system/organizations`,countLabel:"organizations",count:i.orgs},{title:"Roles",description:"Configure roles and access levels",icon:_,href:`${t}/system/roles`,countLabel:"roles",count:i.roles},{title:"Permissions",description:"Manage permission rules and assignments",icon:k,href:`${t}/system/permissions`,countLabel:"permissions",count:i.permissions},{title:"Audit Log",description:"View system activity and changes",icon:z,href:`${t}/system/audit-log`,countLabel:"entries",count:i.auditLogs},{title:"Profile",description:"View and edit your account settings",icon:A,href:`${t}/system/profile`,countLabel:"",count:null}];return s.jsxs("div",{className:"flex flex-col gap-6 p-4 sm:p-6",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"System Settings"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage applications, users, roles, permissions, and system configuration"})]}),p&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(E,{className:"h-4 w-4 animate-spin"}),"Loading statistics..."]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:g.map(e=>{const o=e.icon;return s.jsxs(j,{className:"cursor-pointer transition-colors hover:bg-accent/50",onClick:()=>m(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,"-")}`,children:[s.jsxs(L,{className:"flex flex-row items-center gap-3 pb-2",children:[s.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary",children:s.jsx(o,{className:"h-5 w-5"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx(N,{className:"text-base",children:e.title}),s.jsx(C,{className:"text-xs",children:e.description})]})]}),s.jsx(v,{className:"pt-0",children:e.count!==null&&s.jsxs(w,{variant:"secondary",children:[e.count," ",e.countLabel]})})]},e.title)})})]})}export{Z as SystemHubPage};
