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,Ot as u,_t as d,pt as f,tt as p,w as m,wt as h,yt as g}from"./index-KVuxnkWj.js";import{t as _}from"./CollectionActions-CDxOJIb6.js";import{t as v}from"./TableShimmer-f7Cf4NTV.js";import{n as y,t as b}from"./useSettingsStyles-X3caKosH.js";var x=e(t(),1),S=n(),C=()=>{let{classes:e}=b(),t=g(),[n,C]=(0,x.useReducer)(e=>e+1,0),[w,T]=(0,x.useState)([]),[E,D]=(0,x.useState)(``),[O,k]=(0,x.useState)(!0),A=(0,x.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});E&&n.append(`keyword`,E);let r=await(await m(`/api/notifications?${n.toString()}`,{signal:t})).json();T(t=>e?[...t,...r]:r),k(r.length>=50)},[E]),j=d(()=>A(w.length));f(async({signal:e})=>{T([]),await A(0,e)},[n,A]);let M=(e,n)=>n?n.split(/[, ]+/).filter(Boolean).map(n=>t(p(e,n))).join(`, `):``;return(0,S.jsxs)(r,{menu:(0,S.jsx)(y,{}),breadcrumbs:[`settingsTitle`,`sharedNotifications`],children:[(0,S.jsx)(a,{keyword:E,setKeyword:D}),(0,S.jsxs)(s,{className:e.table,children:[(0,S.jsx)(o,{children:(0,S.jsxs)(h,{children:[(0,S.jsx)(c,{children:t(`sharedDescription`)}),(0,S.jsx)(c,{children:t(`notificationType`)}),(0,S.jsx)(c,{children:t(`notificationAlways`)}),(0,S.jsx)(c,{children:t(`sharedAlarms`)}),(0,S.jsx)(c,{children:t(`notificationNotificators`)}),(0,S.jsx)(c,{className:e.columnAction})]})}),(0,S.jsxs)(u,{children:[w.map(n=>(0,S.jsxs)(h,{children:[(0,S.jsx)(c,{children:n.description}),(0,S.jsx)(c,{children:t(p(`event`,n.type))}),(0,S.jsx)(c,{children:l(n.always,t)}),(0,S.jsx)(c,{children:M(`alarm`,n.attributes.alarms)}),(0,S.jsx)(c,{children:M(`notificator`,n.notificators)}),(0,S.jsx)(c,{className:e.columnAction,padding:`none`,children:(0,S.jsx)(_,{itemId:n.id,editPath:`/settings/notification`,endpoint:`notifications`,onReload:C})})]},n.id)),O&&(0,S.jsx)(v,{ref:w.length>0?j:null,columns:5,endAction:!0})]})]}),(0,S.jsx)(i,{editPath:`/settings/notification`})]})};export{C as default};