import{TableBody_default as e,TableRow_default as t,Table_default as n}from"./TableRow-zQ6IbNgB.js";import{TableContainer_default as r}from"./TableContainer-DLP0G0fV.js";import{Box_default as i,ButtonWithLoading$1 as a,Card_default as o,DatePicker as s,Grid_default as c,MenuItem_default as l,Paper_default as u,TableCell_default as d,TextField_default as f,TimeService as p,Typography_default as m,__toESM as h,getMomentTz as g,get_default as _,jsx as v,jsxs as y,makeStyles_default as b,require_main as x,require_react as S}from"./index-BSpgqPAY.js";import{tundishesRepository as C}from"./tundishes.repository-hmZi9tX_.js";/* empty css                              */var w=h(x()),T=h(S());const E=g(),D=b(()=>({table:{"--ag-font-size":11,"& .ag-cell-label-container":{height:`2rem`}}})),O=()=>{let h=D(),[g,b]=(0,T.useState)([]),[x,S]=(0,T.useState)(E().startOf(`month`).toDate()),[O,k]=(0,T.useState)(E().toDate()),[A,j]=(0,T.useState)(`thisMonth`),[M,N]=(0,T.useState)(!1),P=e=>{let t,n;switch(e){case`thisWeek`:t=E().startOf(`week`),n=E();break;case`thisMonth`:t=E().startOf(`month`),n=E();break;case`q1`:t=E().month(0).startOf(`quarter`),n=E().month(0).endOf(`quarter`);break;case`q2`:t=E().month(3).startOf(`quarter`),n=E().month(3).endOf(`quarter`);break;case`q3`:t=E().month(6).startOf(`quarter`),n=E().month(6).endOf(`quarter`);break;case`q4`:t=E().month(9).startOf(`quarter`),n=E().month(9).endOf(`quarter`);break;case`thisYear`:t=E().startOf(`year`),n=E();break;default:t=E().startOf(`month`),n=E()}S(t.toDate()),k(n.toDate())},F=e=>{j(e),P(e)},I=async()=>{N(!0);let e=await C.getTundishTrackReport({start:x.toISOString(),end:O.toISOString()});if(e.ok){let t=_(e.data,`tables[0].rows`,[]);b(t)}N(!1)};return v(i,{m:2,children:v(u,{elevation:3,children:v(i,{p:2,children:y(c,{container:!0,spacing:1,children:[v(c,{item:!0,xs:12,children:v(m,{variant:`h6`,children:`Tundish Track Report`})}),y(c,{item:!0,xs:12,container:!0,spacing:3,alignItems:`center`,children:[v(c,{item:!0,style:{minWidth:`300px`},children:y(f,{select:!0,variant:`outlined`,label:`Quick Select`,"aria-label":`Quick Select`,fullWidth:!0,value:A,onChange:e=>F(e.target.value),children:[v(l,{value:`thisWeek`,children:`This Week`}),v(l,{value:`thisMonth`,children:`This Month`}),v(l,{value:`q1`,children:`Q1`}),v(l,{value:`q2`,children:`Q2`}),v(l,{value:`q3`,children:`Q3`}),v(l,{value:`q4`,children:`Q4`}),v(l,{value:`thisYear`,children:`This Year`})]})}),v(c,{item:!0,children:v(s,{value:E(x),onChange:(e,t)=>{e&&(S(e.toDate()),j(`custom`))},timezone:p.getInstance().getServerTimeZone(),label:`Start Date`})}),v(c,{item:!0,children:v(s,{value:E(O),onChange:(e,t)=>{e&&(k(e.toDate()),j(`custom`))},timezone:p.getInstance().getServerTimeZone(),label:`End Date`})}),v(c,{item:!0,children:v(a,{color:`primary`,variant:`contained`,fullWidth:!0,onClick:I,isLoading:M,children:`Search`})})]}),v(c,{item:!0,xs:12,container:!0,children:v(c,{item:!0,style:{height:`50vh`,width:`100%`},className:`ag-theme-material ${h.table}`,children:v(w.AgGridReact,{rowSelection:`single`,getRowId:e=>e.data.RootName,rowData:g,defaultColDef:{sortable:!0,resizable:!0},gridOptions:{rowHeight:25,rowStyle:{fontSize:12}},columnDefs:[{flex:1,field:`RootName`,headerName:`Tundish`},{flex:1,field:`PermanentLiningHeats`},{flex:1,field:`RemainingLife`,valueFormatter:e=>`${(e.value*100).toFixed(2)}%`,cellStyle:e=>{let t=(e.value+1)/2,n=Math.round(255*(1-t)),r=Math.round(255*t),i=Math.abs(e.value);return{backgroundColor:`rgba(${n}, ${r}, 0, ${i*.6})`,color:`#333`,textAlign:`center`}}},{flex:1,field:`HeatsCast`,headerName:`Heats Casted for Period`},{flex:1,field:`Builds`,headerName:`Builds for Period`}]})})}),v(c,{item:!0,xs:12,children:v(o,{style:{maxWidth:`400px`},children:v(r,{children:v(n,{size:`small`,children:y(e,{children:[y(t,{children:[v(d,{children:`Fleet Avg:`}),v(d,{children:(g.reduce((e,t)=>e+t.PermanentLiningHeats,0)/g.length).toFixed(2)})]}),y(t,{children:[v(d,{children:`Heats of Period:`}),v(d,{children:g.reduce((e,t)=>e+t.HeatsCast,0)})]}),y(t,{children:[v(d,{children:`Builds of Period:`}),v(d,{children:g.reduce((e,t)=>e+t.Builds,0)})]}),y(t,{children:[v(d,{children:`Average Heats per Build Of Period`}),v(d,{children:(g.reduce((e,t)=>e+t.HeatsCast,0)/g.reduce((e,t)=>e+t.Builds,0)).toFixed(2)})]})]})})})})})]})})})})};export{O as TundishTrackReports};
//# sourceMappingURL=reports-Ctiq0IMs.js.map