import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,vt as n}from"./mui-BgU4WrXF.js";import{n as r}from"./MenuItem-BNgF7Xqv.js";import{n as i,t as a}from"./SearchHeader-CjrB_H_O.js";import{t as o}from"./TableHead-DZPVxfXH.js";import{A as s,St as c,Y as l,dt as u,pt as d,st as f,vt as p,w as m,wt as h,xt as g,z as _}from"./index-bel1r0Sr.js";import{t as v}from"./CollectionActions-Be6ZPRyC.js";import{t as y}from"./TableShimmer-CBuxG-nx.js";import{n as b,t as x}from"./useSettingsStyles-Bugi6oTj.js";var S=e(t(),1),C=n(),w=()=>{let{classes:e}=x(),t=d(),[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=s(`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 m(`/api/commands?${n.toString()}`,{signal:t})).json();E(t=>e?[...t,...r]:r),A(r.length>=50)},[D]),N=u(()=>M(T.length));return f(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)(h,{className:e.table,children:[(0,C.jsx)(o,{children:(0,C.jsxs)(p,{children:[(0,C.jsx)(g,{children:t(`sharedDescription`)}),(0,C.jsx)(g,{children:t(`sharedType`)}),(0,C.jsx)(g,{children:t(`commandSendSms`)}),!j&&(0,C.jsx)(g,{className:e.columnAction})]})}),(0,C.jsxs)(c,{children:[T.map(n=>(0,C.jsxs)(p,{children:[(0,C.jsx)(g,{children:n.description}),(0,C.jsx)(g,{children:t(l(`command`,n.type))}),(0,C.jsx)(g,{children:_(n.textChannel,t)}),!j&&(0,C.jsx)(g,{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};