1"use strict";(globalThis.webpackChunkespiao_cloud=globalThis.webpackChunkespiao_cloud||[]).push([[9437],{86056(e,s,a){a.d(s,{LL:()=>t.A,Rp:()=>r.A});var t=a(8142),r=(a(21929),a(65276))},79437(e,s,a){a.r(s),a.d(s,{default:()=>V});var t=a(65043),r=a(599),i=a(84063),l=a(14282),n=a(33044),o=a(61072),d=a(78602),c=a(65758),m=a(69091),u=a(39440),h=a(76846),p=a(55257),x=a(98565),v=a(57650),g=a(2364),f=a(12593),j=a(8569),N=a(45479),b=a(30064),y=a.n(b),w=a(2511),A=a(47361),S=a(82431),C=a(86056),k=a(60452);const E=(e,s)=>{const a=new Date(e);a.setDate(a.getDate()+s);return`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`},D=(()=>{const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`})(),F=(E(D,-15),E(D,-180),E(D,15),E(D,-15),E(D,-175),E(D,45),E(D,-30),E(D,-200),E(D,-5),E(D,-30),E(D,-190),E(D,7),E(D,-45),E(D,-210),E(D,28),E(D,-10),E(D,-160),E(D,90),E(D,-10),E(D,-155),E(D,120),E(D,-20),E(D,-170),E(D,25),E(D,-20),E(D,-165),E(D,60),E(D,-5),E(D,-150),E(D,180),E(D,-8),E(D,-145),E(D,10),E(D,-8),E(D,-140),E(D,150),E(D,-25),E(D,-185),E(D,3),E(D,-25),E(D,-180),E(D,35),E(D,-35),E(D,-195),E(D,200),E(D,-60),E(D,-120),E(D,-50),E(D,-100),E(D,-40),E(D,-220),E(D,5),E(D,-12),E(D,-160),E(D,20),E(D,-18),E(D,-170),E(D,12),E(D,-22),E(D,-200),E(D,250),E(D,-14),E(D,-165),E(D,18),E(D,-7),E(D,-155),E(D,40),E(D,-28),E(D,-175),E(D,22),E(D,-33),E(D,-188),E(D,8),E(D,-16),E(D,-192),E(D,14),E(D,-24),E(D,-182),E(D,27),E(D,-19),E(D,-168),E(D,32),E(D,-11),E(D,-158),E(D,55),E(D,-26),E(D,-172),E(D,65),E(D,-9),E(D,-162),E(D,240),E(D,-13),E(D,-150),E(D,6),e=>{if(!e)return"\u2014";const s=e.split("T")[0],[a,t,r]=s.split("-").map(e=>parseInt(e,10)),i=new Date(a,t-1,r);return`${String(i.getDate()).padStart(2,"0")}/${String(i.getMonth()+1).padStart(2,"0")}/${i.getFullYear()}`}),$=e=>new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(e),L=(e,s)=>{const a=new Date(e)-new Date(s);return Math.ceil(a/864e5)},P=e=>{if(!e)return null;const s=e.split("T")[0],[a,t,r]=s.split("-").map(e=>parseInt(e,10));return new Date(a,t-1,r)},B=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;if(!e)return{variant:"secondary",text:"\u2014",days:null};const a=new Date;a.setHours(0,0,0,0);const t=P(e);if(!t)return{variant:"secondary",text:"\u2014",days:null};t.setHours(0,0,0,0);const r=L(t,a);return r<0?{variant:"danger",text:"Vencido",days:r}:r<=s?{variant:"warning",text:`Vence em ${r} dia${1!==r?"s":""}`,days:r}:{variant:"success",text:"OK",days:r}},I=e=>{if(!e)return{};const s=new Date;s.setHours(0,0,0,0);const a=P(e);if(!a)return{};a.setHours(0,0,0,0);return L(a,s)<0?{backgroundColor:"#f8d7da"}:{}},T=e=>{if(!e)return"";const s=e.replace(/\D/g,"");return 14!==s.length?e:s.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/,"$1.$2.$3/$4-$5")},z=e=>{if(null===e||void 0===e)return'""';return`"${String(e).replace(/\r\n/g,"\n").replace(/\r/g,"\n").replace(/"/g,'""')}"`};var O=a(41164),M=a(70579);const _=()=>[(0,N.A)(new Date,-90),new Date],V=e=>{let{empresaHook:s=null}=e;const a=(0,t.useContext)(k.Q),N=sessionStorage.getItem("ddesp"),b=N?JSON.parse((0,w.decode)(N)):null,E=null===b||void 0===b?void 0:b[3],D=null!=E?String(E):"0",P=(0,C.Rp)({userId:D,moduloAtual:a.state.moduloAtual,isMulti:!0,deferInit:!!s}),V=null!==s&&void 0!==s?s:P,{empselecionada:R,handleChangeEmpresa:q}=V,H=Array.isArray(R)?R:R?[R]:[],K=window.innerHeight>500?window.innerHeight-300:500,X=(0,t.useRef)(null),U=(0,t.useRef)(null),G=(0,t.useRef)(null),J=(0,t.useRef)(null),W=(0,t.useRef)(null),Z=(0,t.useRef)(null),[Q,Y]=(0,t.useState)(_),[ee,se]=(0,t.useState)([]),[ae,te]=(0,t.useState)("exata"),[re,ie]=(0,t.useState)(!1),[le,ne]=(0,t.useState)(30),[oe,de]=(0,t.useState)(!1),[ce,me]=(0,t.useState)([]),[ue,he]=(0,t.useState)([]),[pe,xe]=(0,t.useState)([]),[ve,ge]=(0,t.useState)([]),[fe,je]=(0,t.useState)({}),[Ne,be]=(0,t.useState)(!1),[ye,we]=(0,t.useState)(!1),[Ae,Se]=(0,t.useState)("todos"),[Ce,ke]=(0,t.useState)("+ Filtros"),[Ee,De]=(0,t.useState)("success"),[Fe,$e]=(0,t.useState)(null),[Le,Pe]=(0,t.useState)(()=>null!==localStorage.getItem(`periodoDoc${E}`)),[Be,Ie]=(0,t.useState)(()=>"1"===localStorage.getItem(`rastroLoteOcultarFornecedor${E}`)),[Te,ze]=(0,t.useState)(()=>"1"===localStorage.getItem(`rastroLoteIntroHidden${E}`)),[Oe,Me]=(0,t.useState)([]),[_e,Ve]=(0,t.useState)([]),[Re,qe]=(0,t.useState)([]),[He,Ke]=(0,t.useState)({nfesEncontradas:0,fornecedores:0,valorTotal:0,lotesAVencer:0});(0,t.useEffect)(()=>{const e=localStorage.getItem(`periodoDoc${E}`);if(null!==e)try{const s=JSON.parse(e);if(Array.isArray(s)&&s.length>=2){const e=new Date(s[0]),a=new Date(s[1]);Y([e,a])}}catch(s){localStorage.removeItem(`periodoDoc${E}`),Pe(!1)}},[E]);const Xe=Fe?Oe.filter(e=>{var s;const a=null!==(s=null===Fe||void 0===Fe?void 0:Fe.id)&&void 0!==s?s:null===Fe||void 0===Fe?void 0:Fe.value;if(null!=a&&null!=(null===e||void 0===e?void 0:e.empresaId))return Number(e.empresaId)===Number(a);const t=String((null===Fe||void 0===Fe?void 0:Fe.cnpj)||"").replace(/\D/g,"");if(t){return String((null===e||void 0===e?void 0:e.cnpjDestinatario)||"").replace(/\D/g,"").includes(t)}return!0}):Oe,Ue=Re.length>0?Xe.filter(e=>Re.some(s=>s.cnpj===e.cnpjEmitente)):Xe,Ge="todos"===Ae?Ue:Ue.filter(e=>{if(!e.dVal)return!1;const s=new Date;s.setHours(0,0,0,0);const a=new Date(e.dVal);a.setHours(0,0,0,0);const t=L(a,s);return"vencidos"===Ae?t<0:"avencer"===Ae?t>=0&&t<=le:"ok"!==Ae||t>le}),Je=[ee,ce,ue,pe,ve].some(e=>Array.isArray(e)?e.some(e=>String(e||"").trim().length>0):String(e||"").trim().length>0),We=e=>{let{selecionadas:s=[]}=e;const a=(Array.isArray(s)?s:s?[s]:[]).map(e=>{var s,a,t;return t=null!==(s=null!==(a=null===e||void 0===e?void 0:e.cnpj_cpf)&&void 0!==a?a:null===e||void 0===e?void 0:e.cnpj)&&void 0!==s?s:null===e||void 0===e?void 0:e.cnpj_cpf_responsavel,String(t||"").replace(/\D/g,"")}).filter(e=>e&&e.length>=8);
1return Array.from(new Set(a))},Ze=e=>e?"string"===typeof e?e:"object"===typeof e&&(e.url||e.link||e.downloadUrl)||"":"",Qe=e=>!e||""===e||null===e||"undefined"===e,Ye=(e,s)=>{var a,t,r;return[String(null!==(a=null===e||void 0===e?void 0:e.key)&&void 0!==a?a:"").trim(),String(null!==(t=null===e||void 0===e?void 0:e.nItem)&&void 0!==t?t:"").trim(),(e=>{const s=String(e||"").replace(/\D/g,"");return 44===s.length?s:""})(null===e||void 0===e?void 0:e.chaveNfe),String(null!==(r=null===e||void 0===e?void 0:e.lote)&&void 0!==r?r:"").trim()].filter(e=>e&&String(e).length>0).join("|")||String(s)},es=(0,t.useMemo)(()=>{if(!Array.isArray(Q)||null===Q||void 0===Q||!Q[0]||null===Q||void 0===Q||!Q[1])return"";const e=new Intl.DateTimeFormat("pt-BR");return`${e.format(new Date(Q[0]))} at\xe9 ${e.format(new Date(Q[1]))}`},[Q]),ss=e=>{let{containerRef:s,currentTags:a,setTags:t,disabled:r}=e;if(r)return Array.isArray(a)?a:[];const i=String((e=>{const s=null===e||void 0===e?void 0:e.current;if(!s)return"";const a=s.querySelector("input");return a&&"string"===typeof a.value?a.value:""})(s)||"").trim(),l=Array.isArray(a)?a:[];if(!i)return l;const n=i.split(",").map(e=>String(e||"").trim()).filter(e=>e.length>0);if(0===n.length)return l;const o=new Set(l.map(e=>String(e||"").trim()).filter(e=>e.length>0)),d=[...l];n.forEach(e=>{o.has(e)||(o.add(e),d.push(e))}),d.length!==l.length&&t(d);const c=null===s||void 0===s?void 0:s.current,m=c?c.querySelector("input"):null;return m&&"string"===typeof m.value&&(m.value=""),d},as=(0,t.useMemo)(()=>{const e=new Set,s=new Set,a=new Set,t=new Date;t.setHours(0,0,0,0),(Oe||[]).forEach(r=>{const i=String((null===r||void 0===r?void 0:r.lote)||"").trim();if(i&&e.add(i),!i||null===r||void 0===r||!r.dVal)return;const l=(e=>{if(!e)return null;const s=String(e).split("T")[0],[a,t,r]=s.split("-").map(e=>parseInt(e,10));return a&&t&&r?new Date(a,t-1,r):null})(r.dVal);if(!l)return;l.setHours(0,0,0,0);const n=L(l,t);n<0?s.add(i):n>le&&a.add(i)});const r=(null===He||void 0===He?void 0:He.nfesEncontradas)>0?((null===He||void 0===He?void 0:He.valorTotal)||0)/He.nfesEncontradas:0;return{itens:Array.isArray(Oe)?Oe.length:0,lotesUnicos:e.size,lotesVencidos:s.size,lotesOk:a.size,mediaPorNfe:r}},[Oe,le,He,L]),ts=e=>{if(e&&e.chaveNfe&&e.cnpjEmitente){y().fire({title:"Gerando XML",html:"Estamos gerando o XML para voc\xea!",icon:"info",allowOutsideClick:!1,didOpen:()=>{y().showLoading()}});try{const s=[e.chaveNfe,e.cnpjEmitente];S.A.post("/api/historyNfe/",{dest:"downXML",dataPost:s}).then(s=>{const a=s.data;y().hideLoading(),y().update({title:"Pronto!",html:'XML gerado com sucesso!<br/><br/><span class="f-14">Caso o download n\xe3o tenha iniciado,<br/> verifique a permiss\xe3o de pop-ups do seu navegador.</span>',icon:"success",allowOutsideClick:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"}),((e,s)=>{const a=`${s}.xml`,t=document.createElement("a");t.download=a,t.href=window.URL.createObjectURL(new File([e],a,{type:"text/xml"})),t.click(),window.URL.revokeObjectURL(t.href)})(a,e.chaveNfe)}).catch(e=>{y().hideLoading(),y().fire({title:"Ops!",html:"Ocorreu um erro ao gerar o XML, tente novamente daqui a alguns minutos.",icon:"error",allowOutsideClick:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"})})}catch(s){y().hideLoading(),y().fire({icon:"error",title:"Erro ao gerar XML",text:(null===s||void 0===s?void 0:s.message)||"N\xe3o foi poss\xedvel gerar o XML"})}}else y().fire({icon:"error",title:"Erro ao gerar XML",text:"Item inv\xe1lido"})},rs=(0,t.useMemo)(()=>[{id:"acao",header:"A\xe7\xe3o",size:120,Cell:e=>{let{row:s}=e;return(0,M.jsx)("div",{children:(0,M.jsxs)(r.A,{children:[(0,M.jsx)(A.A,{title:"Visualizar DANFE",arrow:!0,children:(0,M.jsx)("a",{href:"#!",className:"badge badge-light-success mr-2 pointer",onClick:e=>{e.preventDefault(),(s=>{if(s&&s.chaveNfe&&s.cnpjEmitente){y().fire({title:"Gerando DANFE",html:"Estamos gerando o DANFE para voc\xea!",icon:"info",allowOutsideClick:!1,didOpen:()=>{y().showLoading()}});try{const e=[s.chaveNfe,s.cnpjEmitente];S.A.post("/api/historyNfe/",{dest:"printDanfe",dataPost:e}).then(e=>{const s=e.data;y().fire({title:"Pronto!",html:"O DANFE foi gerado com sucesso e ser\xe1 aberto em uma nova aba.",icon:"success",allowOutsideClick:!0,showConfirmButton:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"}).then(()=>{window.open(s,"_blank"),y().hideLoading(),y().close()})}).catch(e=>{y().hideLoading(),y().fire({title:"Ops!",html:"Ocorreu um erro ao gerar o DANFE, tente novamente daqui a alguns minutos.",icon:"error",allowOutsideClick:!0,showConfirmButton:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"})})}catch(e){y().hideLoading(),y().fire({icon:"error",title:"Erro ao abrir DANFE",text:(null===e||void 0===e?void 0:e.message)||"N\xe3o foi poss\xedvel gerar a DANFE"})}}else y().fire({icon:"error",title:"Erro ao abrir DANFE",text:"Item inv\xe1lido"})})(s.original)},children:(0,M.jsx)("i",{className:"far fa-file f-12"})})}),(0,M.jsx)(A.A,{title:"Baixar XML",arrow:!0,children:(0,M.jsx)("a",{href:"#!",className:"badge badge-light-primary mr-2 pointer",onClick:e=>{e.preventDefault(),ts(s.original)},children:(0,M.jsx)("i",{className:"fa fa-download f-12"})})})]})})}},{accessorKey:"lote",header:"Lote",size:120}
1,{accessorKey:"dVal",header:"Validade",size:150,Cell:e=>{let{cell:s}=e;const a=s.getValue(),t=B(a,le);return(0,M.jsxs)("div",{children:[(0,M.jsx)("div",{children:F(a)}),(0,M.jsx)(i.A,{bg:t.variant,className:"mt-1",children:t.text})]})}},{accessorKey:"emissao",header:"Emiss\xe3o",size:100,Cell:e=>{let{cell:s}=e;return F(s.getValue())}},{id:"fornecedor",header:"Fornecedor",size:200,Cell:e=>{let{row:s}=e;return(0,M.jsxs)("div",{children:[(0,M.jsx)("div",{style:{fontSize:"12px",fontWeight:"bold"},children:T(s.original.cnpjEmitente)}),(0,M.jsx)("div",{style:{fontSize:"11px",color:"#666"},children:s.original.fornecedorNome||"\u2014"})]})}},{id:"nf",header:"NF",size:120,Cell:e=>{let{row:s}=e;return(0,M.jsxs)("div",{children:[(0,M.jsxs)("div",{style:{fontSize:"12px"},children:[s.original.nNf,"/",s.original.serie]}),(0,M.jsx)(l.A,{size:"sm",variant:"link",className:"rounded",style:{fontSize:"11px",padding:0},onClick:()=>(e=>{if(e&&e.chaveNfe&&e.cnpjEmitente){y().fire({title:"Gerando DANFE",html:"Estamos gerando o DANFE para voc\xea!",icon:"info",allowOutsideClick:!1,didOpen:()=>{y().showLoading()}});try{const s=[e.chaveNfe,e.cnpjEmitente];S.A.post("/api/historyNfe/",{dest:"printDanfe",dataPost:s}).then(e=>{const s=e.data;y().fire({title:"Pronto!",html:"O DANFE foi gerado com sucesso e ser\xe1 aberto em uma nova aba.",icon:"success",allowOutsideClick:!0,showConfirmButton:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"}).then(()=>{window.open(s,"_blank"),y().hideLoading(),y().close()})}).catch(e=>{y().hideLoading(),y().fire({title:"Ops!",html:"Ocorreu um erro ao gerar o DANFE, tente novamente daqui a alguns minutos.",icon:"error",allowOutsideClick:!0,showConfirmButton:!0,confirmButtonText:"OK",confirmButtonColor:"#297BEA"})})}catch(s){y().hideLoading(),y().fire({icon:"error",title:"Erro ao abrir DANFE",text:(null===s||void 0===s?void 0:s.message)||"N\xe3o foi poss\xedvel gerar a DANFE"})}}else y().fire({icon:"error",title:"Erro ao abrir DANFE",text:"Item inv\xe1lido"})})(s.original),children:"Abrir NF"})]})}},{id:"produto",header:"Produto",size:250,Cell:e=>{let{row:s}=e;return(0,M.jsxs)("div",{children:[(s.original.cProd||s.original.codigoProduto)&&(0,M.jsxs)("div",{style:{fontSize:"11px",color:"#666"},children:["C\xf3d: ",s.original.cProd||s.original.codigoProduto]}),(0,M.jsx)("div",{style:{fontSize:"12px"},children:s.original.xProd}),s.original.ncm&&(0,M.jsxs)("div",{style:{fontSize:"11px",color:"#666"},children:["NCM: ",s.original.ncm]})]})}},{id:"qtde",header:"Qtde/Un",size:100,Cell:e=>{let{row:s}=e;return(0,M.jsxs)("div",{style:{textAlign:"right"},children:[s.original.qCom," ",s.original.uCom]})}},{accessorKey:"vProd",header:"Valor",size:110,Cell:e=>{let{cell:s}=e;return(0,M.jsx)("div",{style:{textAlign:"right"},children:$(s.getValue())})}},{id:"cst",header:"CST/ICMS",size:120,Cell:e=>{let{row:s}=e;return(0,M.jsxs)("div",{style:{fontSize:"11px"},children:[s.original.cstIcms&&(0,M.jsxs)("div",{children:["CST: ",s.original.cstIcms]}),null!=s.original.pIcms&&(0,M.jsxs)("div",{children:[s.original.pIcms,"%"]}),null!=s.original.vIcms&&(0,M.jsx)("div",{children:$(s.original.vIcms)})]})}}],[le]);return(0,M.jsxs)("div",{className:"rastreabilidade-por-lote",children:[(0,M.jsxs)(n.A,{className:"mb-3 shadow-sm",children:[(0,M.jsx)("div",{className:"mt-3 ml-3",children:(0,M.jsxs)("h6",{className:"text-muted mb-1",children:[(0,M.jsx)("span",{className:"mdi mdi-magnify mr-2"}),"Rastreabilidade por lote "]})}),(0,M.jsxs)(n.A.Body,{children:[!Te&&(0,M.jsx)("div",{className:"page-banner",children:(0,M.jsxs)("div",{className:"page-banner__top",children:[(0,M.jsxs)("div",{children:[(0,M.jsxs)("h5",{className:"page-banner__title",children:[(0,M.jsx)("i",{className:"mdi mdi-crosshairs-gps mr-2"}),"Rastreio por Lote"]}),(0,M.jsx)("p",{className:"page-banner__desc",children:"Monitore a origem e a validade dos produtos a partir dos lotes informados nas NF-e. Identifique itens vencidos, a vencer e os fornecedores envolvidos, garantindo mais controle e seguran\xe7a sobre sua opera\xe7\xe3o."})]}),(0,M.jsx)("button",{type:"button",className:"close page-banner__action","aria-label":"Fechar",onClick:()=>{ze(!0),localStorage.setItem(`rastroLoteIntroHidden${E}`,"1")}
1,children:(0,M.jsx)("span",{"aria-hidden":"true",children:"\xd7"})})]})}),(0,M.jsxs)(o.A,{className:"mb-2",children:[(0,M.jsxs)(d.A,{lg:5,children:[(0,M.jsx)(C.LL,{hook:V,isMulti:!0,disabled:!1,showGruposButton:!0,showModeToggle:!0})," ",(0,M.jsxs)("div",{className:"border-start ps-4",children:[(0,M.jsx)(h.A,{checked:re,onChange:(e,s)=>ie(s),children:(0,M.jsx)("span",{className:"fw-bold",children:"Lotes com validade pr\xf3xima"})}),re&&(0,M.jsx)("div",{className:"text-muted small mt-1",children:"Com esta opcao ativa, os filtros por lote/produto ficam desativados."}),re&&(0,M.jsx)("div",{className:"mt-3 d-flex align-items-end gap-2",children:(0,M.jsxs)("div",{style:{minWidth:"200px"},children:[(0,M.jsx)(c.A.Label,{className:"small text-muted mb-1",children:"Dias at\xe9 vencimento"}),(0,M.jsx)(c.A.Control,{type:"number",min:"1",max:"365",value:le,onChange:e=>ne(parseInt(e.target.value,10)||30),size:"sm",style:{width:"120px"}}),(0,M.jsx)(i.A,{variant:"light-success",text:"dark",className:"mt-1",children:"Filtro ativo"})]})})]})]}),(0,M.jsxs)(d.A,{lg:3,children:[(0,M.jsx)(c.A.Label,{className:"fw-bold mb-2",children:"Lote(s)"}),(0,M.jsx)("div",{ref:U,children:(0,M.jsx)(v.u,{value:ee,onChange:e=>se([...e]),placeHolder:"Insira os lotes (opcional)",name:"lotes",disabled:re})}),re&&(0,M.jsx)(c.A.Text,{className:"text-muted",children:"Desativado quando validade pr\xf3xima estiver ativa."})]})," ",(0,M.jsxs)(d.A,{lg:4,children:[(0,M.jsx)(c.A.Label,{className:"fw-bold mb-2",children:"Per\xedodo"}),(0,M.jsx)(A.A,{title:"Mant\xe9m o per\xedodo salvo para ser utilizado nas pr\xf3ximas pesquisas.",arrow:!0,placement:"top-start",children:(0,M.jsx)("span",{className:"mdi mdi-information float-right text-primary pointer ml-lg-n2 ml-md-n2 ml-sm-n2 f-12"})}),(0,M.jsx)(c.A.Check,{inline:!0,className:" ml-3 float-right",disabled:re,checked:Le,onChange:e=>{const s=e.target.checked;Pe(s),s?localStorage.setItem(`periodoDoc${E}`,JSON.stringify(Q)):localStorage.removeItem(`periodoDoc${E}`)},label:"Fixar per\xedodo",type:"checkbox",id:"checkPeriodo"}),(0,M.jsx)("div",{style:{opacity:re?.6:1,pointerEvents:re?"none":"auto"},children:(0,M.jsx)(O.A,{periodo:Q,setPeriodo:Y,exibeMaisFiltros:!0,setmaisF:de,maisF:oe,textBtnFiltros:Ce,setTextBtnFiltros:ke,bgBtnFiltros:Ee,setBgBtnFiltros:De})}),re&&(0,M.jsx)(c.A.Text,{className:"text-muted",children:"Periodo bloqueado enquanto validade pr\xf3xima estiver ativa."})]})]}),oe&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("hr",{className:"my-4"}),(0,M.jsxs)("div",{className:"bg-light p-3 rounded-3 mb-4",children:[(0,M.jsx)("h6",{className:"fw-bold mb-3",children:"Filtros Avan\xe7ados"}),(0,M.jsxs)(o.A,{className:"g-3",children:[(0,M.jsxs)(d.A,{md:6,lg:3,children:[(0,M.jsx)(c.A.Label,{className:"small fw-bold",children:"C\xf3digo do Produto / NCM"}),(0,M.jsx)("div",{ref:G,children:(0,M.jsx)(v.u,{value:ce,onChange:e=>me([...e]),placeHolder:"Ex: 000123 ou 30049099",name:"codigoProduto",disabled:re})})]}),(0,M.jsxs)(d.A,{md:6,lg:3,children:[(0,M.jsx)(c.A.Label,{className:"small fw-bold",children:"Descri\xe7\xe3o do Produto"}),(0,M.jsx)("div",{ref:J,children:(0,M.jsx)(v.u,{value:ue,onChange:e=>he([...e]),placeHolder:"Digite a descri\xe7\xe3o",name:"descricaoProduto",disabled:re})})]}),(0,M.jsxs)(d.A,{md:6,lg:3,children:[(0,M.jsx)(c.A.Label,{className:"small fw-bold",children:"N\xfamero da NF-e"}),(0,M.jsx)("div",{ref:W,children:(0,M.jsx)(v.u,{value:pe,onChange:e=>xe([...e]),placeHolder:"Ex: 12345",name:"numeroNfe",disabled:re})})]}),(0,M.jsxs)(d.A,{md:6,lg:3,children:[(0,M.jsx)(c.A.Label,{className:"small fw-bold",children:"Chave de Acesso"}),(0,M.jsx)("div",{ref:Z,children:(0,M.jsx)(v.u,{value:ve,onChange:e=>ge([...e]),placeHolder:"44 d\xedgitos",name:"chaveAcesso",disabled:re})})]})]})]})]}),(0,M.jsx)(o.A,{className:" justify-content-center align-items-center",children:!re&&Je&&(0,M.jsxs)(d.A,{sm:3,className:"text-center d-flex flex-column align-items-center",children:[(0,M.jsx)(c.A.Label,{className:"fw-bold mb-3",children:"Tipo de Busca"}),(0,M.jsxs)(p.A,{name:"tipoBusca",className:"text-center",value:ae,onChange:e=>te(e),disabled:re,inline:!0,children:[(0,M.jsx)(x.A,{value:"exata",className:"mr-3",children:"Exata"}),(0,M.jsx)(x.A,{value:"contem",className:"mr-3",children:"Cont\xe9m"}),(0,M.jsx)(x.A,{value:"inicia",children:"Inicia com"})]})]})}),(0,M.jsx)(n.A.Footer,{className:"",children:(0,M.jsx)(o.A,{className:"g
1-2 justify-content-center",children:(0,M.jsxs)(d.A,{className:"text-center",children:[(0,M.jsxs)(l.A,{variant:"link",size:"sm",className:"rounded",onClick:()=>{qe([]),$e(null),we(!1),Se("todos"),Me([]),Ve([]),Ke({nfesEncontradas:0,fornecedores:0,valorTotal:0,lotesAVencer:0}),je({})},disabled:Ne,children:[(0,M.jsx)("i",{className:"mdi mdi-refresh mr-2"}),"Limpar"]}),(0,M.jsx)(l.A,{variant:"primary",className:"rounded ml-3",size:"sm",onClick:async()=>{if(Ne)return;const e=ss({containerRef:U,currentTags:ee,setTags:se,disabled:re}),s=ss({containerRef:G,currentTags:ce,setTags:me,disabled:re}),a=ss({containerRef:J,currentTags:ue,setTags:he,disabled:re}),t=ss({containerRef:W,currentTags:pe,setTags:xe,disabled:re}),r=ss({containerRef:Z,currentTags:ve,setTags:ge,disabled:re});we(!0),be(!0),qe([]),$e(null),Se("todos"),Me([]),Ve([]),Ke({nfesEncontradas:0,fornecedores:0,valorTotal:0,lotesAVencer:0}),je({});const i={empresas:(H||[]).map(e=>({id:null===e||void 0===e?void 0:e.value,cnpj:null===e||void 0===e?void 0:e.cnpj_cpf,label:null===e||void 0===e?void 0:e.label})),cnpjsParaPesquisa:We({selecionadas:H}),periodo:Array.isArray(Q)?[null!==Q&&void 0!==Q&&Q[0]?new Date(Q[0]).toISOString():null,null!==Q&&void 0!==Q&&Q[1]?new Date(Q[1]).toISOString():null]:null,lotes:(e||[]).join(","),tipoBusca:ae,validadeProxima:re,xDias:le,codigoProduto:(s||[]).join(","),descricaoProduto:(a||[]).join(","),numeroNfe:(t||[]).join(","),chaveAcesso:(r||[]).join(",")};try{var l;const o=await S.A.post("/api/rastroNfe/",{dest:"pesqLotes",dataPost:i}),d=null!==o&&void 0!==o&&null!==(l=o.data)&&void 0!==l&&l.items&&Array.isArray(o.data.items)?o.data.items:[];if(0===d.length){const i=[];e&&e.length>0&&i.push(`Lotes: ${e.join(", ")}`),s&&s.length>0&&i.push(`C\xf3digo Produto: ${s.join(", ")}`),a&&a.length>0&&i.push(`Descri\xe7\xe3o Produto: ${a.join(", ")}`),t&&t.length>0&&i.push(`N\xfamero NF-e: ${t.join(", ")}`),r&&r.length>0&&i.push(`Chave Acesso: ${r.join(", ")}`),re&&i.push(`Vencimento pr\xf3ximo (${le} dias)`);const l=i.length>0?`Filtros aplicados:\n\n${i.join("\n")}\n\nTente ajustar os filtros e buscar novamente.`:"Nenhum lote encontrado com os filtros aplicados.\n\nTente ajustar os filtros e buscar novamente.";y().fire({icon:"info",title:"Nenhum lote localizado",html:`<div>${n=l,String(null!==n&&void 0!==n?n:"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</div>`,confirmButtonText:"OK"}),Me([]),Ve([]),Ke({nfesEncontradas:0,fornecedores:0,valorTotal:0,lotesAVencer:0})}else{const e=function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"emissao",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"desc";const t=[...e];return t.sort((e,t)=>{let r,i;switch(s){case"validade":r=e.dVal?new Date(e.dVal):new Date("9999-12-31"),i=t.dVal?new Date(t.dVal):new Date("9999-12-31");break;case"emissao":r=new Date(e.emissao),i=new Date(t.emissao);break;case"lote":r=e.lote||"",i=t.lote||"";break;case"produto":r=e.xProd||"",i=t.xProd||"";break;case"valor":r=e.vProd||0,i=t.vProd||0;break;default:return 0}return r<i?"asc"===a?-1:1:r>i?"asc"===a?1:-1:0}),t}(d,re?"validade":"emissao",re?"asc":"desc");Me(e),Ve((e=>{const s=new Map;return e.forEach(e=>{const a=e.cnpjEmitente;s.has(a)||s.set(a,{cnpj:e.cnpjEmitente,nome:e.fornecedorNome,uf:e.ufEmitente})}),Array.from(s.values()).sort((e,s)=>(e.nome||"").localeCompare(s.nome||""))})(e)),Ke(function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:30;const a=new Set(e.map(e=>e.chaveNfe)),t=new Set(e.map(e=>e.cnpjEmitente)),r=e.reduce((e,s)=>e+(parseFloat(s.vProd)||0),0),i=new Date;i.setHours(0,0,0,0);const l=new Set;return e.forEach(e=>{if(!e.dVal)return;const a=new Date(e.dVal);a.setHours(0,0,0,0);const t=L(a,i);t>=0&&t<=s&&l.add(e.lote)}),{nfesEncontradas:a.size,fornecedores:t.size,valorTotal:r,lotesAVencer:l.size}}(e,le)),setTimeout(()=>{X.current&&X.current.scrollIntoView({behavior:"smooth",block:"start"})},500)}je({})}catch(o){y().fire({icon:"error",title:"Erro ao buscar",text:(null===o||void 0===o?void 0:o.message)||"N\xe3o foi poss\xedvel consultar rastreabilidade agora."}),Me([])}finally{be(!1)}var n},disabled:0===H.length||Ne,children:Ne?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("i",{className:"mdi mdi-loading mdi-spin mr-2"}),"Buscando..."]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("i",{className:"mdi mdi-magnify mr-2"}),"Buscar"]})})]})})})]})]}),Oe.length>0&&(0,M.jsxs)(o.A,{className:"justify-content-center mb-0",children:[(0,M.jsx)(d.A,{sm:6,lg:3,children:(0,M.jsx)(n.A,{className:"summary-card mb-3 summary-card--nfe",children:(0,M.jsx)(n.A.Body,{children:(0,M.jsxs)("div",{className:"summary-card__row",children:[(0,M.jsxs)("div",{className:"summary-card__text",children:[(0,M.jsx)("div",{className:"d-flex align-items-start justify-content-between gap-2",children:(0,M.jsx)("div",{className:"summary-label mb-0",children:"NF-es encontradas"})}),(0,M.jsx)("div",{className:"summary-value",children:He.nfesEncontradas}),es&&(0,M.jsxs)("div",{className:"summary-meta",children:["Per\xedodo: ",es]}),(0,M.jsxs)("div",{className:"mt-2 pt-2 border-top",children:[(0,M.jsxs)("div",{className:"summary-detail-row small text-muted",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Itens"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:as.itens})]}),(0,M.jsxs)("div",{className:"summary-detail-row small text-muted mt-1",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Lotes \xfanicos"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:as.lotesUnicos})]})]})]}),(0,M.jsx)("div",{className:"summary-card__icon","aria-hidden":!0,
1children:(0,M.jsx)("i",{className:"mdi mdi-file-document-multiple-outline"})})]})})})}),(0,M.jsx)(d.A,{sm:6,lg:3,children:(0,M.jsx)(n.A,{className:"summary-card mb-3 summary-card--forn",children:(0,M.jsx)(n.A.Body,{children:(0,M.jsxs)("div",{className:"summary-card__row",children:[(0,M.jsxs)("div",{className:"summary-card__text",children:[(0,M.jsx)("div",{className:"summary-label",children:"Fornecedores"}),(0,M.jsx)("div",{className:"summary-value",children:He.fornecedores}),(0,M.jsxs)("div",{className:"mt-2 pt-2 border-top",children:[(0,M.jsxs)("div",{className:"summary-detail-row small text-muted",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Filtro"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:Re.length>0?`${Re.length} selecionado(s)`:"nenhum"})]}),(0,M.jsxs)("div",{className:"summary-detail-row small text-muted mt-1",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Emitentes listados"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:_e.length})]})]})]}),(0,M.jsx)("div",{className:"summary-card__icon","aria-hidden":!0,children:(0,M.jsx)("i",{className:"mdi mdi-account-multiple-outline"})})]})})})}),(0,M.jsx)(d.A,{sm:6,lg:3,children:(0,M.jsx)(n.A,{className:"summary-card mb-3 summary-card--valor",children:(0,M.jsx)(n.A.Body,{children:(0,M.jsxs)("div",{className:"summary-card__row",children:[(0,M.jsxs)("div",{className:"summary-card__text",children:[(0,M.jsx)("div",{className:"summary-label",children:"Valor total"}),(0,M.jsx)("div",{className:"summary-value",children:$(He.valorTotal)}),(0,M.jsxs)("div",{className:"mt-2 pt-2 border-top",children:[(0,M.jsxs)("div",{className:"summary-detail-row small text-muted",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"M\xe9dia por NF-e"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:$(as.mediaPorNfe)})]}),(0,M.jsxs)("div",{className:"summary-detail-row small text-muted mt-1",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Registros"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:Oe.length})]})]})]}),(0,M.jsx)("div",{className:"summary-card__icon","aria-hidden":!0,children:(0,M.jsx)("i",{className:"mdi mdi-cash-multiple"})})]})})})}),(0,M.jsx)(d.A,{sm:6,lg:3,children:(0,M.jsx)(n.A,{className:"summary-card mb-3 summary-card--avencer",children:(0,M.jsx)(n.A.Body,{children:(0,M.jsxs)("div",{className:"summary-card__row",children:[(0,M.jsxs)("div",{className:"summary-card__text",children:[(0,M.jsxs)("div",{className:"summary-label",children:["Lotes a vencer (\u2264 ",le," dias)"]}),(0,M.jsx)("div",{className:"summary-value text-warning",children:He.lotesAVencer}),(0,M.jsxs)("div",{className:"mt-2 pt-2 border-top",children:[(0,M.jsxs)("div",{className:"summary-detail-row small text-muted",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"Vencidos"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:as.lotesVencidos})]}),(0,M.jsxs)("div",{className:"summary-detail-row small text-muted mt-1",children:[(0,M.jsx)("span",{className:"summary-detail-label",children:"OK"})," ",(0,M.jsx)("span",{className:"summary-detail-value fw-bold text-dark",children:as.lotesOk})]})]})]}),(0,M.jsx)("div",{className:"summary-card__icon","aria-hidden":!0,children:(0,M.jsx)("i",{className:"mdi mdi-alert-circle-outline"})})]})})})})]}),Oe.length>0&&(0,M.jsx)(n.A,{className:"mb-3",ref:X,children:(0,M.jsxs)(n.A.Body,{children:[(0,M.jsx)(o.A,{className:"mb-2",children:(0,M.jsx)(d.A,{md:12,children:(0,M.jsxs)("h6",{className:"text-muted mb-3",children:[(0,M.jsx)("i",{className:"mdi mdi-calendar-alert mr-2"}),"Filtro r\xe1pido por Status de Validade"]})})}),(0,M.jsx)(o.A,{children:(0,M.jsxs)(d.A,{md:12,className:"d-flex gap-2 flex-wrap",children:[(0,M.jsxs)("div",{className:"mr-2 badge p-2 cursor-pointer "+("todos"===Ae?"bg-primary text-white":"bg-light text-dark border"),onClick:()=>Se("todos"),style:{cursor:"pointer",userSelect:"none"},title:"Mostrar todos os itens",children:[(0,M.jsx)("i",{className:"mdi mdi-checkbox-marked-circle-outline mr-1"}),"Todos (",Ue.length,")"]}),(0,M.jsxs)("div",{className:"mr-2 badge p-2 cursor-pointer "+("vencidos"===Ae?"bg-danger text-white":"bg-light text-dark border"),onClick:()=>Se("vencidos"),style:{cursor:"pointer",userSelect:"none"},title:"Mostrar itens vencidos",children:[(0,M.jsx)("i",{className:"mdi mdi-close-circle-outline mr-1"}),"Vencidos"]}),(0,M.jsxs)("div",{className:"mr-2 badge p-2 cursor-pointer "+("avencer"===Ae?"bg-warning text-dark":"bg-light text-dark border"),onClick:()=>Se("avencer"),style:{cursor:"pointer",userSelect:"none"},title:`Mostrar itens a vencer em at\xe9 ${le} dias`,children:[(0,M.jsx)("i",{className:"mdi mdi-alert-circle-outline mr-1"}),"A vencer (\u2264 ",le,"d)"]}),(0,M.jsxs)("div",{className:"badge p-2 cursor-pointer "+("ok"===Ae?"bg-success text-white":"bg-light text-dark border"),onClick:()=>Se("ok"),style:{cursor:"pointer",userSelect:"none"},title:`Mostrar itens com validade maior que ${le} dias`,children:[(0,M.jsx)("i",{className:"mdi mdi-check-circle-outline mr-1"}),"V\xe1lidos (",`>${le}d`,")"]})]})}),_e.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("hr",{className:"my-3"}),(0,M.jsx)(o.A,{className:"mb-2",children:(0,M.jsxs)(d.A,{md:12,className:"d-flex align-items-center justify-content-between flex-wrap gap-2",children:[(0,M.jsxs)("h6",{className:"text-muted mb-3",children:[(0,M.jsx)("i",{className:"mdi mdi-filter-multiple mr-2"}),"Filtros r\xe1pidos por Fornecedor"]}),(0,M.jsx)(l.A,{variant:"outline-secondary",size:"sm",className:"rounded",onClick:()=>{const e=!Be;Ie(e),localStorage.setItem(`rastroLoteOcultarFornecedor${E}`,e?"1":"0")},children:Be?"Mostrar":"Ocultar"})]})}),!Be&&(0,M.jsxs)(o.A,{className:"mb-3",children:[(0,M.jsxs)(d.A,{md:4,children:[(0,M.jsx)(c.A.Label,{children:"Selecionar Fornecedores"}),(0,M.jsx)(g.Ay,{options:_e.map(e=>({value:e.cnpj,label:`${T(e.cnpj)} - ${e.nome} (${e.uf})`,emitente:e})),value:Re.map(e=>({value:e.cnpj,label:`${T(e.cnpj)} - ${e.nome} (${e.uf})`,emitente:e})),onChange:e=>{e&&e.length>0?qe(e.map(e=>e.emitente)):qe([])},isMulti:!0,isSearchable:!0,isClearable:!0,placeholder:"Selecione um ou mais fornecedores...",noOptionsMessage:()=>"Nenhum fornecedor encontrado",styles:{control:e=>({...e,fontSize:"14px",borderRadius:"4px"}),option:e=>({...e,fontSize:"13px"}),menu:e=>({...e,zIndex:1050}),menuPortal:e=>({...e,zIndex:1050})},menuPortalTarget:document.body})]}),(0,M.jsxs)(d.A,{md:8,className:"d-flex align-items-end gap-3",children:[Re.length>0&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(l.A,{variant:"info",size:"sm",className:"rounded mr-2",onClick:async()=>{const e=[...new Set((Ge||[]).map(e=>
1null===e||void 0===e?void 0:e.key).filter(Boolean))];if(0!==e.length){y().fire({title:"Gerando arquivo ZIP",html:`Processando ${e.length} NF-e(s)...`,icon:"info",allowOutsideClick:!1,didOpen:()=>{y().showLoading()}});try{const s=[{original:"",key:e,tipo:0,doc:0,orig:"lote",email:""}],a=await S.A.post("/api/historyNfe/",{dest:"downloadLote",dataPost:s}),t=Ze(a.data);if(y().close(),Qe(t))return void y().fire({icon:"error",title:"Erro",text:"Nenhum documento encontrado para download."});window.open(t,"_blank"),y().fire({icon:"success",title:"Download iniciado",text:`Arquivo ZIP com ${e.length} XML(s) est\xe1 sendo baixado!`,timer:2500})}catch(t){var s,a;y().close(),y().fire({icon:"error",title:"Erro no download",text:(null===t||void 0===t||null===(s=t.response)||void 0===s||null===(a=s.data)||void 0===a?void 0:a.message)||(null===t||void 0===t?void 0:t.message)||"N\xe3o foi poss\xedvel baixar os arquivos"})}}else y().fire({icon:"warning",title:"Nenhum item",html:"Nenhuma NF-e dispon\xedvel para download neste lote."})},title:"Baixar todos os XMLs dos fornecedores selecionados",children:[(0,M.jsx)("i",{className:"mdi mdi-download mr-1"}),"Baixar lote (",Ge.length," items)"]}),(0,M.jsxs)(l.A,{variant:"outline-info",size:"sm",className:"rounded mr-2",onClick:()=>{const e=[...new Set(Ge.map(e=>e.chaveNfe))];y().fire({icon:"info",title:"NF-es dos fornecedores",text:`${e.length} NF-e(s) encontrada(s)`})},children:[(0,M.jsx)("i",{className:"mdi mdi-information mr-1"}),"Info"]})]}),(0,M.jsxs)(l.A,{variant:"outline-secondary",size:"sm",className:"rounded",onClick:()=>qe([]),disabled:0===Re.length,children:[(0,M.jsx)("i",{className:"mdi mdi-close mr-1"}),"Limpar filtro"]})]})]})]})]})}),Oe.length>0&&(0,M.jsx)(n.A,{children:(0,M.jsxs)(n.A.Body,{children:[(0,M.jsx)(o.A,{className:"mb-3",children:(0,M.jsxs)(d.A,{children:[(0,M.jsxs)(l.A,{variant:"success",onClick:async()=>{const e=Object.keys(fe).filter(e=>fe[e]);if(0===e.length)return void y().fire({icon:"warning",title:"Nenhum item selecionado",text:"Selecione ao menos um item para download"});const s=new Map;(Ge||[]).forEach((e,a)=>{s.set(Ye(e,a),e)});const a=[...new Set(e.map(e=>{var a;return null===(a=s.get(e))||void 0===a?void 0:a.key}).filter(Boolean))];if(0!==a.length){y().fire({title:"Gerando arquivo ZIP",html:`Processando ${a.length} NF-e(s)...`,icon:"info",allowOutsideClick:!1,didOpen:()=>{y().showLoading()}});try{const e=[{original:"",key:a,tipo:0,doc:0,orig:"lote",email:""}],s=await S.A.post("/api/historyNfe/",{dest:"downloadLote",dataPost:e}),t=Ze(s.data);if(y().close(),Qe(t))return void y().fire({icon:"error",title:"Erro",text:"Nenhum documento encontrado para download."});window.open(t,"_blank"),y().fire({icon:"success",title:"Download iniciado",text:`Arquivo ZIP com ${a.length} XML(s) est\xe1 sendo baixado!`,timer:2500}),je({})}catch(i){var t,r;y().close(),y().fire({icon:"error",title:"Erro no download",text:(null===i||void 0===i||null===(t=i.response)||void 0===t||null===(r=t.data)||void 0===r?void 0:r.message)||(null===i||void 0===i?void 0:i.message)||"N\xe3o foi poss\xedvel baixar os arquivos"})}}else y().fire({icon:"error",title:"Sele\xe7\xe3o inv\xe1lida",text:"Nenhum documento v\xe1lido foi selecionado para download."})},disabled:0===Object.keys(fe).filter(e=>fe[e]).length,className:"mr-2 rounded",children:[(0,M.jsx)("i",{className:"mdi mdi-download mr-1"}),"Baixar XML selecionados (",Object.keys(fe).filter(e=>fe[e]).length,")"]}),(0,M.jsxs)(l.A,{variant:"outline-secondary",className:"rounded",onClick:()=>{0!==Oe.length?function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rastreabilidade-lotes.csv";if(0===e.length)return void y().fire({icon:"warning",title:"Nenhum dado",text:"Nenhum dado para exportar"});const a=e.map(e=>{var s,a,t,r,i,l;return[e.empresaNome||"",T(e.cnpjDestinatario)||"",e.chaveNfe||"",e.nNf||"",e.serie||"",F(e.emissao),T(e.cnpjEmitente)||"",e.fornecedorNome||"",e.ufEmitente||"",null!==(s=e.nItem)&&void 0!==s?s:"",e.xProd||"",e.ncm||"",e.lote||"",F(e.dFab),F(e.dVal),null!==(a=e.qCom)&&void 0!==a?a:"",e.uCom||"",null!==(t=e.vProd)&&void 0!==t?t:"",e.cfop||"",e.cstIcms||"",null!==(r=e.pIcms)&&void 0!==r?r:"",null!==(i=e.vBcIcms)&&void 0!==i?i:"",null!==(l=e.vIcms)&&void 0!==l?l:""]}),t=[["Empresa","CNPJ Destinat\xe1rio","Chave NF-e","N\xfamero NF","S\xe9rie","
1Emiss\xe3o","CNPJ Emitente","Fornecedor","UF","Item","Produto","NCM","Lote","Data Fabrica\xe7\xe3o","Data Validade","Quantidade","Unidade","Valor Produto","CFOP","CST ICMS","Al\xedquota ICMS","BC ICMS","Valor ICMS"].join(";"),...a.map(e=>e.map(z).join(";"))].join("\n"),r=new Blob(["\ufeff"+t],{type:"text/csv;charset=utf-8;"}),i=document.createElement("a"),l=URL.createObjectURL(r);i.setAttribute("href",l),i.setAttribute("download",s),i.style.visibility="hidden",document.body.appendChild(i),i.click(),document.body.removeChild(i)}(Oe,`rastreabilidade-lotes-${(new Date).getTime()}.csv`):y().fire({icon:"warning",title:"Nenhum dado",text:"Realize uma busca primeiro para exportar os dados"})},children:[(0,M.jsx)("i",{className:"mdi mdi-file-excel mr-1"}),"Exportar CSV"]})]})}),(0,M.jsx)(f.zp,{columns:rs,data:Ge,localization:j.c,getRowId:(e,s)=>Ye(e,s),enableRowSelection:!0,enableSelectAll:!0,enableGlobalFilter:!0,onRowSelectionChange:je,state:{rowSelection:fe},enableColumnResizing:!0,enableStickyHeader:!0,enableStickyFooter:!0,enablePagination:!0,initialState:{pagination:{pageSize:10,pageIndex:0},density:"compact"},muiTableContainerProps:{sx:{maxHeight:`${K}px`}},muiTableProps:{sx:{fontSize:"13px",fontFamily:'"Nunito", sans-serif',color:"#666"}},muiTableBodyProps:{sx:{fontSize:{xs:"10px",sm:"11px",md:"12px",lg:"13px",xl:"13px"},color:"#666"}},muiTableHeadCellProps:{sx:{fontSize:{xs:"10px",sm:"11px",md:"12px",lg:"13px",xl:"13px"},fontFamily:'"Nunito", sans-serif',color:"#666",fontWeight:"bold",backgroundColor:"#f8f9fa"}},muiTableBodyCellProps:{sx:{fontSize:{xs:"10px",sm:"11px",md:"12px",lg:"13px",xl:"13px"},paddingTop:"0px",paddingBottom:"0px",fontFamily:'"Nunito", sans-serif',color:"#666"}},muiTablePaperProps:{sx:{fontSize:{xs:"10px",sm:"11px",md:"12px",lg:"13px",xl:"13px"}}},muiTableBodyRowProps:e=>{let{row:s}=e;return{sx:{...I(s.original.dVal)}}},renderTopToolbarCustomActions:()=>{const e=(H||[]).map(e=>(e=>{var s,a,t;return{cnpj:(null===e||void 0===e?void 0:e.cnpj_cpf)||(null===e||void 0===e?void 0:e.cnpj)||(null===e||void 0===e||null===(s=e.label)||void 0===s?void 0:s.split(" - ")[0])||"",nome:(null===e||void 0===e||null===(a=e.label)||void 0===a?void 0:a.split(" - ").slice(1).join(" - "))||(null===e||void 0===e?void 0:e.nome)||"",id:null!==(t=null===e||void 0===e?void 0:e.value)&&void 0!==t?t:null===e||void 0===e?void 0:e.id}})(e)).filter(e=>e.cnpj||e.nome||null!=e.id);if(0===e.length)return null;if(e.length<=2)return(0,M.jsxs)("div",{className:"d-flex align-items-center flex-wrap gap-2",children:[(0,M.jsx)("span",{className:"text-muted small mr-1",children:"Empresas:"}),e.map((e,s)=>{const a=!!Fe&&(null!=Fe.id&&null!=e.id?Number(Fe.id)===Number(e.id):Fe.cnpj===e.cnpj),t=`${T(e.cnpj)||e.cnpj}${e.nome?` - ${e.nome}`:""}`;return(0,M.jsx)(i.A,{variant:a?"primary":"light",className:"f-12 mb-0 f-w-400 mr-2",style:{cursor:"pointer",border:a?"2px solid #297BEA":"1px solid #ddd"},onClick:()=>{$e(a?null:{cnpj:e.cnpj,nome:e.nome,id:e.id})},title:a?"Clique para remover filtro":"Clique para filtrar apenas esta empresa",children:t},`empresa-chip-${s}-${e.id||e.cnpj}`)})]});const s=Fe?`${T(Fe.cnpj)||Fe.cnpj} - ${Fe.nome||""}`:`${e.length} empresas`;return(0,M.jsxs)("div",{className:"d-flex align-items-center flex-wrap gap-2",children:[(0,M.jsx)("span",{className:"text-muted small mr-1",children:"Empresas:"}),(0,M.jsxs)(m.A,{id:"dropdown-empresas-toolbar",title:(0,M.jsxs)("span",{className:"py-0",children:[(0,M.jsx)("i",{className:"feather icon-briefcase mr-1"}),s]}),variant:Fe?"primary":"light",className:"d-inline-block mr-2 py-0",size:"sm",children:[Fe&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(u.A.Item,{onClick:()=>$e(null),className:"dropdown-item-remover",style:{fontSize:"12px",color:"#ff5252"},children:[(0,M.jsx)("i",{className:"feather icon-x mr-1"}),"Remover filtro"]}),(0,M.jsx)(u.A.Divider,{})]}),(0,M.jsx)(u.A.Header,{style:{fontSize:"11px",fontWeight:"bold"},children:"Filtrar por empresa:"}),e.map((e,s)=>{const a=!!Fe&&(null!=Fe.id&&null!=e.id?Number(Fe.id)===Number(e.id):Fe.cnpj===e.cnpj);return(0,M.jsxs)(u.A.Item,{onClick:()=>$e({cnpj:e.cnpj,nome:e.nome,id:e.id}),className:"dropdown-item-empresa",style:{fontSize:"12px",backgroundColor:a?"#e3f2fd":"transparent",fontWeight:a?"bold":"normal",color:"#333"},children:[a&&(0,M.jsx)("i",{className:"feather icon-check mr-1",style:{color:"#297BEA"}}),T(e.cnpj)||e.cnpj,e.nome?` - ${e.nome}`:""]},`empresa-dropdown-${s}-${e.id||e.cnpj}`)}
1)]})]})},renderToolbarInternalActions:e=>{let{table:s}=e;return(0,M.jsx)(M.Fragment,{children:(0,M.jsx)(f.O7,{table:s})})}})]})}),0===Oe.length&&H.length>0&&(0,M.jsx)(n.A,{children:(0,M.jsxs)(n.A.Body,{className:"text-center py-5",children:[(0,M.jsx)("i",{className:"mdi mdi-magnify",style:{fontSize:"48px",color:"#ccc"}}),(0,M.jsx)("p",{className:"mt-3 text-muted",children:ye?"Nenhum registro localizado com os filtros informados.":'Clique em "Buscar" para pesquisar lotes nas NF-es recebidas'})]})}),0===H.length&&(0,M.jsx)(n.A,{children:(0,M.jsxs)(n.A.Body,{className:"text-center py-5",children:[(0,M.jsx)("i",{className:"mdi mdi-alert-circle-outline",style:{fontSize:"48px",color:"#ffc107"}}),(0,M.jsx)("p",{className:"mt-3 text-muted",children:"Selecione ao menos uma empresa para iniciar a busca"})]})})]})}}}]); 2//# sourceMappingURL=9437.224515b4.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.