import{r as n,d as N,j as e,H as b,g as u,w,F as v,N as y,v as _}from"./vendor-laZsiqLO.js";import{G as k}from"./GuestLayout-Bncnlxxo.js";import{P}from"./PostCard-S-gB25Ls.js";import{B as S}from"./button-B8f8jW4H.js";import{S as l}from"./skeleton-uyR1XZG9.js";import{u as E}from"./useTranslation-BW0o-tkY.js";import"./SiteLogo-DML5Oulk.js";import"./dropdown-menu-CpMN0BZ0.js";import"./utils-RgT4yCq8.js";import"./input-CT5MkJwj.js";import"./sheet-Cp4V1hdh.js";import"./useFlashMessages-CQoLOBuv.js";import"./AdSlot-HY9FvbmL.js";import"./RightSidebarFooter-BO77c1r9.js";import"./avatar-1RNhlzAH.js";import"./badge-CJ9RzXvO.js";import"./card-BKDXjfy_.js";function F({category:a,posts:x}){const[c,f]=n.useState(x.data),[o,p]=n.useState(x.next_page_url),[i,h]=n.useState(!1),m=n.useRef(null),{t:s}=E();n.useEffect(()=>{if(!m.current)return;const t=new IntersectionObserver(r=>{r[0].isIntersecting&&o&&!i&&g()},{threshold:.1,rootMargin:"100px"});return t.observe(m.current),()=>t.disconnect()},[o,i]);const g=async()=>{if(o){h(!0);try{const r=(await N.get(o,{headers:{Accept:"application/json"}})).data;r.data&&Array.isArray(r.data)?(f(j=>[...j,...r.data]),p(r.next_page_url)):(console.error("API Error: Expected JSON with 'data' array, got:",r),p(null))}catch(t){console.error("Failed to load more posts:",t)}finally{h(!1)}}},d=()=>e.jsxs("div",{className:"flex flex-col space-y-3",children:[e.jsx(l,{className:"aspect-[16/9] w-full rounded-xl"}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(l,{className:"h-4 w-20 rounded-full"}),e.jsx(l,{className:"h-3 w-16"})]}),e.jsx(l,{className:"h-6 w-full"}),e.jsx(l,{className:"h-6 w-3/4"})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(b,{title:`${a.name} ${s("_news_title","News")}`}),e.jsxs("div",{className:"bg-background min-h-screen pb-20",children:[e.jsx("div",{className:"relative bg-muted/30 border-b border-border",children:e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-12 max-w-[1280px]",children:[e.jsxs("nav",{className:"flex items-center text-sm text-muted-foreground mb-6 font-medium",children:[e.jsx(u,{href:"/",className:"hover:text-primary transition-colors",children:s("_home","Home")}),e.jsx(w,{className:"w-4 h-4 mx-2 opacity-50 rtl:-scale-x-100"}),e.jsx("span",{className:"text-foreground",children:a.name})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-end justify-between gap-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h1",{className:"text-4xl md:text-5xl font-black tracking-tight capitalize text-foreground font-serif flex items-center gap-3",children:[e.jsx(v,{className:"w-10 h-10 text-primary"}),a.name]}),e.jsxs("p",{className:"text-lg text-muted-foreground max-w-2xl leading-relaxed",children:[s("_category_description_start","Browse the latest headlines, in-depth analysis, and reports from the"),e.jsx("span",{className:"font-semibold text-foreground mx-1",children:a.name}),s("_category_description_end","section.")]})]}),e.jsx("div",{className:"hidden md:block opacity-50",children:e.jsx(y,{className:"w-24 h-24 text-muted-foreground/20"})})]})]})}),e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-12 max-w-[1280px]",children:[c.length>0?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-6 gap-y-10",children:[c.map(t=>e.jsx("div",{className:"animate-in fade-in zoom-in-95 duration-500",children:e.jsx(P,{post:t})},t.id)),i&&e.jsxs(e.Fragment,{children:[e.jsx(d,{}),e.jsx(d,{}),e.jsx(d,{}),e.jsx(d,{})]})]}):e.jsxs("div",{className:"text-center py-24 bg-muted/20 rounded-xl border border-dashed border-muted-foreground/25 flex flex-col items-center",children:[e.jsx(_,{className:"w-16 h-16 text-muted-foreground/30 mb-4"}),e.jsx("h3",{className:"text-xl font-bold text-muted-foreground",children:s("_no_news_in_category","No news found in this category.")}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2 mb-6",children:s("_check_back_soon","We haven't published any stories here yet. Check back soon.")}),e.jsx(S,{asChild:!0,variant:"outline",children:e.jsx(u,{href:"/",children:s("_back_to_home","Back to Home")})})]}),e.jsx("div",{ref:m,className:"py-12 text-center",children:!i&&!o&&c.length>0&&e.jsxs("div",{className:"flex items-center justify-center gap-4 text-muted-foreground/50",children:[e.jsx("div",{className:"h-px w-16 bg-border"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-widest",children:s("_end_of_content","End of content")}),e.jsx("div",{className:"h-px w-16 bg-border"})]})})]})]})]})}F.layout=a=>e.jsx(k,{children:a});export{F as default};
