1import{j as e}from"./vendor-motion-CPxq9Xvn.js";import{r as n}from"./vendor-i18n-CO3kK2bH.js";import{a3 as ue,ai as pe,u as J,a6 as k,ar as je,ax as ve,a as ge,B as l,aG as fe,a7 as m,ao as G,b0 as V,eQ as D,ei as ne,D as q,q as F,aj as R,r as U,eR as de,al as H,$ as Ne,k as be,at as X,ak as we,aI as $,a4 as Y,X as ye,aJ as ke,an as v}from"./index-CFAvyuXu.js";import{C as Z}from"./card-CkkuFnhL.js";import{B as De}from"./badge-B9GAfHbC.js";import{U as ee}from"./upload-BKNIN1AN.js";import"./vendor-react-CQmBMThG.js";const Se=["all","pending_submission","submitted","in_progress","awaiting_author_review","awaiting_revision_info","completed","failed_to_submit","cancelled"];function Ue(){const{toast:o}=ue(),x=pe(),[S,oe]=n.useState("all"),[c,z]=n.useState(null),[O,C]=n.useState(null),[ae,L]=n.useState(""),[h,P]=n.useState(null),[f,u]=n.useState(null),[E,g]=n.useState(""),[M,N]=n.useState(""),[se,te]=n.useState("application/pdf"),[ie,T]=n.useState(!1),[I,b]=n.useState("upload"),[p,w]=n.useState(null),[ce,A]=n.useState(!1),le=n.useRef(null),{data:_,isLoading:me}=J({queryKey:["/api/admin/human-services",S],queryFn:async()=>{const a=S!=="all"?`?status=${S}`:"";return(await v("GET",`/api/admin/human-services${a}`)).json()}}),{data:i}=J({queryKey:["/api/admin/human-services",c],queryFn:async()=>(await v("GET",`/api/admin/human-services/${c}`)).json(),enabled:!!c}),{data:t,isFetching:xe}=J({queryKey:["/api/admin/human-services",h,"raw-digiwork"],queryFn:async()=>(await v("GET",`/api/admin/human-services/${h}/raw-digiwork`)).json(),enabled:!!h,staleTime:0,gcTime:0}),W=k({mutationFn:async({id:a,reason:s})=>{const r=await v("POST",`/api/admin/human-services/${a}/refund`,{reason:s||void 0}),j=await r.json();if(!r.ok)throw new Error(j.message||"Erro");return j},onSuccess:a=>{o({title:a.idempotent?"Já estava cancelado":"â Estorno realizado",description:a.refundId?`Refund ${a.refundId} (${a.refundStatus||"ok"}) â DigiWork notificado em paralelo`:"Pedido marcado como cancelado"}),x.invalidateQueries({queryKey:["/api/admin/human-services"]}),C(null),L(""),z(null)},onError:a=>o({title:"Falha no estorno",description:a.message,variant:"destructive"})}),d=k({mutationFn:async a=>{const s=await v("POST",`/api/admin/human-services/${a}/resync-from-digiwork`),r=await s.json();if(!s.ok)throw new Error(r.message||"Erro");return r},onSuccess:(a,s)=>{o({title:a.updated?"â Dados atualizados!":"Tudo em sincronia",description:`Status: ${a.status} · Entregáveis: ${a.deliverableCount??0}`}),x.invalidateQueries({queryKey:["/api/admin/human-services"]}),x.invalidateQueries({queryKey:["/api/admin/human-services",s]})},onError:a=>o({title:"Resync falhou",description:a.message,variant:"destructive"})}),K=k({mutationFn:async({id:a,fileName:s,downloadUrl:r,mimeType:j})=>{const y=await v("POST",`/api/admin/human-services/${a}/manual-deliverable`,{fileName:s,downloadUrl:r,mimeType:j}),re=await y.json();if(!y.ok)throw new Error(re.message||"Erro");return re},onSuccess:(a,s)=>{o({title:"â Entregável inserido",description:s.fileName}),x.invalidateQueries({queryKey:["/api/admin/human-services"]}),x.invalidateQueries({queryKey:["/api/admin/human-services",s.id]}),u(null),g(""),N(""),te("application/pdf")},onError:a=>o({title:"Falha ao inserir entregável",description:a.message,variant:"destructive"})}),Q=k({mutationFn:async({id:a,file:s})=>{const r=new FormData;r.append("file",s);const j=await fetch(`/api/admin/human-services/${a}/upload-deliverable`,{method:"POST",body:r,credentials:"include"}),y=await j.json();if(!j.ok)throw new Error(y.message||"Erro no upload");return y},onSuccess:(a,s)=>{o({title:"â PDF enviado com sucesso!",description:`Arquivo salvo permanentemente. URL: ${a.downloadUrl}`}),x.invalidateQueries({queryKey:["/api/admin/human-services"]}),x.invalidateQueries({queryKey:["/api/admin/human-services",s.id]}),u(null),w(null),b("upload")},onError:a=>o({title:"Falha no upload",description:a.message,variant:"destructive"})}),B=k({mutationFn:async a=>{const s=await v("POST",`/api/admin/human-services/${a}/reprocess-da`),r=await s.json();if(!s.ok)throw new Error(r.message||"Erro");return r},onSuccess:(a,s)=>{o({title:"â DA reprocessado!",description:"Número inválido removido · URLs renovadas · Certificado regenerado"}),x.invalidateQueries({queryKey:["/api/admin/human-services"]}),x.invalidateQueries({queryKey:["/api/admin/human-services",s]})},onError:a=>o({title:"Reprocessar DA falhou",description:a.message,variant:"destructive"})}),he=a=>
1a.status!=="cancelled"&&a.status!=="completed";return e.jsx(je,{children:e.jsxs("div",{className:"min-h-screen px-4 md:px-10 py-6 md:py-10 pb-24 md:pb-10",children:[e.jsxs("header",{className:"mb-6 flex items-start justify-between gap-3 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold text-emerald-100 flex items-center gap-2",children:[e.jsx(ve,{className:"h-7 w-7"})," Serviços Humanos (DigiWork)"]}),e.jsx("p",{className:"text-slate-400 text-sm mt-1",children:"Painel interno â visÃvel só pra admins. Mostra integration name real pra debug."})]}),e.jsx(ge,{href:"/admin/digiwork-webhooks",children:e.jsxs(l,{variant:"outline",size:"sm","data-testid":"link-webhooks-config",children:[e.jsx(fe,{className:"h-3.5 w-3.5 mr-1.5"})," Configurar Webhooks"]})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:Se.map(a=>e.jsx("button",{onClick:()=>oe(a),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${S===a?"bg-emerald-600 text-white":"bg-white/10 text-slate-300 hover:bg-white/15"}`,"data-testid":`filter-${a}`,children:a},a))}),me?e.jsx(Z,{className:"p-10 text-center",children:e.jsx(m,{className:"h-6 w-6 mx-auto animate-spin"})}):!_||_.length===0?e.jsx(Z,{className:"p-10 text-center text-slate-500",children:"Nenhum pedido"}):e.jsx(Z,{className:"overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-white/5 text-xs uppercase text-slate-400",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3",children:"Serviço"}),e.jsx("th",{className:"text-left p-3 hidden md:table-cell",children:"Autor"}),e.jsx("th",{className:"text-left p-3",children:"Status"}),e.jsx("th",{className:"text-left p-3 hidden md:table-cell",children:"External ID"}),e.jsx("th",{className:"text-left p-3 hidden lg:table-cell",children:"Criado"}),e.jsx("th",{className:"p-3"})]})}),e.jsx("tbody",{children:_.map(a=>e.jsxs("tr",{className:"border-t border-white/5 hover:bg-white/5",children:[e.jsx("td",{className:"p-3 font-medium",children:a.serviceLabel}),e.jsx("td",{className:"p-3 hidden md:table-cell text-slate-300",children:a.authorName||a.authorEmail||"â"}),e.jsx("td",{className:"p-3",children:e.jsx(De,{variant:"outline",children:a.status})}),e.jsx("td",{className:"p-3 hidden md:table-cell text-xs font-mono text-slate-400",children:a.externalPedidoId||"â"}),e.jsx("td",{className:"p-3 hidden lg:table-cell text-xs text-slate-400",children:new Date(a.createdAt).toLocaleString("pt-BR")}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex gap-1.5 justify-end flex-wrap",children:[e.jsx(l,{size:"sm",variant:"outline",onClick:()=>z(a.id),"data-testid":`button-detail-${a.id}`,children:"Ver"}),a.externalPedidoId&&e.jsx(l,{size:"sm",variant:"outline",className:"text-cyan-400 border-cyan-700/50 hover:bg-cyan-950/30",disabled:d.isPending&&d.variables===a.id,onClick:()=>d.mutate(a.id),"data-testid":`button-resync-${a.id}`,title:"Sincronizar com DigiWork agora",children:d.isPending&&d.variables===a.id?e.jsx(m,{className:"h-3 w-3 animate-spin"}):e.jsx(G,{className:"h-3 w-3"})}),a.externalPedidoId&&e.jsx(l,{size:"sm",variant:"outline",className:"text-violet-400 border-violet-700/50 hover:bg-violet-950/30",onClick:()=>{P(a.id),T(!1)},"data-testid":`button-inspect-${a.id}`,title:"Inspecionar resposta raw do DigiWork",children:e.jsx(V,{className:"h-3 w-3"})}),a.status==="completed"&&e.jsx(l,{size:"sm",variant:"outline",className:"text-amber-400 border-amber-700/50 hover:bg-amber-950/30",onClick:()=>{u(a.id),g(""),N("")},"data-testid":`button-manual-deliver-${a.id}`,title:"Entregar arquivo manualmente",children:e.jsx(D,{className:"h-3 w-3"})}),he(a)&&e.jsx(l,{size:"sm",variant:"outline",className:"text-rose-400 border-rose-700/50 hover:bg-rose-950/30",onClick:()=>{C(a.id),L("")},"data-testid":`button-refund-${a.id}`,children:e.jsx(ne,{className:"h-3 w-3"})})]})})]},a.id))})]})}),e.jsx(q,{open:!!c,onOpenChange:a=>!a&&z(null),children:e.jsxs(F,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(R,{children:e.jsx(U,{children:i?.serviceLabel||"Detalhe"})}),i?e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Status local:"})," ",i.status]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Status DigiWork:"})," ",i.externalStatusRaw||"â"]}
1),e.jsxs("div",{children:[e.jsx("strong",{children:"External Pedido ID:"})," ",e.jsx("code",{className:"text-xs",children:i.externalPedidoId||"â"})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"External Request ID:"})," ",e.jsx("code",{className:"text-xs",children:i.externalRequestId})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Autor:"})," ",i.authorName," (",i.authorEmail,")"]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Input payload:"}),e.jsx("pre",{className:"bg-slate-900 text-emerald-200 p-3 rounded text-xs overflow-x-auto mt-1",children:JSON.stringify(i.rawInputPayload,null,2)})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Deliverable fields (snapshot):"}),(i.deliverableFields||[]).length===0?e.jsx("span",{className:"text-slate-500 ml-2",children:"nenhum"}):e.jsx("ul",{className:"mt-1 space-y-1",children:(i.deliverableFields||[]).map((a,s)=>e.jsxs("li",{className:"text-xs flex gap-2 items-start",children:[e.jsxs("span",{className:"text-violet-300 font-mono shrink-0",children:["[",a.tipo||"?","]"]}),e.jsx("span",{className:"text-slate-300 font-medium",children:a.label}),a.valor&&/^https?:\/\//i.test(a.valor)?e.jsx("a",{href:a.valor,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 underline truncate max-w-[260px]",children:a.valor}):e.jsx("span",{className:"text-emerald-300 truncate max-w-[260px]",children:a.valor})]},a.fieldId||s))})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Deliverables (arquivos formais):"}),(i.deliverables||[]).length===0?e.jsx("span",{className:"text-rose-400 ml-2",children:"0 â arquivo não extraÃdo ainda"}):e.jsx("ul",{className:"mt-1 space-y-1",children:(i.deliverables||[]).map(a=>e.jsxs("li",{className:"text-xs",children:[e.jsx("a",{href:a.downloadUrl,target:"_blank",rel:"noopener noreferrer",className:"text-emerald-400 underline",children:a.fileName})," ","(v",a.version,")"]},a.id))})]}),e.jsxs("div",{children:[e.jsx("strong",{children:"Timeline:"}),e.jsx("ol",{className:"mt-1 space-y-1",children:(i.timeline||[]).map(a=>e.jsxs("li",{className:"text-xs",children:[e.jsx("span",{className:"text-slate-500",children:new Date(a.createdAt).toLocaleString("pt-BR")})," ","â ",a.fromStatus||"â
"," â ",e.jsx("strong",{children:a.toStatus})," ",e.jsxs("span",{className:"text-slate-400",children:["(",a.cause,")"]})]},a.id))})]}),e.jsxs("div",{className:"flex gap-2 pt-2 flex-wrap",children:[i.externalPedidoId&&e.jsxs(l,{size:"sm",variant:"outline",className:"text-cyan-400 border-cyan-700/50",disabled:d.isPending,onClick:()=>c&&d.mutate(c),"data-testid":"button-detail-resync",children:[d.isPending?e.jsx(m,{className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(G,{className:"h-3.5 w-3.5 mr-1"}),"Resync DigiWork"]}),i.externalPedidoId&&e.jsxs(l,{size:"sm",variant:"outline",className:"text-violet-400 border-violet-700/50",onClick:()=>{P(c),T(!1)},"data-testid":"button-detail-inspect",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"})," Inspecionar DigiWork"]}),i.status==="completed"&&e.jsxs(l,{size:"sm",variant:"outline",className:"text-amber-400 border-amber-700/50",onClick:()=>{u(c),g(""),N("")},"data-testid":"button-detail-manual-deliver",children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1"})," Entregar manualmente"]}),i.serviceSlug==="direito_autoral"&&e.jsxs(l,{size:"sm",variant:"outline",className:"text-emerald-400 border-emerald-700/50",disabled:B.isPending,onClick:()=>c&&B.mutate(c),"data-testid":"button-detail-reprocess-da",children:[B.isPending?e.jsx(m,{className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(de,{className:"h-3.5 w-3.5 mr-1"}),"Reprocessar DA"]})]})]}):e.jsx(m,{className:"h-6 w-6 animate-spin mx-auto"})]})}),e.jsx(q,{open:!!h,onOpenChange:a=>!a&&P(null),children:e.jsxs(F,{className:"max-w-3xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2 text-violet-300",children:[e.jsx(V,{className:"h-5 w-5"})," Inspeção DigiWork"]}),e.jsx(H,{children:"Resposta ao vivo da API DigiWork para este pedido â campos, tipos e URLs detectadas."})]}),xe?e.jsx("div",{className:"flex justify-center py-10",children:e.jsx(m,{className:"h-8 w-8 animate-spin text-violet-400"})}):t?e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{className:"bg-white/5 rounded-lg p-3",children:[e.jsx("p",{className:"text-slate-400",children:"Status local"}),e.jsx("p",{className:"font-bold text-white",children:t.localStatus})]}),e.jsxs("div",{className:"bg-white/5 rounded-lg p-3",children:[e.jsx("p",{className:"text-slate-400",children:"Status DigiWork"}),e.jsx("p",{className:"font-bold text-white",children:t.externalStatusRaw||"â"})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-slate-200 mb-2",children:["fetchPedido"," ",e.jsx("span",{className:t.fetchPedido?.ok?"text-emerald-400":"text-rose-400",children:t.fetchPedido?.ok?"â ok":"â falhou"})]}),t.fetchPedido?.normalized&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-xs text-slate-400",children:["Arquivos diretos: ",e.jsx("strong",{children:t.fetchPedido.normalized.arquivos})," · ","Campos: ",e.jsx("strong",{children:t.fetchPedido.normalized.campos?.length??0})]}),(t.fetchPedido.normalized.campos||[]).map((a,s)=>e.jsx("div",{className:`rounded-lg border p-3 text-xs ${a.valorIsUrl?"border-emerald-500/40 bg-emerald-950/15":"border-white/10 bg-white/5"}`,children:e.jsxs("div",{className:"flex gap-2 items-center flex-wrap",children:[e.jsx("span",{className:`font-mono px-1.5 py-0.5 rounded text-[10px] ${a.valorIsUrl?"bg-emerald-500/20 text-emerald-300":"bg-white/10 text-slate-300"}`,children:a.tipo||"?"}),e.jsx("span",{className:"font-medium text-white",children:a.label}),a.valorIsUrl&&e.jsx("span",{className:"text-emerald-400 font-bold",children:"â URL detectada â"}),!a.hasValor&&e.jsx("span",{className:"text-slate-500",children:"sem valor"}),a.arquivosCount>0&&e.jsxs("span",{className:"text-cyan-400",children:[a.arquivosCount," arquivo(s) em arquivos[]"]})]})},s))]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-slate-200 mb-2",children:["refreshDeliverableUrls"," ",e.jsx("span",{className:t.refreshUrls?.ok?"text-emerald-400":"text-amber-400",children:t.refreshUrls?.ok?"â ok":"â falhou/sem dados"})]}),t.refreshUrls?.normalized&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Arquivos: ",e.jsx("strong",{children:t.refreshUrls.normalized.arquivos})," · ","Campos: ",e.jsx("strong",{children:t.refreshUrls.normalized.campos?.length??0})]})]}),t.snapshotCampos&&t.snapshotCampos.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-slate-200 mb-2",children:"Snapshot no DB (campos)"}),t.snapshotCampos.map((a,s)=>e.jsxs("div",{className:`rounded-lg border p-3 text-xs mb-2 ${a.valorIsUrl?"border-emerald-500/40 bg-emerald-950/15":"border-white/10 bg-white/5"}`,children:[e.jsxs("div",{className:"flex gap-2 items-center flex-wrap mb-1",children:[e.jsxs("span",{className:"font-mono text-violet-300",children:["[",a.tipo||"?","]"]}),e.jsx("span",{className:"font-medium text-white",children:a.label}),a.valorIsUrl&&e.jsx("span",{className:"text-emerald-400 font-bold",children:"â URL â"})]}),a.valorIsUrl&&a.valor&&e.jsx("a",{href:a.valor,target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 underline break-all text-[11px]",children:a.valor})]},s))]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold text-slate-200 mb-2",children:["Deliverables formais no DB: ",e.jsx("strong",{children:t.existingDeliverables?.length??0})]}),t.existingDeliverables?.length===0&&e.jsx("p",{className:"text-xs text-rose-400",children:'â Nenhum arquivo formal salvo ainda. Se campos acima têm URL, clique "Resync" ou "Entregar manualmente".'})]}),e.jsxs("div",{children:[e.jsxs("button",{className:"flex items-center gap-1.5 text-xs text-slate-400 hover:text-white transition-colors",onClick:()=>T(a=>!a),children:[ie?e.jsx(Ne,{className:"h-3 w-3"}):e.jsx(be,{className:"h-3 w-3"}),"Ver resposta raw JSON completa"]}),ie&&e.jsx("pre",{className:"bg-slate-900 text-emerald-200 p-3 rounded text-[10px] overflow-x-auto mt-2 max-h-64",children:JSON.stringify(t.fetchPedido?.rawData,null,2)})]})]}):e.jsx("p",{className:"text-slate-500 text-sm",children:"Sem dados â pedido pode não ter externalPedidoId."}),e.jsx(X,{children:e.jsxs("div",{className:"flex gap-2 w-full flex-wrap",children:[h&&e.jsxs(e.Fragment,{children:[e.jsxs(l,{size:"sm",variant:"outline",className:"text-cyan-400 border-cyan-700/50",disabled:d.isPending,onClick:()=>d.mutate(h),children:[d.isPending?e.jsx(m,{className:"h-3.5 w-3.5 animate-spin mr-1"}):e.jsx(G,{className:"h-3.5 w-3.5 mr-1"}),"Resync agora"]}),e.jsxs(l,{size:"sm",variant:"outline",className:"text-amber-400 border-amber-700/50",onClick:()=>{u(h),g(""),N("")},children:[e.jsx(D,{className:"h-3.5 w-3.5 mr-1"})," Entregar manualmente"]})]}),e.jsx(l,{variant:"outline",className:"ml-auto",onClick:()=>P(null),children:"Fechar"})]})})]})}),e.jsx(q,{open:!!f,onOpenChange:a=>{a||(u(null),w(null),b("upload"))},children:e.jsxs(F,{className:"max-w-lg","data-testid":"dialog-manual-deliver",children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2 text-amber-300",children:[e.jsx(D,{className:"h-5 w-5"})," Entregar arquivo manualmente"]}),e.jsx(H,{children:'Salva o PDF diretamente no nosso Object Storage (URL permanente). O autor baixa normalmente após clicar em "Atualizar status".'})]}),e.jsxs("div",{className:"flex rounded-lg overflow-hidden border border-white/10 text-xs font-semibold",children:[e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1.5 py-2 transition-colors ${I==="upload"?"bg-emerald-600 text-white":"bg-white/5 text-slate-400 hover:bg-white/10"}`,onClick:()=>b("upload"),"data-testid":"mode-upload",children:[e.jsx(ee,{className:"h-3.5 w-3.5"})," Fazer upload do PDF"]}),e.jsxs("button",{className:`flex-1 flex items-center justify-center gap-1.5 py-2 transition-colors ${I==="url"?"bg-emerald-600 text-white":"bg-white/5 text-slate-400 hover:bg-white/10"}`,onClick:()=>b("url"),"data-testid":"mode-url",children:[e.jsx(we,{className:"h-3.5 w-3.5"})," Inserir URL"]})]}),I==="upload"?e.jsxs("div",{className:"space-y-3 py-1",children:[e.jsxs("div",{className:`relative flex flex-col items-center justify-center gap-3 rounded-xl border-2 border-dashed p-8 transition-colors cursor-pointer ${ce?"border-emerald-400 bg-emerald-950/30":"border-white/20 bg-white/[0.02] hover:border-white/30 hover:bg-white/[0.04]"}`,onDragOver:a=>{a.preventDefault(),A(!0)},onDragLeave:()=>A(!1),onDrop:a=>{a.preventDefault(),A(!1);const s=a.dataTransfer.files[0];s&&w(s)},onClick:()=>le.current?.click(),"data-testid":"dropzone-pdf",children:[e.jsx("input",{ref:le,type:"file",accept:"application/pdf,.pdf",className:"hidden",onChange:a=>{const s=a.target.files?.[0];s&&w(s)},"data-testid":"input-file-pdf"}),p?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"h-10 w-10 text-emerald-400"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-bold text-emerald-200",children:p.name}),e.jsxs("p",{className:"text-xs text-slate-400 mt-0.5",children:[Math.round(p.size/1024)," KB · Clique para trocar"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"h-10 w-10 text-slate-500"}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-300",children:"Arraste o PDF aqui"}),e.jsx("p",{className:"text-xs text-slate-500 mt-1",children:"ou clique para selecionar · até 30 MB"})]})]})]}),p&&e.jsx("p",{className:"text-[11px] text-slate-400 text-center",children:"O arquivo será salvo permanentemente no nosso servidor e o autor poderá baixar imediatamente."})]}):e.jsxs("div",{className:"space-y-3 py-1",children:[e.jsxs("div",{children:[e.jsxs($,{htmlFor:"manual-url",className:"text-xs",children:["URL do arquivo ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsx(Y,{id:"manual-url",value:M,onChange:a=>
1{if(N(a.target.value),!E&&a.target.value)try{const r=new URL(a.target.value).pathname.split("/").pop()||"";r&&g(decodeURIComponent(r))}catch{}},placeholder:"https://...",className:"mt-1 font-mono text-xs","data-testid":"input-manual-url"})]}),e.jsxs("div",{children:[e.jsxs($,{htmlFor:"manual-filename",className:"text-xs",children:["Nome do arquivo ",e.jsx("span",{className:"text-rose-400",children:"*"})]}),e.jsx(Y,{id:"manual-filename",value:E,onChange:a=>g(a.target.value),placeholder:"ficha_catalografica.pdf",className:"mt-1","data-testid":"input-manual-filename"})]}),e.jsxs("div",{children:[e.jsx($,{htmlFor:"manual-mime",className:"text-xs",children:"MIME type"}),e.jsx(Y,{id:"manual-mime",value:se,onChange:a=>te(a.target.value),placeholder:"application/pdf",className:"mt-1 font-mono text-xs","data-testid":"input-manual-mime"})]})]}),e.jsxs(X,{children:[e.jsx(l,{variant:"outline",onClick:()=>{u(null),w(null),b("upload")},children:"Cancelar"}),I==="upload"?e.jsx(l,{disabled:!p||Q.isPending,onClick:()=>f&&p&&Q.mutate({id:f,file:p}),className:"bg-emerald-600 hover:bg-emerald-500","data-testid":"button-upload-deliver-confirm",children:Q.isPending?e.jsxs(e.Fragment,{children:[e.jsx(m,{className:"h-4 w-4 animate-spin mr-1.5"})," Enviandoâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(ee,{className:"h-4 w-4 mr-1.5"})," Enviar PDF"]})}):e.jsx(l,{disabled:!M.trim()||!E.trim()||K.isPending,onClick:()=>f&&K.mutate({id:f,fileName:E.trim(),downloadUrl:M.trim(),mimeType:se.trim()||"application/pdf"}),"data-testid":"button-manual-deliver-confirm",children:K.isPending?e.jsx(m,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"h-4 w-4 mr-1.5"})," Inserir entregável"]})})]})]})}),e.jsx(q,{open:!!O,onOpenChange:a=>!a&&C(null),children:e.jsxs(F,{className:"max-w-md","data-testid":"dialog-refund-confirm",children:[e.jsxs(R,{children:[e.jsxs(U,{className:"flex items-center gap-2 text-amber-300",children:[e.jsx(ye,{className:"h-5 w-5"})," Estornar pedido?"]}
1),e.jsxs(H,{children:["Vai chamar a API Woovi pra devolver o valor ao autor, marcar o pedido como"," ",e.jsx("code",{children:"cancelled"})," e notificar o DigiWork via webhook (se configurado). O autor recebe notificação no sino. Esta ação é ",e.jsx("strong",{children:"irreversÃvel"}),"."]})]}),e.jsxs("div",{className:"py-2",children:[e.jsx($,{htmlFor:"refund-reason",className:"text-xs",children:"Motivo (opcional, registrado em audit)"}),e.jsx(ke,{id:"refund-reason",value:ae,onChange:a=>L(a.target.value),placeholder:"Ex: autor solicitou cancelamento via WhatsApp; pedido duplicado; etc.",rows:3,className:"mt-1","data-testid":"input-refund-reason"})]}),e.jsxs(X,{children:[e.jsx(l,{variant:"outline",onClick:()=>C(null),"data-testid":"button-refund-cancel",children:"Cancelar"}),e.jsx(l,{variant:"destructive",disabled:W.isPending,onClick:()=>O&&W.mutate({id:O,reason:ae}),"data-testid":"button-refund-confirm",children:W.isPending?e.jsx(m,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"h-4 w-4 mr-1.5"})," Confirmar estorno"]})})]})]})})]})})}export{Ue 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.