import{j as e,S as n,h as a,H as f}from"./vendor-ClLR6ncd.js";import{d as h}from"./PlayArrow-C5BebwRO.js";import{d as x}from"./Stop-D8ZTRatE.js";import{H as y}from"./ui-DKQGUVKw.js";import{o as g,h as j,i as u,f as c,j as m,aw as S,ar as v,L as z}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{E as d}from"./Messages-BRmQDxrZ.js";import{R as w}from"./RefreshDataButton-BMv_Vwgi.js";import{D as Q}from"./ui-DEn7LX9m.js";import"./AccordionDetails-Bqc4B-Ut.js";import"./WarningMessage-4TK5GdCH.js";import"./Warning-DsmyDRzF.js";import"./Box-Co2WcNPC.js";import"./Link-BLwKPJFF.js";function p(){return m(["autoOptimizer","status"],t=>u({url:c(t,"auto/optimize/status")}))}function o(t){return t.isSuccess&&t.data==="stopped"}function l(){const t=S();return()=>{v.invalidateQueries([...t,"autoOptimizer"])}}function b(){const t=p(),r=l();return j((s,i)=>u({url:c(i,"auto/optimize",o(t)?"start":"stop"),headers:{Accept:"*/*"},method:"put"}),{onSettled:r})}function C({disabled:t,changeStatusMutation:r,style:s}){const i=p();return e.jsx(f,{style:s,disabled:t||i.isFetching||i.isError||r.isLoading,color:o(i)?void 0:"error",variant:"contained",startIcon:i.isSuccess?o(i)?e.jsx(h,{}):e.jsx(x,{}):null,onClick:r.mutate,children:i.isSuccess?o(i)?"Run":"Stop":i.isError?"Can't run":""})}function A(){const t=m(["autoOptimizer","message"],async r=>(await u({url:c(r,"auto/optimize/message")})).trim());return t.isLoading?e.jsx(z,{}):t.isError?e.jsx(d,{error:t.error}):e.jsx(a,{whiteSpace:"pre-wrap",children:t.data})}function K(){const t=b(),r=p(),s=l();return e.jsxs(n,{spacing:g(),sx:{flexGrow:1},children:[e.jsxs(n,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h4",children:"Automatic Optimizer"}),e.jsxs(n,{direction:"row",spacing:2,children:[e.jsx(w,{disabled:r.isFetching||t.isLoading,onClick:s}),e.jsx(Q,{Component:C,componentProps:{changeStatusMutation:t}})]})]}),e.jsx(a,{variant:"subtitle2",color:"text.secondary",children:"The automatic optimizer tool if active works continuously in the background optimizing idle indices."}),e.jsx(d,{error:t.error,resetError:t.reset}),e.jsx(A,{}),e.jsx(y,{title:"About Automatic Optimizer output",helpText:`The message shows the state of each index in the repository. The format
        is 'index oscore (deleted%) activity'. The deleted% is an estimate of
        the number of deleted triples still in in index. 'activity' tells of any
        current activity on the index. 'i' is most common meaning 'idle', that
        is, no activity. '2' means a level 2 optimization being done. 'p' is a
        purge of deleted triples.`})]})}export{K as default};
