import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,wt as n}from"./mui-B6lh3XSP.js";import{n as r}from"./MenuItem-HQNtf0LG.js";import{n as i,t as a}from"./SearchHeader-CmohWzoP.js";import{t as o}from"./TableHead-_KJlbpnj.js";import{At as s,Dt as c,G as l,O as u,Ot as d,_t as f,pt as p,tt as m,w as h,wt as g,yt as _}from"./index-KVuxnkWj.js";import{t as v}from"./CollectionActions-CDxOJIb6.js";import{t as y}from"./TableShimmer-f7Cf4NTV.js";import{n as b,t as x}from"./useSettingsStyles-X3caKosH.js";var S=e(t(),1),C=n(),w=()=>{let{classes:e}=x(),t=_(),[n,w]=(0,S.useReducer)(e=>e+1,0),[T,E]=(0,S.useState)([]),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(!0),j=u(`limitCommands`),M=(0,S.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});D&&n.append(`keyword`,D);let r=await(await h(`/api/commands?${n.toString()}`,{signal:t})).json();E(t=>e?[...t,...r]:r),A(r.length>=50)},[D]),N=f(()=>M(T.length));return p(async({signal:e})=>{E([]),await M(0,e)},[n,M]),(0,C.jsxs)(r,{menu:(0,C.jsx)(b,{}),breadcrumbs:[`settingsTitle`,`sharedSavedCommands`],children:[(0,C.jsx)(a,{keyword:D,setKeyword:O}),(0,C.jsxs)(s,{className:e.table,children:[(0,C.jsx)(o,{children:(0,C.jsxs)(g,{children:[(0,C.jsx)(c,{children:t(`sharedDescription`)}),(0,C.jsx)(c,{children:t(`sharedType`)}),(0,C.jsx)(c,{children:t(`commandSendSms`)}),!j&&(0,C.jsx)(c,{className:e.columnAction})]})}),(0,C.jsxs)(d,{children:[T.map(n=>(0,C.jsxs)(g,{children:[(0,C.jsx)(c,{children:n.description}),(0,C.jsx)(c,{children:t(m(`command`,n.type))}),(0,C.jsx)(c,{children:l(n.textChannel,t)}),!j&&(0,C.jsx)(c,{className:e.columnAction,padding:`none`,children:(0,C.jsx)(v,{itemId:n.id,editPath:`/settings/command`,endpoint:`commands`,onReload:w})})]},n.id)),k&&(0,C.jsx)(y,{ref:T.length>0?N:null,columns:j?3:4,endAction:!0})]})]}),(0,C.jsx)(i,{editPath:`/settings/command`,disabled:j})]})};export{w as default};