PageSourceSearch

https://trial.deepedge.ai/static/js/8547.c902aee0.chunk.js

js deepedge.ai collected 2026-10-05 11:57:15 UTC 27,684 bytes, 2 lines download raw bytes

1"use strict";(globalThis.webpackChunkdeepedge_platform||=[]).push([[8547],{38547(e,t,i){i.r(t),i.d(t,{default:()=>T});var n=i(65043),a=i(83625),o=i(24056),s=i(7353),r=i(94496),l=i(35721),d=i(71322),c=i(12110),u=i(26494),p=i(79650),h=i(61596),x=i(71806),g=i(84882),m=i(28076),v=i(10039),f=i(73460),y=i(55200),A=i(56908),b=i(70579);const j=e=>{const{xAxis:t,series:i,width:n,height:a,barLabel:o,borderRadius:r,tooltip:l,innerRadius:d,barGap:c,barCategoryGap:u,color:p}=e;return(0,b.jsx)(s.A,{sx:{height:a,width:n},children:(0,b.jsx)(A.E,{xAxis:t,series:i,width:n,height:a,barLabel:o,borderRadius:r,tooltip:l,innerRadius:d,barGap:c,barCategoryGap:u,sx:{"& .MuiChartsAxis-root text":{fill:"var(--type-meta) !important"},"& .MuiChartsAxis-tickLabel":{fill:"var(--type-meta) !important"},"& .MuiChartsAxis-line":{stroke:"var(--glass-color) !important"},"& .MuiChartsGrid-line":{stroke:"var(--glass-color) !important"},"& .MuiChartsBar-label":{fill:"var(--type-primary) !important"}}})})};var _=i(10611),w=i(3438),S=i(73216);const C=e=>{const{title:t,progress:i,progressValue:n,unitName:a,description:o,defects:l,operationalEfficiency:d,listView:p,plant_id:h,factory_id:x}=e,g=(0,S.Zp)(),f=e=>{e.stopPropagation(),h&&g((e=>`/vi-dashboard/${encodeURIComponent(e||"plant")}/product`)(a),{state:{plant_id:h,title:a,factory_id:x,solution_id:localStorage.getItem("solutionId")||void 0,solutionName:localStorage.getItem("solutionName")||void 0}})};return p?(0,b.jsxs)(m.A,{hover:!0,sx:{"&:last-child td":{borderBottom:0},"&:hover":{backgroundColor:"rgba(255, 255, 255, 0.03)"}},children:[(0,b.jsx)(v.A,{sx:{color:"var(--type-primary)",fontWeight:600},children:a}),(0,b.jsxs)(v.A,{sx:{color:"var(--type-primary)",minWidth:180},children:[(0,b.jsxs)(s.A,{sx:{display:"flex",alignItems:"center",gap:1.5},children:[(0,b.jsx)(_.A,{variant:"determinate",value:i,sx:{flex:1,minWidth:80,height:8,borderRadius:1,backgroundColor:"var(--glass-color)","& .MuiLinearProgress-bar":{backgroundColor:"var(--leading-color)"}}}),(0,b.jsxs)(r.A,{variant:"body2",sx:{color:"var(--type-primary)",minWidth:36,textAlign:"right"},children:[n,"%"]})]}),(0,b.jsx)(r.A,{variant:"caption",sx:{color:"var(--type-meta)",display:"block",mt:.75},children:l})]}),(0,b.jsx)(v.A,{sx:{color:"var(--type-primary)"},children:d}),(0,b.jsx)(v.A,{align:"right",sx:{whiteSpace:"nowrap"},children:(0,b.jsx)(w.A,{variant:"contained",size:"small",onClick:f,children:"Analyze"})})]}):(0,b.jsx)(c.A,{className:"vi-card",sx:{width:"100%",height:"100%",background:"#252528",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",boxShadow:"none",padding:0},children:(0,b.jsxs)(u.A,{children:[(0,b.jsx)(r.A,{variant:"h6",component:"div",className:"small-text",sx:{color:"var(--type-meta)",fontSize:"var(--type-meta-size) !important",fontWeight:"var(--type-meta-weight) !important",m:0},children:t}),(0,b.jsxs)(s.A,{sx:{display:"flex",alignItems:"center",marginTop:1,marginBottom:6},children:[(0,b.jsx)(_.A,{variant:"determinate",value:i,sx:{width:"40%",marginRight:1,height:30,borderRadius:1,backgroundColor:"var(--glass-color)","& .MuiLinearProgress-bar":{backgroundColor:"var(--leading-color)"}}}),(0,b.jsxs)(r.A,{variant:"body2",sx:{color:"var(--type-primary)",fontSize:"var(--type-emphasis-size) !important",fontWeight:"var(--type-emphasis-weight) !important"},children:[n,"%"]})]}),(0,b.jsxs)(s.A,{sx:{marginBottom:6},children:[(0,b.jsx)(r.A,{variant:"body4",className:"card-title",sx:{color:"var(--type-primary)",fontSize:"var(--type-subheading-size) !important",fontWeight:"var(--type-subheading-weight) !important",lineHeight:"var(--type-subheading-line) !important",whiteSpace:"normal"},gutterBottom:!0,children:a}),(0,b.jsx)(r.A,{variant:"body2",className:"small-text",sx:{color:"var(--type-card-body)",fontSize:"var(--type-meta-size) !important"},gutterBottom:!0,children:o})]}),(0,b.jsxs)(s.A,{sx:{display:"flex",justifyContent:"space-between",marginTop:2,marginBottom:4,flexWrap:"wrap",gap:2},children:[(0,b.jsxs)(r.A,{variant:"body2",sx:{fontSize:"var(--type-meta-size) !important"},children:[(0,b.jsx)("div",{style:{color:"var(--type-meta)",fontSize:"var(--type-label-size)"},children:"Defects/Units"}),(0,b.jsx)("div",{style:{color:"var(--type-primary)",fontWeight:600,fontSize:"var(--type-emphasis-size)"},children:l})]}),(0,b.jsxs)(r.A,{variant:"body2",sx:{fontSize:"var(--type-meta-size) !important"},children:[(0,b.jsx)("div",{style:{color:"var(--type-meta)",fontSize:"var(--type-label-size)"},children:"Operational Efficiency"}),(0,b.jsx)("div",{style:{color:"var(--type-primary)",fontWeight:600,fontSize:"var(--type-emphasis-size)"},children:d})]})]}),(0,b.jsx)(w.A,{variant:"contained",sx:{marginTop:3},onClick:f,children:"Analyse"})]})})};var N=i(94412),I=i(97929),k=(i(51604),i(77447)),R=i(69002),$=i(91964),z=i(4151),D=i(14704),P=(i(67654),i(42406));const E=e=>{var t,i;let{PlantsListData:a,products:o,PlantsData:A,lineId:_}=e;const{factory_id:w}
1=(0,S.g)(),k=(0,S.zy)(),[E,B]=(0,n.useState)(!1),L=(0,n.useRef)([]),W=(0,n.useRef)([]),M=(0,n.useRef)(),[,T]=(0,n.useReducer)(e=>e+1,0),[V,F]=(0,n.useState)(0),H=(0,D.wA)(),U=null===(t=k.state)||void 0===t?void 0:t.id,[G,O]=(localStorage.getItem("solutionRole"),(0,n.useState)({ongoing_sessions_count:0,ongoing_sessions_model_count:0,all_sessions_model_count:0})),[X,Y]=(0,n.useState)("grid"),[Z,q]=(0,n.useState)(!0),[J,K]=(0,n.useState)(!1);console.log("Analytics PlantsData",A),(0,n.useEffect)(()=>{a.length>0&&Array.isArray(a[0])&&a[0].length>0?(ee(),te(U)):a.length>0&&(q(!1),K(!1),W.current=[],T())},[a,_]);(0,n.useRef)(null),(0,n.useRef)(!1);const Q=(0,n.useRef)(0);(0,n.useEffect)(()=>{te(U),console.log("factory_idd",U)},[]);const ee=async()=>{const e=++Q.current;q(!0),K(!0),W.current=[],T();try{const t=`${window.ENV.API_URL}`,i={Authorization:`Bearer ${(0,$.getCokkie)("jwtToken")}`,accept:"application/json"},n=a[0];L.current=n,H((0,z.kr)(n)),q(!1);const s=_?`&line_id=${_}`:"";await Promise.all(n.map(async a=>{try{var r,l,d,c,u,p,h;const x=(null===(r=o[0])||void 0===r?void 0:r.length)>0?o[0].map(e=>`product_id=${e}`).join("&"):"",g=x?R.A.get(`${t}/visual-inspection/defect/?${x}`,{headers:i}):(null===(l=a.products)||void 0===l?void 0:l.length)>0?Promise.all(a.products.map(e=>R.A.get(`${t}/visual-inspection/defect/?product_id=${e}`,{headers:i}))):Promise.resolve(null),[m,v,f]=await Promise.all([g,R.A.get(`${t}/visual-inspection/inspection_unit/count?plant_id=${a._id}${s}`,{headers:i}),R.A.get(`${t}/visual-inspection/inspection_session/count?plant_id=${a._id}${s}`,{headers:i})]);if(e!==Q.current)return;let y=[];x?y=(null===m||void 0===m?void 0:m.data)||[]:Array.isArray(m)&&(y=m.flatMap(e=>(null===e||void 0===e?void 0:e.data)||[]));const A=(null===v||void 0===v?void 0:v.data)||{},b=null!==(d=null!==(c=A.total_inspection_units)&&void 0!==c?c:A.total_inspection_unit_count)&&void 0!==d?d:0,j=null!==(u=null!==(p=A.total_defects)&&void 0!==p?p:A.defected_inspection_unit_count)&&void 0!==u?u:0,_=null!==(h=A.missed_defects)&&void 0!==h?h:[],{count:w=0,live_model_count:S=0}=f.data||{},{_id:C,name:N,createdAt:I,updatedAt:k}=a,$={_id:C,name:N,createdAt:I,updatedAt:k,total_inspection_unit_count:b,defected_inspection_unit_count:j,defects:y,defectCount:j,missedDefects:_,live_inspections:w,live_models:S},z=[...W.current],D=z.findIndex(e=>e._id===C);D>=0?z[D]=$:z.push($);const P=new Map(n.map((e,t)=>[e._id,t]));z.sort((e,t)=>{var i,n;return(null!==(i=P.get(e._id))&&void 0!==i?i:0)-(null!==(n=P.get(t._id))&&void 0!==n?n:0)}),W.current=z,T()}catch(g){var x;console.error("Error fetching plant details",null===a||void 0===a?void 0:a._id,(null===(x=g.response)||void 0===x?void 0:x.data)||g.message)}})),console.log("FullPlantDetails:",W.current)}catch(i){var t;console.error("Error fetching plant details",(null===(t=i.response)||void 0===t?void 0:t.data)||i.message)}finally{e===Q.current&&(q(!1),K(!1))}},te=async()=>{try{const e=`${window.ENV.API_URL}`,t={Authorization:`Bearer ${(0,$.getCokkie)("jwtToken")}`,accept:"application/json"},i=await R.A.get(`${e}/visual-inspection/inspection_session/count?factory_id=${U}`,{headers:t});null!==i&&void 0!==i&&i.data&&O(i.data)}catch(e){console.error("Error fetching session count:",e)}},ie=["#8E37D2","#EBB700","#FF4DA2","#D9D9D9"],ne=W.current.flatMap(e=>e.defects||[]),ae={};ne.forEach(e=>{const t=e.category||"Unknown",i=(null===e||void 0===e?void 0:e.score_threshold)||0;ae[t]=i});const oe=W.current.flatMap(e=>e.defects||[]).map((e,t)=>{var i;const n=(null===e||void 0===e||null===(i=e.score_thresholds)||void 0===i?void 0:i.error)||0;return{label:e.category||"Unknown",value:(100*n).toFixed(2),color:ie[t%ie.length]}});console.log("plantDetailsRef",W);const se=W.current.flatMap(e=>e.missedDefects||[]),re=W.current.reduce((e,t)=>e+(t.defected_inspection_unit_count||0),0),le=se.map((e,t)=>({name:e.category_name||"Unknown",value:re>0?(e.item_count/re*100).toFixed(2):"0.00",count:e.item_count||0,color:ie[t%ie.length]})),de=le.length?[{scaleType:"band",data:le.map(e=>e.name),barCategoryGap:.8}]:[],ce=le.map(e=>({data:[e.value],color:e.color,valueFormatter:()=>e.name}));(0,n.useEffect)(()=>{M.current&&F(M.current.offsetWidth);const e=()=>
1{M.current&&F(M.current.offsetWidth)};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);const ue=((null===(i=W.current)||void 0===i?void 0:i.length)>0?W.current:[]).map(e=>{var t,i;const n=null!==(t=null!==(i=e.defected_inspection_unit_count)&&void 0!==i?i:e.total_defects)&&void 0!==t?t:0,a=e.total_inspection_unit_count||0,o=a?n/a*100:0,s=100-o;return{title:"Defect Density",color:"#EB0000",progress:Math.round(o),progressValue:Math.round(o),unitName:e.name,defects:`${n}/${a}`,operationalEfficiency:`${Math.round(s)}%`,plant_id:e._id}})||[],pe={position:"relative",backgroundColor:"#252528",border:"1px solid rgba(255, 255, 255, 0.1)",boxShadow:"none",width:"100%",height:"100%",minHeight:{xs:240,md:280},borderRadius:"10px",boxSizing:"border-box"},he={position:"absolute",top:"16px",left:"16px",color:"rgba(255, 255, 255, 0.55)",fontSize:14,fontWeight:600};return(0,b.jsx)(s.A,{sx:{background:"transparent",minHeight:0,display:"flex",flexDirection:"column",width:"100%",maxWidth:"100%",overflowX:"clip",padding:0},children:Z?(0,b.jsx)(s.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"50vh",width:"100%"},children:(0,b.jsx)(P.A,{})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(s.A,{className:"solution-dashboard-charts-row",sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"5fr 5fr 2fr"},gap:2,mb:2,width:"100%",alignItems:"stretch"},children:[(0,b.jsxs)(s.A,{className:"vi-card",sx:pe,children:[(0,b.jsx)(r.A,{sx:he,children:"Defect Density"}),(0,b.jsxs)(s.A,{sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},alignItems:{xs:"flex-start",sm:"center"},gap:2,width:"100%",height:"100%",pt:{xs:5,md:6},pr:2,pb:2,boxSizing:"border-box"},children:[(0,b.jsx)(s.A,{sx:{flexShrink:0,lineHeight:0,alignSelf:{xs:"center",sm:"auto"}},children:(0,b.jsx)(y.V,{data:oe,innerRadius:50,outerRadius:80,paddingAngle:2,cornerRadius:2,startAngle:-160,endAngle:200,cx:95,cy:120,width:200,height:240})}),(0,b.jsx)(l.A,{sx:{color:"#f3f4f6",padding:0,flex:1,minWidth:0,m:0},children:oe.map((e,t)=>(0,b.jsxs)(d.Ay,{sx:{display:"flex",justifyContent:"space-between",paddingY:.5},children:[(0,b.jsxs)(s.A,{sx:{display:"flex",alignItems:"center"},children:[(0,b.jsx)("span",{style:{background:e.color,height:"10px",width:"10px",borderRadius:"10px",marginRight:"8px"}}),(0,b.jsx)(r.A,{variant:"body2",sx:{color:"#f3f4f6"},children:e.label})]}),(0,b.jsxs)(r.A,{variant:"body2",sx:{color:"rgba(255, 255, 255, 0.55)"},children:[e.value,"%"]})]},t))})]})]}),(0,b.jsxs)(s.A,{ref:M,className:"vi-card",sx:{...pe,display:"flex",alignItems:"center",justifyContent:"flex-start"},children:[(0,b.jsx)(r.A,{sx:he,children:"Missing Defects"}),(0,b.jsx)(j,{xAxis:de,series:ce,width:.3*V,height:280,borderRadius:4,innerRadius:2,barGapRatio:.5,barGap:.3,barCategoryGap:.5,margin:{top:10},tooltip:{trigger:"item",renderTooltip:e=>{var t,i;let{series:n,dataIndex:a}=e;return(0,b.jsx)("div",{style:{padding:"4px 8px"},children:null===(t=n[a])||void 0===t||null===(i=t.valueFormatter)||void 0===i?void 0:i.call(t)})}}}),(0,b.jsx)(l.A,{sx:{color:"#f3f4f6",padding:0,width:"100%",pl:2},children:0===le.length?(0,b.jsx)(d.Ay,{sx:{justifyContent:"center",color:"rgba(255,255,255,0.45)"},children:"No data to display"}):le.map(e=>(0,b.jsxs)(d.Ay,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingY:.5},children:[(0,b.jsxs)(s.A,{sx:{display:"flex",alignItems:"center"},children:[(0,b.jsx)("span",{style:{background:e.color,height:"10px",width:"10px",borderRadius:"10px",marginRight:"8px"}}),(0,b.jsx)(r.A,{variant:"body2",sx:{color:"#f3f4f6"},children:e.name})]}),(0,b.jsxs)(r.A,{variant:"body2",sx:{color:"rgba(255, 255, 255, 0.55)"},children:[e.value,"%"]})]},e.id))})]}),(0,b.jsxs)(s.A,{sx:{display:"flex",flexDirection:"column",gap:2,height:"100%",minHeight:280},className:"solution-dashboard-live-stats",children:[(0,b.jsx)(c.A,{className:"vi-card",sx:{backgroundColor:"#252528",border:"1px solid rgba(255, 255, 255, 0.1)",boxShadow:"none",width:"100%",flex:1,display:"flex",flexDirection:"column",borderRadius:"10px"},children:(0,b.jsxs)(u.A,{sx:{padding:"15px",flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[(0,b.jsx)(r.A,{variant:"body3",sx:{color:"rgba(255, 255, 255, 0.75)",fontSize:14},children:"Live Models"}),(0,b.jsx)(r.A,{variant:"body2",sx:{color:"#f3f4f6",fontSize:{xs:"2rem",md:"3rem"},lineHeight:1.1,fontWeight:700},children:G.ongoing_sessions_model_count||0})]})}),(0,b.jsx)(c.A,{className:"vi-card",sx:{backgroundColor:"#252528",border:"1px solid rgba(255, 255, 255, 0.1)",boxShadow:"none",width:"100%",flex:1,display:"flex",flexDirection:"column",borderRadius:"10px"},children:(0,b.jsxs)(u.A,{sx:{padding:"15px",flex:1,display:"flex",flexDirection:"column",justifyContent:"center"},children:[(0,b.jsx)(r.A,{variant:"body2",sx:{color:"rgba(255, 255, 255, 0.75)",fontSize:14},children:"Live Inspections"}),(0,b.jsx)(r.A,{variant:"body2",sx:{color:"#f3f4f6",fontSize:{xs:"2rem",md:"3rem"},lineHeight:1.1,fontWeight:700},children:G.ongoing_sessions_count||0})]})})]})]}),(0,b.jsx)("div",{className:"vi-toggle",children:(0,b.jsxs)("div",{className:"vi-toggle__group",role:"tablist","aria-label":"Plant view",children:[(0,b.jsx)("button",{type:"button",role:"tab","aria-selected":"list"===X,
1className:"vi-toggle__btn"+("list"===X?" is-active":""),onClick:e=>{e.stopPropagation(),Y("list"),B(!0)},children:(0,b.jsx)(N.g,{icon:I.ITF})}),(0,b.jsx)("button",{type:"button",role:"tab","aria-selected":"grid"===X,className:"vi-toggle__btn"+("grid"===X?" is-active":""),onClick:e=>{e.stopPropagation(),Y("grid"),B(!1)},children:(0,b.jsx)(N.g,{icon:I.l9V})})]})}),E?(0,b.jsx)(s.A,{className:"vi-table-wrap",children:(0,b.jsx)(p.A,{component:h.A,elevation:0,className:"vi-card vi-table",sx:{backgroundColor:"#252528",border:"1px solid rgba(255, 255, 255, 0.1)",boxShadow:"none",width:"100%",overflow:"hidden"},children:(0,b.jsxs)(x.A,{size:"small",children:[(0,b.jsx)(g.A,{children:(0,b.jsxs)(m.A,{children:[(0,b.jsx)(v.A,{sx:{color:"#B5B7C0",fontSize:"small",fontWeight:600},children:"Plant"}),(0,b.jsx)(v.A,{sx:{color:"#B5B7C0",fontSize:"small",fontWeight:600},children:"Defects"}),(0,b.jsx)(v.A,{sx:{color:"#B5B7C0",fontSize:"small",fontWeight:600},children:"Operational Efficiency"}),(0,b.jsx)(v.A,{align:"right",sx:{color:"#B5B7C0",fontSize:"small",fontWeight:600},children:"Action"})]})}),(0,b.jsx)(f.A,{children:ue.map((e,t)=>(0,b.jsx)(C,{title:e.title,progress:e.progress,progressValue:e.progressValue,unitName:e.unitName,description:e.description,defects:e.defects,operationalEfficiency:e.operationalEfficiency,listView:E,plant_id:e.plant_id,factory_id:U},t))})]})})}):(0,b.jsxs)(s.A,{className:"solution-dashboard-plants-grid",sx:{dis
1play:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(2, minmax(0, 1fr))",md:"repeat(3, minmax(0, 1fr))",lg:"repeat(4, minmax(0, 1fr))"},gap:2,width:"100%"},children:[ue.map((e,t)=>(0,b.jsx)(C,{title:e.title,progress:e.progress,progressValue:e.progressValue,unitName:e.unitName,description:e.description,defects:e.defects,operationalEfficiency:e.operationalEfficiency,plant_id:e.plant_id,factory_id:U},e.plant_id||t)),J&&0===ue.length?(0,b.jsx)(s.A,{sx:{gridColumn:"1 / -1",display:"flex",justifyContent:"center",py:6},children:(0,b.jsx)(P.A,{})}):null]})]})})};var B=i(91042),L=i(83703),W=i(40237),M=(i(56474),i(57260),i(22322),i(44655));const T=()=>{var e,t,i,r,l,d,c,u,p,h,x;const g=(0,S.Zp)(),m=(0,S.zy)(),{solution_id:v}=(0,S.g)(),f="executive"===localStorage.getItem("solutionRole"),y=null===(e=m.state)||void 0===e?void 0:e.id,A=null===(t=m.state)||void 0===t?void 0:t.plant_id,j=null===(i=m.state)||void 0===i?void 0:i.line_id,_=v||(null===(r=m.state)||void 0===r?void 0:r.solution_id)||localStorage.getItem("solutionId")||"",w=(null===(l=m.state)||void 0===l?void 0:l.solutionName)||localStorage.getItem("solutionName")||"Solution",C=(null===(d=m.state)||void 0===d?void 0:d.factoryName)||localStorage.getItem("factname")||"",N=(null===(c=m.state)||void 0===c?void 0:c.plantName)||localStorage.getItem("plantname")||"",I=(null===(u=m.state)||void 0===u?void 0:u.lineName)||localStorage.getItem("lineName")||"",R=null===(p=m.state)||void 0===p?void 0:p.product_id,$=null===(h=m.state)||void 0===h?void 0:h.product_ids,z=(null===(x=m.state)||void 0===x?void 0:x.productName)||"",[D,T]=(0,n.use
1State)(()=>{var e;const t=null===(e=m.state)||void 0===e?void 0:e.initialTab;return 1===t||"inspection"===t?1:0}),[V,F]=(0,n.useState)(_),[H,U]=(0,n.useState)(w),[G,O]=(0,n.useState)(!_),[X,Y]=(0,n.useState)([]),[Z,q]=(0,n.useState)([]),[J,K]=(0,n.useState)([]),[Q,ee]=(0,n.useState)(C),[te,ie]=(0,n.useState)(N),[ne,ae]=(0,n.useState)(I),[oe,se]=(0,n.useState)(z),[re,le]=(0,n.useState)(y||""),[de,ce]=(0,n.useState)(j||""),[ue,pe]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(V)return void O(!1);let e=!1;return O(!0),(async()=>{try{const t=await(0,k.A)(`${window.ENV.API_URL}/solutions/`,"GET");if(e)return;const i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=Array.isArray(e)?e:[];return t.find(e=>(0,M.k1)(e))||t.find(e=>!(0,M.X)(e))||t[0]||null}((e=>Array.isArray(e)?e:Array.isArray(null===e||void 0===e?void 0:e.data)?e.data:Array.isArray(null===e||void 0===e?void 0:e.solutions)?e.solutions:[])(t));if(null===i||void 0===i||!i._id)return void pe(!0);const n=(null===i||void 0===i?void 0:i.name)||(null===i||void 0===i?void 0:i.title)||(null===i||void 0===i?void 0:i.solution_name)||"Solution";localStorage.setItem("solutionId",i._id),localStorage.setItem("solutionName",n),F(i._id),U(n)}catch(t){console.error("Failed to bootstrap dashboard solution:",t),e||pe(!0)}finally{e||O(!1)}})(),()=>{e=!0}},[V]);const he=e=>{const{children:t,value:i,index:n,...a}=e;return(0,b.jsx)("div",{role:"tabpanel",hidden:i!==n,id:`simple-tabpanel-${n}`,"aria-labelledby":`simple-tab-${n}`,...a,children:i===n&&(0,b.jsx)(s.A,{className:"solution-dashboard-tabpanel",children:t})})},xe=e=>({id:`simple-tab-${e}`,"aria-controls":`simple-tabpanel-${e}`}),ge=[{label:"Solutions",onClick:f?void 0:()=>g("/solutions")},{label:"Dashboard"}],me=J[0]||[],ve=1===me.length?me[0]:void 0,fe=G||!ue&&Boolean(V);return(0,b.jsxs)("div",{className:"vi",children:[!G&&V?(0,b.jsx)(L.Ay,{solution_id:V,factory_id:re||y,plant_id:A,line_id:j,product_id:R,product_ids:$,factoryName:Q,plantName:te,lineName:ne,productName:oe,onFactoryChange:e=>{null!==e&&void 0!==e&&e._id&&le(e._id),null!==e&&void 0!==e&&e.name&&(ee(e.name),localStorage.setItem("factname",e.name)),ie(""),ae(""),se(""),ce(""),localStorage.removeItem("plantname"),localStorage.removeItem("lineName")},onLineChange:e=>{ce((null===e||void 0===e?void 0:e._id)||""),ae((null===e||void 0===e?void 0:e.name)||""),null!==e&&void 0!==e&&e.name?localStorage.setItem("lineName",e.name):localStorage.removeItem("lineName")},onFilterChange:(e,t,i)=>{Y([e]),q([i]),K([t]),pe(!0);const n=Array.isArray(e)?e:[],a=Array.isArray(t)?t:[];if(1===n.length){var o;const e=(null===(o=n[0])||void 0===o?void 0:o.name)||"";ie(e),e&&localStorage.setItem("plantname",e)}else ie(""),ae(""),se(""),localStorage.removeItem("plantname"),localStorage.removeItem("lineName");1===a.length?se(e=>e||z):0!==a.length||R||se("")}}):null,(0,b.jsxs)("div",{className:"vi-body",children:[(0,b.jsx)(W.A,{items:ge,onBack:()=>{f||(V?g(`/solutions/${V}`,{state:{solutionName:H,solutionId:V}}):g("/solutions"))},"aria-label":"Dashboard path"}),(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"vi-tabs",children:(0,b.jsxs)(a.A,{value:D,onChange:(e,t)=>
1{T(t)},variant:"scrollable",scrollButtons:"auto",allowScrollButtonsMobile:!0,"aria-label":"Dashboard views",children:[(0,b.jsx)(o.A,{label:"Analytics",...xe(0)}),(0,b.jsx)(o.A,{label:"Inspection",...xe(1)})]})}),(0,b.jsx)(he,{value:D,index:0,children:fe?(0,b.jsx)(s.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"50vh"},children:(0,b.jsx)(P.A,{})}):(0,b.jsx)(E,{PlantsListData:X,products:J,PlantsData:Z,lineId:de},`${X}-${de}-${me.join(",")}`)}),(0,b.jsx)(he,{value:D,index:1,children:fe?(0,b.jsx)(s.A,{sx:{display:"flex",justifyContent:"center",alignItems:"center",minHeight:"50vh"},children:(0,b.jsx)(P.A,{})}):(0,b.jsx)(B.N,{PlantsListData:X,products:J,PlantsData:Z,lineId:de,productId:ve},`${X}-${de}-${me.join(",")}`)})]})]})]})}},91042(e,t,i){var n=i(65043),a=(i(14704),i(7353)),o=i(68903),s=i(94496),r=i(3438),l=i(69002),d=i(91964),c=i(42406),u=i(70579);i.d(t,["N",0,e=>{let{PlantsListData:t,products:i,plantId:p,productId:h,plantName:x,lineId:g,isProductAnalytics:m=!1}=e;const v=(0,n.useMemo)(()=>t&&Array.isArray(t)&&t.length>0?t[0]||[]:p?[{_id:p,name:x||`Plant ${p}`}]:[],[t,p]),[f,y]=(0,n.useState)({}),[A,b]=(0,n.useState)({}
1),[j,_]=(0,n.useState)(!0);return console.log("PlantsListData",t),console.log("plantId",p),console.log("productId",h),console.log("plantName",x),console.log("plants",v),(0,n.useEffect)(()=>{console.log("Inspection useEffect triggered with plants:",v);v.length>0?(async()=>{_(!0);const e=`${window.ENV.API_URL}`,t={Authorization:`Bearer ${(0,d.getCokkie)("jwtToken")}`,accept:"application/json"},i={};for(const a of v){const o=a._id?a._id:a;try{const n=new URLSearchParams({plant_id:o});h&&n.append("product_id",h),g&&n.append("line_id",g),console.log("Inspection API URL:",`${e}/visual-inspection/inspection_unit/?${n.toString()}`);const[a,s]=await Promise.all([l.A.get(`${e}/visual-inspection/inspection_unit/?${n.toString()}`,{headers:t}),l.A.get(`${e}/visual-inspection/batch?plant_id=${o}`,{headers:t})]),r=a.data||[],d=s.data||[];Object.fromEntries(d.map(e=>[e._id,e])),console.log("defectArray",r),console.log("batchArray",d);const c=[];r.forEach(e=>{var t;const i=d.find(t=>t._id===e.batch_id),n=(null===i||void 0===i?void 0:i.batch_no)||"N/A",a=null!==i&&void 0!==i&&i.updatedAt?new Date(i.updatedAt).toLocaleTimeString():"N/A";c.push({image:e.image_url||null,result:null!==(t=e.defects)&&void 0!==t&&t.length?"defect":"perfect",date:a,batchNo:n})}),i[o]={cards:c}}catch(n){console.error(`Error fetching data for plant ${o}:`,n),i[o]={cards:[]}}}y(i),_(!1)})():_(!1)},[v,h,g]),j?(0,u.jsx)(a.A,{sx:{display:"flex",justifyContent:"center",py:6},children:(0,u.jsx)(c.A,{})}):(0,u.jsx)(a.A,{sx:{background:"transparent",minHeight:"auto",p:0},children:v.map(e=>{const t=f[e._id?e._id:e],i=(null===t||void 0===t?void 0:t.cards)||[],n=e.name;return m?(0,u.jsx)(o.Ay,{container:!0,spacing:2,children:i.map((e,t)=>(0,u.jsx)(o.Ay,{item:!0,xs:12,sm:6,md:4,lg:2,children:(0,u.jsxs)(a.A,{children:[e.image?(0,u.jsx)("img",{src:e.image,style:{width:"100%",height:"150px",objectFit:"cover",borderRadius:"10px"}}):(0,u.jsx)(a.A,{sx:{width:"100%",height:"150px",backgroundColor:"#313134",borderRadius:"10px"}}),(0,u.jsxs)(a.A,{sx:{mt:1},children:[(0,u.jsxs)(a.A,{sx:{display:"flex",justifyContent:"space-between"},children:[(0,u.jsx)(s.A,{variant:"caption",sx:{color:"#737373"},children:e.date}),(0,u.jsx)(s.A,{variant:"caption",sx:{color:"#737373"},children:e.batchNo})]}),(0,u.jsx)(s.A,{variant:"body2",sx:{mt:.5,color:"#C3C3C3",fontWeight:"bold"},children:"perfect"===e.result?"Perfect":"defect"===e.result?"Defect":""})]})]})},t))},e._id):(0,u.jsxs)(a.A,{sx:{mb:4},children:[(0,u.jsxs)(a.A,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,u.jsx)(s.A,{variant:"h6",sx:{color:"#686868"},children:n}),i.length>6&&(0,u.jsx)(r.A,{variant:"contained",color:"primary",onClick:()=>b(t=>({...t,[e._id]:!t[e._id]})),children:A[e._id]?"View Less":"View All"})]}),(0,u.jsx)(o.Ay,{container:!0,spacing:2,children:(A[e._id]?i:i.slice(0,6)).map((e,t)=>(0,u.jsx)(o.Ay,{item:!0,xs:12,sm:6,md:4,lg:2,children:(0,u.jsxs)(a.A,{children:[e.image?(0,u.jsx)("img",{src:e.image,style:{width:"100%",height:"150px",objectFit:"cover",borderRadius:"10px"}}):(0,u.jsx)(a.A,{sx:{width:"100%",height:"150px",backgroundColor:"#313134",borderRadius:"10px"}}),(0,u.jsxs)(a.A,{sx:{mt:1},children:[(0,u.jsxs)(a.A,{sx:{display:"flex",justifyContent:"space-between"},children:[(0,u.jsx)(s.A,{variant:"caption",sx:{color:"#737373"},children:e.date}),(0,u.jsx)(s.A,{variant:"caption",sx:{color:"#737373"},children:e.batchNo})]}),(0,u.jsx)(s.A,{variant:"body2",sx:{mt:.5,color:"#C3C3C3",fontWeight:"bold"},children:"perfect"===e.result?"Perfect":"defect"===e.result?"Defect":""})]})]})},t))})]},e._id)})})}])},55200(e,t,i){i(65043);var n=i(57644),a=i(42406),o=i(70579);i.d(t,["V",0,e=>{const{data:t=[],loading:i=!1,innerRadius:s,outerRadius:r,paddingAngle:l,cornerRadius:d,startAngle:c,endAngle:u,cx:p,cy:h,width:x=200,height:g=240}=e;return i?(0,o.jsx)("div",{style:{width:x,height:g,display:"flex",alignItems:"center",justifyContent:"center"},children:(0,o.jsx)(a.A,{})}):null!==t&&void 0!==t&&t.length?(0,o.jsx)(n.r,{series:[{data:null!==t&&void 0!==t?t:[],innerRadius:s,outerRadius:r,paddingAngle:l,cornerRadius:d,startAngle:c,endAngle:u,cx:p,cy:h}],slotProps:{legend:{hidden:!0}
1,noDataOverlay:{sx:{fill:"var(--type-meta)",fontSize:"var(--type-emphasis-size)",fontFamily:"var(--font-sans)",fontWeight:"var(--type-emphasis-weight)"}}},width:x,height:g}):(0,o.jsx)("div",{style:{width:x,height:g,display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(255, 255, 255, 0.45)"},children:"No data to display"})}])},44655(e,t,i){const n=function(){return String(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").toLowerCase().replace(/[^a-z0-9]/g,"")},a=function(){return n(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(null===e||void 0===e?void 0:e.type)||(null===e||void 0===e?void 0:e.solution_type)||(null===e||void 0===e?void 0:e.solutionType)||(null===e||void 0===e?void 0:e["Solution Type"])||""}(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))},o=function(){var e,t;let i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const o=a(i),s=`${o} ${n((null===i||void 0===i?void 0:i.template)||(null===i||void 0===i||null===(e=i.config)||void 0===e||null===(t=e.meta)||void 0===t?void 0:t.template)||"")}`.trim();if(/track|reid|reidentification|persontrack|occupancy|footfall|multicamera/.test(s))return!0;const r=String((null===i||void 0===i?void 0:i.name)||(null===i||void 0===i?void 0:i.title)||"").toLowerCase();if(!r)return!1;return!!/person\s*track|re-?\s*id|tracking|occupancy/.test(r)&&!(o&&!/custom|general|track|reid/.test(o))};i.d(t,["X",0,o,"k1",0,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(o(e))return!1;const t=a(e);return!t||/visual|inspect|^vi$/.test(t)}])},56474(){},22322(){}}]);
2//# sourceMappingURL=8547.c902aee0.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.