PageSourceSearch

https://santaritadoeste.sp.gov.br/assets/index-D9eSejVH.js

js santaritadoeste.sp.gov.br collected 2026-09-25 05:40:39 UTC 24,990 bytes, 1 lines download raw bytes

1import{j as e,r as p}from"./react-core-SJCqmpBs.js";import{a as Z,J as y,B as E,a4 as b,a5 as A,a6 as P,a7 as V,a8 as k,a9 as F,b4 as te,aH as R,I as ie,b6 as ne,b7 as le,b8 as ce,b9 as de}from"./index-HPRL_Gmq.js";import{A as me}from"./AdminHeader-C68IE-W0.js";import{S as G}from"./skeleton-ZENifBrq.js";import{T as ue,a as pe,b as H,c as J}from"./Tabs-Comue9ZB.js";import{f as T,O as M,a as I,T as Y,b as ee,j as K,F as xe,k as Q,u as he,l as be,p as L,m as ge,n as je,e as ve,o as fe,d as _e,q as Ne}from"./useEmendaExecucao-Dd7ldbW9.js";import{C as ye,a as we}from"./Card-BwWpkBqR.js";import{u as Se}from"./index.esm-BYybDVNF.js";import{a as Ce}from"./zod-rUjrEA2w.js";import{u as Ee}from"./index-CwEkjK02.js";import{G as Ae,P as Pe}from"./pdfProcessor-De7AqafM.js";import{m as W,bm as ae,b as U,br as se,P as re,S as Ve,cT as ke}from"./icons-Ftwg0gFU.js";import{o as Fe,s as N,n as q,_ as $,b as Te}from"./schemas-CXGFQPNk.js";import"./radix-Cn1BSsAS.js";import"./supabase-Dr7v01qy.js";import"./dates-CW3_KQM6.js";import"./animation-9S7D5_Pu.js";import"./dnd-D1ccY35k.js";import"./pdf-6Wor9Jnl.js";function Ie({emendas:o}){const l=o.length,c=o.reduce((t,d)=>t+(d.valor_previsto??0),0),m=o.reduce((t,d)=>t+(d.valor_repassado??0),0),x=new Set(o.map(t=>t.exercicio)).size,u=[{label:"Emendas",value:String(l)},{label:"Exercícios",value:String(x)},{label:"Valor previsto",value:T(c)},{label:"Valor repassado",value:T(m)}];return e.jsx("div",{className:"mb-6 grid grid-cols-2 gap-3 lg:grid-cols-4 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-1",children:u.map(t=>e.jsx(ye,{children:e.jsxs(we,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:t.label}),e.jsx("p",{className:"text-xl font-semibold tabular-nums",children:t.value})]})},t.label))})}function Oe({onDraft:o}){const{client:l}=Z(),[c,m]=p.useState(!1),[x,u]=p.useState(""),t=p.useCallback(async r=>{if(!r.trim()){y.error("Nada para analisar");return}m(!0);try{const s=await Ae.analyzeEmenda(l,r);o(s),y.success("Dados extraídos! Revise antes de salvar."),s.issues.length&&y.warning("A IA apontou possíveis inconsistências",{description:s.issues.join(" · ")})}catch{y.error("Falha ao analisar o documento.")}finally{m(!1)}},[l,o]),d=p.useCallback(async r=>{const s=r[0];if(s){m(!0);try{const j=await new Pe().processPDF(l,s);await t(j.text)}catch{y.error("Não foi possível ler o PDF.")}finally{m(!1)}}},[l,t]),{getRootProps:_,getInputProps:n,isDragActive:f}=Ee({onDrop:d,accept:{"application/pdf":[".pdf"]},maxFiles:1,disabled:c});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{..._(),className:`flex flex-col items-center justify-center gap-2 rounded-xl border border-dashed p-6 text-center transition-[background-color,border-color,transform] duration-200 ease-out ${f?"border-primary bg-primary/5 motion-safe:scale-[1.01]":"border-border bg-muted/30 hover:bg-muted/50"}`,children:[e.jsx("input",{...n()}),c?e.jsx(W,{className:"size-6 animate-spin text-primary"}):e.jsx(ae,{className:"size-6 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Solte o PDF aqui…":"Arraste o ofício / plano de trabalho (PDF) ou clique para enviar"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"h-px flex-1 bg-border"})," ou cole o texto"," ",e.jsx("span",{className:"h-px flex-1 bg-border"})]}),e.jsx("textarea",{value:x,onChange:r=>u(r.target.value),rows:5,placeholder:"Cole aqui o texto do documento da emenda…","aria-label":"Texto do documento da emenda para extração com IA",className:"w-full resize-y rounded-lg border border-border bg-background p-3 text-sm",disabled:c}),e.jsxs(E,{type:"button",onClick:()=>t(x),disabled:c||!x.trim(),className:"gap-2",children:[c?e.jsx(W,{className:"size-4 animate-spin"}):e.jsx(U,{className:"size-4"}),"Extrair com IA"]})]})}const De=2100,Re=Fe({exercicio:q().int().min(2e3).max(De),origem:$(["federal","estadual","municipal"]),numero_identificacao:N().min(1,"Informe o número de identificação"),ato_normativo:N().nullable(),tipo:$(["individual","bancada","comissao","relator","outro"]),autoria:N().min(2,"Informe a autoria"),forma_repasse:$(["transferencia_especial","fundo_a_fundo","convenio","com_finalidade_definida","outro"]).nullable(),instrumento_numero:N().nullable(),valor_previsto:q().nonnegative().nullable(),valor_repassado:q().nonnegative().nullable(),objeto:N().min(5,"Descreva o objeto/finalidade"),funcao_governo:N().nullable(),plano_trabalho:N().nullable(),data_inicio_prevista:N().nullable(),data_termino_prevista:N().nullable(),documento_origem_url:N().nullable(),is_public:Te()});function ze(o){const l=[];return o.valor_previsto!=null&&o.valor_repassado!=null&&o.valor_repassado>o.valor_previsto&&l.push({field:"valor_repassado",severity:"warning",message:"Valor repassado é maior que o previsto — confirme os valores."}),o.data_inicio_prevista&&o.data_termino_prevista&&o.data_termino_prevista<o.data_inicio_prevista&&l.push({field:"data_termino_prevista",severity:"warning",message:"Término previsto é anterior ao início."}),o.funcao_governo||l.push({field:"funcao_governo",severity:"warning",message:"Função de governo não informada."}),l}const Le={exercicio:new Date().getFullYear(),origem:"federal",numero_identificacao:"",ato_normativo:null,tipo:"individual",autoria:"",forma_repasse:null,instrumento_numero:null,valor_previsto:null,valor_repassado:null,objeto:"",funcao_governo:null,plano_trabalho:null,data_inicio_prevista:null,data_termino_prevista:null,documento_origem_url:null,is_public:!0};function qe(o){const{id:l,company_id:c,ai_confidence:m,created_at:x,updated_at:u,deleted_at:t,...d}=o;return d}function $e({emenda:o,onSubmit:l,onCancel:c}){const[m,x]=p.useState(o?.ai_confidence??null),[u,t]=p.useState(()=>{const a=o?.ai_confidence;return a?new Set(Object.keys(a).filter(i=>(a[i]??1)<.6)):new Set}),[d,_]=p.useState(!1),n=Se({resolver:Ce(Re),defaultValues:o?qe(o):Le});p.useEffect(()=>{const a=n.watch((i,{name:v})=>{v&&t(C=>{if(!C.has(v))return C;const h=new Set(C);return h.delete(v),h})});return()=>a.unsubscribe()},[n]);const f=a=>{const i=n.getValues(),v=(O,D,oe)=>O!=null&&D.includes(O)?O:oe;n.reset({...i,exercicio:a.exercicio??i.exercicio,origem:v(a.origem,M,i.origem)??i.origem,numero_identificacao:a.numero_identificacao??"",ato_normativo:a.ato_normativo,tipo:v(a.tipo,Y,"individual")??"individual",autoria:a.autoria??"",forma_repasse:v(a.forma_repasse,K,null),instrumento_numero:a.instrumento_numero,valor_previsto:a.valor_previsto,valor_repassado:a.valor_repassado,objeto:a.objeto??"",funcao_governo:v(a.funcao_governo,Q,null),plano_trabalho:a.plano_trabalho,data_inicio_prevista:a.data_inicio_prevista,data_termino_prevista:a.data_termino_prevista}),x(a.confidence);const C=new Set,h=(O,D)=>{D!=null&&D!==""&&C.add(O)};h("exercicio",a.exercicio),h("origem",a.origem),h("numero_identificacao",a.numero_identificacao),h("ato_normativo",a.ato_normativo),h("tipo",a.tipo),h("autoria",a.autoria),h("forma_repasse",a.forma_repasse),h("instrumento_numero",a.instrumento_numero),h("valor_previsto",a.valor_previsto),h("valor_repassado",a.valor_repassado),h("objeto",a.objeto),h("funcao_governo",a.funcao_governo),h("plano_trabalho",a.plano_trabalho),h("data_inicio_prevista",a.data_inicio_prevista),h("data_termino_prevista",a.data_termino_prevista),t(C)},r=a=>u.has(a),s=a=>
1r(a)&&!!(m&&(m[a]??1)<.6),j=n.handleSubmit(async a=>{const i=ze(a);i.length&&y.warning("Verifique os avisos",{description:i.map(v=>v.message).join(" · ")}),_(!0);try{await l(a,m)}finally{_(!1)}}),w=a=>n.register(a,{setValueAs:i=>i===""||i===null||i===void 0?null:Number(i)}),S=u.size;return e.jsxs("div",{className:"space-y-6",children:[!o&&e.jsxs("div",{className:"rounded-lg border border-border p-4",children:[e.jsx("p",{className:"mb-3 text-sm font-medium",children:"Preenchimento assistido por IA"}),e.jsx(Oe,{onDraft:f})]}),!o&&S>0&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-violet-200 bg-violet-50/60 px-3 py-2 text-xs text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-300 motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-top-1",children:[e.jsx(U,{className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsxs("span",{children:[S," ",S===1?"campo preenchido":"campos preenchidos"," pela IA — confira os destacados antes de salvar."]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-6",children:[e.jsxs(z,{title:"Identificação",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{label:"Exercício",ai:r("exercicio"),warn:s("exercicio"),children:e.jsx(b,{type:"number",...n.register("exercicio",{valueAsNumber:!0})})}),e.jsx(g,{label:"Origem",ai:r("origem"),warn:s("origem"),children:e.jsxs(A,{value:n.watch("origem"),onValueChange:a=>n.setValue("origem",a),children:[e.jsx(P,{"aria-label":"Origem",children:e.jsx(V,{})}),e.jsx(k,{children:M.map(a=>e.jsx(F,{value:a,children:I[a]},a))})]})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{label:"Nº identificação",ai:r("numero_identificacao"),warn:s("numero_identificacao"),children:e.jsx(b,{...n.register("numero_identificacao")})}),e.jsx(g,{label:"Ato normativo",ai:r("ato_normativo"),children:e.jsx(b,{...n.register("ato_normativo")})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{label:"Tipo",ai:r("tipo"),warn:s("tipo"),children:e.jsxs(A,{value:n.watch("tipo"),onValueChange:a=>n.setValue("tipo",a),children:[e.jsx(P,{"aria-label":"Tipo",children:e.jsx(V,{})}),e.jsx(k,{children:Y.map(a=>e.jsx(F,{value:a,children:ee[a]},a))})]})}),e.jsx(g,{label:"Autoria",ai:r("autoria"),warn:s("autoria"),children:e.jsx(b,{...n.register("autoria")})})]})]}),e.jsxs(z,{title:"Repasse e valores",className:"border-t border-border pt-6",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{label:"Forma de repasse",ai:r("forma_repasse"),children:e.jsxs(A,{value:n.watch("forma_repasse")??"",onValueChange:a=>n.setValue("forma_repasse",a),children:[e.jsx(P,{"aria-label":"Forma de repasse",children:e.jsx(V,{placeholder:"—"})}),e.jsx(k,{children:K.map(a=>e.jsx(F,{value:a,children:xe[a]},a))})]})}),e.jsx(g,{label:"Nº instrumento (convênio/contrato)",ai:r("instrumento_numero"),children:e.jsx(b,{...n.register("instrumento_numero")})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(g,{label:"Valor previsto (R$)",ai:r("valor_previsto"),warn:s("valor_previsto"),children:e.jsx(b,{type:"number",step:"0.01",...w("valor_previsto")})}),e.jsx(g,{label:"Valor repassado (R$)",ai:r("valor_repassado"),warn:s("valor_repassado"),children:e.jsx(b,{type:"number",step:"0.01",...w("valor_repassado")})})]})]}),e.jsxs(z,{title:"Objeto e cronograma",className:"border-t border-border pt-6",children:[e.jsx(g,{label:"Objeto / finalidade",ai:r("objeto"),warn:s("objeto"),children:e.jsx("textarea",{...n.register("objeto"),rows:3,className:"w-full rounded-lg border border-border bg-background p-2 text-sm"})}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(g,{label:"Função de governo",ai:r("funcao_governo"),warn:s("funcao_governo"),children:e.jsxs(A,{value:n.watch("funcao_governo")??"",onValueChange:a=>n.setValue("funcao_governo",a),children:[e.jsx(P,{"aria-label":"Função de governo",children:e.jsx(V,{placeholder:"—"})}),e.jsx(k,{children:Q.map(a=>e.jsx(F,{value:a,children:a},a))})]})}),e.jsx(g,{label:"Início previsto",ai:r("data_inicio_prevista"),children:e.jsx(b,{type:"date",...n.register("data_inicio_prevista")})}),e.jsx(g,{label:"Término previsto",ai:r("data_termino_prevista"),children:e.jsx(b,{type:"date",...n.register("data_termino_prevista")})})]}),e.jsx(g,{label:"Plano de trabalho / cronograma",ai:r("plano_trabalho"),children:e.jsx("textarea",{...n.register("plano_trabalho"),rows:2,className:"w-full rounded-lg border border-border bg-background p-2 text-sm"})})]}),e.jsx(z,{title:"Publicação",className:"border-t border-border pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{checked:n.watch("is_public"),onCheckedChange:a=>n.setValue("is_public",a),id:"is_public"}),e.jsx(R,{htmlFor:"is_public",children:"Publicar no portal"})]})}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx(E,{type:"submit",disabled:d,children:d?"Salvando…":"Salvar"}),e.jsx(E,{type:"button",variant:"outline",onClick:c,children:"Cancelar"})]})]})]})}function z({title:o,children:l,className:c}){return e.jsxs("section",{className:`space-y-4 ${c??""}`,children:[e.jsx("h3",{className:"text-[0.7rem] font-semibold uppercase tracking-wider text-muted-foreground",children:o}),l]})}function g({label:o,warn:l,ai:c,children:m}){const x=p.useId(),u=`${x}-label`,t=p.isValidElement(m)?p.cloneElement(m,{id:x,"aria-labelledby":u}):m,d=l?"rounded-lg ring-1 ring-amber-300":c?"rounded-lg bg-violet-50/40 ring-1 ring-violet-400/50 dark:bg-violet-500/[0.06]":"";return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(R,{id:u,htmlFor:x,className:"flex items-center gap-1.5 text-xs",children:[o,l?e.jsx("span",{role:"img","aria-label":"Confiança baixa da IA neste campo, revise",className:"text-amber-600 motion-safe:animate-in motion-safe:zoom-in-75",children:"⚠"}):c?e.jsx("span",{role:"img","aria-label":"Preenchido pela IA, confira",className:"text-violet-500 motion-safe:animate-in motion-safe:fade-in motion-safe:zoom-in-75",children:e.jsx(U,{className:"size-3","aria-hidden":"true"})}):null]}),e.jsx("div",{className:`transition-[box-shadow,background-color] duration-300 ease-out ${d}`,children:t})]})}const X={beneficiario:"",beneficiario_documento:null,descricao_despesa:"",numero_empenho:"",valor_empenhado:null,valor_liquidado:null,valor_pago:null,data_empenho:null};function Be({emendaId:o}){const{data:l=[]}=he(o),{addMany:c,addOne:m,remove:x}=be(o),u=p.useRef(null),[t,d]=p.useState(X),[_,n]=p.useState(0),f=async s=>{const j=await s.text(),w=ge(j);if(w.length){y.error("CSV com colunas obrigatórias não reconhecidas",{description:`Faltando: ${w.join(", ")}. Use cabeçalhos como beneficiario, descricao, empenho, empenhado, liquidado, pago.`}),u.current&&(u.current.value="");return}const S=je(j);if(!S.length){y.error("Nenhuma linha de dados encontrada no CSV"),u.current&&(u.current.value="");return}await c.mutateAsync(S),u.current&&(u.current.value="")},r=()=>{d(X),n(s=>s+1)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Execução (17.3)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:u,type:"file",accept:".csv,text/csv",hidden:!0,onChange:s=>s.target.files?.[0]&&f(s.target.files[0])}),e.jsxs(E,{type:"button",size:"sm",variant:"outline",className:"gap-1",onClick:()=>u.current?.click(),children:[e.jsx(ae,{className:"size-4"})," Importar CSV"]})]})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Beneficiário"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Descrição da despesa"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Empenho"}),e.jsx("th",{scope:"col",className:"p-2 text-right",children:"Empenhado"}),e.jsx("th",{scope:"col",className:"p-2 text-right",children:"Liquidado"}),e.jsx("th",{scope:"col",className:"p-2 text-right",children:"Pago"}),e.jsx("th",{scope:"col",className:"p-2",children:e.jsx("span",{className:"sr-only",children:"Ações"})})]})}),e.jsxs("tbody",{children:[l.map(s=>e.jsxs("tr",{className:"border-t border-border transition-colors duration-150 hover:bg-muted/30",children:[e.jsx("td",{className:"p-2",children:s.beneficiario}),e.jsx("td",{className:"max-w-xs truncate p-2",children:s.descricao_despesa}),e.jsx("td",{className:"p-2",children:s.numero_empenho}),e.jsx("td",{className:"p-2 text-right tabular-nums",children:T(s.valor_empenhado)}),e.jsx("td",{className:"p-2 text-right tabular-nums",children:T(s.valor_liquidado)}),e.jsx("td",{className:"p-2 text-right tabular-nums",children:T(s.valor_pago)}),e.jsx("td",{className:"p-2 text-right",children:e.jsx("button",{type:"button","aria-label":`Remover lançamento ${s.numero_empenho}`,onClick:()=>x.mutate(s.id),className:"text-muted-foreground transition-colors hover:text-destructive",children:e.jsx(se,{className:"size-4"})})})]},s.id)),l.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-4 text-center text-muted-foreground",children:"Sem lançamentos. Importe um CSV ou adicione manualmente."})})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-5",children:[e.jsx(b,{"aria-label":"Beneficiário/credor",placeholder:"Beneficiário",value:t.beneficiario,onChange:s=>d({...t,beneficiario:s.target.value})}),e.jsx(b,{"aria-label":"Número do empenho",placeholder:"Nº empenho",value:t.numero_empenho,onChange:s=>d({...t,numero_empenho:s.target.value})}),e.jsx(b,{"aria-label":"Valor empenhado",placeholder:"Empenhado",inputMode:"decimal",onChange:s=>d({...t,valor_empenhado:L(s.target.value)})}),e.jsx(b,{"aria-label":"Valor liquidado",placeholder:"Liquidado",inputMode:"decimal",onChange:s=>d({...t,valor_liquidado:L(s.target.value)})}),e.jsx(b,{"aria-label":"Valor pago",placeholder:"Pago",inputMode:"decimal",onChange:s=>d({...t,valor_pago:L(s.target.value)})}),e.jsx(b,{"aria-label":"Descrição da despesa",placeholder:"Descrição da despesa",className:"col-span-2 sm:col-span-4",value:t.descricao_despesa,onChange:s=>d({...t,descricao_despesa:s.target.value})}),e.jsx(b,{"aria-label":"Documento do beneficiário (CPF/CNPJ)",placeholder:"CPF/CNPJ (opcional)",value:t.beneficiario_documento??"",onChange:s=>d({...t,beneficiario_documento:s.target.value||null})}),e.jsxs(E,{type:"button",size:"sm",className:"gap-1",onClick:async()=>
1{if(!t.beneficiario||!t.numero_empenho||!t.descricao_despesa){y.error("Preencha beneficiário, empenho e descrição");return}await m.mutateAsync(t),r()},children:[e.jsx(re,{className:"size-4"})," Adicionar"]})]},_)]})}const B={ocorrencia:"Não ocorrência de emendas",execucao:"Não execução de emendas"};function Me(o,l,c){const m=c==="ocorrencia"?`não houve emendas parlamentares de origem ${I[l].toLowerCase()}`:`não houve execução orçamentária e financeira de emendas parlamentares de origem ${I[l].toLowerCase()}`;return`Declaramos que, no exercício de ${o}, ${m} no âmbito deste Ente.`}function Ue(){const{data:o=[]}=ve(),{upsert:l}=fe(),[c,m]=p.useState(new Date().getFullYear()),[x,u]=p.useState("federal"),[t,d]=p.useState("ocorrencia"),[_,n]=p.useState(""),f=_||Me(c,x,t);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4 rounded-lg border border-border p-4",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"decl-exercicio",className:"text-xs",children:"Exercício"}),e.jsx(b,{id:"decl-exercicio",type:"number",value:c,onChange:r=>m(Number(r.target.value))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{className:"text-xs",children:"Origem"}),e.jsxs(A,{value:x,onValueChange:r=>u(r),children:[e.jsx(P,{"aria-label":"Origem da declaração",children:e.jsx(V,{})}),e.jsx(k,{children:M.map(r=>e.jsx(F,{value:r,children:I[r]},r))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{className:"text-xs",children:"Escopo"}),e.jsxs(A,{value:t,onValueChange:r=>d(r),children:[e.jsx(P,{"aria-label":"Escopo da declaração",children:e.jsx(V,{})}),e.jsx(k,{children:Object.keys(B).map(r=>e.jsx(F,{value:r,children:B[r]},r))})]})]})]}),e.jsx("textarea",{"aria-label":"Texto da declaração",placeholder:"Digite o texto da declaração...",value:f,onChange:r=>n(r.target.value),rows:3,className:"w-full rounded-lg border border-border bg-background p-2 text-sm"}),e.jsx(E,{onClick:()=>l.mutate({exercicio:c,origem:x,escopo:t,texto:f,is_public:!0}),children:"Salvar declaração"})]}),e.jsx("div",{className:"space-y-2",children:o.map(r=>e.jsxs("div",{className:"rounded-lg border border-border p-3 text-sm",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[r.exercicio," · ",I[r.origem]," · ",B[r.escopo]]}),e.jsx("p",{children:r.texto})]},r.id))})]})}function da(){const{data:o=[],isLoading:l}=_e(),{create:c,update:m,remove:x}=Ne(),{companyId:u}=Z(),t=ie(),[d,_]=p.useState("emendas"),[n,f]=p.useState(""),[r,s]=p.useState(!1),[j,w]=p.useState(null),S=p.useMemo(()=>o.filter(i=>[i.autoria,i.objeto,i.numero_identificacao].join(" ").toLowerCase().includes(n.toLowerCase())),[o,n]),a=async(i,v)=>{if(j){await m.mutateAsync({id:j.id,data:i}),s(!1);return}const C=await c.mutateAsync(i);w({...i,id:C,company_id:u??"",ai_confidence:v,created_at:new Date().toISOString(),updated_at:null,deleted_at:null}),y.info("Emenda criada — agora lance a execução orçamentária (17.3) abaixo.")};return e.jsxs("div",{className:"mx-auto min-h-screen max-w-[1400px] px-4 pb-8 pt-24 sm:pt-28 lg:px-8",children:[e.jsx(me,{title:"Emendas Parlamentares",description:"Cadastro e execução de emendas (PNTP item 17).",breadcrumbs:[{label:"Emendas"}],className:"mb-6"}),e.jsxs(ue,{value:d,onValueChange:_,children:[e.jsxs(pe,{className:"mb-6 gap-1",children:[e.jsx(H,{value:"emendas",children:"Emendas"}),e.jsx(H,{value:"declaracoes",children:"Declarações"})]}),e.jsxs(J,{value:"emendas",children:[e.jsx(Ie,{emendas:o}),e.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(Ve,{className:"absolute left-2.5 top-2.5 size-4 text-muted-foreground"}),e.jsx(b,{value:n,onChange:i=>f(i.target.value),placeholder:"Buscar por autor, objeto, número…",className:"pl-8"})]}),e.jsxs(E,{className:"gap-1",onClick:()=>{w(null),s(!0)},children:[e.jsx(re,{className:"size-4"})," Nova emenda"]})]}),e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-xs text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Exercício"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Origem"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Autoria"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Tipo"}),e.jsx("th",{scope:"col",className:"p-2 text-left",children:"Objeto"}),e.jsx("th",{scope:"col",className:"p-2 text-right",children:"Previsto"}),e.jsx("th",{scope:"col",className:"p-2",children:e.jsx("span",{className:"sr-only",children:"Ações"})})]})}),e.jsxs("tbody",{children:[l&&Array.from({length:5}).map((i,v)=>e.jsxs("tr",{className:"border-t border-border",children:[Array.from({length:6}).map((C,h)=>e.jsx("td",{className:"p-2",children:e.jsx(G,{className:"h-4 w-full"})},h)),e.jsx("td",{className:"p-2",children:e.jsx(G,{className:"ml-auto h-4 w-10"})})]},`sk-${v}`)),!l&&S.map(i=>e.jsxs("tr",{className:"border-t border-border transition-colors duration-150 hover:bg-muted/40",children:[e.jsx("td",{className:"p-2 tabular-nums",children:i.exercicio}),e.jsx("td",{className:"p-2",children:I[i.origem]}),e.jsx("td",{className:"p-2",children:i.autoria}),e.jsx("td",{className:"p-2",children:ee[i.tipo]}),e.jsx("td",{className:"max-w-xs truncate p-2",children:i.objeto}),e.jsx("td",{className:"p-2 text-right tabular-nums",children:T(i.valor_previsto)}),e.jsxs("td",{className:"whitespace-nowrap p-2 text-right",children:[e.jsx("button",{type:"button","aria-label":`Editar emenda ${i.numero_identificacao}`,className:"mr-2 text-muted-foreground transition-colors hover:text-primary",onClick:()=>{w(i),s(!0)},children:e.jsx(ke,{className:"size-4"})}),e.jsx("button",{type:"button","aria-label":`Remover emenda ${i.numero_identificacao}`,className:"text-muted-foreground transition-colors hover:text-destructive",onClick:async()=>{await t({title:"Remover emenda?",description:"A emenda será removida do portal."})&&x.mutate(i.id)},children:e.jsx(se,{className:"size-4"})})]})]},i.id)),!l&&S.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"p-6 text-center text-muted-foreground",children:"Nenhuma emenda cadastrada."})})]})]})})]}),e.jsx(J,{value:"declaracoes",children:e.jsx(Ue,{})})]}),e.jsx(ne,{open:r,onOpenChange:s,children:e.jsxs(le,{className:"w-full overflow-y-auto sm:max-w-2xl",children:[e.jsx(ce,{children:e.jsx(de,{children:j?"Editar emenda":"Nova emenda"})}),e.jsxs("div",{className:"mt-4 space-y-8",children:[e.jsx($e,{emenda:j,onSubmit:a,onCancel:()=>s(!1)},j?.id??"new"),j&&e.jsx("div",{className:"border-t border-border pt-6",children:e.jsx(Be,{emendaId:j.id})})]})]})})]})}export{da as AdminEmendas,da 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.