1/* ANPG DEVTEAM - 23/09/2026, 12:53:51 */ 2import{e as P,u as N,k as E,j as e}from"./data-vendor-BRYI0K8G.js";import{r as o}from"./react-vendor-Bj9LQV-u.js";import{A as $}from"./AdminLayout-Dwt36cjQ.js";import{I as B}from"./input-DXoiBR8B.js";import{al as H,w as p,b as v,aV as K,am as u,bh as l}from"./index-cwV7SCbt.js";import{B as g}from"./badge-DH3OcwR0.js";import{S as L}from"./star-DIWblV4s.js";import{A as Q}from"./arrow-up-kiv4FSV1.js";import{A as T}from"./arrow-down-C1khJ9Kn.js";import{T as I}from"./trash-2-DsWPE62z.js";import{S as F}from"./search-BiS5Q1yZ.js";import{P as z}from"./plus-DNnuudfk.js";import"./message-square-PMubaXRc.js";import"./newspaper-CHlewEV4.js";import"./tag-C9YMMS4O.js";import"./camera-BaCLsw_E.js";import"./shield-check-WsIH1iGp.js";import"./sliders-horizontal-BQ-86nOU.js";import"./user-check-C6J6ewlk.js";import"./network-O6WVq_gh.js";import"./clock-BrMjUDom.js";import"./book-open-YlczfV9G.js";import"./bot-Dh7mXPIY.js";import"./gavel-PkPxUdh7.js";import"./presentation-CMVRwA7v.js";import"./clipboard-check-CX6a16zF.js";import"./folder-open-Caf45xKb.js";import"./settings-2-Bi0RsXgx.js";import"./label-ZRKjaR0k.js";import"./rocket-C18tjCXj.js";import"./user-GGMDWiDQ.js";import"./arrow-left-BeqZSyXi.js";import"./circle-check-big-B8jnYIp7.js";import"./charts-vendor-Cs07Jtv5.js";import"./motion-vendor-DMc3mo8t.js";import"./i18n-vendor-BSIZ7LIS.js";const b={document:"Documento",seismic_campaign:"Campanha SÃsmica",well:"Poço",map:"Mapa",gallery:"Galeria",field_activity:"Actividade de Campo"};function Ce(){var y;const f=P(),[x,w]=o.useState(""),[i,q]=o.useState(""),[n,c]=o.useState(null);o.useEffect(()=>{const s=setTimeout(()=>q(x.trim()),300);return()=>clearTimeout(s)},[x]);const{data:t,isLoading:C}=N({queryKey:["admin-data-center-highlights"],queryFn:()=>u.list(!0)}),{data:m,isFetching:D}=N({queryKey:["admin-data-center-search",i],enabled:i.length>=2,placeholderData:E,queryFn:()=>H({q:i,limit:30})}),_=o.useMemo(()=>new Set((t??[]).map(s=>`${s.item_type}:${s.item_id}`)),[t]),h=()=>{f.invalidateQueries({queryKey:["admin-data-center-highlights"]}),f.invalidateQueries({queryKey:["data-center-highlights"]})},S=async s=>{c(`${s.item_type}:${s.item_id}`);try{await u.add(s.item_type,s.item_id),l.success("Destaque adicionado"),h()}catch{l.error("Não foi possÃvel adicionar o destaque")}finally{c(null)}},A=async s=>{c(s);try{await u.remove(s),l.success("Destaque removido"),h()}catch{l.error("Não foi possÃvel remover o destaque")}finally{c(null)}},j=async(s,a)=>{if(!t)return;const r=[...t],d=s+a;if(!(d<0||d>=r.length)){[r[s],r[d]]=[r[d],r[s]];try{await u.reorder(r.map(k=>k.id)),h()}catch{l.error("Não foi possÃvel reordenar")}}};return e.jsxs($,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("span",{className:"p-2 rounded-lg bg-[#0d5484]/10 text-[#0d5484]",children:e.jsx(L,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Destaques do Centro de Dados"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Selecione conteúdos publicados para destacar no topo do Centro de Dados GeocientÃficos."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("section",{children:[e.jsxs("h2",{className:"text-lg font-semibold mb-3",children:["Destaques actuais (",(t==null?void 0:t.length)??0,")"]}),C?e.jsx("div",{className:"text-center py-10 text-muted-foreground",children:e.jsx(p,{className:"w-5 h-5 mx-auto animate-spin"})}):t!=null&&t.length?e.jsx("ul",{className:"space-y-2",children:t.map((s,a)=>e.jsxs("li",{className:"flex items-center gap-3 border rounded-lg p-3",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{className:"text-muted-foreground hover:text-primary disabled:opacity-30",onClick:()=>j(a,-1),disabled:a===0,"aria-label":"Subir",children:e.jsx(Q,{className:"w-4 h-4"})}),e.jsx("button",{className:"text-muted-foreground hover:text-primary disabled:opacity-30",onClick:()=>j(a,1),disabled:a===t.length-1,"aria-label":"Descer",children:e.jsx(T,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{variant:"secondary",className:"text-xs",children:b[s.item_type]??s.item_type}),s.status!=="published"&&e.jsx(g,{variant:"outline",className:"text-xs",children:s.status})]}),e.jsx("p",{className:"font-medium truncate mt-1",children:s.title})]}),e.jsx(v,{variant:"ghost",size:"icon",onClick:()=>A(s.id),disabled:n===s.id,"aria-label":"Remover",children:n===s.id?e.jsx(p,{className:"w-4 h-4 animate-spin"}):e.jsx(I,{className:"w-4 h-4 text-destructive"})})]},s.id))}):e.jsx("p",{className:"text-sm text-muted-foreground border rounded-lg p-6 text-center",children:"Ainda não há destaques. Pesquise ao lado e clique em «Destacar»."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-3",children:"Adicionar destaque"}),e.jsxs("div",{className:"relative mb-4",children:[e.jsx(F,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),e.jsx(B,{value:x,onChange:s=>w(s.target.value),placeholder:"Pesquisar conteúdos publicadosâ¦",className:"pl-10"}),D&&e.jsx(p,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 animate-spin text-muted-foreground"})]}),i.length<2?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Escreva pelo menos 2 caracteres para pesquisar."}):(y=m==null?void 0:m.data)!=null&&y.length?e.jsx("ul",{className:"space-y-2",children:m.data.map(s=>{const a=`${s.item_type}:${s.item_id}`,r=_.has(a);return e.jsxs("li",{className:"flex items-center gap-3 border rounded-lg p-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(g,{variant:"secondary",className:"text-xs",children:b[s.item_type]??s.item_type}),e.jsx("p",{className:"font-medium truncate mt-1",children:s.title})]}),r?e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-emerald-600",children:[e.jsx(K,{className:"w-4 h-4"}),"Destacado"]}):e.jsxs(v,{size:"sm",onClick:()=>S(s),disabled:n===a,children:[n===a?e.jsx(p,{className:"w-4 h-4 mr-1.5 animate-spin"}):e.jsx(z,{className:"w-4 h-4 mr-1.5"}),"Destacar"]})]},a)})}):e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sem resultados para «",i,"»."]})]})]})]})}export{Ce 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.