import{j as e,S as i,h as a,s as I,H as x,a6 as R,a2 as g}from"./vendor-ClLR6ncd.js";import{d as _}from"./Add-CLrXAvOx.js";import{d as $}from"./Edit-Bg-98YAB.js";import{d as B}from"./Delete-BD9BsoWc.js";import{d as b}from"./Check-zAjPzJBD.js";import{h as N,i as W,f as O,L as v}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{R as Q}from"./RefreshDataButton-BMv_Vwgi.js";import{E as z}from"./Messages-BRmQDxrZ.js";import{C as E}from"./CreateDialogContext-Buan56-U.js";import{D as M}from"./index-DY-IkI-n.js";import{D as c}from"./ui-DEn7LX9m.js";import{L as G}from"./index-CENwCLvw.js";import{u as w,a as y,t as H,w as J}from"./configs-CU7rYFSb.js";import{C as U}from"./Card-DCyqxUVE.js";import{C}from"./CardContent-B36bxiGw.js";import{C as K}from"./Chip-DoCs8Smb.js";import{C as V}from"./CardActions-DbEyUhB8.js";import"./DialogContent-DR8Wx7Lo.js";import"./DialogTitle-i0lt2jWQ.js";import"./WarningMessage-4TK5GdCH.js";import"./Warning-DsmyDRzF.js";import"./Box-Co2WcNPC.js";import"./Link-BLwKPJFF.js";const{useDialogContext:p,DialogContextProvider:X}=E();function Y(t){return(J.find(r=>r.value===t)||{label:t}).label}function Z(t){return(H.find(r=>r.value===t)||{label:t}).label}function q({mutation:t}){const r=p();return e.jsx(M,{...r,dialogTitle:"Delete index",dialogBodyMessage:`Do you want to delete index ${r.openParameter} permanently?`,submitTitle:"Delete",onSubmit:t.mutate})}function o({label:t,value:r}){return e.jsxs(i,{direction:"row",gap:1,flexWrap:"wrap",alignItems:"center",children:[e.jsxs(a,{fontWeight:"bold",children:[t,":"]}),typeof r=="string"?e.jsx(a,{children:r}):r]})}function d({label:t,values:r}){return e.jsx(o,{label:`Apply indexing to ${t}`,value:r.length===0?"All":e.jsx(a,{sx:{wordBreak:"break-all"},children:r.join(", ")})})}function ee({name:t,showLoader:r,predicates:s,indexLiterals:n,indexResources:l,indexFields:m,minimumWordSize:D,stopWords:u,wordFilters:j,tokenizer:T,innerChars:F,borderChars:P,types:S,graphs:L}){const{open:k,openParameter:A}=p(),f=!!A;return e.jsxs(U,{sx:{width:450},children:[e.jsx(R,{title:t}),r?e.jsx(C,{children:e.jsx(v,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(C,{sx:{pt:0,pb:0,display:"flex",flexDirection:"column",gap:1},children:[e.jsx(o,{label:"SPOG fields indexed",value:m.length===0?"None":m.join(", ")}),e.jsx(d,{label:"predicates",values:s}),e.jsx(o,{label:"Apply indexing to literals",value:Array.isArray(n)?n.join(", "):n?e.jsx(b,{}):e.jsx(g,{})}),e.jsx(o,{label:"Apply indexing to resources",value:e.jsxs(i,{direction:"row",spacing:1,alignItems:"center",children:[l?e.jsx(b,{}):e.jsx(g,{}),l==="short"?e.jsx(a,{color:"text.secondary",children:"(only the last part)"}):null]})}),e.jsx(d,{label:"graphs",values:L}),e.jsx(d,{label:"RDF types",values:S}),e.jsx(o,{label:"Tokenizer",value:Z(T)}),e.jsx(o,{label:"Minimum word size",value:D.toString()}),e.jsx(o,{label:"Stop words",value:u.length===0?"None":u.map(h=>e.jsx(K,{label:h},h))}),e.jsx(o,{label:"Word filters",value:j.length===0?"None":j.map(Y).join(", ")}),e.jsx(o,{label:"Inner characters",value:F.join(", ")||"None"}),e.jsx(o,{label:"Border characters",value:P.join(", ")||"None"})]}),e.jsxs(V,{disableSpacing:!0,children:[e.jsx(c,{Component:x,componentProps:{disabled:f,component:I,to:`./edit/${encodeURI(t)}`,relative:"path",startIcon:e.jsx($,{})},children:"edit"}),e.jsx(c,{Component:x,componentProps:{disabled:f,color:"error",startIcon:e.jsx(B,{}),onClick:()=>{k(t)}},children:"delete"})]})]})]})}function te(){const{indexesListQuery:t,indexesListInfoQueries:r}=w();return t.isSuccess?t.data.length===0?e.jsx(a,{children:"No freetext indexes defined yet"}):e.jsx(i,{direction:"row",gap:2,flexWrap:"wrap",children:r.map((s,n)=>e.jsx(ee,{name:t.data[n],showLoader:!s.isSuccess,...s.data},t.data[n]))}):e.jsx(v,{})}function re(){const t=p(),r=y();return N((s,n)=>W({url:O(n,"freetext/indices",t.openParameter),method:"delete"}),{onSettled:()=>{t.resetOpenParameter()},onSuccess:(s,n)=>r({resetIndexesList:!0,removeIndex:n})})}function ne(){const t=re(),{indexesListQuery:r,indexesListInfoQueries:s}=w(),n=y();return e.jsxs(i,{spacing:2,sx:{flexGrow:1},children:[e.jsx(q,{mutation:t}),e.jsxs(i,{direction:"row",justifyContent:"space-between",children:[e.jsx(a,{variant:"h4",children:"Freetext Indexes"}),e.jsxs(i,{direction:"row",spacing:2,children:[e.jsx(Q,{disabled:r.isFetching||s.some(l=>l.isFetching)||t.isLoading,onClick:()=>n({resetIndexesList:!0})}),e.jsx(c,{Component:x,componentProps:{variant:"contained",sx:{alignSelf:"flex-start"},component:I,to:"./new",relative:"path",startIcon:e.jsx(_,{})},children:"Add new index"})]})]}),e.jsx(G,{}),e.jsx(z,{error:t.error,resetError:t.reset}),e.jsx(te,{})]})}function Pe(){return e.jsx(X,{children:e.jsx(ne,{})})}export{Pe as default};
