1import{r as d,_ as v,bR as N,ac as o,j as e,S as w,B as c,bJ as y,V as _,bU as D,bV as A}from"./index-CYggsFjq.js";const k=()=>{const[f,m]=d.useState([]),[g,x]=d.useState(!0),u=v(),{toast:l}=N();d.useEffect(()=>{(async()=>{const{data:{session:t}}=await o.auth.getSession();if(!t){u("/admin/login");return}h()})()},[]);const h=async()=>{x(!0);const{data:t,error:r}=await o.from("news_articles").select("*").order("sort_date",{ascending:!1,nullsFirst:!1});r?l({title:"Error",description:r.message,variant:"destructive"}):m(t||[]),x(!1)},p=async(t,r)=>{if(!confirm(`Delete "${r}"?`))return;const{error:s}=await o.from("news_articles").delete().eq("id",t);A({category:"admin",event:"news.delete_duplicate",outcome:s?"failed":"success",error:s==null?void 0:s.message,context:{id:t}}),s?l({title:"Error",description:s.message,variant:"destructive"}):(l({title:"Deleted"}),m(n=>n.filter(j=>j.id!==t)))},a=new Map;for(const t of f){const r=t.sort_date||"no-date";a.has(r)||a.set(r,[]),a.get(r).push(t)}const i=Array.from(a.entries()).filter(([,t])=>t.length>1).sort((t,r)=>r[0].localeCompare(t[0])),b=i.reduce((t,[,r])=>t+r.length,0);return e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsx(w,{title:"Duplicate Articles",description:"Admin duplicate detection",noIndex:!0}),e.jsxs("div",{className:"container py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-heading font-bold text-foreground",children:"Duplicate Articles"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Grouped by publication date · ",i.length," groups · ",b," articles"]})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(c,{variant:"outline",size:"sm",onClick:()=>u("/admin/news"),children:"News CMS"})})]}),g?e.jsx("p",{className:"text-muted-foreground",children:"Loadingâ¦"}):i.length===0?e.jsx("p",{className:"text-muted-foreground",children:"No duplicate dates found."}):e.jsx("div",{className:"space-y-6",children:i.map(([t,r])=>e.jsxs("div",{className:"bg-card border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 bg-muted/50 border-b border-border flex items-center justify-between",children:[e.jsx("div",{className:"font-heading font-bold text-foreground",children:t==="no-date"?"No date":t}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.length," articles"]})]}),e.jsx("table",{className:"w-full text-sm",children:e.jsx("tbody",{children:r.map(s=>e.jsxs("tr",{className:"border-b border-border last:border-0 hover:bg-muted/30",children:[e.jsxs("td",{className:"p-3",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.title}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:["/",s.slug," · ",s.category," · ",s.is_published?"Live":"Draft",s.date_display?` · ${s.date_display}`:""]}),s.summary&&e.jsx("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2 max-w-3xl",children:s.summary}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:s.tags.map(n=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-foreground border border-border",children:n},n))})]}),e.jsx("td",{className:"p-3 w-32 text-right",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>window.open(y(s.category,s.slug),"_blank"),title:"View",children:e.jsx(_,{className:"h-4 w-4"})}),e.jsx(c,{variant:"ghost",size:"icon",onClick:()=>p(s.id,s.title),title:"Delete",children:e.jsx(D,{className:"h-4 w-4 text-destructive"})})]})})]},s.id))})})]},t))})]})]})};export{k 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.