import{j as e,T as i,cB as c,c as d,E as g,w as p,an as u,ao as x,av as f,aH as h,x as j,k as D,cc as y,cJ as b,r as m,B as S,ar as v,a5 as w,cK as F}from"./main-TIUJvpaR.js";import{I as C}from"./Info-DCV6yur1.js";import{D as T}from"./paginated-resources-KKWqbuJW.js";import{u as E,a as L,G as P,D as I,b as B,c as k}from"./use-datatable-query-GunfT5m0.js";import{D as M}from"./data-table-add-item-button-rLvL8LGv.js";import{a as Q,b as z,c as H}from"./datatable-page-with-header-layout-Bbr3vl7W.js";import{T as q}from"./table-Bwvbdqc8.js";import{S as A}from"./select-T49HzTXy.js";import{F as N}from"./formatted-bytes-Z5HHbbV8.js";import{D as R}from"./Download-osF2RugY.js";import{C as K}from"./confirmation-dialog-Ds1Wl8FN.js";import{S as W}from"./skeleton-uSF3jNnm.js";import"./FilterAlt-TOiEFGZR.js";import"./select-filter-panel-Bmcw5umN.js";import"./use-normalized-models-DEvVtvvO.js";import"./form-chip-field-ebQy8_UE.js";import"./input-C85ULg8F.js";import"./ArrowRightAlt-CPRMvsTm.js";import"./DateRange-LhM59-62.js";import"./use-base-date-picker-state-DYQU3Rut.js";import"./use-date-formatter-hhGEq_P-.js";import"./KeyboardArrowRight-C0U0wgwT.js";import"./use-date-range-picker-state-Df5vuAtM.js";import"./list-DlNGU0yW.js";import"./switch-Bj7wwiPq.js";import"./formatted-date-CsxGDhkC.js";import"./dialog-footer-yCpPZGPO.js";import"./use-current-date-time-BdzpdEnL.js";import"./Edit-_sVfUVPu.js";import"./accordion-CabB8onw.js";import"./checkbox-kZVscZNC.js";import"./CheckBoxOutlineBlank-p6gxL9Ym.js";import"./Add-CRE_6SK0.js";import"./dashboard-layout-context-DA6Q35rI.js";import"./use-toggle-dashboard-left-sidebar-BuzWlDo2.js";import"./ArrowDownward-B1kd_Dtq.js";import"./useEffectEvent-Bgk8rSJ3.js";import"./use-pointer-events-B6G-2ez3.js";import"./useGlobalListeners-_BzTaAbJ.js";import"./pretty-bytes-bO14ePu9.js";const G=""+new URL("bug-fixing-BghMoLQY.svg",import.meta.url).href,V=[{key:"message",visibleInMode:"all",width:"flex-3 min-w-200",header:()=>e.jsx(i,{message:"Message"}),body:t=>t.message},{key:"datetime",header:()=>e.jsx(i,{message:"Date"}),body:t=>e.jsx(c,{date:t.datetime})},{key:"severity",header:()=>e.jsx(i,{message:"Severity"}),body:t=>e.jsxs("span",{className:d("flex items-center gap-6 text-xs capitalize",t.level==="error"?"text-danger":"text-primary"),children:[t.level==="error"?e.jsx(g,{size:"sm"}):e.jsx(C,{size:"sm"}),t.level]})}];function $(){const{trans:t}=p();return u({mutationFn:r=>J(r),onSuccess:async()=>{await f.invalidateQueries({queryKey:T("logs/error")}),h(t(j("Log file deleted")))},onError:r=>x(r)})}function J({identifier:t}){return D.delete(`logs/error/${t}`).then(r=>r.data)}function He(){const{searchParams:t,sortDescriptor:r,mergeIntoSearchParams:o,setSearchQuery:a,isFiltering:l}=E(b),n=L({...y.logs.error(t)});return e.jsxs(Q,{children:[e.jsx(P,{query:n}),e.jsxs(z,{children:[e.jsx(I,{searchValue:t.query,onSearchChange:a,actions:e.jsx(O,{data:n.data,onParamsChange:o})}),e.jsxs(H,{children:[e.jsx(q,{columns:V,data:n.items,sortDescriptor:r,onSortChange:o,enableSelection:!1}),n.isEmpty&&e.jsx(B,{isFiltering:l,image:G,title:e.jsx(i,{message:"No errors have been logged yet"}),filteringTitle:e.jsx(i,{message:"No matching error log entries"})}),e.jsx(k,{query:n,onPageChange:s=>o({page:s}),onPerPageChange:s=>o({perPage:s})})]})]})]})}function O({data:t,onParamsChange:r}){var n;const o=m.useRef(!1),[a,l]=m.useState(null);return m.useEffect(()=>{if(t.files.length&&!o.current){o.current=!0;const s=t.files[0].identifier;l(s),s!==t.selectedFile&&r({file:s})}},[t,r,o]),e.jsxs(m.Fragment,{children:[e.jsx(U,{files:t.files??null,selectedFile:a,onSelected:s=>{l(s.identifier),r({file:s.identifier})}}),e.jsx(S,{variant:"outline",color:"danger",disabled:!a,onClick:()=>v(Y,{identifier:a}),children:e.jsx(i,{message:"Delete"})}),a&&e.jsx(M,{elementType:"a",download:(n=t.files.find(s=>s.identifier===a))==null?void 0:n.name,href:`api/v1/logs/error/${a}/download`,icon:e.jsx(R,{}),children:e.jsx(i,{message:"Download log"})})]})}function U({files:t,selectedFile:r,onSelected:o}){return t?t.length?e.jsx(A,{appearance:"dropdown",selectionMode:"single",selectedValue:r,size:"sm",minWidth:"min-w-[210px]",children:t==null?void 0:t.map(a=>e.jsxs(w,{value:a.identifier,onSelected:()=>o(a),children:[a.name," (",e.jsx(N,{bytes:a.size}),")"]},a.identifier))}):null:e.jsx(W,{variant:"rect",className:"max-w-[210px]"})}function Y({identifier:t}){const r=$();return e.jsx(K,{title:e.jsx(i,{message:"Delete log file"}),body:e.jsx(i,{message:"Are you sure you want to delete this log file?"}),confirm:e.jsx(i,{message:"Delete"}),onConfirm:()=>r.mutate({identifier:t},{onSuccess:()=>F()}),isLoading:r.isPending,isDanger:!0})}export{He as Component};
