"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4980],{34980:(e,t,n)=>{n.r(t),n.d(t,{Documentation:()=>D,default:()=>I,useStyles:()=>O});var o=n(37876),a=n(14232),l=n(18608),i=n(45756),r=n(77018),s=n(63724),d=n(38554),u=n(71538),c=n(54821),m=n(8733),p=n(81781),v=n(75850),b=n(69915),h=n(11934),C=n(52822),g=n(65103),x=n(77742),f=n(89996),N=n(52512),y=n(62222),A=n(84059),j=n(92636);let w=()=>{let[e,t]=(0,a.useState)(!1),[n,l]=(0,a.useState)(null),{userSession:i}=(0,j.j)(),{setGlobalSnackbarState:r}=(0,N.W)(),s=(0,x.A)();return{downloadCertificatePdf:async e=>{let{certificateContent:n,client:a}=e,{lotnumber:i,owner:d,term:u,type:c,unit:p}=n;try{t(!0);let{errors:e,data:n}=await a.query({query:h.ym,variables:{input:{unit:p,owner:d,term:u,type:c,lotnumber:i}}});if(e||!n||n.error)throw e;(0,C.lK)(n.pdfDownload,u)}catch(e){(c===g.e_.Coa||c===g.e_.Coo)&&l?l(c):r({open:!0,message:s.formatMessage({id:"NO_PRODUCT_DOC_ONLINE",defaultMessage:"In some cases, our product documentation may not be available online. Please {contactUs} to request a copy."},{contactUs:(0,o.jsx)(y.N,{href:f.mA.customerSupport(),children:(0,o.jsx)(m.A,{id:"CONTACT_US_LOWERCASE",defaultMessage:"contact us"})})}),variant:N.m$.Error})}finally{t(!1)}},showCertificatePdf:e=>{let{certificateContent:t,isCOA:n}=e,{brand:o,lotNumber:a,productNumber:l}=t,r=n?f.Or:f.Ce,s=(0,A.xS)(i,r.index(o,l||"",a||""));window.open(s.as,"_blank")},pdfLoading:e,certificateNotFoundModal:n,handlePDFLoading:t,handleCertificateNotFoundModal:l}};var _=n(38906),k=n(35152),E=n(4737);let O=(0,l.makeStyles)()(e=>({documentItemContainer:{marginBottom:e.spacing(2)},documentLink:{cursor:"pointer"},expandedLayout:{backgroundColor:e.palette.common.white,border:"1px solid ".concat(e.palette.grey[400]),borderRadius:e.shape.borderRadius,[e.breakpoints.up("md")]:{padding:e.spacing(6)},[e.breakpoints.down("lg")]:{border:"0px",padding:e.spacing(0,0,0)}},lotContentContainer:{margin:e.spacing(2,0)},lotNumber:{marginBottom:e.spacing(2)},title:{marginBottom:e.spacing(2)},titleContainer:{display:"block",marginBottom:e.spacing(1),[e.breakpoints.up("sm")]:{display:"flex",alignItems:"center"}}})),D=e=>{var t;let{brand:n,certificateType:l,documentType:h,isCrmProduct:C,isExpandedLayout:g=!0,productNumber:x,title:f}=e,N=(0,a.useRef)(!1),{data:y,loading:A}=(0,v.OM)({variables:{input:{brand:n,documentType:h,productNumber:x}}}),{downloadCertificatePdf:j,pdfLoading:D,showCertificatePdf:I}=w(),{classes:L,cx:T}=O(),M=null==y?void 0:null===(t=y.getCertificateContent)||void 0===t?void 0:t.content,S=h===b.U_.CofAnalysisDoc,B=(e,t)=>{(0,k.sendCertificatesDownloadEvent)({fileExtension:e,productNumber:x,lotNumber:t})},R=(e,t)=>{var o,a,i;(null==t?void 0:null===(o=t.text)||void 0===o?void 0:o.source)==="GDI"?(B("pdf",t.lotNumber),j({certificateContent:{lotnumber:null==t?void 0:t.lotNumber,owner:null==t?void 0:null===(a=t.text)||void 0===a?void 0:a.owner,term:x,type:l,unit:null==t?void 0:null===(i=t.text)||void 0===i?void 0:i.unit},client:e})):t.url?(B("html",t.lotNumber),window.open(t.url,"_blank")):(B("html",t.lotNumber),I({certificateContent:{brand:n,productNumber:x,lotNumber:null==t?void 0:t.lotNumber},isCOA:S}))};return(0,a.useEffect)(()=>{if(!N.current&&A){N.current=!0;return}(0,k.sendDocumentationImpressionEvent)({action:"coa search impression",detail:!C&&(null==M?void 0:M.length)?"coa list download":"coa unavailable",productId:x})},[null==M?void 0:M.length,C,A]),(0,o.jsx)(c.Y,{children:e=>{var t;return(0,o.jsxs)(i.A,{className:T(g&&L.expandedLayout),children:[(0,o.jsx)(r.A,{className:L.title,variant:"h3",children:f}),(0,o.jsx)(s.A,{className:L.lotContentContainer,container:!0,children:(0,o.jsx)(s.A,{xs:6,children:(0,o.jsx)(r.A,{variant:"caption",children:(0,o.jsx)(m.A,{id:"DOCUMENTATION_LOT_BATCH_NUMBER",defaultMessage:"Lot/Batch Number"})})})}),!C&&(null==M?void 0:null===(t=M.slice(0,5))||void 0===t?void 0:t.map(t=>(0,o.jsx)(s.A,{className:L.documentItemContainer,container:!0,children:(0,o.jsx)(s.A,{xs:6,children:(0,o.jsx)(d.A,{className:L.documentLink,onClick:()=>R(e,t),rel:"nofollow",children:null==t?void 0:t.lotNumber})})},null==t?void 0:t.id))),(null==M?void 0:M.length)&&!C?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(u.A,{}),(0,o.jsx)(_.Rp,{documentType:h,productNumber:x})]}):(0,o.jsx)(E.Y,{documentType:h,productNumber:x}),D&&(0,o.jsx)(p.A,{})]})}})},I=D}}]); //# sourceMappingURL=./4980.cd757b7023425d46.js.map