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