import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,t as n,wt as r,zt as i}from"./mui-B6lh3XSP.js";import{t as a}from"./IconButton-BEBOUWhl.js";import{n as o}from"./MenuItem-HQNtf0LG.js";import{t as s}from"./TableHead-_KJlbpnj.js";import{At as c,Dt as l,Ot as u,p as d,pt as f,u as p,w as m,wt as h,yt as g}from"./index-KVuxnkWj.js";import{t as _}from"./ReportsMenu-XWwKkI0p.js";import{t as v}from"./TableShimmer-f7Cf4NTV.js";var y=e(t(),1),b=r(),x=n()(e=>({columnAction:{width:`1%`,paddingRight:e.spacing(1)}})),S=()=>{let{classes:e}=x(),t=g(),n=i(e=>e.calendars.items),[r,S]=(0,y.useReducer)(e=>e+1,0),[C,w]=(0,y.useState)([]),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)();f(async({signal:e})=>{E(!0);try{w(await(await m(`/api/reports`,{signal:e})).json())}finally{E(!1)}},[r]);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)(c,{children:[(0,b.jsx)(s,{children:(0,b.jsxs)(h,{children:[(0,b.jsx)(l,{children:t(`sharedType`)}),(0,b.jsx)(l,{children:t(`sharedDescription`)}),(0,b.jsx)(l,{children:t(`sharedCalendar`)}),(0,b.jsx)(l,{className:e.columnAction})]})}),(0,b.jsx)(u,{children:T?(0,b.jsx)(v,{columns:4,endAction:!0}):C.map(t=>(0,b.jsxs)(h,{children:[(0,b.jsx)(l,{children:k(t.type)}),(0,b.jsx)(l,{children:t.description}),(0,b.jsx)(l,{children:n[t.calendarId].name}),(0,b.jsx)(l,{className:e.columnAction,padding:`none`,children:(0,b.jsx)(a,{size:`small`,onClick:()=>O(t.id),children:(0,b.jsx)(d,{fontSize:`small`})})})]},t.id))})]}),(0,b.jsx)(p,{style:{transform:`none`},open:!!D,endpoint:`reports`,itemId:D,onResult:e=>{O(null),e&&S()}})]})};export{S as default};