1import{e as ie,j as e,aB as ke,aJ as ze,S as n,aC as Me,aX as De,d$ as Re,aG as Fe,aH as Oe,aI as Ee,d as z,a1 as ne,e0 as Te,P as r,r as m,u as We,f as Ae,e1 as $e,c as Be,B as p,M as le,G as f,T as b,a as d,v as O,C as g,k as ce,e2 as de,a0 as q,s as pe,Q as Pe,N as Le,dU as qe,a_ as E,b6 as T}from"./index-DFCDAUq3.js";import{U as Ge,C as Qe,d as Ue,E as Ne,S as _e}from"./AttachFile-D2eB4Uad.js";import{u as He}from"./index-aZNB2WEW.js";import{s as Ke}from"./removeSpecialChar-uOaqPFin.js";import{u as Ve}from"./solution-request.service-CJpLUTyW.js";import{S as Xe}from"./StatusChip-ByX5VguI.js";import{D as Ye}from"./DownloadConfirmation-DtGj3uOK.js";import{u as Je,a as Ze,b as es}from"./controller.service-C1QA56N2.js";import{R as ue}from"./CloudDownloadOutlined-DAJc4nrO.js";import{R as ss}from"./SmileOutlined-BeAAICkS.js";import{R as ts}from"./SendOutlined-BRHiZXoo.js";import"./CheckCircleFilled-XhWCqe7o.js";import"./format-BZfnMJDj.js";import"./toDate-CP9kJ8oq.js";const as=ie.injectEndpoints({endpoints:C=>({getMessages:C.query({query:l=>({url:`/Dealer/getMessages?requestId=${l}`,method:"GET"}),transformResponse:l=>l.data}),sendMessage:C.mutation({query:({data:l})=>({url:"/Dealer/chat",method:"POST",body:l,formData:!0}),async onQueryStarted({successHandler:l},{dispatch:a,queryFulfilled:j}){try{const{data:c}=await j;c.message==="send"&&(a(ie.util.updateQueryData("getMessages",c.data.ticketNo.toString(),x=>{x.push(c.data)})),l())}catch(c){console.log(c)}}})})}),{useGetMessagesQuery:os,useSendMessageMutation:rs}=as,G=({dialogSize:C="sm",children:l,handleDialogClose:a,openDialog:j,dialogTitle:c,additionalHeaderContent:x,dialogContent:M,dialogActionText:D,isLoading:y,hasAction:t,handleSubmission:w,handleSubmissionBtnColor:W,simpleAction:I,submitButtonColor:u,childrenItems:S})=>e.jsxs(ke,{maxWidth:C,TransitionComponent:ze,keepMounted:!0,fullWidth:!0,onClose:a,open:j,sx:{"& .MuiDialog-paper":{p:0},transition:"transform 225ms"},children:[e.jsxs(n,{direction:"row",justifyContent:"space-between",alignItems:"center",children:[e.jsx(Me,{sx:{m:0,p:2},id:"customized-dialog-title",children:c}),!!x&&e.jsx(n,{direction:"row",gap:1,marginRight:10,children:x}),e.jsx(De,{"aria-label":"close",onClick:a,sx:{position:"absolute",right:8,top:8,color:k=>k.palette.grey[500]},children:e.jsx(Re,{})})]}),e.jsxs(Fe,{children:[e.jsx(Oe,{sx:{paddingY:1},children:M}),I&&e.jsx(n,{justifyContent:"center",alignItems:"center",mt:2,children:l}),!I&&l]}),e.jsxs(Ee,{children:[e.jsx(z,{variant:"outlined",color:"secondary",type:"button",onClick:a,children:"Cancel"}),t&&e.jsx(ne,{loading:y,disabled:y,variant:"contained",onClick:w,loadingPosition:"end",endIcon:e.jsx(Te,{}),type:"submit",children:D||"Submit"}),I&&e.jsx(ne,{loading:y,disabled:y,variant:"contained",color:W,onClick:w,loadingPosition:"end",children:D||"Submit"})]})]});G.defaultProps={dialogSize:"sm",dialogActionText:"Submit",isLoading:!1};G.propTypes={dialogSize:r.oneOf(["xs","sm","md","lg","xl"]),handleDialogClose:r.func,handleSubmission:r.func,openDialog:r.bool,dialogTitle:r.string,handleSubmissionBtnColor:r.string,additionalHeaderContent:r.node,dialogContent:r.node,children:r.node,dialogActionText:r.string,isLoading:r.bool,hasAction:r.bool,childrenItems:r.bool,simpleAction:r.bool};const ys=m.forwardRef((C,l)=>{var V,X,Y,J,Z,ee,se,te,ae,oe,re;const a=We(),j=Ae(),{uniqueId:c}=$e(),{dbUserId:x,user:M}=Be(),{cars:D}=Je(void 0,{selectFromResult:({data:s})=>{const o={};return s==null||s.forEach(i=>{o[i.Id]=i}),{cars:o}}}),{controllers:y}=Ze(void 0,{selectFromResult:({data:s})=>{const o={};return s==null||s.forEach(i=>{o[i.Id]=i}),{controllers:o}}}),{request:t={}}=Ve(x,{refetchOnMountOrArgChange:!0,selectFromResult:({data:s,...o})=>({request:s==null?void 0:s.find(i=>i.uniqueId==c),...o})}),{solutions:w}=es(void 0,{refetchOnMountOrArgChange:!0,selectFromResult:({data:s})=>{const o={};return s==null||s.forEach(i=>{o[i.solutionname]=i.aliasName||i.solutionname}),{solutions:o}}}),{data:W=[]}=os(t.Id,{skip:!t.Id,pollingInterval:3e3}),[I,{isLoading:u}]=rs(),[S,k]=m.useState(""),[h,R]=m.useState(null),Q=async()=>
1{if(S.trim()===""&&!h)E(T({open:!0,message:"Message or file required",variant:"alert",alert:{color:"error"},close:!1}));else{const s=new FormData;s.append("message",S||""),s.append("ticketNo",t.Id),h&&h.length&&s.append("file",h[0],Ke(h[0].name)),s.append("senderName",M.firstname+" "+M.lastname),s.append("receiverId",1),s.append("senderId",x);try{await I({data:s}).unwrap(),k(""),R(null)}catch(o){console.log(o),E(T({open:!0,message:"Failed to send message.",variant:"alert",alert:{color:"error"},close:!1}))}}},me=s=>{(s==null?void 0:s.key)==="Enter"&&Q()},[F,U]=m.useState(),xe=s=>{U(F?null:s==null?void 0:s.currentTarget)},he=s=>{k(S+s.emoji)},N=!!F,_=N?"simple-popper":void 0,ge=()=>{U(null)},fe=()=>{R(null)},[be,H]=m.useState(!1),je=()=>{H(!0)},ye=async(s,o)=>{const i=s.includes(".")?s:`${s}.bin`,Ie=`${qe}/file-services/${o}/${encodeURIComponent(s)}`,v=document.createElement("a");v.href=Ie,v.setAttribute("download",i),document.body.appendChild(v),v.click(),v.parentNode.removeChild(v)},[K,A]=m.useState(!1),{getRootProps:Se}=He({noClick:!0,noKeyboard:!0,multiple:!1,onDrop:s=>{s&&s.length&&(R(s),E(T({open:!0,message:"File ready to send!",variant:"success"}))),A(!1)},onDragEnter:()=>A(!0),onDragLeave:()=>A(!1)}),$=m.useRef(),ve=()=>{$.current&&$.current.click()},Ce=s=>{s.target.files&&s.target.files.length&&(R([s.target.files[0]]),E(T({open:!0,message:"File ready to send!",variant:"success"})))},[we,B]=m.useState(!1),[P,L]=m.useState("");return e.jsxs(p,{sx:{display:"flex",background:a.palette.background.default},children:[e.jsx(le,{content:!1,sx:{pt:2,pl:2,transition:a.transitions.create("width",{easing:a.transitions.easing.easeOut,duration:a.transitions.duration.shorter+200})},children:e.jsxs(f,{container:!0,spacing:2,children:[e.jsx(f,{item:!0,xs:12,sx:{bgcolor:a.palette.background.paper,pr:2,pb:2,borderBottom:`1px solid ${a.palette.divider}`},children:e.jsx(f,{container:!0,justifyContent:"space-between",children:e.jsx(f,{item:!0,children:e.jsxs(n,{direction:"row",alignItems:"center",spacing:1,flexWrap:"wrap",children:[e.jsx(Ge,{user:{online_status:!0,name:`File Service -${c}`}}),e.jsxs(n,{direction:"row",spacing:1,alignItems:"center",flexWrap:"wrap",children:[e.jsxs(b,{variant:"h4",children:[e.jsx(d,{id:"pages.details.title",defaultMessage:"File Service"})," -",c]}),e.jsx(O,{title:"Status",children:e.jsx(Xe,{value:t.status,size:"small"})}),e.jsx(O,{title:"Download Original File",children:e.jsx(z,{disableElevation:!0,disableRipple:!0,disableFocusRipple:!0,variant:"contained",endIcon:e.jsx(ue,{}),color:"primary",size:"small",onClick:()=>ye(t.originalFile,t.uniqueId),children:e.jsx(d,{id:"pages.details.original",defaultMessage:"Original"})})}),t.modFile&&e.jsx(O,{title:"Download Mod File",children:e.jsx(z,{disableElevation:!0,disableRipple:!0,disableFocusRipple:!0,variant:"contained",endIcon:e.jsx(ue,{}),color:"primary",size:"small",onClick:()=>je(),children:e.jsx(d,{id:"pages.details.mod",defaultMessage:"MOD"})})})]})]})})})}),e.jsxs(f,{container:!0,item:!0,xs:12,children:[e.jsx(f,{item:!0,xs:12,sm:4,md:4,lg:3,children:e.jsxs(n,{spacing:1,children:[e.jsx(b,{variant:"h6",sx:{pb:.5,borderBottom:`1px solid ${a.palette.divider}`,color:a.palette.primary.main,fontWeight:600,letterSpacing:"0.5px"},children:e.jsx(d,{id:"chat.vehicleInfo",defaultMessage:"Vehicle Details"})}),e.jsxs(p,{sx:{display:"grid",gap:1,p:1,borderRadius:1,bgcolor:"background.paper",boxShadow:"0 1px 4px rgba(0,0,0,0.05)"},children:[[["chat.make",(V=D[t.make])==null?void 0:V.carname],["chat.controller",(X=y[t.ecu])==null?void 0:X.controllername],["chat.model",t.model],["chat.year",t.year],["chat.engine",t.engine],["chat.power",t.power],["chat.ecu",t.exactEcu],["chat.tool",t.readingTool],["chat.gearbox",t.gearbox],["chat.fuel",t.fuel],["chat.credits",t.credits]].filter(([,s])=>s).map(([s,o])=>e.jsxs(n,{direction:"row",alignItems:"center",spacing:.5,children:[e.jsxs(b,{variant:"caption",color:"text.secondary",sx:{fontWeight:600,fontSize:"0.75rem"},children:[e.jsx(d,{id:s}),":"]}),e.jsx(g,{label:o,variant:"outlined",size:"small",color:"primary",sx:{fontWeight:500,height:"24px",fontSize:"0.75rem"}})]},s)),t.automaticSolutions&&e.jsxs(p,{children:[e.jsx(b,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.75rem",fontWeight:600,display:"block",mb:.5},children:e.jsx(d,{id:"chat.automatic",defaultMessage:"Automatic Solutions"})}),e.jsx(n,{direction:"row",spacing:.25,flexWrap:"wrap",useFlexGap:!0,children:(J=(Y=t.automaticSolutions)==null?void 0:Y.split(","))==null?void 0:J.map(s=>e.jsx(g,{sx:{m:.25,borderRadius:"4px",borderWidth:"1px",height:"20px",fontSize:"0.7rem"},label:w[s],variant:"outlined",size:"small",color:"success"},s))})]}),t.requestSolutions&&e.jsxs(p,{children:[e.jsx(b,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.75rem",fontWeight:600,display:"block",mb:.5},children:e.jsx(d,{id:"chat.solutions",defaultMessage:"Manual Solutions"})}),e.jsx(n,{direction:"row",spacing:.25,flexWrap:"wrap",useFlexGap:!0,children:(ee=(Z=t.requestSolutions)==null?void 0:Z.split(","))==null?void 0:ee.map(s=>e.jsx(g,{sx:{m:.25,borderRadius:"4px",borderWidth:"1px",height:"20px",fontSize:"0.7rem"},label:w[s],variant:"outlined",size:"small",color:"warning"},s))})]}),t.slave&&e.jsxs(p,{children:[e.jsx(b,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.75rem",fontWeight:600,display:"block",mb:.5},children:e.jsx(d,{id:"chat.slave",defaultMessage:"Slave"})}),e.jsx(g,{label:t.slave.toUpperCase(),variant:"outlined",size:"small",color:"warning",sx:{fontWeight:500,borderRadius:"4px",borderWidth:"1px",height:"24px",fontSize:"0.75rem"}})]}),((te=(se=t==null?void 0:t.dtc)==null?void 0:se.dtcOffList)==null?void 0:te.length)>0&&e.jsxs(p,{children:[e.jsxs(n,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:.5},children:[e.jsx(b,{variant:"caption",color:"text.secondary",sx:{fontSize:"0.75rem",fontWeight:600},children:e.jsx(d,{id:"chat.dtc",defaultMessage:"DTC Off"})}),e.jsx(z,{size:"small",variant:"outlined",onClick:()=>B(!0),sx:{fontSize:"0.7rem",py:0,px:1},children:e.jsx(d,{id:"common.viewAll",defaultMessage:"View all"})})]}),e.jsxs(n,{direction:"row",spacing:.25,flexWrap:"wrap",useFlexGap:!0,children:[t.dtc.dtcOffList.slice(0,8).map(s=>e.jsx(g,{sx:{m:.25,borderRadius:"4px",borderWidth:"1px",height:"20px",fontSize:"0.7rem"},label:s,variant:"outlined",size:"small",color:"secondary"},s)),t.dtc.dtcOffList.length>8&&e.jsx(g,{label:`+${t.dtc.dtcOffList.length-8} more`,variant:"outlined",size:"small",color:"secondary",sx:{m:.25,height:"20px",fontSize:"0.7rem"},onClick:()=>B(!0)})]})]})]})]})}),e.jsxs(f,{item:!0,xs:12,sm:8,md:8,lg:9,component:ce,sx:{p:2,mt:{xs:2,md:0}},children:[e.jsx(de,{sx:{overflowX:"hidden",height:"calc(85vh - 10rem)"},children:e.jsx(p,{sx:{pl:1,pr:3},children:e.jsx(Qe,{theme:a,dbUserId:x,messages:W,uniqueId:t.uniqueId})})}),e.jsx(p,{...Se(),sx:{width:"100%",mt:2,mb:1,px:{xs:1,sm:2},display:"flex",alignItems:"center",position:"relative"},children:e.jsxs(ce,{elevation:6,sx:{width:"100%",borderRadius:{xs:2,sm:999},boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",display:"flex",alignItems:"center",px:{xs:1,sm:2},py:{xs:.5,sm:1},bgcolor:s=>K?s.palette.mode==="dark"?"rgba(30,30,30,0.95)":s.palette.background.paper:s.palette.mode==="dark"?"rgba(30,30,30,0.85)":s.palette.background.paper,backdropFilter:"blur(8px)",border:"1px solid",borderColor:K?a.palette.primary.main:a.palette.divider,transition:"all 0.2s","&:focus-within":{boxShadow:`0 0 0 2px ${a.palette.primary.light}`,borderColor:a.palette.primary.main}},children:[e.jsx(q,{onClick:ve,sx:{mr:{xs:.5,sm:1},color:"text.secondary",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{color:"primary.main",transform:"scale(1.15) rotate(-15deg)",bgcolor:"rgba(25, 118, 210, 0.08)"},"&:active":{transform:"scale(0.95) rotate(-5deg)"}},size:"small",children:e.jsx(Ue,{fontSize:"small"})}),e.jsx("input",{ref:$,type:"file",style:{display:"none"},onChange:Ce}),e.jsx(q,{ref:F,"aria-describedby":_,onClick:xe,sx:{opacity:.7,mr:{xs:.5,sm:1},color:"text.secondary",transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)","&:hover":{color:"primary.main",transform:"scale(1.15)",o
1pacity:1,bgcolor:"rgba(25, 118, 210, 0.08)"},"&:active":{transform:"scale(0.95)"}},size:"small",color:"secondary",children:e.jsx(ss,{style:{fontSize:"1.2rem"}})}),e.jsx(pe,{fullWidth:!0,disabled:u,multiline:!0,maxRows:4,minRows:1,placeholder:j.formatMessage({id:"chat.messageRequired",defaultMessage:"Your Message..."}),value:S,onChange:s=>k(s.target.value.length<=1?s.target.value.trim():s.target.value),onKeyPress:me,variant:"standard",InputProps:{disableUnderline:!0,sx:{fontSize:{xs:"0.9rem",sm:"1.1rem"},bgcolor:"transparent",borderRadius:999,px:{xs:.5,sm:1},py:{xs:.5,sm:.75},"&.Mui-disabled":{color:"text.secondary",opacity:.7}}}}),h&&e.jsx(g,{label:(ae=h[0])==null?void 0:ae.name,onDelete:fe,color:"primary",size:"small",sx:{ml:{xs:.5,sm:1},maxWidth:{xs:120,sm:180},transition:"all 0.3s","&:hover":{bgcolor:"primary.dark",transform:"scale(1.02)"},"& .MuiChip-label":{fontSize:{xs:"0.75rem",sm:"0.875rem"},px:{xs:1,sm:1.5}}}}),e.jsx(O,{title:u?"Sending...":"Send",children:e.jsx("span",{children:e.jsx(q,{color:"primary",onClick:Q,size:"small",sx:{ml:{xs:.5,sm:1},bgcolor:u?"action.disabled":"primary.main",color:"white","&:hover":{bgcolor:u?"action.disabled":"primary.dark",transform:u?"none":"scale(1.12)"},transition:"all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",boxShadow:2,"&:active":{transform:u?"none":"scale(0.95)"}},disabled:u||!S.trim()&&!h,children:u?e.jsx(p,{sx:{width:{xs:16,sm:24},height:{xs:16,sm:24},border:"2px solid #fff",borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite","@keyframes spin":{"0%":{transform:"rotate(0deg)"},"100%":{transform:"rotate(360deg)"}}}}):e.jsx(ts,{style:{fontSize:{xs:"1rem",sm:"1.2rem"}}})})})})]})}),e.jsx(Pe,{id:_,open:N,anchorEl:F,placement:"top-end",disablePortal:!0,popperOptions:{modifiers:[{name:"offset",options:{offset:[0,10]}}]},ref:l,children:e.jsx(Le,{onClickAway:ge,children:e.jsx(le,{elevation:8,content:!1,children:e.jsx(Ne,{onEmojiClick:he,defaultSkinTone:_e.DARK,autoFocusSearch:!1})})})})]})]})]})}),e.jsx(Ye,{open:be,setOpen:H,modFilename:t.modFile,uniqueId:t.uniqueId}),((re=(oe=t==null?void 0:t.dtc)==null?void 0:oe.dtcOffList)==null?void 0:re.length)>0&&e.jsx(G,{dialogSize:"sm",openDialog:we,handleDialogClose:()=>{B(!1),L("")},dialogTitle:`DTC Off Codes (${(t.dtc.dtcOffList||[]).length})`,dialogContent:e.jsxs(n,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(pe,{size:"small",placeholder:j.formatMessage({id:"common.searchCodes",defaultMessage:"Search codes..."}),value:P,onChange:s=>L(s.target.value),fullWidth:!0}),e.jsx(z,{variant:"outlined",color:"secondary",onClick:()=>L(""),children:e.jsx(d,{id:"common.clear",defaultMessage:"Clear"})})]}),hasAction:!1,children:e.jsx(p,{sx:{maxHeight:440},children:e.jsx(de,{children:e.jsx(n,{direction:"row",spacing:.75,flexWrap:"wrap",useFlexGap:!0,children:(t.dtc.dtcOffList||[]).filter(s=>P?String(s).toLowerCase().includes(P.toLowerCase()):!0).map(s=>e.jsx(g,{label:s,size:"small",variant:"outlined",sx:{m:.5}},s))})})})})]})});export{ys as default};
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.