import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,Nt as n,t as r,vt as i}from"./mui-BgU4WrXF.js";import{t as a}from"./IconButton-oialqkv3.js";import{n as o}from"./MenuItem-BNgF7Xqv.js";import{t as s}from"./TableHead-DZPVxfXH.js";import{St as c,p as l,pt as u,st as d,u as f,vt as p,w as m,wt as h,xt as g}from"./index-bel1r0Sr.js";import{t as _}from"./ReportsMenu-CwjT__h7.js";import{t as v}from"./TableShimmer-CBuxG-nx.js";var y=e(t(),1),b=i(),x=r()(e=>({columnAction:{width:`1%`,paddingRight:e.spacing(1)}})),S=()=>{let{classes:e}=x(),t=u(),r=n(e=>e.calendars.items),[i,S]=(0,y.useReducer)(e=>e+1,0),[C,w]=(0,y.useState)([]),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)();d(async({signal:e})=>{E(!0);try{w(await(await m(`/api/reports`,{signal:e})).json())}finally{E(!1)}},[i]);let k=e=>{switch(e){case`events`:return t(`reportEvents`);case`route`:return t(`reportPositions`);case`summary`:return t(`reportSummary`);case`trips`:return t(`reportTrips`);case`stops`:return t(`reportStops`);default:return e}};return(0,b.jsxs)(o,{menu:(0,b.jsx)(_,{}),breadcrumbs:[`reportTitle`,`reportScheduled`],children:[(0,b.jsxs)(h,{children:[(0,b.jsx)(s,{children:(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:t(`sharedType`)}),(0,b.jsx)(g,{children:t(`sharedDescription`)}),(0,b.jsx)(g,{children:t(`sharedCalendar`)}),(0,b.jsx)(g,{className:e.columnAction})]})}),(0,b.jsx)(c,{children:T?(0,b.jsx)(v,{columns:4,endAction:!0}):C.map(t=>(0,b.jsxs)(p,{children:[(0,b.jsx)(g,{children:k(t.type)}),(0,b.jsx)(g,{children:t.description}),(0,b.jsx)(g,{children:r[t.calendarId].name}),(0,b.jsx)(g,{className:e.columnAction,padding:`none`,children:(0,b.jsx)(a,{size:`small`,onClick:()=>O(t.id),children:(0,b.jsx)(l,{fontSize:`small`})})})]},t.id))})]}),(0,b.jsx)(f,{style:{transform:`none`},open:!!D,endpoint:`reports`,itemId:D,onResult:e=>{O(null),e&&S()}})]})};export{S as default};