1import{c as qe,u as w,b as u,j as e}from"./vendor-query-CAW0R6Fd.js";import{r as m}from"./vendor-react-BIBNHc4z.js";import{bb as Fe,g as Ce,j as D,t as A,v as L,b1 as ne,x as O,B as o,au as P,k as R,b7 as V,b3 as M,G as k,c6 as f,ax as y,cB as Ke,as as Se,c5 as ze,cC as Ee,cD as Qe,q as n,cE as Te,cF as De,cG as Ae,cH as Le,cI as Oe,cJ as Pe,cK as Re,cL as Ve,cM as He,cN as $e,cO as Be,cP as Ge,bc as Je,cQ as Ue,cR as We,ci as Xe,Q as Ye,ak as Ze}from"./index-Dr2jZQpy.js";import{S as J}from"./separator-DfRyqQ8N.js";import{D as H,C as $,P as B}from"./react-beautiful-dnd.esm-CCXwC5WM.js";import{M as G}from"./MenuItemModal-wkknatiC.js";import{u as es,c as ss,d as as,t as ns,a as ts,b as is}from"./menu-items-transparencia.service-DcjQv7Po.js";import"./ui-radix-CMPBktV5.js";import"./utils-objBp_8x.js";import"./charts-DbJut-2U.js";import"./input-Bu5ViSvB.js";import"./select-FsSDRbDW.js";import"./textarea-lJhBRSVg.js";import"./IconPicker-TO0Z9kfO.js";import"./CategoryCascadeSelector-BPaGP0u_.js";import"./command-Cu_G-7WE.js";import"./popover-CafwvRnH.js";import"./paginas.service-Df5dL9fm.js";import"./atos-normativos.service-DNqJyaTg.js";import"./licitacoes.service-B7TUpkJ3.js";import"./portais-setoriais.service-CMvrITdr.js";const Fs=()=>{var ae;m.useEffect(()=>{if(window.location.hash!=="#links-rodape")return;const s=setTimeout(()=>{var a;(a=document.getElementById("links-rodape"))==null||a.scrollIntoView({behavior:"smooth",block:"start"})},400);return()=>clearTimeout(s)},[]),Fe();const{toast:d}=Ce(),t=qe(),[te,_]=m.useState(!1),[I,q]=m.useState(null),[rs,ie]=m.useState({titulo:"",tipo_link:"url_direta",link_url:"",link_referencia_id:"",icone:"Menu",visivel:!0,abrir_nova_aba:!1}),[re,F]=m.useState(!1),[C,K]=m.useState(null),[os,oe]=m.useState({titulo:"",tipo_link:"url_direta",link_url:"",link_referencia_id:"",icone:"Link",visivel:!0,abrir_nova_aba:!1}),[le,S]=m.useState(!1),[z,E]=m.useState(null),[ce,Q]=m.useState(!1),[j,T]=m.useState(null),{data:g}=w({queryKey:n.menus.principalAdmin(),queryFn:Ue}),x=g==null?void 0:g.filter(s=>!s.parent_id),{data:N}=w({queryKey:n.menus.topAdmin(),queryFn:We}),{data:v}=w({queryKey:n.menus.transparenciaAdmin(),queryFn:is}),h=v==null?void 0:v.filter(s=>!s.parent_id),{data:b}=w({queryKey:n.menus.footerAdmin(),queryFn:Xe}),{data:p}=w({queryKey:n.menus.config(),queryFn:async()=>{const s=await Ye(),a={};return s.filter(l=>["menu_tema","top_menu_visivel","top_menu_tema"].includes(l.chave)).forEach(l=>{a[l.chave]=l.valor}),a}}),de=u({mutationFn:async s=>I?await Ee(I.id,s):await Qe(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.principalAdmin()}),d({title:I?"Item atualizado":"Item criado"}),_(!1),q(null)},onError:s=>{d({title:"Erro ao salvar",description:s.message,variant:"destructive"})}}),U=u({mutationFn:Te,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.principalAdmin()}),d({title:"Item removido"})}}),W=u({mutationFn:async({id:s})=>await De(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.principalAdmin()})}}),ue=u({mutationFn:Ae,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.principalAdmin()}),d({title:"Ordem atualizada"})}}),me=u({mutationFn:async s=>C?await Le(C.id,s):await Oe(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.topAdmin()}),t.invalidateQueries({queryKey:n.menus.top()}),d({title:C?"Item atualizado":"Item criado"}),F(!1),K(null)},onError:s=>{d({title:"Erro ao salvar",description:s.message,variant:"destructive"})}}),pe=u({mutationFn:Pe,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.topAdmin()}),t.invalidateQueries({queryKey:n.menus.top()}),d({title:"Item removido"})}}),xe=u({mutationFn:async({id:s})=>await Re(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.topAdmin()}),t.invalidateQueries({queryKey:n.menus.top()})}}),he=u({mutationFn:Ve,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.topAdmin()}),t.invalidateQueries({queryKey:n.menus.top()}),d({title:"Ordem atualizada"})}}),je=u({mutationFn:async s=>z?await es(z.id,s):await ss(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.transparenciaAdmin()}),t.invalidateQueries({queryKey:n.menus.transparencia()}),d({title:z?"Item atualizado":"Item criado"}),S(!1),E(null)},onError:s=>{d({title:"Erro ao salvar",description:s.message,variant:"destructive"})}}),X=u({mutationFn:as,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.transparenciaAdmin()}),t.invalidateQueries({queryKey:n.menus.transparencia()}),d({title:"Item removido"})}}),Y=u({mutationFn:async({id:s})=>await ns(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.transparenciaAdmin()}),t.invalidateQueries({queryKey:n.menus.transparencia()})}}),ge=u({mutationFn:ts,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.transparenciaAdmin()}),t.invalidateQueries({queryKey:n.menus.transparencia()}),d({title:"Ordem atualizada"})}}),ve=u({mutationFn:async s=>j?await He(j.id,s):await $e(s),onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.footerAdmin()}),t.invalidateQueries({queryKey:n.menus.footer()}),d({title:j?"Link atualizado":"Link criado"}),Q(!1),T(null)},onError:s=>{d({title:"Erro ao salvar",description:s.message,variant:"destructive"})}}),fe=u({mutationFn:Be,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.footerAdmin()}),t.invalidateQueries({queryKey:n.menus.footer()}),d({title:"Link deletado"})}}),ye=u({mutationFn:Ge,onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.footerAdmin()}),t.invalidateQueries({queryKey:n.menus.footer()}),d({title:"Ordem atualizada"})}});u({mutationFn:async({chave:s,valor:a})=>{await Je(s,{valor:a})},onSuccess:()=>{t.invalidateQueries({queryKey:n.menus.config()}),d({title:"Configuração atualizada"})}});const Ne=s=>{if(!s.destination||!x)return;const a=Array.from(x),[l]=a.splice(s.source.index,1);a.splice(s.destination.index,0,l);const i=a.map((c,r)=>({id:c.id,ordem:r}));ue.mutate(i)},be=s=>{if(!s.destination||!N)return;const a=Array.from(N),[l]=a.splice(s.source.index,1);a.splice(s.destination.index,0,l);const i=a.map((c,r)=>({id:c.id,ordem:r}));he.mutate(i)},we=s=>{if(!s.destination||!h)return;const a=Array.from(h),[l]=a.splice(s.source.index,1);a.splice(s.destination.index,0,l);const i=a.map((c,r)=>({id:c.id,ordem:r}));ge.mutate(i)},Me=s=>{if(!s.destination||!b)return;const a=Array.from(b),[l]=a.splice(s.source.index,1);a.splice(s.destination.index,0,l);const i=a.map((c,r)=>({id:c.id,ordem:r}));ye.mutate(i)},Z=s=>{q(s),ie({titulo:s.titulo,tipo_link:s.tipo_link,link_url:s.link_url||"",link_referencia_id:s.link_referencia_id||"",icone:s.icone||"Menu",visivel:s.visivel,abrir_nova_aba:s.abrir_nova_aba}),_(!0)},ke=s=>{K(s),oe({titulo:s.titulo,tipo_link:s.tipo_link,link_url:s.link_url||"",link_referencia_id:s.link_referencia_id||"",icone:s.icone,visivel:s.visivel,abrir_nova_aba:s.abrir_nova_aba}),F(!0)},ee=s=>{E(s),S(!0)},_e=s=>{T(s),Q(!0)},Ie=s=>{const a=j?{...s,id:j.id}:s;ve.mutate(a)},se=s=>{const a=Ze[s];return a?e.jsx(a,{className:"h-4 w-4"}):e.jsx(ne,{className:"h-4 w-4"})};return p!=null&&p.menu_tema,(ae=p==null?void 0:p.top_menu_visivel)==null||ae.ativo,p!=null&&p.top_menu_tema,e.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-bold",children:"Cabeçalho e Rodapé"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:"Gerencie todos os menus e links do site"})]}),e.jsxs(D,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(L,{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"h-5 w-5"}),"Menu Principal"]}),e.jsx(O,{children:"Arraste para reordenar os itens"})]}),e.jsxs(o,{onClick:()=>{q(null),_(!0)},size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Novo Item"]})]})}),e.jsx(R,{children:e.jsx(H,{onDragEnd:Ne,children:e.jsx($,{droppableId:"menu-items",direction:"horizontal",children:s=>e.jsxs("div",{...s.droppableProps,ref:s.innerRef,className:"flex flex-wrap gap-2 min-w-0",children:[x==null?void 0:x.map((a,l)=>{const i=(g==null?void 0:g.filter(c=>c.parent_id===a.id))||[];return e.jsx(B,{draggableId:a.id,index:l,children:c=>e.jsxs("div",{ref:c.innerRef,...c.draggableProps,...c.dragHandleProps,className:"border rounded p-2 bg-background text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:a.titulo}),i.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.length," sub)"]}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>W.mutate({id:a.id}),children:a.visivel?e.jsx(M,{className:"h-3 w-3"}):e.jsx(k,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>Z(a),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>U.mutate(a.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]}),i.length>0&&e.jsx("div",{className:"ml-6 mt-1 border-l-2 border-muted pl-3 space-y-1",children:i.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-1 text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Ⳡ",r.titulo]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>W.mutate({id:r.id}),children:r.visivel?e.jsx(M,{className:"h-3 w-3"}):e.jsx(k,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>Z(r),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>U.mutate(r.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]},r.id))})]})},a.id)}),s.placeholder]})})})})]}),e.jsx(J,{}),e.jsxs(D,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(L,{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-5 w-5"}),"Top Menu"]}),e.jsx(O,{children:"Menu superior do site"})]}),e.jsxs(o,{onClick:()=>{K(null),F(!0)},size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Novo Item"]})]})}),e.jsx(R,{children:e.jsx(H,{onDragEnd:be,children:e.jsx($,{droppableId:"top-menu-items",children:s=>e.jsxs("div",{...s.droppableProps,ref:s.innerRef,className:"space-y-2",children:[N==null?void 0:N.map((a,l)=>e.jsx(B,{draggableId:a.id,index:l,children:i=>e.jsxs("div",{ref:i.innerRef,...i.draggableProps,className:"border rounded p-3 bg-background flex items-center gap-3",children:[e.jsx("div",{...i.dragHandleProps,children:e.jsx(V,{className:"h-4 w-4 text-muted-foreground"})}),se(a.icone),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:a.titulo}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.link_url})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>xe.mutate({id:a.id}),children:a.visivel?e.jsx(M,{className:"h-3 w-3"}):e.jsx(k,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>ke(a),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>pe.mutate(a.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]})},a.id)),s.placeholder]})})})})]}),e.jsx(J,{}),e.jsxs(D,{children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(L,{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-5 w-5"}),"Menu do Portal da Transparência"]}
1),e.jsx(O,{children:"Itens exibidos apenas no cabeçalho das páginas de transparência. Arraste para reordenar."})]}),e.jsxs(o,{onClick:()=>{E(null),S(!0)},size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Novo Item"]})]})}),e.jsx(R,{children:e.jsx(H,{onDragEnd:we,children:e.jsx($,{droppableId:"menu-transparencia-items",direction:"horizontal",children:s=>e.jsxs("div",{...s.droppableProps,ref:s.innerRef,className:"flex flex-wrap gap-2 min-w-0",children:[h==null?void 0:h.map((a,l)=>{const i=(v==null?void 0:v.filter(c=>c.parent_id===a.id))||[];return e.jsx(B,{draggableId:a.id,index:l,children:c=>e.jsxs("div",{ref:c.innerRef,...c.draggableProps,...c.dragHandleProps,className:"border rounded p-2 bg-background text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:a.titulo}),i.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",i.length," sub)"]}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>Y.mutate({id:a.id}),children:a.visivel?e.jsx(M,{className:"h-3 w-3"}):e.jsx(k,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>ee(a),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>X.mutate(a.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]}),i.length>0&&e.jsx("div",{className:"ml-6 mt-1 border-l-2 border-muted pl-3 space-y-1",children:i.map(r=>e.jsxs("div",{className:"flex items-center justify-between py-1 text-xs",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Ⳡ",r.titulo]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>Y.mutate({id:r.id}),children:r.visivel?e.jsx(M,{className:"h-3 w-3"}):e.jsx(k,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>ee(r),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-5 w-5 p-0",onClick:()=>X.mutate(r.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]},r.id))})]})},a.id)}),s.placeholder]})})})})]}),e.jsx(J,{}),e.jsxs(D,{id:"links-rodape",className:"scroll-mt-20",children:[e.jsx(A,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(L,{className:"flex items-center gap-2",children:[e.jsx(ze,{className:"h-5 w-5"}),"Menu do Rodapé"]}),e.jsx(O,{children:'Links exibidos como "Links" no rodapé do site'})]}),e.jsxs(o,{onClick:()=>{T(null),Q(!0)},size:"sm",children:[e.jsx(P,{className:"h-4 w-4 mr-2"}),"Novo Link"]})]})}),e.jsx(R,{children:e.jsx(H,{onDragEnd:Me,children:e.jsx($,{droppableId:"footer-links",children:s=>e.jsxs("div",{...s.droppableProps,ref:s.innerRef,className:"space-y-2",children:[b==null?void 0:b.map((a,l)=>e.jsx(B,{draggableId:a.id,index:l,children:i=>e.jsxs("div",{ref:i.innerRef,...i.draggableProps,className:"border rounded p-3 bg-background flex items-center gap-3",children:[e.jsx("div",{...i.dragHandleProps,children:e.jsx(V,{className:"h-4 w-4 text-muted-foreground"})}),a.icone&&se(a.icone),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-sm",children:a.titulo}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.link_url})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>_e(a),children:e.jsx(f,{className:"h-3 w-3"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>fe.mutate(a.id),children:e.jsx(y,{className:"h-3 w-3"})})]})]})},a.id)),s.placeholder]})})})})]}),e.jsx(G,{isOpen:te,onClose:()=>{_(!1),q(null)},onSave:s=>de.mutate(s),editingItem:I,mode:"menu_principal",menuItems:x==null?void 0:x.map(s=>({id:s.id,titulo:s.titulo}))}),e.jsx(G,{isOpen:re,onClose:()=>{F(!1),K(null)},onSave:s=>me.mutate(s),editingItem:C,mode:"top_menu"}),e.jsx(G,{isOpen:le,onClose:()=>{S(!1),E(null)},onSave:s=>je.mutate(s),editingItem:z,mode:"menu_principal",menuItems:h==null?void 0:h.map(s=>({id:s.id,titulo:s.titulo}))}),e.jsx(G,{isOpen:ce,onClose:()=>{Q(!1),T(null)},onSave:Ie,editingItem:j,mode:"footer_links"})]})};export{Fs 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.