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{St as s,dt as c,pt as l,st as u,vt as d,w as f,wt as p,xt as m}from"./index-bel1r0Sr.js";import{t as h}from"./CollectionActions-Be6ZPRyC.js";import{t as g}from"./TableShimmer-CBuxG-nx.js";import{n as _,t as v}from"./useSettingsStyles-Bugi6oTj.js";var y=e(t(),1),b=n(),x=()=>{let{classes:e}=v(),t=l(),[n,x]=(0,y.useReducer)(e=>e+1,0),[S,C]=(0,y.useState)([]),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(!0),O=(0,y.useCallback)(async(e,t)=>{let n=new URLSearchParams({limit:50,offset:e});w&&n.append(`keyword`,w);let r=await(await f(`/api/calendars?${n.toString()}`,{signal:t})).json();C(t=>e?[...t,...r]:r),D(r.length>=50)},[w]),k=c(()=>O(S.length));return u(async({signal:e})=>{C([]),await O(0,e)},[n,O]),(0,b.jsxs)(r,{menu:(0,b.jsx)(_,{}),breadcrumbs:[`settingsTitle`,`sharedCalendars`],children:[(0,b.jsx)(a,{keyword:w,setKeyword:T}),(0,b.jsxs)(p,{className:e.table,children:[(0,b.jsx)(o,{children:(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{children:t(`sharedName`)}),(0,b.jsx)(m,{className:e.columnAction})]})}),(0,b.jsxs)(s,{children:[S.map(t=>(0,b.jsxs)(d,{children:[(0,b.jsx)(m,{children:t.name}),(0,b.jsx)(m,{className:e.columnAction,padding:`none`,children:(0,b.jsx)(h,{itemId:t.id,editPath:`/settings/calendar`,endpoint:`calendars`,onReload:x})})]},t.id)),E&&(0,b.jsx)(g,{ref:S.length>0?k:null,columns:2,endAction:!0})]})]}),(0,b.jsx)(i,{editPath:`/settings/calendar`})]})};export{x as default};