1import{j as e,r as t,L as a}from"./vendor-react-BH6F5oQJ.js";import{g as s,d as r}from"./slug-D4LuRHo0.js";import{A as l,P as i,a as n,b as d}from"./AdminLayout-CKCESQT6.js";import{L as c}from"./LazyRichTextEditor-ByQjI7gT.js";import{C as o,M as u,N as m,m as h,a2 as p,a3 as x,a4 as g,s as f,D as j,a5 as b,B as v,f as y,c as w,a1 as N,F as _,z as k,H as C,G as S,a6 as A,t as P,n as U,o as T,q as F,k as D,R as L}from"./index-dRqPaCFl.js";import{a as E}from"./validations-CCZ89lfg.js";import{b as $,e as I,T as z,a as B,c as q,d as R}from"./table-C7ziGuLk.js";import{D as M,a as H,b as V,c as O,d as W,e as G}from"./dialog-5O1RHm7r.js";import{L as J}from"./label-RVODh2pd.js";import{T as Y}from"./textarea-DyrIuoRK.js";import{S as K,a as Q,b as X,c as Z,d as ee}from"./select-DsVkFSYt.js";import{T as te,a as ae,b as se,c as re}from"./tabs-Bc5GG4D6.js";import{g as le,h as ie,i as ne,j as de,J as ce,$ as oe,q as ue,S as me,Z as he,aa as pe,U as xe,a as ge,C as fe,D as je,f as be,s as ve}from"./vendor-icons-CaI5__By.js";import{C as ye}from"./checkbox-B-wu_leF.js";import{u as we,a as Ne}from"./vendor-query-CC4VRGyP.js";import{C as _e}from"./calendar-C9CRNsnp.js";import{u as ke}from"./useActivityLogger-D_WtAITb.js";import{u as Ce}from"./useAdminActivityNotifications-B8Iov43A.js";import{f as Se}from"./format-hXGQLsWs.js";import"./vendor-ui-B4WC06Sp.js";import"./separator-KtQ1mSuG.js";import"./index-CCdGLatk.js";import"./Combination-DzDAyqvK.js";import"./vendor-supabase-COwyE4EW.js";import"./index-B3FPD4RS.js";import"./en-US-DUAJ-5Wt.js";import"./types-BnfuoFvn.js";import"./index-D5Ei2fSx.js";const Ae=({title:t,description:a,imageUrl:s,url:r,category:l})=>{const i=(e,t)=>e?e.length>t?e.substring(0,t)+"...":e:"",n=r||"delphigrc.org/research/...",d=t||"Publication Title",c=a||"Publication description will appear here...",g=(()=>{if(s){const e=x(s);if(e)return e}return`https://ypsdkqazkbvieilcqyke.supabase.co/functions/v1/og-image?${new URLSearchParams({title:d,category:l||"Research"}).toString()}`})();return e.jsxs(o,{children:[e.jsxs(u,{className:"pb-3",children:[e.jsx(m,{className:"text-lg font-medium",children:"Social Share Preview"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Preview how your publication will appear when shared on social media"})]}),e.jsx(h,{children:e.jsxs(te,{defaultValue:"facebook",className:"w-full",children:[e.jsxs(ae,{className:"grid w-full grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 mb-4 h-auto",children:[e.jsxs(se,{value:"facebook",className:"gap-1.5",children:[e.jsx(le,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Facebook"})]}),e.jsxs(se,{value:"linkedin",className:"gap-1.5",children:[e.jsx(ie,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"LinkedIn"})]}),e.jsxs(se,{value:"bluesky",className:"gap-1.5",children:[e.jsx("img",{src:p,alt:"Bluesky",className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Bluesky"})]}),e.jsxs(se,{value:"whatsapp",className:"gap-1.5",children:[e.jsx(ne,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"WhatsApp"})]}),e.jsxs(se,{value:"telegram",className:"gap-1.5",children:[e.jsx(de,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Telegram"})]})]}),e.jsx(re,{value:"facebook",children:e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[e.jsx("div",{className:"aspect-[1.91/1] bg-muted",children:e.jsx("img",{src:g,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-3 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide mb-1",children:n.replace(/https?:\/\//,"").split("/")[0]}),e.jsx("h3",{className:"font-semibold text-foreground line-clamp-2 mb-1",children:i(d,100)}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:i(c,150)})]})]})}),e.jsx(re,{value:"linkedin",children:e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-white dark:bg-zinc-900",children:[e.jsx("div",{className:"aspect-[1.91/1] bg-muted",children:e.jsx("img",{src:g,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-3 border-t",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-2 mb-1",children:i(d,100)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.replace(/https?:\/\//,"").split("/")[0]})]})]})}),e.jsx(re,{value:"bluesky",children:e.jsx("div",{className:"border rounded-xl overflow-hidden bg-white dark:bg-zinc-900 max-w-md",children:e.jsx("div",{className:"p-3",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx("span",{className:"text-primary font-semibold text-sm",children:"DG"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-1",children:[e.jsx("span",{className:"font-semibold text-sm",children:"Delphi Global"}),e.jsx("span",{className:"text-muted-foreground text-sm",children:"@delphigrc.bsky.social"})]}),e.jsx("p",{className:"text-sm mb-2",children:i(d,100)}),e.jsxs("div",{className:"border rounded-lg overflow-hidden",children:[e.jsx("div",{className:"aspect-[1.91/1] bg-muted",children:e.jsx("img",{src:g,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:n.replace(/https?:\/\//,"").split("/")[0]}),e.jsx("h4",{className:"font-medium text-sm line-clamp-1",children:i(d,60)})]})]})]})]})})})}),e.jsx(re,{value:"whatsapp",children:e.jsx("div",{className:"bg-[#e5ddd5] dark:bg-zinc-800 p-4 rounded-lg",children:e.jsx("div",{className:"max-w-xs ml-auto",children:e.jsxs("div",{className:"bg-[#dcf8c6] dark:bg-emerald-900 rounded-lg p-2 shadow-sm",children:[e.jsxs("div",{className:"border rounded-lg overflow-hidden bg-white dark:bg-zinc-800 mb
1-2",children:[e.jsx("div",{className:"aspect-[1.91/1]",children:e.jsx("img",{src:g,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-0.5",children:n.replace(/https?:\/\//,"").split("/")[0]}),e.jsx("h4",{className:"font-medium text-xs line-clamp-2 text-foreground",children:i(d,80)}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:i(c,100)})]})]}),e.jsx("p",{className:"text-xs text-right text-muted-foreground",children:"12:34"})]})})})}),e.jsx(re,{value:"telegram",children:e.jsx("div",{className:"bg-[#17212b] p-4 rounded-lg",children:e.jsxs("div",{className:"max-w-sm",children:[e.jsxs("div",{className:"bg-[#2b5278] rounded-lg overflow-hidden",children:[e.jsx("div",{className:"aspect-[1.91/1]",children:e.jsx("img",{src:g,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-xs text-white/60 mb-1 font-medium",children:n.replace(/https?:\/\//,"").split("/")[0].toUpperCase()}),e.jsx("h4",{className:"font-medium text-white text-sm line-clamp-2 mb-1",children:i(d,80)}),e.jsx("p",{className:"text-xs text-white/70 line-clamp-2",children:i(c,120)})]})]}),e.jsx("p",{className:"text-xs text-right text-white/50 mt-1",children:"12:34"})]})})})]})})]})};const Pe=e=>{const a=e.pageSize??25,s=we(),{syncAfterPublish:r}=g(),l=["admin-articles-list",e.page,a,e.search,e.publicationType??null],{data:i,isLoading:n,isFetching:d,isError:c,error:o,refetch:u}=Ne({queryKey:l,queryFn:()=>async function({page:e,pageSize:t,search:a,publicationType:s}){const r=(e-1)*t,l=r+t-1;let i=f.from("articles").select("id,title,slug,subtitle,summary,template_type,layout_type,publication_type,author_id,editor_id,status,featured,featured_image_url,featured_image_alt,template_settings,view_count,published_at,created_at,updated_at",{count:"exact"}).order("created_at",{ascending:!1}).range(r,l);s&&(i=i.eq("publication_type",s));const n=a.trim();if(n){const e=`%${d=n,d.replace(/[%_\\,]/g,e=>`\\${e}`)}%`;i=i.or(`title.ilike.${e},slug.ilike.${e}`)}var d;const{data:c,error:o,count:u}=await i;if(o)throw o;return{articles:c??[],totalCount:u??0}}({page:e.page,pageSize:a,search:e.search,publicationType:e.publicationType}),placeholderData:e=>e,staleTime:3e4}),m=(null==i?void 0:i.articles)??[],h=(null==i?void 0:i.totalCount)??0,p=t.useCallback(()=>{s.invalidateQueries({queryKey:["admin-articles-list"]})},[s]);t.useEffect(()=>{const e=f.channel("admin-articles-changes").on("postgres_changes",{event:"*",schema:"public",table:"articles"},()=>{p()}).subscribe();return()=>{f.removeChannel(e)}},[p]);const x=t.useCallback(async e=>{const{data:t,error:a}=await f.from("articles").select("id,title,slug,subtitle,summary,content,template_type,layout_type,publication_type,author_id,editor_id,status,featured,featured_image_url,featured_image_alt,gallery_images,template_settings,seo_settings,view_count,published_at,created_at,updated_at").eq("id",e).maybeSingle();if(a)throw a;return t??null},[]),b=t.useCallback(async e=>{var t;try{const{data:{user:a}}=await f.auth.getUser();if(!a)return j({title:"Error",description:"You must be logged in to create articles",variant:"destructive"}),null;const s=(null==(t=e.title)?void 0:t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||"",{data:r,error:l}=await f.from("articles").insert([{title:e.title||"",slug:s,subtitle:e.subtitle,summary:e.summary,content:e.content||{},template_type:e.template_type||"research",layout_type:e.layout_type||"hero",publication_type:e.publication_type||"article",author_id:e.author_id||a.id,status:e.status||"draft",published_at:e.published_at||null,featured:e.featured||!1,template_settings:e.template_settings||{},seo_settings:e.seo_settings||{}}]).select().maybeSingle();if(l)throw l;return j({title:"Success",description:"Article created successfully"}),p(),r}catch(a){let e="Failed to create article";const t=a;return"57014"===(null==t?void 0:t.code)?e="Database timeout - the operation took too long. Please try again or c
1ontact support.":"42501"===(null==t?void 0:t.code)?e="Permission denied. You don't have rights to create articles. Please make sure you have super_admin role.":a instanceof Error&&(e=a.message),j({title:"Error",description:e,variant:"destructive"}),null}},[p]),v=t.useCallback(async(e,t)=>{try{const a=Object.fromEntries(Object.entries(t).filter(([,e])=>null!=e)),{data:s,error:r}=await f.from("articles").update(a).eq("id",e).select().maybeSingle();if(r)throw r;return j({title:"Success",description:"Article updated successfully"}),p(),s}catch(a){return j({title:"Error",description:a instanceof Error?a.message:"Failed to update article",variant:"destructive"}),null}},[p]),y=t.useCallback(async e=>{try{const{error:t}=await f.from("articles").delete().eq("id",e);if(t)throw t;return j({title:"Success",description:"Article deleted successfully"}),p(),!0}catch(t){return j({title:"Error",description:t instanceof Error?t.message:"Failed to delete article",variant:"destructive"}),!1}},[p]),w=t.useCallback(async e=>{const t=await x(e),a=(null==t?void 0:t.published_at)||(new Date).toISOString(),s=await v(e,{status:"published",published_at:a});return s&&t&&await r(e,t.slug,t.title),s},[x,v,r]),N=t.useCallback(async e=>v(e,{status:"draft"}),[v]);return{articles:m,totalCount:h,pageSize:a,loading:n,isFetching:d,isError:c,error:o,fetchArticleById:x,createArticle:b,updateArticle:v,deleteArticle:y,publishArticle:w,unpublishArticle:N,refetch:u}};const Ue=t.memo(function({article:s,onEdit:r,onDelete:l,onPublish:i,onUnpublish:n,hideCategory:d=!1,previewPathPrefix:c="/research/"}){const o=t.useMemo(()=>function(e){const t=b(e.template_settings).category;return Array.isArray(t)?t[0]?w(t[0]):"N/A":"string"==typeof t&&t?w(t):"N/A"}(s),[s.template_settings]),u=t.useMemo(()=>b(s.template_settings).author||"Unknown",[s.template_settings]),m=`${c}${s.slug||s.id}`,h="published"===s.status;return e.jsxs($,{children:[e.jsx(I,{className:"font-medium",children:e.jsxs("div",{className:"max-w-md",children:[e.jsx("div",{className:"mb-1 font-medium text-foreground line-clamp-1",children:s.title}),e.jsx("div",{className:"text-xs text-muted-foreground line-clamp-1",children:s.summary})]})}),!d&&e.jsx(I,{children:e.jsx(v,{variant:"secondary",children:o})}),e.jsx(I,{className:"text-muted-foreground",children:u}),e.jsx(I,{children:e.jsxs("div",{className:"flex gap-2 items-center",children:[h?e.jsx(v,{variant:"default",className:"bg-green-600",children:"Published"}):e.jsx(v,{variant:"secondary",children:"Draft"}),s.featured&&e.jsx(v,{variant:"default",className:"bg-accent text-accent-foreground",children:"Featured"})]})}),e.jsx(I,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[h?e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>n(s.id),title:"Unpublish",children:e.jsx(ce,{className:"h-4 w-4 text-orange-600"})}):e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>i(s.id),title:"Publish",children:e.jsx(oe,{className:"h-4 w-4 text-green-600"})}),e.jsx(y,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(a,{to:m,target:"_blank",rel:"noopener noreferrer",children:e.jsx(ue,{className:"h-4 w-4"})})}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>r(s.id),children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx(y,{variant:"ghost",size:"sm",onClick:()=>l(s.id,s.title),children:e.jsx(he,{className:"h-4 w-4 text-destructive"})})]})})]})}),Te=({fixedPublicationType:a}={})=>{const o=a??"article",u="announcement"===a,m=!u,h=u?"Announcements Management":"Publications Management",p=u?{loading:"Loading announcements...",subtitle:"Create and manage announcements with rich content",add:"Add Announcement",editTitle:"Edit Announcement",addTitle:"Add New Announcement",editDescription:"Update the announcement",addDescription:"Create a new announcement with rich content",titlePlaceholder:"Announcement title",slugHelp:"á¡á£á¤áá URL-á¡ á¨áá¥ááá ááááªá®áááááá¡áááá¡. áááááá§áááá áá®áááá ááá¢áá á áá¡áááá, áªáá¤á ááá áá á¢áá áááá. áᣠáªáá ááááá, ááá¢áááá¢á£á áá ááááá áá áááá á¡áááá£á áááá.",previewUrlPrefix:"/announcements/",contentLabel:"Announcement Content *",contentPlaceholder:"Write your announcement here. Use the toolbar to format text, add images, links, and embeds...",designrrHelp:"Paste Designrr embed URL or iframe src to show flipbook above the announcement. Example: https://designrr.page/?id=xxx&token=xxx&h=xxx",authorsHelp:"Select one or more authors for this announcement.",fellowsHelp:"Select fellows associated with this announcement.",previewTitleFallback:"Announcement title",searchPlaceholder:"Search announcements...",emptyList:"No announcements found",notFound:"Announcement not found",loadFailed:"Failed to load announcement details",saveFellowsError:"The announcement was saved, but linking fellows failed.",saveAuthorsError:"The announcement was saved, but linking authors failed.",publishedDateLabel:"Announcement date",shareUrlBase:"https://delphigrc.org/announcements/"}:{loading:"Loading publications...",subtitle:"Create and manage publications with rich content",add:"Add Publication",editTitle:"Edit Publication",addTitle:"Add New Publication",editDescription:"Update the publication",addDescription:"Create a new publication with rich content",titlePlaceholder:"Publication title",slugHelp:"á¡á£á¤áá URL-á¡ á¨áá¥ááá á¡á¢áá¢ááá¡áááá¡. áááááá§áááá áá®áááá ááá¢áá á áá¡áááá, áªáá¤á ááá áá á¢áá áááá. áᣠáªáá ááááá, ááá¢áááá¢á£á áá ááááá áá áááá á¡áááá£á áááá.",previewUrlPrefix:"/research/",contentLabel:"Article Content *",contentPlaceholder:"Write your article here. Use the toolbar to format text, add images, links, and embeds...",designrrHelp:"Paste Designrr embed URL or iframe src to show flipbook above the article. Example: https://designrr.page/?id=xxx&token=xxx&h=xxx",authorsHelp:"Select one or more authors for this publication.",fellowsHelp:"Select fellows associated with this publication.",previewTitleFallback:"Article title",searchPlaceholder:"Search publications...",emptyList:"No publications foun
1d",notFound:"Article not found",loadFailed:"Failed to load article details",saveFellowsError:"The article was saved, but linking fellows failed.",saveAuthorsError:"The article was saved, but linking authors failed.",publishedDateLabel:"Publication date",shareUrlBase:"https://delphigrc.org/research/"},[x,j]=t.useState(1),[b,k]=t.useState(""),L=t.useDeferredValue(b);t.useEffect(()=>{j(1)},[L]);const{articles:le,totalCount:ie,pageSize:ne,loading:de,isFetching:ce,fetchArticleById:oe,createArticle:ue,updateArticle:me,deleteArticle:he,publishArticle:we,unpublishArticle:Ne}=Pe({page:x,pageSize:25,search:L,publicationType:a});Ce();const{logActivity:Te}=ke(),{syncAfterPublish:Fe}=g(),[De,Le]=t.useState(!1),[Ee,$e]=t.useState(null),[Ie,ze]=t.useState(null),[Be,qe]=t.useState(""),[Re,Me]=t.useState([]),[He,Ve]=t.useState(!1),[Oe,We]=t.useState([]),[Ge,Je]=t.useState([]),[Ye,Ke]=t.useState([]),[Qe,Xe]=t.useState({title:"",slug:"",category:[],publication_type:o,author_id:"",author:"",authorBio:"",summary:"",content:"",readTime:"",featured:!1,featuredImageUrl:"",designrrUrl:"",status:"draft",published_at:null}),[Ze,et]=t.useState(!1),tt=t.useMemo(()=>`admin-publication-draft:${a??"all"}`,[a]),at=t.useCallback(()=>{try{sessionStorage.removeItem(tt)}catch{}},[tt]),st=t.useCallback(e=>Boolean(e.title.trim()||e.summary.trim()||e.content.trim()),[]);t.useEffect(()=>{(async()=>{Ve(!0);try{const{data:e,error:t}=await f.from("authors").select("id, name, role, avatar_url, is_active").order("is_active",{ascending:!1}).order("name");if(t)throw t;const{data:a,error:s}=await f.from("fellows").select("id, name, title, avatar_url, is_active").order("is_active",{ascending:!1}).order("name");if(s)throw s;const r=[...(e||[]).map(e=>({...e,type:"author"})),...(a||[]).map(e=>({id:e.id,name:e.name,role:e.title,avatar_url:e.avatar_url,is_active:e.is_active,type:"fellow"}))];Me(r),Je(a||[])}catch(e){_.error("Failed to load authors and fellows")}finally{Ve(!1)}})()},[]),t.useEffect(()=>{if(Qe.content){const e=N(Qe.content);Qe.readTime&&""!==Qe.readTime&&"0 min read"!==Qe.readTime||Xe(t=>({...t,readTime:e}))}},[Qe.content]);const rt=Math.max(1,Math.ceil(ie/ne)),lt=0===ie?0:(x-1)*ne+1,it=Math.min(x*ne,ie),nt=()=>{Xe({title:"",slug:"",category:[],publication_type:o,author_id:"",author:"",authorBio:"",summary:"",content:"",designrrUrl:"",readTime:"",featured:!1,featuredImageUrl:"",status:"draft",published_at:null}),$e(null),ze(null),We([]),Ke([]),at()};t.useEffect(()=>{if(!De||!st(Qe))return;const e=window.setTimeout(()=>{try{sessionStorage.setItem(tt,JSON.stringify({formData:Qe,selectedAuthors:Ye,selectedFellows:Oe,editingArticle:Ee,savedAt:Date.now()}))}catch{}},400);return()=>window.clearTimeout(e)},[De,Qe,Ye,Oe,Ee,tt,st]);const dt=t.useCallback(()=>{try{const e=sessionStorage.getItem(tt);if(!e)return!1;const t=JSON.parse(e);return!(!t.formData||!st(t.formData))&&(!t.editingArticle&&(Xe(t.formData),Ke(t.selectedAuthors??[]),We(t.selectedFellows??[]),$e(null),_.message("Restored your unsaved draft"),!0))}catch{return!1}},[tt,st]),ct=t.useCallback(()=>{dt()||nt(),Le(!0)},[dt]),ot=t.useCallback(async e=>{var t;try{const s=await oe(e);if(!s)return void _.error(p.notFound);const r="string"==typeof s.content?s.content:(null==(t=s.content)?void 0:t.text)||s.content||"",l=s.template_settings,i=null==l?void 0:l.category,n=Array.isArray(i)?i:i?[i]:[],d=[...new Set(n.map(w))];Xe({title:s.title,slug:s.slug||"",category:d,publication_type:s.publication_type||o,author_id:s.author_id||"",author:(null==l?void 0:l.author)||"",authorBio:(null==l?void 0:l.authorBio)||"",summary:s.summary||"",content:r,readTime:(null==l?void 0:l.readTime)||"",featured:s.featured||!1,featuredImageUrl:s.featured_image_url||"",designrrUrl:(null==l?void 0:l.designrrUrl)||(null==l?void 0:l.flippingbookUrl)||"",status:s.status,published_at:s.published_at||null}),$e(e),ze(s);try{const{data:t,error:a}=await f.from("article_fellows").select("fellow_id").eq("article_id",e);if(a)throw a;We((null==t?void 0:t.map(e=>e.fellow_id))||[]);const{data:s,error:r}=await f.from("article_authors").select("author_id").eq("article_id",e);if(r)throw r;Ke((null==s?void 0:s.map(e=>e.author_id))||[])}catch(a){0}Le(!0)}catch(a){_.error(p.loadFailed)}},[oe,o,p.notFound,p.loadFailed]),ut=t.useCallback(async(e,t)=>{if(confirm(`Are you sure you want to delete "${t}"?`)){const a=le.find(t=>
1t.id===e);await he(e)&&await Te({activityType:"article_delete",entityType:"article",entityId:e,entityName:t,actionDescription:u?`Deleted announcement: ${t}`:`Deleted article: ${t}`,oldValues:a?{title:a.title,status:a.status,publication_type:a.publication_type}:void 0})}},[le,he,Te]),mt=t.useCallback(async e=>{const t=le.find(t=>t.id===e);await we(e),t&&await Te({activityType:"article_publish",entityType:"article",entityId:e,entityName:t.title,actionDescription:u?`Published announcement: ${t.title}`:`Published article: ${t.title}`,oldValues:{status:"draft"},newValues:{status:"published",published_at:(new Date).toISOString()}})},[le,we,Te]),ht=t.useCallback(async e=>{const t=le.find(t=>t.id===e);await Ne(e),t&&await Te({activityType:"article_unpublish",entityType:"article",entityId:e,entityName:t.title,actionDescription:u?`Unpublished announcement: ${t.title}`:`Unpublished article: ${t.title}`,oldValues:{status:"published",published_at:t.published_at},newValues:{status:"draft"}})},[le,Ne,Te]),pt=async(e=!1,t=!0,l=!1)=>{var i,n;if(!Qe.title||!Qe.summary||0===Ye.length||m&&0===Qe.category.length)return void(l||_.error(m?"Please complete all required fields (title, summary, at least one author, and one category).":"Please complete all required fields (title, summary, and at least one author)."));const d=Qe.slug||s(Qe.title),c=r(d);if(c)return void(l||_.error(c));if(await(async(e,t)=>{try{let a=f.from("articles").select("id").eq("slug",e);t&&(a=a.neq("id",t));const{data:s,error:r}=await a;return!r&&s&&s.length>0}catch(a){return!1}})(d,Ee||void 0))return void(l||_.error(`The URL "${d}" is already taken. Please choose a different slug.`));const o=Ye[0],h={title:Qe.title,slug:d,subtitle:Qe.summary,summary:Qe.summary,content:Qe.content,author_id:o,publication_type:a??Qe.publication_type,template_type:"research",layout_type:"hero",featured:Qe.featured,status:e?"draft":"published",featured_image_url:Qe.featuredImageUrl||"",featured_image_alt:Qe.title},x=E.safeParse(h);if(!x.success){if(!l){const e=x.error.errors.map(e=>`${e.path.join(".")}: ${e.message}`).join("\n");_.error("Validation Error",{description:e})}return}const g=Re.find(e=>e.id===o),j={title:Qe.title,subtitle:Qe.summary,summary:Qe.summary,content:Qe.content,author_id:o,publication_type:a??Qe.publication_type,template_type:"research",layout_type:"hero",featured:Qe.featured,status:e?"draft":"published",featured_image_url:Qe.featuredImageUrl||null,published_at:e?null:Qe.published_at||(new Date).toISOString(),template_settings:{category:m?Qe.category:[],author:(null==g?void 0:g.name)||Qe.author,author_id:o,author_type:(null==g?void 0:g.type)||"author",authorBio:Qe.authorBio,readTime:Qe.readTime,designrrUrl:(null==(i=Qe.designrrUrl)?void 0:i.trim())||void 0}};try{let a;if(Ee)await me(Ee,j),a=Ee;else{const e=await ue(j);a=null==e?void 0:e.id}if(a){if(await f.from("article_fellows").delete().eq("article_id",a),Oe.length>0){const e=Oe.map(e=>({article_id:a,fellow_id:e})),{error:t}=await f.from("article_fellows").insert(e);t&&_.error(p.saveFellowsError)}if(await f.from("article_authors").delete().eq("article_id",a),Ye.length>0){const e=Ye.map((e,t)=>({article_id:a,author_id:e,author_order:t})),{error:t}=await f.from("article_authors").insert(e);t&&_.error(p.saveAuthorsError)}}if(a){const t=Ee?"article_update":"article_create",s=Ee?u?`Updated announcement: ${Qe.title}`:`Updated article: ${Qe.title}`:u?`Created new announcement: ${Qe.title}`:`Created new article: ${Qe.title}`;await Te({activityType:t,entityType:"article",entityId:a,entityName:Qe.title,actionDescription:s,oldValues:Ee&&Ie?{title:Ie.title,status:Ie.status,category:null==(n=Ie.template_settings)?void 0:n.category,featured:Ie.featured}:void 0,newValues:{title:Qe.title,status:e?"draft":"published",category:Qe.category,featured:Qe.featured,authors:Ye,fellows:Oe}})}if(a&&!e){const e=Qe.title.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");await Fe(a,e,Qe.title)}a&&!Ee&&$e(a),t?(Le(!1),nt()):l||_.success("Content saved successfully.")}catch(b){l||_.error("An error occurred.")}},xt=t.useRef(()=>{});xt.current=()=>{De&&Qe.title.trim()&&Qe.summary.trim()&&0!==Ye.length&&(m&&0===Qe.category.length||pt(!0,!1,!0))},t.useEffect(()=>{const e=()=>{"hidden"===document.visibilityState&&xt.current()};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[]),t.useEffect(()=>{const e=e=>{De&&st(Qe)&&(e.preventDefault(),e.returnValue="")};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[De,Qe,st]);return de&&0===le.length?e.jsx(l,{children:e.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent mx-auto"}),e.jsx("p",{className:"text-muted-foreground",children:p.loading})]})})}):e.jsxs(l,{children:[e.jsxs(C,{children:[e.jsx("meta",{name:"robots",content:"noindex,nofollow"}),e.jsxs("title",{children:[h," - Admin - Delphi Global Research Center"]})]}),e.jsxs("div",{className:"p-6",children:[e.jsxs("div",{className:"mb-8 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"mb-2 font-heading text-3xl font-bold text-foreground",children:h}),e.jsx("p",{className:"text-muted-foreground",children:p.subtitle})]}),e.jsxs(M,{open:De,onOpenChange:e=>{Le(!!e)},children:[e.jsxs(y,{onClick:ct,children:[e.jsx(pe,{className:"mr-2 h-4 w-4"}),p.add]}
1),e.jsxs(H,{className:"max-w-[95vw] max-h-[95vh] overflow-hidden flex flex-col",children:[e.jsxs(V,{children:[e.jsx(O,{children:Ee?p.editTitle:p.addTitle}),e.jsx(W,{children:Ee?p.editDescription:p.addDescription})]}),e.jsxs(te,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ae,{className:"grid w-full grid-cols-3",children:[e.jsx(se,{value:"content",children:"Content"}),e.jsx(se,{value:"metadata",children:"Metadata"}),e.jsx(se,{value:"preview",children:"Preview"})]}),e.jsxs("div",{className:"flex-1 py-4",children:[e.jsxs(re,{value:"content",className:"space-y-4 mt-0 overflow-y-auto max-h-[calc(95vh-280px)]",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"title",children:"Title *"}),e.jsx(S,{id:"title",placeholder:p.titlePlaceholder,value:Qe.title,onChange:e=>Xe({...Qe,title:e.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"slug",children:"Custom URL (Slug) *"}),e.jsx(S,{id:"slug",placeholder:"custom-url-slug (auto-generated from title)",value:Qe.slug,onChange:e=>{const t=e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-");Xe({...Qe,slug:t})}}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p.slugHelp}),Qe.slug&&e.jsxs("p",{className:"text-xs text-primary",children:["Preview URL: ",p.previewUrlPrefix,Qe.slug]})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{children:p.contentLabel}),e.jsx(c,{content:Qe.content,onChange:e=>{Xe({...Qe,content:e}),qe(e)},placeholder:p.contentPlaceholder})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"designrr-url",children:"Designrr (optional)"}),e.jsx(S,{id:"designrr-url",placeholder:"https://designrr.page/?id=632405&token=3032853806&h=2732",value:Qe.designrrUrl,onChange:e=>Xe({...Qe,designrrUrl:e.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p.designrrHelp})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsx(y,{variant:"secondary",onClick:()=>pt(!0,!1),disabled:!Qe.title||!Qe.summary||0===Ye.length||m&&0===Qe.category.length,children:"Save content"})})]}),e.jsxs(re,{value:"metadata",className:"space-y-4 mt-0 overflow-y-auto max-h-[calc(90vh-280px)]",children:[!a&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"publication-type",children:"Publication type *"}),e.jsxs(K,{value:Qe.publication_type,onValueChange:e=>Xe({...Qe,publication_type:e}),children:[e.jsx(Q,{id:"publication-type",children:e.jsx(X,{placeholder:"Select a type"})}),e.jsxs(Z,{children:[e.jsx(ee,{value:"article",children:"Article"}),e.jsx(ee,{value:"report",children:"Report"}),e.jsx(ee,{value:"opinion",children:"Opinion"}),e.jsx(ee,{value:"announcement",children:"Announcement"})]})]})]}),m&&e.jsxs("div",{className:"grid gap-2 border rounded-lg p-4 bg-muted/20",children:[e.jsx("div",{className:"flex items-center gap-2 mb-2",children:e.jsx(J,{children:"Categories *"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select one or more categories. The article will appear on every selected research page."}),e.jsx("div",{className:"grid gap-2 max-h-60 overflow-y-auto border rounded-lg p-3 bg-background",children:A.map(({label:t})=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ye,{id:`category-${t}`,checked:Qe.category.includes(t),onCheckedChange:e=>{Xe(e?{...Qe,category:[...Qe.category,t]}:{...Qe,category:Qe.category.filter(e=>e!==t)})}}),e.jsx("label",{htmlFor:`category-${t}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:t})]},t))}),Qe.category.length>0&&e.jsxs("p",{className:"text-sm text-primary font-medium",children:["Selected: ",Qe.category.length," categories"]}),0===Qe.category.length&&e.jsx("p",{className:"text-sm text-destructive",children:"Selecting at least one category is required"})]}),e.jsxs("div",{className:"grid gap-2 border rounded-lg p-4 bg-muted/20",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx(J,{children:"Authors *"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p.authorsHelp}),e.jsx("div",{className:"grid gap-2 max-h-60 overflow-y-auto border rounded-lg p-3 bg-background",children:He?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):0===Re.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No authors available"}):Re.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ye,{id:`author-${t.id}`,checked:Ye.includes(t.id),onCheckedChange:e=>{Ke(e?[...Ye,t.id]:Ye.filter(e=>e!==t.id))}}),e.jsxs("label",{htmlFor:`author-${t.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:[t.name," - ",t.role," (","author"===t.type?"Author":"Fellow",")",!t.is_active&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(Inactive)"})]})]},t.id))}),Ye.length>0&&e.jsxs("p",{className:"text-sm text-primary font-medium",children:["Selected: ",Ye.length," author",1===Ye.length?"":"s"]}),0===Ye.length&&e.jsx("p",{className:"text-sm text-destructive",children:"Selecting at least one author is required"})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"authorBio",children:"Author Bio"}),e.jsx(S,{id:"authorBio",placeholder:"Brief author description",value:Qe.authorBio,onChange:e=>Xe({...Qe,authorBio:e.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"readTime",children:"Read Time"}),e.jsx(S,{id:"readTime",placeholder:"e.g., 10 min read (auto-calculated)",value:Qe.readTime,onChange:e=>Xe({...Qe,readTime:e.target.value})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Auto-calculated from content. You can override this value manually."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"published_at",children:p.publishedDateLabel}),e.jsxs(i,{children:[e.jsx(n,{asChild:!0,children:e.jsxs(y,{id:"published_at",variant:"outline",className:P("justify-start text-left font-normal",!Qe.published_at&&"text-muted-foreground"),children:[e.jsx(ge,{className:"mr-2 h-4 w-4"}),Qe.published_at?Se(new Date(Qe.published_at),"PPP"):e.jsx("span",{children:"Choose a date"})]})}),e.jsx(d,{className:"w-auto p-0",align:"start",children:e.jsx(_e,{mode:"single",selected:Qe.published_at?new Date(Qe.published_at):void 0,onSelect:e=>Xe({...Qe,published_at:e?e.toISOString():null}),initialFocus:!0,className:"pointer-events-auto"})})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"If left blank, the current publish date will be used automatically."})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"summary",children:"Summary *"}),e.jsx(Y,{id:"summary",placeholder:"Brief description for preview...",rows:3,value:Qe.summary,onChange:e=>Xe({...Qe,summary:e.target.value})})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(J,{htmlFor:"featuredImage",children:"Featured Image"}),e.jsx(S,{id:"featuredImage",type:"file",accept:"image/*",onChange:async e=>{var t;const a=null==(t=e.target.files)?void 0:t[0];if(a)if(a.type.startsWith("image/"))if(a.size>5242880)_.error("Image size should be less than 5MB");else{et(!0);try{const e=a.name.split(".").pop(),t=`${`${Math.random().toString(36).substring(2)}_${Date.now()}.${e}`}`,{error:s,data:r}=await f.storage.from("article-images").upload(t,a);if(s)throw s;const{data:{publicUrl:l}}=f.storage.from("article-images").getPublicUrl(t);0,Xe(e=>({...e,featuredImageUrl:l})),_.success("Image uploaded successfully.")}catch(s){_.error("Failed to upload image")}finally{et(!1)}}else _.error("Please upload an image file")},disabled:Ze}),Ze&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."}),Qe.featuredImageUrl&&e.jsxs("div",{className:"mt-2",children:[e.jsx("img",{src:Qe.featuredImageUrl,alt:"Featured preview",className:"h-32 w-full object-cover rounded-lg"}),e.jsx(y,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>Xe({...Qe,featuredImageUrl:""}),children:"Remove Image"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"featured",checked:Qe.featured,onChange:e=>Xe({...Qe,featured:e.target.checked}),className:"h-4 w-4"}),e.jsx(J,{htmlFor:"featured",className:"cursor-pointer",children:"Mark as featured"})]}),e.jsxs("div",{className:"grid gap-2 border-t pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx(J,{children:"Fellows"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:p.fellowsHelp}),e.jsx("div",{className:"grid gap-2 max-h-60 overflow-y-auto border rounded-lg p-3",children:0===Ge.length?e.jsx("p",{className:"text-sm text-muted-foreground",children:"No fellows available"}):Ge.map(t=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(ye,{id:`fellow-${t.id}`,checked:Oe.includes(t.id),onCheckedChange:e=>{We(e?[...Oe,t.id]:Oe.filter(e=>e!==t.id))}}),e.jsxs("label",{htmlFor:`fellow-${t.id}`,className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 cursor-pointer",children:[t.name," - ",t.title,!t.is_active&&e.jsx("span",{className:"text-muted-foreground ml-1",children:"(Inactive)"})]})]},t.id))}),Oe.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Selected: ",Oe.length," fellow",1===Oe.length?"":"s"]})]})]}),e.jsxs(re,{value:"preview",className:"mt-0 overflow-y-auto max-h-[calc(90vh-280px)]",children:[Qe.featuredImageUrl?e.jsx("div",{className:"mb-6 -mx-6 -mt-4",children:e.jsx("img",{src:Qe.featuredImageUrl,alt:Qe.title||"Featured",className:"w-full h-[255px] md:h-[340px] object-cover",onLoad:()=>{},onError:e=>{}})}):null,e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:gap-8",children:[e.jsx("aside",{className:"lg:w-72 lg:flex-shrink-0",children:e.jsxs("div",{className:"lg:sticky lg:top-0 space-y-6",children:[m&&Qe.category.length>0&&e.jsx("div",{className:"flex justify-start",children:e.jsx(v,{variant:"secondary",className:"text-base px-3 py-1",children:Qe.category.join(", ")})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium",children:Ye.length>1?"Authors":"Author"})]}),e.jsx("div",{className:"space-y-3",children:Ye.length>0?Ye.map(t=>{const a=Re.find(e=>e.id===t);return a?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs(U,{className:"h-10 w-10 flex-shrink-0",children:[e.jsx(T,{src:a.avatar_url,alt:a.name}),e.jsx(F,{className:"text-sm",children:a.name.charAt(0)})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-sm text-foreground truncate",children:a.name}),e.jsx("p",{className:"text-xs text-muted-foreground leading-tight",children:a.role})]})]},t):null}):e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border border-border bg-card",children:[e.jsx(U,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(F,{className:"text-sm",children:"A"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("p",{className:"font-medium text-sm text-foreground truncate",children:"Author"})})]})})]}),e.jsxs("div",{className:"space-y-3 pt-3 border-t border-border",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(_e,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-foreground",children:(new Date).toLocaleDateString("ka-GE")})]}),Qe.readTime&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(fe,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-foreground",children:Qe.readTime})]})]}),e.jsxs("div",{className:"space-y-2 pt-3 border-t border-border",children:[e.jsxs(y,{variant:"outline",size:"sm",className:"w-full justify-start text-sm h-10 px-3",disabled:!0,children:[e.jsx(je,{className:"mr-2 h-4 w-4"}),"Download PDF"]}),e.jsxs(y,{variant:"outline",size:"sm",className:"w-full justify-start text-sm h-10 px-3",disabled:!0,children:[e.jsx(be,{className:"mr-2 h-4 w-4"}),"Share"]})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("header",{className:"mb-8",children:e.jsx("h1",{className:"mb-8 font-heading text-4xl font-medium leading-tight text-foreground md:text-5xl text-left",children:Qe.title||p.previewTitleFallback})}),e.jsx("div",{className:"mb-8 pb-6 border-b border-border",children:e.jsxs("div",{className:"flex items-center justify-end gap-3 text-sm text-muted-foreground",children:[Ye.length>0?e.jsxs("span",{children:["By"," ",Ye.map(e=>{const t=Re.find(t=>
1t.id===e);return(null==t?void 0:t.name)||""}).filter(Boolean).join(", ")]}):e.jsx("span",{children:"By Author"}),e.jsx("span",{children:"â¢"}),e.jsx("span",{children:(new Date).toLocaleDateString("ka-GE")})]})}),Qe.summary&&e.jsx("div",{className:"mb-8 p-6 rounded-lg bg-blue-50/50 dark:bg-blue-950/20 border border-blue-100 dark:border-blue-900/30",children:e.jsx("p",{className:"text-lg leading-relaxed text-[hsl(var(--summary-text))]",children:Qe.summary})}),e.jsx("div",{className:"article-preview-content prose prose-sm sm:prose lg:prose-lg xl:prose-xl max-w-none",style:{wordWrap:"break-word",overflowWrap:"break-word"},dangerouslySetInnerHTML:{__html:D(Be||Qe.content||"<p class='text-muted-foreground italic'>Content preview will appear here...</p>")}})]})]}),e.jsx("div",{className:"mt-8",children:e.jsx(Ae,{title:Qe.title,description:Qe.summary||"",imageUrl:Qe.featuredImageUrl,url:Qe.slug?`${p.shareUrlBase}${Qe.slug}`:void 0,category:m?Qe.category[0]||"Research":"Announcements"})})]})]})]})]}),e.jsxs(G,{className:"border-t pt-4",children:[e.jsx(y,{variant:"outline",onClick:()=>{Le(!1),nt()},children:"Cancel"}),e.jsx(y,{variant:"secondary",onClick:()=>pt(!0),children:"Save as draft"}),e.jsx(y,{onClick:()=>pt(!1),children:Ee?"Update and publish":"Publish"})]})]})]})]}),e.jsxs("div",{className:"mb-6 flex items-center gap-4",children:[e.jsxs("div",{className:"relative flex-1 max-w-md",children:[e.jsx(ve,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(S,{placeholder:p.searchPlaceholder,value:b,onChange:e=>k(e.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[ie," total",ce&&!de?" · Updatingâ¦":""]})]}),e.jsxs("div",{className:P("rounded-lg border border-border bg-card shadow-card transition-opacity",ce&&!de&&"opacity-70"),children:[e.jsxs(z,{children:[e.jsx(B,{children:e.jsxs($,{children:[e.jsx(q,{children:"Title"}),!u&&e.jsx(q,{children:"Category"}),e.jsx(q,{children:"Author"}),e.jsx(q,{children:"Status"}),e.jsx(q,{className:"text-right",children:"Actions"})]})}),e.jsx(R,{children:0===le.length?e.jsx($,{children:e.jsx(I,{colSpan:u?4:5,className:"text-center py-8 text-muted-foreground",children:p.emptyList})}):le.map(t=>e.jsx(Ue,{article:t,onEdit:ot,onDelete:ut,onPublish:mt,onUnpublish:ht,hideCategory:u,previewPathPrefix:p.previewUrlPrefix},t.id))})]}),e.jsxs("div",{className:"flex flex-col gap-3 border-t border-border px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",lt,"â",it," of ",ie]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{variant:"outline",size:"sm",disabled:x<=1||ce,onClick:()=>j(e=>Math.max(1,e-1)),children:"Previous"}),e.jsxs("span",{className:"text-sm text-muted-foreground tabular-nums",children:["Page ",x," of ",rt]}),e.jsx(y,{variant:"outline",size:"sm",disabled:x>=rt||ce,onClick:()=>j(e=>Math.min(rt,e+1)),children:"Next"})]})]})]})]})]})};export{Te 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.