import{TableBody_default as e,TableRow_default as t,Table_default as n}from"./TableRow-BoHdNGcf.js";import{TableContainer_default as r}from"./TableContainer-B6Z3WurN.js";import{TableHead_default as i}from"./TableHead-CCKLMX1w.js";import{Button_default as a,CircularProgress_default as o,Fragment as s,PageTitle as c,Paper_default as l,TableCell_default as u,__toESM as d,fetchLookupTables as f,find_default as p,getLadleOverviewTable as m,get_default as h,isNil_default as g,jsx as _,jsxs as v,require_react as y,setLadleForModify as b,useAppDispatch as x,useAppSelector as S}from"./index-BlKb1bsp.js";import"./root-type.enum-C3eBp3GL.js";import"./component-qQWxZWwo.js";import{metricColors as C}from"./metric-colors.data-jhCujSX2.js";import"./change-ladle.modal-Bw85pNcZ.js";import"./location-selector-DWfRAf_s.js";import"./RootStateSelector-CJYSsZDz.js";import{RootSetStateModalComponent as w}from"./root-set-state-modal.component-CtJRIdV1.js";const T=[{componentTypeId:211,name:`Barrel`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:204,name:`Min`}]},{componentTypeId:227,name:`SlagLine`,metrics:[{metricTypeId:210,name:`Heats`},{metricTypeId:204,name:`Min`}]},{componentTypeId:216,name:`Coll Nozzle`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:220,name:`Plate`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:229,name:`Upper Nozzle`,metrics:[{metricTypeId:210,name:`Heats`}]},{componentTypeId:202,name:`Plug1`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:205,name:`Min`}]},{componentTypeId:203,name:`Plug1 Block`,metrics:[{metricTypeId:205,name:`Min`}]},{componentTypeId:205,name:`Plug2`,metrics:[{metricTypeId:203,name:`Heats`},{metricTypeId:205,name:`Min`}]},{componentTypeId:206,name:`Plug2 Block`,metrics:[{metricTypeId:205,name:`Min`}]}];var E=d(y());const D=({metricType:e,componentType:t,root:n})=>{let r=(0,E.useMemo)(()=>{var r;let i=(r=p(n.components,e=>e.componentTypeId===t.componentTypeId))?.metrics;return p(i,t=>t.metricTypeId===e.metricTypeId)},[n]);if(g(r))return _(u,{},`root-${n.rootId}-${t.name}-${e.name}`);let i=g(r?.value)?``:Math.round(r.value),a=r?.metricState==1?``:h(C,r?.metricState,`rgba(0,0,0,0)`);return _(u,{style:{backgroundColor:a,border:`1px solid #C0C0C0`,color:Number.isNaN(i)||i==0?`darkgray`:`black`},className:`text-center`,children:i===``?``:new Intl.NumberFormat().format(i)},`root-${n.rootId}-${t.name}-${e.name}`)},O=({root:e})=>{let t=e.supervisorInstructions?`Supervisor comments: ${e.supervisorInstructions}`:``,n=e.workerComments?`Operator comments: ${e.workerComments}`:``;return v(`div`,{className:`truncate`,title:`${t}\n\n${n}`,children:[e.supervisorInstructions??``,e.supervisorInstructions&&_(`br`,{}),e.workerComments??``]})},k=({root:e})=>{let n=x(),r=S(e=>e.common.lookupTables),i=h(r,`roots[${e.rootId}].rootName`,``),o=h(r,`locations[${e.locationId}].locationName`,``),s=h(e,`currentHeat.heatName`,``),c=h(r,`rootStates[${e.rootStateId}].rootStateName`,``),l=()=>{n(b(e))};return v(t,{hover:!0,children:[_(u,{children:i}),_(u,{children:o}),_(u,{children:s}),_(u,{children:c}),_(u,{children:_(a,{size:`small`,variant:`outlined`,color:`primary`,onClick:l,style:{whiteSpace:`nowrap`},children:`Set State`})}),_(u,{children:_(O,{root:e},`root-${e.rootId}-comments`)}),T.reduce((t,n)=>[...t,n.metrics.map(t=>_(D,{root:e,metricType:t,componentType:n},`root-${e.rootId}_metricType-${t.metricTypeId}_componentType-${n.componentTypeId}`))],[])]})},A=({isLoading:a})=>{let c=S(e=>e.ladleOverview.roots),d=S(e=>{var t;return(t=e.ladleOverview.ladleForModify)?.renderModal});return v(l,{style:{paddingLeft:`1rem`,paddingTop:`0.3rem`},children:[_(`h1`,{className:`ladle-overview-table__title`,children:`All Ladles`}),_(s,{children:a?_(`div`,{style:{display:`flex`,justifyContent:`center`,alignContent:`center`,padding:`18rem`},children:_(o,{})}):_(r,{children:v(n,{size:`small`,children:[v(i,{children:[v(t,{children:[_(u,{colSpan:6}),T.map(e=>_(u,{className:`text-center`,colSpan:e.metrics.length,children:e.name},`header-${e.name}`))]}),v(t,{children:[_(u,{children:`Ladle`}),_(u,{children:`Location`}),_(u,{children:`Heat`}),_(u,{children:`State/Comment`}),_(u,{}),_(u,{children:`Supervisor/Operator Comments`}),T.reduce((e,t)=>[...e,...Object.entries(t.metrics).map(([e,n])=>_(u,{style:{width:`4rem`},className:`text-center`,children:n.name},`header-${t.name}-${n.name}`))],[])]})]}),_(e,{children:Object.values(c).map(e=>_(k,{root:e},`root-${e.rootId.toString()}`))})]})})}),d&&_(w,{loadWithComponents:!0})]})},j=()=>{let[e,t]=(0,E.useState)(!1),n=x();function r(){t(!0),n(f()),n(m(!0)).then(()=>t(!1))}return(0,E.useEffect)(()=>r(),[]),v(`div`,{className:`container-fluid`,children:[_(c,{title:`Ladle Overview`}),_(A,{isLoading:e})]})};export{j as LadleOverviewComponent};
//# sourceMappingURL=ladle-overview-Bj49IQYG.js.map