import{r as e}from"./rolldown-runtime-Dv2bCSZU.js";import{l as t,n,r,t as i}from"./@emotion/react-CtiGf2aw.js";import{g as a,h as o,m as s,o as c,r as l,t as u,y as d}from"./antd-C-W8y9Fd.js";import{n as f,r as p}from"./@tanstack/react-query-DAdXAEX9.js";import{a as m,n as h,r as g}from"./main.6.9.js";var _=e(t());function v(){let{mutateAsync:e,isPending:t}=f({mutationFn:async e=>h({action:`logs/delete`,data:{ids:e}})});return{deleteLog:t=>e(t),isLogDeleting:t}}function y(e){let{data:t,isLoading:n,isFetching:r,refetch:i}=p({refetchOnWindowFocus:!1,queryKey:[`all_logs`,`logs-${e.pageNo}`],queryFn:async()=>h({action:`logs/all`,data:e})});return{isLoading:n,refetch:i,isLogsFetching:r,logs:t?.data?.logs??[],total:t?.data?.count??0,current:t?.data?.current??0,pages:t?.data?.pages??0}}var b=[{title:g(`Id`),dataIndex:`id`,key:`id`},{title:g(`User`),dataIndex:`user`,key:`user`,render:e=>e?.display_name??``},{title:g(`Command`),dataIndex:`command`,key:`command`},{title:g(`Details`),dataIndex:`details`,key:`details`,render:(e,t,s)=>r(o,{children:[n(c,{children:n(a,{children:e?.driver&&`Driver: ${e?.driver}`})}),n(`hr`,{}),n(c,{children:n(a,{children:e?.files&&r(i,{children:[n(`span`,{children:`Files:`}),n(`li`,{children:e?.files?.map(e=>n(`ol`,{children:e?.path},`${s}-${e?.path}`))})]})})})]})},{title:g(`Created`),dataIndex:`created_at`,key:`created_at`}];function x(){let[e,t]=(0,_.useState)({pageNo:1,limit:20}),{isLoading:i,isLogsFetching:a,logs:o,total:c,refetch:f}=y(e),{isLogDeleting:p,deleteLog:h}=v(),[g,x]=(0,_.useState)([]),S=()=>{h(g).then(e=>{e.code===`SUCCESS`?(x([]),f(),m().success({message:e?.message||`Log deleted successfully`})):m().error({message:e?.message||`Failed to delete logs`})})},C={selectedRowKeys:g,onChange:e=>{x(e)}},w=g.length>0;return r(s,{gap:`middle`,vertical:!0,children:[r(s,{align:`center`,gap:`middle`,children:[n(d,{type:`primary`,onClick:S,disabled:!w,loading:p,children:`Delete`}),w?r(u,{children:[`Selected `,g.length,` items`]}):null]}),n(l,{rowKey:`id`,columns:b,rowSelection:C,dataSource:o,loading:i||a,pagination:{current:e.pageNo,total:c,pageSize:e.limit,onChange:(e,n)=>{t({pageNo:e,limit:n})},position:[`bottomRight`,`topLeft`]}})]})}var S=x;export{S as default};