import{t as e}from"./useQuery-DoHBdk1I.js";import{t}from"./label-DJXLXb2R.js";import{t as n}from"./search-CLoq7i9Y.js";import{t as r}from"./user-BXtGUaN4.js";import{Pt as i,S as a,b as o,jt as s,m as c,r as l,u,ut as d}from"./index-cYnyErBl.js";import{n as f}from"./skeleton-BYSy5H0w.js";import{a as p,c as m,i as h,n as g,o as _,r as v,s as y,t as b}from"./table-CgoZ-Hky.js";import{t as x}from"./input-DMNsEatJ.js";import{t as S}from"./useDebounce-Bp4Kcvvd.js";var C=i(s(),1),w={getAll:e=>l.get(`/activity-logs`,{params:e})},T=d(),E=(e=``)=>e.includes(`login`)?`text-info bg-info/8 border-info/20`:e.includes(`logout`)?`text-muted-foreground bg-muted/60 border-border`:e.includes(`deleted`)?`text-destructive bg-destructive/8 border-destructive/20`:e.includes(`created`)?`text-success bg-success/8 border-success/20`:e.includes(`updated`)?`text-warning bg-warning/8 border-warning/20`:e.includes(`imported`)||e.includes(`uploaded`)||e.includes(`zip`)?`text-purple-600 bg-purple-50 border-purple-200 dark:text-purple-400 dark:bg-purple-500/10 dark:border-purple-500/20`:`text-foreground bg-muted/60 border-border`;function D(){let[i,s]=(0,C.useState)(``),[l,d]=(0,C.useState)(``),[D,O]=(0,C.useState)(``),[k,A]=(0,C.useState)(1),j=S(i,400),{data:M,isLoading:N}=e({queryKey:[`activity-logs`,j,l,D,k],queryFn:()=>w.getAll({event:j,date_from:l,date_to:D,page:k,per_page:20}).then(e=>e.data)}),P=M?.data??[];return(0,T.jsxs)(`div`,{children:[(0,T.jsx)(f,{title:`Activity Log`,description:`Rekaman seluruh aktivitas admin dalam sistem.`}),(0,T.jsxs)(`div`,{className:`flex gap-2.5 mb-4 flex-wrap items-end`,children:[(0,T.jsxs)(`div`,{className:`relative flex-1 min-w-48`,children:[(0,T.jsx)(n,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,T.jsx)(x,{value:i,onChange:e=>s(e.target.value),placeholder:`Filter nama aksi...`,className:`pl-9 h-9 text-sm`})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(t,{className:`text-xs text-muted-foreground`,children:`Dari`}),(0,T.jsx)(x,{type:`date`,value:l,onChange:e=>d(e.target.value),className:`w-36 h-9 text-sm`})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsx)(t,{className:`text-xs text-muted-foreground`,children:`Sampai`}),(0,T.jsx)(x,{type:`date`,value:D,onChange:e=>O(e.target.value),className:`w-36 h-9 text-sm`})]}),(i||l||D)&&(0,T.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-9 text-xs text-muted-foreground`,onClick:()=>{s(``),d(``),O(``),A(1)},children:`Reset`})]}),(0,T.jsx)(`div`,{className:`rounded-2xl border border-border bg-card shadow-sm overflow-hidden`,children:N?(0,T.jsx)(m,{rows:8,cols:3}):P.length===0?(0,T.jsx)(y,{icon:c,heading:`Tidak ada log`,subtext:`Belum ada aktivitas yang tercatat.`}):(0,T.jsxs)(b,{children:[(0,T.jsx)(p,{children:(0,T.jsxs)(_,{className:`bg-muted/40 hover:bg-muted/40 border-b border-border`,children:[(0,T.jsx)(h,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Aksi`}),(0,T.jsx)(h,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Oleh`}),(0,T.jsx)(h,{className:`text-[11px] font-bold uppercase tracking-wider text-muted-foreground`,children:`Waktu`})]})}),(0,T.jsx)(g,{children:P.map(e=>(0,T.jsxs)(_,{className:`hover:bg-muted/20 transition-colors border-border/60`,children:[(0,T.jsx)(v,{className:`py-3`,children:(0,T.jsxs)(`span`,{className:o(`inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border`,E(e.description)),children:[(0,T.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-current shrink-0`}),e.description]})}),(0,T.jsx)(v,{className:`py-3`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,T.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center shrink-0`,children:(0,T.jsx)(r,{className:`h-3 w-3 text-primary`})}),(0,T.jsx)(`span`,{className:`text-sm text-foreground`,children:e.causer_name})]})}),(0,T.jsx)(v,{className:`py-3 text-sm text-muted-foreground tabular`,children:a(e.created_at)})]},e.id))})]})}),M?.meta&&M.meta.last_page>1&&(0,T.jsxs)(`div`,{className:`flex items-center justify-between mt-4`,children:[(0,T.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[M.meta.total,` aktivitas tercatat`]}),(0,T.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,T.jsx)(u,{variant:`outline`,size:`sm`,className:`h-8 px-3 text-xs`,disabled:k===1,onClick:()=>A(e=>e-1),children:`← Prev`}),(0,T.jsx)(u,{variant:`outline`,size:`sm`,className:`h-8 px-3 text-xs`,disabled:k>=M.meta.last_page,onClick:()=>A(e=>e+1),children:`Next →`})]})]})]})}export{D as default};