PageSourceSearch

https://sentinel-365-c9d4f.web.app/assets/DocumentosList-BYjyE5jy.js

js sentinel-365-c9d4f.web.app collected 2026-10-03 12:38:38 UTC 40,260 bytes, 1 lines download raw bytes

1import{r as u,j as e}from"./react-vendor-pafHdoJx.js";import{R as se,b as B,d as D,u as q,E as Q,C as re}from"./index-Db0fDLGN.js";import{E as oe}from"./EntityList-DHyuL9ql.js";import{C as ee}from"./ComplianceBadges-B6KO2l0w.js";import{O as ne}from"./ObjectDrawer-DyT69DrE.js";import{A as le}from"./AdaInline-Ct5kRNHe.js";import{C as ie}from"./Comments-C_vFA2mA.js";import{A as ce}from"./ActivityFeed-DAmzN5j6.js";import{E as de}from"./ErrorState-B9i6eo2M.js";import{t as H,av as me,v as Z,aC as te,al as V,o as ue,aE as pe,ae as xe,X as fe}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";function ge({term:t,children:l}){const[i,c]=u.useState(!1),s=se[t];return s?e.jsxs("span",{className:"relative inline-flex items-center cursor-help underline decoration-dotted underline-offset-2",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),tabIndex:0,"aria-describedby":i?`tooltip-${t}`:void 0,children:[l,i&&e.jsxs("span",{id:`tooltip-${t}`,role:"tooltip",className:"absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2 w-64 px-3 py-2 rounded-lg text-xs text-left shadow-lg pointer-events-none",style:{background:"var(--surface-elevated)",border:"1px solid var(--border-primary)",color:"var(--page-text)",boxShadow:"var(--shadow-lg)"},children:[e.jsx("p",{className:"font-semibold mb-0.5",children:s.full}),e.jsx("p",{className:"text-[11px] opacity-80 leading-snug",children:s.description})]})]}):e.jsx(e.Fragment,{children:l})}const ae={cte:"CT-e",mdfe:"MDF-e",nfe:"NF-e",nfse:"NFS-e",ciot:"CIOT",pef:"PEF"},J={rascunho:"Rascunho",processando:"Processando",autorizado:"Autorizado",rejeitado:"Rejeitado",cancelado:"Cancelado",erro:"Erro"},he={autorizado:"#10B981",processando:"#F59E0B",rejeitado:"#EF4444",erro:"#EF4444",cancelado:"#9CA3AF",rascunho:"#9CA3AF"};function ye({label:t}){return e.jsxs("div",{className:"text-xs text-center py-8",style:{color:"var(--page-text-muted)"},children:["Carregando ",t,"…"]})}function G({icon:t,title:l,body:i}){return e.jsxs("div",{className:"text-center py-10",style:{color:"var(--page-text-muted)"},children:[e.jsx(t,{className:"w-8 h-8 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"text-sm",children:l}),i&&e.jsx("p",{className:"text-[11px] mt-1",children:i})]})}function ve({message:t}){return e.jsxs("div",{className:"text-center py-8 text-sm",style:{color:"#EF4444"},children:[e.jsx(V,{className:"w-6 h-6 mx-auto mb-2"}),"Erro ao carregar: ",t]})}function U(t){if(!t)return"—";const l=new Date(t);return isNaN(l.getTime())?"—":l.toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function T({title:t,children:l}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide mb-1.5",style:{color:"var(--page-text-muted)"},children:t}),e.jsx("div",{className:"space-y-1",children:l})]})}function C({label:t,value:l,mono:i}){return e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{style:{color:"var(--page-text-muted)"},children:t}),e.jsx("span",{className:i?"font-mono text-right break-all":"text-right",style:{color:"var(--page-text)"},children:l})]})}function be({doc:t}){const{data:l}=B(()=>D.fiscalDocumentHistory(t.ref),[t.ref]),i=l==null?void 0:l.document,c={...t,...i||{},embarcadorNome:(i==null?void 0:i.embarcadorNome)||t.embarcadorNome,motoristaNome:(i==null?void 0:i.motoristaNome)||t.motoristaNome,vehiclePlate:(i==null?void 0:i.vehiclePlate)||t.vehiclePlate},s=c.type||c.tipo||"",n=ae[s]||s.toUpperCase()||"—",m=J[c.status]||c.status||"—",f=he[c.status]||"var(--page-text-muted)";t=c;const a=t;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(T,{title:"Identificação",children:[e.jsx(C,{label:"Tipo",value:n}),e.jsx(C,{label:"Ref. interno",value:t.ref,mono:!0}),t.numero&&e.jsx(C,{label:"Número",value:t.numero,mono:!0}),a.serie&&e.jsx(C,{label:"Série",value:String(a.serie),mono:!0}),t.chaveNfe&&e.jsx(C,{label:"Chave fiscal",value:t.chaveNfe,mono:!0}),a.protocoloAutorizacao&&e.jsx(C,{label:"Protocolo autorização",value:a.protocoloAutorizacao,mono:!0}),e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{style:{color:"var(--page-text-muted)"},children:"Status"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:f},children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:f}}),m]})]}),a.statusSefazLabel&&e.jsx(C,{label:"SEFAZ",value:`${a.statusSefaz} · ${a.statusSefazLabel}`}),a.mensagemSefaz&&e.jsxs("div",{className:"flex items-start justify-between gap-3 text-sm",children:[e.jsx("span",{style:{color:"var(--page-text-muted)"},children:"Mensagem SEFAZ"}),e.jsx("span",{className:"text-right text-[12px]",style:{color:"var(--page-text)"},children:a.mensagemSefaz})]}),a.contingencia&&e.jsx("p",{className:"text-[11px] mt-2 p-2 rounded",style:{background:"rgba(245,158,11,0.10)",color:"#D97706"},children:"⚠️ Emitido em modo contingência (SEFAZ offline). Será reenviado quando voltar."})]}),(a.caminhoXml||a.caminhoDacte||a.caminhoDanfe||a.caminhoDamdfe)&&e.jsxs(T,{title:"Arquivos oficiais",children:[a.caminhoDacte&&e.jsxs("a",{href:a.caminhoDacte,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"},children:"📄 DACTE (PDF)"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]}),a.caminhoDanfe&&e.jsxs("a",{href:a.caminhoDanfe,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"},children:"📄 DANFE (PDF)"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]}),a.caminhoDamdfe&&e.jsxs("a",{href:a.caminhoDamdfe,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"},children:"📄 DAMDFE (PDF)"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]}),a.caminhoXml&&e.jsxs("a",{href:a.caminhoXml,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"}
1,children:"📋 XML assinado"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]}),a.caminhoXmlCancelamento&&e.jsxs("a",{href:a.caminhoXmlCancelamento,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"},children:"📋 XML cancelamento"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]}),a.caminhoXmlEncerramento&&e.jsxs("a",{href:a.caminhoXmlEncerramento,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-2 text-sm hover-surface p-2 rounded",children:[e.jsx("span",{style:{color:"var(--page-text)"},children:"📋 XML encerramento MDF-e"}),e.jsx("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:"baixar →"})]})]}),(t.embarcadorNome||t.motoristaNome||t.vehiclePlate)&&e.jsxs(T,{title:"Operação",children:[t.embarcadorNome&&e.jsx(C,{label:"Embarcador",value:t.embarcadorNome}),t.motoristaNome&&e.jsx(C,{label:"Motorista",value:t.motoristaNome}),t.vehiclePlate&&e.jsx(C,{label:"Veículo",value:t.vehiclePlate,mono:!0}),t.dispatchId&&e.jsx(C,{label:"Despacho",value:t.dispatchId,mono:!0})]}),t.valor!=null&&e.jsx(T,{title:"Valores",children:e.jsx(C,{label:"Valor total",value:Number(t.valor||0).toLocaleString("pt-BR",{style:"currency",currency:"BRL"})})}),e.jsxs(T,{title:"Datas",children:[e.jsx(C,{label:"Criado em",value:U(t.createdAt)}),t.webhookReceivedAt&&e.jsx(C,{label:"Resposta SEFAZ",value:U(t.webhookReceivedAt)}),t.cancelledAt&&e.jsx(C,{label:"Cancelado em",value:U(t.cancelledAt)})]}),t.focusMotivo&&e.jsx(T,{title:"Motivo / mensagem SEFAZ",children:e.jsx("div",{className:"text-sm whitespace-pre-wrap p-2 rounded-md",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:t.focusMotivo})}),!t.focusMotivo&&(t.status==="erro"||t.status==="rejeitado")&&t.focusResponse&&e.jsx(T,{title:"Resposta do provedor",children:e.jsx("pre",{className:"text-[11px] whitespace-pre-wrap p-2 rounded-md font-mono overflow-auto max-h-60",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:typeof t.focusResponse=="string"?t.focusResponse:JSON.stringify(t.focusResponse,null,2)})}),t.cancelJustificativa&&e.jsx(T,{title:"Justificativa do cancelamento",children:e.jsx("div",{className:"text-sm whitespace-pre-wrap p-2 rounded-md",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:t.cancelJustificativa})})]})}function je({doc:t}){const{toast:l}=q(),[i,c]=u.useState(null),[s,n]=u.useState({pdf:null,xml:null}),[m,f]=u.useState(null),a=async()=>{c("pdf"),f(null);try{const p=await D.fiscalDownload(t.ref,"pdf");n({pdf:p.danfe||p.url,xml:p.xml})}catch(p){const y=(p==null?void 0:p.message)||"Falha ao buscar links de download";f(y),l({title:y,kind:"error"})}finally{c(null)}},h=t.status==="cancelado";return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)"},children:[e.jsx("p",{className:"text-sm",style:{color:"var(--page-text)"},children:"Os arquivos oficiais (DANFE/DACTe + XML assinado) são gerados pela SEFAZ."}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--page-text-muted)"},children:"O download abre o arquivo direto no servidor do provedor (URL temporária autenticada)."})]}),!s.pdf&&!s.xml&&e.jsxs("button",{onClick:a,disabled:i!==null||h,className:"w-full inline-flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm font-semibold text-white disabled:opacity-40",style:{background:"#F97316"},children:[e.jsx(me,{className:"w-4 h-4"}),i?"Buscando…":"Carregar links de download"]}),(s.pdf||s.xml)&&e.jsxs("div",{className:"space-y-2",children:[s.pdf&&e.jsxs("a",{href:s.pdf,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-3 px-3 py-2 rounded-lg",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Z,{className:"w-4 h-4",style:{color:"#EF4444"}}),"DANFE / DACTe (PDF)"]}),e.jsx(te,{className:"w-4 h-4",style:{color:"var(--page-text-muted)"}})]}),s.xml&&e.jsxs("a",{href:s.xml,target:"_blank",rel:"noopener noreferrer",className:"flex items-center justify-between gap-3 px-3 py-2 rounded-lg",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Z,{className:"w-4 h-4",style:{color:"#0EA5E9"}}
1),"XML assinado"]}),e.jsx(te,{className:"w-4 h-4",style:{color:"var(--page-text-muted)"}})]})]}),h&&e.jsx("div",{className:"text-xs text-center",style:{color:"var(--page-text-muted)"},children:"Documento cancelado. Os arquivos podem não estar disponíveis."}),m&&e.jsx("div",{className:"text-sm text-center",style:{color:"#EF4444"},children:m})]})}const Ne={webhook:xe,cancel:pe,create:Z,update:H},ke={webhook:"#10B981",cancel:"#EF4444",create:"#3B82F6",update:"#9CA3AF"};function Ce({ref:t}){const{data:l,loading:i,error:c}=B(()=>D.fiscalDocumentHistory(t),[t]);return i?e.jsx(ye,{label:"histórico"}):c?e.jsx(ve,{message:c}):!l||l.timeline.length===0?e.jsx(G,{icon:ue,title:"Sem eventos registrados.",body:"Eventos do SEFAZ (autorização, rejeição, cancelamento) e ações do operador aparecem aqui."}):e.jsx("div",{className:"space-y-2",children:l.timeline.map(s=>{const n=Ne[s.type]||H,m=ke[s.type]||"#9CA3AF";return e.jsxs("div",{className:"flex items-start gap-3 px-3 py-2 rounded-lg",style:{background:"var(--surface-secondary)"},children:[e.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 mt-0.5",style:{background:`${m}15`,border:`1px solid ${m}40`},children:e.jsx(n,{className:"w-3.5 h-3.5",style:{color:m}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm",style:{color:"var(--page-text)"},children:[s.description||(s.newStatus?`Status: ${J[s.newStatus]||s.newStatus}`:s.type),s.actor&&e.jsxs("span",{className:"text-[10px] ml-2",style:{color:"var(--page-text-muted)"},children:["· ",s.actor]})]}),e.jsxs("div",{className:"text-[10px] mt-0.5",style:{color:"var(--page-text-muted)"},children:[U(s.createdAt),s.source&&e.jsxs(e.Fragment,{children:[" · ",s.source]}),s.motivo&&e.jsxs(e.Fragment,{children:[" · ",s.motivo]})]})]})]},s.id)})})}function we({doc:t,onChange:l}){const{toast:i}=q(),{data:c,refetch:s}=B(()=>D.fiscalDocumentHistory(t.ref),[t.ref]),n=c==null?void 0:c.document,m=Array.isArray(n==null?void 0:n.cces)?n.cces:[],f=((n==null?void 0:n.cceSequencia)||0)+1,[a,h]=u.useState(""),[p,y]=u.useState(!1),b=(t.type||t.tipo||"").toLowerCase(),x=(b==="cte"||b==="nfe"||b==="cte_os")&&t.status==="autorizado",j=m.length>=20,v=(()=>{const d=(n==null?void 0:n.dataEmissaoSefaz)||(n==null?void 0:n.webhookReceivedAt)||(n==null?void 0:n.createdAt);if(!d)return null;const g=new Date(d);return isNaN(g.getTime())?null:Math.floor((Date.now()-g.getTime())/(1440*60*1e3))})(),N=v!=null&&v>30,w=v!=null?Math.max(0,30-v):null,R=async()=>{var d;if(a.length<15){i({kind:"warning",title:"Correção deve ter no mínimo 15 caracteres"});return}y(!0);try{const g=await D.fiscalEmitCce(t.ref,a,f);i({kind:"success",title:`CCe nº ${g.sequencia} emitida`,description:((d=g.focus)==null?void 0:d.mensagem_sefaz)||"Solicitação enviada à SEFAZ."}),h(""),s(),l==null||l()}catch(g){const r=(g==null?void 0:g.message)||"Falha ao emitir Carta de Correção";i({kind:"error",title:r})}finally{y(!1)}};return x?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg p-3 text-xs space-y-1",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)"},children:[e.jsx("p",{className:"font-semibold",style:{color:"var(--page-text)"},children:"📜 Carta de Correção Eletrônica (CCe)"}),e.jsxs("p",{style:{color:"var(--page-text-muted)"},children:["Ajuste SINIEF ",b==="nfe"?"7/2005":"8/2007",". Corrija erros sem cancelar o documento."]}),e.jsxs("ul",{className:"ml-4 mt-1 list-disc",style:{color:"var(--page-text-secondary)"},children:[e.jsxs("li",{children:[m.length," de 20 correções emitidas ",j&&e.jsx("strong",{style:{color:"#EF4444"},children:"(limite atingido)"})]}),w!=null&&e.jsx("li",{children:N?e.jsxs("strong",{style:{color:"#EF4444"},children:["Prazo expirado (",v," dias desde autorização)"]}):`${w} dias restantes no prazo de 30 dias`}),e.jsx("li",{children:"Não pode corrigir: valor_total, datas, remetente/destinatário, alíquotas/base ICMS"})]})]}),m.length>0&&e.jsx(T,{title:`Histórico (${m.length})`,children:m.map((d,g)=>e.jsxs("div",{className:"rounded p-2 text-xs space-y-1",style:{background:"var(--surface-secondary)"},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-semibold",style:{color:"var(--page-text)"},children:["CCe nº ",d.sequencia]}),d.status&&e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full",style:{background:d.status==="autorizado"?"rgba(16,185,129,0.15)":"rgba(245,158,11,0.15)",color:d.status==="autorizado"?"#10B981":"#D97706"},children:d.status})]}),e.jsx("p",{style:{color:"var(--page-text)"},children:d.correcao}),d.protocolo&&e.jsxs("p",{className:"font-mono text-[10px]",style:{color:"var(--page-text-muted)"},children:["Protocolo: ",d.protocolo]}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[d.caminhoPdf&&e.jsx("a",{href:d.c
1aminhoPdf,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] underline",style:{color:"#3B82F6"},children:"PDF"}),d.caminhoXml&&e.jsx("a",{href:d.caminhoXml,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] underline",style:{color:"#3B82F6"},children:"XML"})]})]},g))}),!j&&!N&&e.jsxs(T,{title:`Nova Carta de Correção (nº ${f})`,children:[e.jsx("textarea",{value:a,onChange:d=>h(d.target.value),placeholder:"Descreva a correção necessária (mín. 15, máx. 1000 caracteres)...",className:"w-full px-3 py-2 rounded-lg text-sm",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)",minHeight:100},maxLength:1e3}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:[a.length," / 1000 caracteres"]}),e.jsx("button",{type:"button",onClick:R,disabled:p||a.length<15,className:"px-4 py-2 rounded-md text-sm font-medium text-white disabled:opacity-40",style:{background:"#F97316"},children:p?"Emitindo…":`Emitir CCe nº ${f}`})]})]})]}):e.jsx(G,{icon:V,title:"Carta de Correção indisponível",body:t.status!=="autorizado"?'CCe só pode ser emitida para documentos com status "autorizado".':"CCe disponível apenas para CT-e e NF-e."})}function Ee({doc:t,onChange:l}){const{toast:i}=q(),[c,s]=u.useState(!1),[n,m]=u.useState(!1),{data:f}=B(()=>D.fiscalDocumentHistory(t.ref),[t.ref]),a=f==null?void 0:f.document,h=(t.type||t.tipo||"").toLowerCase(),p=h==="cte_os"?"cte":h,y=["cte","nfe","mdfe","nfse","cte_os"].includes(h),b=h==="mdfe",x=t.status==="autorizado",j=t.status==="encerrado"||!!(a!=null&&a.encerradoEm),v=(()=>{if(!b||!x)return null;const d=(a==null?void 0:a.dataEmissaoSefaz)||(a==null?void 0:a.webhookReceivedAt)||(a==null?void 0:a.createdAt);if(!d)return null;const g=new Date(d);return isNaN(g.getTime())?null:Math.floor((Date.now()-g.getTime())/(1440*60*1e3))})(),N=v!=null&&v>25,w=v!=null&&v>30,R=async()=>{s(!0);try{await D.fiscalReenviarWebhook(p,t.ref),i({kind:"success",title:"Reenvio solicitado",description:"O provedor enviará nova notificação em segundos."})}catch(d){i({kind:"error",title:(d==null?void 0:d.message)||"Falha ao solicitar reenvio"})}finally{s(!1)}};return y?e.jsxs("div",{className:"space-y-3",children:[b&&x&&!j&&e.jsx("div",{className:"rounded-lg p-3 space-y-2",style:{background:w?"rgba(239,68,68,0.10)":N?"rgba(245,158,11,0.10)":"rgba(99,102,241,0.08)",border:`1px solid ${w?"rgba(239,68,68,0.40)":N?"rgba(245,158,11,0.40)":"rgba(99,102,241,0.30)"}`},children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:w?"#DC2626":N?"#D97706":"#4F46E5"},children:w?"🔴 MDF-e bloqueado SEFAZ":N?"⚠️ Encerre antes de 30 dias":"📦 Encerrar manifesto"}),e.jsx("p",{className:"text-[11px] mt-0.5",style:{color:"var(--page-text)"},children:w?`MDF-e em aberto há ${v} dias — SEFAZ bloqueia novas emissões da empresa.`:N?`MDF-e em aberto há ${v} dias. SEFAZ bloqueia empresa após 30 dias.`:"Após chegada da carga, encerre o MDF-e pra fechar a operação na SEFAZ (obrigatório por lei)."})]}),e.jsx("button",{type:"button",onClick:()=>m(!0),className:"px-3 py-2 rounded-md text-xs font-medium text-white shrink-0",style:{background:w?"#DC2626":N?"#D97706":"#4F46E5"},children:"Encerrar agora"})]})}),b&&j&&e.jsxs("div",{className:"rounded-lg p-2 text-xs",style:{background:"rgba(16,185,129,0.10)",border:"1px solid rgba(16,185,129,0.30)"},children:[e.jsx("p",{className:"font-semibold",style:{color:"#10B981"},children:"✅ MDF-e encerrado"}),((a==null?void 0:a.encerradoMunicipio)||(a==null?void 0:a.encerradoUf))&&e.jsxs("p",{className:"mt-0.5",style:{color:"var(--page-text)"},children:[a==null?void 0:a.encerradoMunicipio,"/",a==null?void 0:a.encerradoUf,(a==null?void 0:a.encerradoData)&&` em ${a.encerradoData}`]}),(a==null?void 0:a.caminhoXmlEncerramento)&&e.jsx("a",{href:a.caminhoXmlEncerramento,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] underline mt-1 inline-block",style:{color:"#3B82F6"},children:"XML do evento de encerramento"})]}
1),e.jsxs("button",{type:"button",onClick:R,disabled:c,className:"w-full inline-flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm font-medium hover-surface disabled:opacity-50",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"},children:[e.jsx(H,{className:"w-4 h-4"}),c?"Reenviando…":"Solicitar reenvio de notificação webhook"]}),e.jsx("p",{className:"text-[10px] px-2",style:{color:"var(--page-text-muted)"},children:'Útil quando o documento ficou parado em "processando" e o webhook Focus não chegou. Pede ao Focus pra reenviar a última notificação.'}),n&&e.jsx(Fe,{doc:t,onClose:()=>m(!1),onDone:()=>{m(!1),l==null||l()}})]}):null}function Fe({doc:t,onClose:l,onDone:i}){const{toast:c}=q(),[s,n]=u.useState(""),[m,f]=u.useState(""),[a,h]=u.useState(()=>new Date().toISOString().slice(0,10)),[p,y]=u.useState(!1),b=async()=>{if(!s||!m){c({kind:"warning",title:"Município e UF obrigatórios pra encerrar"});return}y(!0);try{await D.fiscalEncerrarMdfe(t.ref,{municipio:s,uf:m.toUpperCase(),data:a}),c({kind:"success",title:"MDF-e encerrado",description:`${s}/${m.toUpperCase()}`}),i()}catch(x){c({kind:"error",title:(x==null?void 0:x.message)||"Falha ao encerrar MDF-e"})}finally{y(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.4)"},onClick:l,children:e.jsxs("div",{className:"app-internal rounded-lg p-4 max-w-md w-full mx-4 space-y-3",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)"},onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--page-text)"},children:"Encerrar MDF-e"}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--page-text-muted)"},children:"Informe o município/UF onde a operação foi concluída. Esta ação é obrigatória por lei e indica que o transporte chegou ao destino."})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-[10px] mb-1 uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Município"}),e.jsx("input",{type:"text",value:s,onChange:x=>n(x.target.value.toUpperCase()),placeholder:"SÃO PAULO",className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] mb-1 uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"UF"}),e.jsx("input",{type:"text",value:m,maxLength:2,onChange:x=>f(x.target.value.toUpperCase()),placeholder:"SP",className:"w-full px-3 py-2 rounded-md text-sm uppercase",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] mb-1 uppercase tracking-wider",style:{color:"var(--page-text-muted)"},children:"Data do encerramento"}),e.jsx("input",{type:"date",value:a,onChange:x=>h(x.target.value),className:"w-full px-3 py-2 rounded-md text-sm",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx("button",{onClick:l,type:"button",className:"px-4 py-2 rounded-md text-sm hover-surface",style:{color:"var(--page-text-muted)"},children:"Cancelar"}),e.jsx("button",{onClick:b,disabled:p,type:"button",className:"px-4 py-2 rounded-md text-sm font-medium text-white disabled:opacity-50",style:{background:"#4F46E5"},children:p?"Encerrando…":"Confirmar encerramento"})]})]})})}function De({doc:t,onChange:l}){var Y,K;const{toast:i}=q(),{data:c,refetch:s}=B(()=>D.fiscalDocumentHistory(t.ref),[t.ref]),n=c==null?void 0:c.document,f=(t.type||t.tipo||"").toLowerCase()==="mdfe"&&t.status==="autorizado",[a,h]=u.useState(""),[p,y]=u.useState(""),[b,x]=u.useState(!1),[j,v]=u.useState(""),[N,w]=u.useState(""),[R,d]=u.useState(""),[g,r]=u.useState(""),[S,$]=u.useState(!1),E=Array.isArray(n==null?void 0:n.condutoresIncluidos)?n.condutoresIncluidos:[],A=Array.isArray(n==null?void 0:n.dfesIncluidos)?n.dfesIncluidos:[],z=!!(n!=null&&n.carregamentoPosterior),M=async()=>
1{if(!a.trim()){i({kind:"warning",title:"Nome obrigatório"});return}const o=p.replace(/\D/g,"");if(o.length!==11){i({kind:"warning",title:"CPF deve ter 11 dígitos"});return}x(!0);try{await D.fiscalIncluirCondutorMdfe(t.ref,a.trim(),o),i({kind:"success",title:`Condutor ${a} incluído`}),h(""),y(""),s(),l==null||l()}catch(k){i({kind:"error",title:(k==null?void 0:k.message)||"Falha ao incluir condutor"})}finally{x(!1)}},O=async()=>{if(!j){i({kind:"warning",title:"Protocolo MDF-e obrigatório"});return}if(!/^\d{7}$/.test(N)){i({kind:"warning",title:"Código IBGE carregamento (7 dígitos)"});return}const o=R.replace(/\D/g,"");if(o.length!==44){i({kind:"warning",title:"Chave deve ter 44 dígitos"});return}if(!/^\d{7}$/.test(g)){i({kind:"warning",title:"Código IBGE descarregamento (7 dígitos)"});return}const F=o.slice(20,22)==="57";$(!0);try{await D.fiscalIncluirDfeMdfe(t.ref,{protocolo:j,codigo_municipio_carregamento:N,documentos:[{...F?{chave_cte:o}:{chave_nfe:o},codigo_municipio_descarregamento:g}]}),i({kind:"success",title:`${F?"CT-e":"NF-e"} incluído(a) no MDF-e`}),d(""),r(""),s(),l==null||l()}catch(L){i({kind:"error",title:(L==null?void 0:L.message)||"Falha ao incluir DF-e"})}finally{$(!1)}};if(!f)return e.jsx(G,{icon:V,title:"Eventos MDF-e indisponíveis",body:t.status!=="autorizado"?"Eventos só podem ser registrados em MDF-e autorizado.":"Esta aba é exclusiva para MDF-e."});const _=[];n!=null&&n.encerradoEm&&_.push({tipo:"encerramento",quando:n.encerradoEm,descricao:`Encerrado em ${n.encerradoMunicipio||"—"}/${n.encerradoUf||"—"} · ${n.encerradoData||"—"}`,cor:"#10B981",icone:"✅"}),n!=null&&n.cancelledAt&&_.push({tipo:"cancelamento",quando:n.cancelledAt,descricao:n.cancelJustificativa||"MDF-e cancelado",cor:"#EF4444",icone:"❌"});for(const o of E)_.push({tipo:"condutor_incluido",quando:o.incluidoEm,descricao:`Condutor ${o.nome} (CPF ${(Y=o.cpf)==null?void 0:Y.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/,"$1.$2.***-$4")}) incluído`,cor:"#3B82F6",icone:"👤"});for(const o of A)_.push({tipo:"dfe_incluido",quando:o.incluidoEm,descricao:`${((K=o.documentos)==null?void 0:K.length)||0} DF-e(s) incluído(s) — município carreg ${o.codigoMunicipioCarregamento}`,cor:"#7C3AED",icone:"📋"});return _.sort((o,k)=>{var P,X,I,W;const F=((P=o.quando)==null?void 0:P._seconds)||((X=o.quando)==null?void 0:X.seconds)||(typeof o.quando=="string"?new Date(o.quando).getTime()/1e3:0);return(((I=k.quando)==null?void 0:I._seconds)||((W=k.quando)==null?void 0:W.seconds)||(typeof k.quando=="string"?new Date(k.quando).getTime()/1e3:0))-F}),e.jsxs("div",{className:"space-y-4",children:[_.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold mb-2",style:{color:"var(--page-text)"},children:["📜 Timeline de eventos (",_.length,")"]}),e.jsx("div",{className:"space-y-1.5",children:_.map((o,k)=>{var F,L;return e.jsxs("div",{className:"flex items-start gap-2 p-2 rounded text-xs",style:{background:"var(--surface-secondary)"},children:[e.jsx("span",{style:{fontSize:14},children:o.icone}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{style:{color:"var(--page-text)"},children:o.descricao}),e.jsx("p",{className:"text-[10px] mt-0.5",style:{color:"var(--page-text-muted)"},children:(F=o.quando)!=null&&F.toDate?o.quando.toDate().toLocaleString("pt-BR"):typeof o.quando=="string"?new Date(o.quando).toLocaleString("pt-BR"):(L=o.quando)!=null&&L._seconds?new Date(o.quando._seconds*1e3).toLocaleString("pt-BR"):"—"})]}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold px-2 py-0.5 rounded",style:{background:`${o.cor}20`,color:o.cor},children:o.tipo.replace(/_/g," ")})]},k)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--page-text)"},children:"👤 Incluir condutor"}),e.jsx("p",{className:"text-[11px] mb-2",style:{color:"var(--page-text-muted)"},children:"Adiciona condutor ao MDF-e. Use quando o motorista não estava no manifesto inicial."}),E.length>0&&e.jsx("div",{className:"space-y-1 mb-2",children:E.map((o,k)=>{var F;return e.jsxs("div",{className:"text-[11px] p-2 rounded",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:[e.jsx("span",{className:"font-semibold",children:o.nome}),e.jsxs("span",{className:"font-mono ml-2",style:{color:"var(--page-text-muted)"},children:["CPF ",(F=o.cpf)==null?void 0:F.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/,"$1.$2.$3-$4")]}),o.caminhoXml&&e.jsx("a",{href:o.caminhoXml,target:"_blank",rel:"noopener noreferrer",className:"ml-2 underline",style:{color:"#3B82F6"},children:"XML"})]},k)})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx("input",{type:"text",placeholder:"Nome completo",value:a,onChange:o=>h(o.target.value.toUpperCase()),className:"col-span-2 px-3 py-2 rounded-md text-sm",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}}),e.jsx("input",{type:"text",placeholder:"CPF",value:p,onChange:o=>y(o.target.value),inputMode:"numeric",className:"px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]}),e.jsx("button",{type:"button",onClick:M,disabled:b,className:"mt-2 px-4 py-2 rounded-md text-sm font-medium text-white disabled:opacity-50",style:{background:"#4F46E5"},children:b?"Incluindo…":"Incluir condutor"})]}),e.jsx("hr",{style:{borderColor:"var(--border-primary)"}}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-1",style:{color:"var(--page-text)"},children:"📋 Incluir CT-e / NF-e"}),z?e.jsx("p",{className:"text-[11px] mb-2",style:{color:"var(--page-text-muted)"},children:"Anexa CT-e/NF-e adicional ao MDF-e autorizado. Auto-detecta tipo pela chave (modelo 55=NF-e, 57=CT-e)."}):e.jsx("div",{className:"rounded p-2 text-[11px]",style:{background:"rgba(245,158,11,0.10)",color:"#D97706"},children:'⚠️ MDF-e não foi emitido com indicativo de "carregamento posterior". SEFAZ rejeitará inclusão de novos DF-es. Tente assim mesmo se acha que está marcado.'}),A.length>0&&e.jsx("div",{className:"space-y-1 my-2",children:A.map((o,k)=>{var F,L;return e.jsxs("div",{className:"text-[11px] p-2 rounded",style:{background:"var(--surface-secondary)",color:"var(--page-text)"},children:[e.jsxs("p",{className:"font-semibold",children:["Protocolo ",o.protocolo," · ",((F=o.documentos)==null?void 0:F.length)||0," doc(s)"]}),(L=o.documentos)==null?void 0:L.map((P,X)=>{var I;return e.jsxs("p",{className:"font-mono text-[10px] truncate",children:[(I=P.tipo)==null?void 0:I.toUpperCase(),": ",P.chave]},X)}),o.caminhoXml&&e.jsx("a",{href:o.caminhoXml,target:"_blank",rel:"noopener noreferrer",className:"text-[10px] underline",style:{color:"#3B82F6"},children:"XML"})]},k)})}),e.jsxs("div",{className:"space-y-2 mt-2",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",placeholder:"Protocolo do MDF-e",value:j,onChange:o=>v(o.target.value),className:"px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}}),e.jsx("input",{type:"text",placeholder:"IBGE município carregamento (7 díg)",value:N,onChange:o=>w(o.target.value.replace(/\D/g,"").slice(0,7)),inputMode:"numeric",className:"px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]}),e.jsx("input",{type:"text",placeholder:"Chave CT-e ou NF-e (44 dígitos)",value:R,onChange:o=>d(o.target.value.replace(/\D/g,"").slice(0,44)),inputMode:"numeric",className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}}),e.jsx("input",{type:"text",placeholder:"IBGE município descarregamento (7 díg)",value:g,onChange:o=>r(o.target.value.replace(/\D/g,"").slice(0,7)),inputMode:"numeric",className:"w-full px-3 py-2 rounded-md text-sm font-mono",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text)"}})]}),e.jsx("button",{type:"button",onClick:O,disabled:S,className:"mt-2 px-4 py-2 rounded-md text-sm font-medium text-white disabled:opacity-50",style:{background:"#4F46E5"},children:S?"Incluindo…":"Incluir DF-e"})]})]})}const Se={autorizado:"ok",processando:"warn",rejeitado:"error",erro:"error",cancelado:"unknown",rascunho:"unknown"};function Xe(){const[t,l]=u.useState("todos"),[i,c]=u.useState("todos"),[s,n]=u.useState(null),[m,f]=u.useState(null),[a,h]=u.useState(""),{toast:p}=q(),{data:y,loading:b,error:x,refetch:j}=B(()=>D.fiscalDocuments(t==="todos"?void 0:t,i==="todos"?void 0:i,200),[t,i]),v=u.useMemo(()=>((y==null?void 0:y.documents)||[]).map(S=>{const $=S.type||S.tipo||"",E=S.status||"";return{...S,tipoLabel:ae[$]||$.toUpperCase()||"—",statusLabel:J[E]||E||"—",statusBadge:Se[E]||"unknown"}}),[y]),N=[{key:"tipo",label:"Tipo",width:90,render:r=>e.jsx("span",{className:"text-xs font-bold",style:{color:"#F97316"},children:e.jsx(ge,{term:r.tipoLabel,children:r.tipoLabel})}),sortValue:r=>r.tipoLabel},{key:"numero",label:"Número",width:110,render:r=>e.jsx("span",{className:"font-mono text-xs",children:r.numero||"—"}),sortValue:r=>r.numero||""},{key:"chave",label:"Chave SEFAZ",width:"1.5fr",render:r=>e.jsx("span",{className:"font-mono text-[10px] truncate block",children:r.chaveNfe||"—"})},{key:"embarcador",label:"Cliente",width:"1fr",render:r=>r.embarcadorNome||"—",sortValue:r=>r.embarcadorNome||""},{key:"criado",label:"Emissão",width:130,render:r=>Ae(r.createdAt),sortValue:r=>r.createdAt||""},{key:"status",label:"Status",width:130,render:r=>{const E=(r.type||r.tipo||"").toLowerCase()==="mdfe"&&r.status==="autorizado"&&!r.encerradoEm,A=(()=>
1{if(!E)return null;const M=r.dataEmissaoSefaz||r.webhookReceivedAt||r.createdAt;if(!M)return null;const O=new Date(typeof M=="string"?M:M!=null&&M._seconds?M._seconds*1e3:M);return isNaN(O.getTime())?null:Math.floor((Date.now()-O.getTime())/(1440*60*1e3))})(),z=A==null?null:A>30?"#EF4444":A>25?"#D97706":null;return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ee,{label:r.statusLabel,status:r.statusBadge}),z&&e.jsxs("span",{className:"text-[10px] font-semibold px-1.5 py-0.5 rounded",style:{background:`${z}20`,color:z},title:A>30?`MDF-e em aberto há ${A} dias — SEFAZ bloqueia empresa`:`MDF-e em aberto há ${A} dias — encerre antes de 30`,children:[A,"d"]})]})},sortValue:r=>r.status},{key:"valor",label:"Valor",width:100,align:"right",render:r=>e.jsx("span",{className:"font-mono",children:(r.valor??0).toLocaleString("pt-BR",{style:"currency",currency:"BRL",maximumFractionDigits:0})}),sortValue:r=>r.valor||0}],w=r=>new Promise(S=>{const $=r.filter(E=>E.status!=="cancelado").map(E=>E.ref).filter(Boolean);if($.length===0){p({title:"Selecione documentos não cancelados",kind:"warning"}),S();return}h(""),f({refs:$,resolve:S})}),R=async()=>{if(m){if(a.trim().length<15){p({title:"Justificativa precisa ter pelo menos 15 caracteres",kind:"warning"});return}try{const r=await D.fiscalBulkCancel({refs:m.refs,justificativa:a.trim()});p({title:`${r.ok}/${r.total} documentos cancelados`,description:r.failed>0?`${r.failed} falha(s) — veja Histórico de cada documento.`:void 0,kind:r.failed===0?"success":"warning"}),j(),m.resolve(),f(null)}catch(r){p({title:(r==null?void 0:r.message)||"Falha ao cancelar em lote",kind:"error"})}}},d=v.filter(r=>r.status==="erro"||r.status==="rejeitado").length,g=v.filter(r=>r.status==="processando").length;return x&&!b?e.jsx(Q,{children:e.jsx(de,{error:x,onRetry:j,title:"Não foi possível carregar os documentos fiscais"})}):e.jsxs(Q,{children:[e.jsx(oe,{rows:v,rowKey:r=>r.id,columns:N,loading:b,filterChips:[{key:"todos",label:"Todos os tipos",active:t==="todos",onClick:()=>l("todos")},{key:"cte",label:"CT-e",active:t==="cte",onClick:()=>l("cte")},{key:"mdfe",label:"MDF-e",active:t==="mdfe",onClick:()=>l("mdfe")},{key:"nfe",label:"NF-e",active:t==="nfe",onClick:()=>l("nfe")},{key:"nfse",label:"NFS-e",active:t==="nfse",onClick:()=>l("nfse")},{key:"ciot",label:"CIOT",active:t==="ciot",onClick:()=>l("ciot")},{key:"pef",label:"PEF",active:t==="pef",onClick:()=>l("pef")}],savedViews:[{id:"autorizado",name:"Autorizados",apply:()=>c("autorizado"),star:!0},{id:"processando",name:"Processando",apply:()=>c("processando")},{id:"erro",name:"Com erro",apply:()=>c("rejeitado")},{id:"cancelado",name:"Cancelados",apply:()=>c("cancelado")},{id:"todos_st",name:"Limpar status",apply:()=>c("todos")}],bulkActions:[{key:"cancel",label:"Cancelar selecionados",icon:e.jsx(fe,{className:"w-3.5 h-3.5"}),variant:"destructive",run:w}],onRowOpen:r=>n(r),emptyTitle:t==="todos"&&i==="todos"?"Nenhum documento fiscal ainda.":"Nenhum documento com esses filtros.",emptyBody:t==="todos"&&i==="todos"?"Emita CT-e/MDF-e/NF-e a partir de uma viagem ou cotação para vê-los aqui.":"Tente outro filtro ou limpe os filtros.",adaCard:d>0||g>5?e.jsx(le,{variant:d>0?"warn":"info",title:d>0?`${d} documento(s) com erro ou rejeição.`:`${g} documento(s) ainda processando.`,body:d>0?"Abra cada um, veja o motivo da SEFAZ no Resumo e reemita após corrigir.":"Aguarde o webhook da SEFAZ — pode levar alguns minutos em horário de pico.",actions:d>0?[{label:"Filtrar erros",onClick:()=>c("rejeitado"),variant:"primary"}]:[]}):void 0}),e.jsx(ne,{open:!!s,onClose:()=>n(null),title:s?`${s.tipoLabel} ${s.numero||s.ref}`:"",subtitle:s&&e.jsx(ee,{label:s.statusLabel,status:s.statusBadge}),tabs:[{key:"resumo",label:"Resumo",content:s&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(be,{doc:s}),e.jsx(Ee,{doc:s,onChange:j})]})},{key:"xmlpdf",label:"XML/PDF",content:s&&e.jsx(je,{doc:s})},{key:"correcoes",label:"Correções (CCe)",content:s&&e.jsx(we,{doc:s,onChange:j})},...s&&(s.type==="mdfe"||s.tipo==="mdfe")?[{key:"mdfe_eventos",label:"Eventos MDF-e",content:e.jsx(De,{doc:s,onChange:j})}]:[],{key:"historico",label:"Histórico",content:s&&e.jsx(Ce,{ref:s.ref})},{key:"atividade",label:"Atividade",content:s&&e.jsx(ce,{objectType:"documento",objectId:s.id})},{key:"comentarios",label:"Comentários",content:s&&e.jsx(ie,{objectType:"documento",objectId:s.id})}],size:"lg"}),m&&e.jsx(re,{open:!0,onClose:()=>{m.resolve(),f(null)},title:`Cancelar ${m.refs.length} documento(s)?`,description:e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{children:"O cancelamento é enviado à SEFAZ. Documentos com mais de 24h podem ser rejeitados."}),e.jsx("label",{className:"block text-xs",style:{color:"var(--page-text-muted)"},children:"Justificativa (mín. 15 caracteres) — exigida pela SE
1FAZ"}),e.jsx("textarea",{value:a,onChange:r=>h(r.target.value),className:"w-full px-2 py-1 rounded text-sm",style:{background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",color:"var(--page-text)",minHeight:80},placeholder:"Ex: erro de digitação no destinatário, valor incorreto, etc."}),e.jsxs("p",{className:"text-[10px]",style:{color:"var(--page-text-muted)"},children:[a.trim().length," / 15 caracteres mín."]})]}),confirmLabel:"Cancelar documentos",onConfirm:R})]})}function Ae(t){if(!t)return"—";const l=new Date(t);return isNaN(l.getTime())?"—":l.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"2-digit"})+" "+l.toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"})}export{Xe as DocumentosList};

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.