import{r,j as e}from"./vendor-react-9M-xu2bR.js";import{C as u,v as h,G as f}from"./ui-components-BxvihT61.js";import"./framework-BM176iet.js";import{b as j}from"./vendor-ui-utils-3tkeUVaX.js";import{a as g}from"./index-CTBPkbPG.js";import{s as N}from"./systemObjects-DSpePIIy.js";import{bb as n,L as b}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";const m=N.find(s=>s.name==="sys_audit_log"),i=m.views[0].columns;function V(){const s=g(),[o,c]=r.useState([]),[x,d]=r.useState(!0),l=r.useCallback(async()=>{if(s){d(!0);try{const t=await s.find("sys_audit_log",{$orderby:{createdAt:"desc"}});c(t.data||[])}catch{j.error("Failed to load audit logs")}finally{d(!1)}}},[s]);return r.useEffect(()=>{l()},[l]),e.jsxs("div",{className:"flex flex-col gap-4 sm:gap-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"bg-primary/10 p-2 rounded-md shrink-0",children:e.jsx(n,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Audit Log"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"View system activity and user actions"})]})]}),e.jsx(u,{children:e.jsx(h,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b bg-muted/50",children:i.map(t=>{const a=m.fields.find(p=>p.name===t);return e.jsx("th",{className:"h-10 px-3 sm:px-4 text-left font-medium text-muted-foreground whitespace-nowrap",children:a?.label??t},t)})})}),e.jsx("tbody",{children:x?e.jsx("tr",{children:e.jsx("td",{className:"p-6 text-center",colSpan:i.length,children:e.jsx(b,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):o.length===0?e.jsx("tr",{children:e.jsx("td",{className:"p-4 sm:p-6 text-center text-sm text-muted-foreground",colSpan:i.length,children:e.jsxs("div",{className:"flex flex-col items-center gap-2 py-4",children:[e.jsx(n,{className:"h-8 w-8 text-muted-foreground/50"}),e.jsx("p",{children:"No audit logs found."}),e.jsx(f,{variant:"secondary",className:"text-xs",children:"Read-only"})]})})}):o.map(t=>e.jsx("tr",{className:"border-b hover:bg-muted/50 transition-colors",children:i.map(a=>e.jsx("td",{className:"h-10 px-3 sm:px-4 whitespace-nowrap",children:String(t[a]??"")},a))},t.id||t._id))})]})})})})]})}export{V as AuditLogPage};
