import{r as l,d as j,j as e,H as N,g as p,w as _,v as b}from"./vendor-laZsiqLO.js";import{G as v}from"./GuestLayout-Bncnlxxo.js";import{P as w}from"./PostCard-S-gB25Ls.js";import{B as y}from"./button-B8f8jW4H.js";import{S as i}from"./skeleton-uyR1XZG9.js";import{u as k}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 S({source:t,posts:f}){const[c,h]=l.useState(f.data),[r,d]=l.useState(f.next_page_url),[o,u]=l.useState(!1),m=l.useRef(null),{t:a}=k();l.useEffect(()=>{if(!m.current)return;const s=new IntersectionObserver(x=>{x[0].isIntersecting&&r&&!o&&g()},{threshold:.1,rootMargin:"100px"});return s.observe(m.current),()=>s.disconnect()},[r,o]);const g=async()=>{if(!(!r||o)){u(!0);try{const s=await j.get(r,{headers:{Accept:"application/json"}});s.data&&Array.isArray(s.data.data)?(h(x=>[...x,...s.data.data]),d(s.data.next_page_url)):d(null)}catch(s){console.error("Failed to load more posts:",s),d(null)}finally{u(!1)}}},n=()=>e.jsxs("div",{className:"flex flex-col space-y-3",children:[e.jsx(i,{className:"aspect-[16/9] w-full rounded-xl"}),e.jsxs("div",{className:"space-y-2 pt-2",children:[e.jsx(i,{className:"h-4 w-20 rounded-full"}),e.jsx(i,{className:"h-6 w-full"}),e.jsx(i,{className:"h-4 w-3/4"})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(N,{title:`${a("_news_from","News from")} ${t.name}`}),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(p,{href:"/",className:"hover:text-primary transition-colors",children:a("_home","Home")}),e.jsx(_,{className:"w-4 h-4 mx-2 opacity-50 rtl:-scale-x-100"}),e.jsx("span",{className:"text-foreground",children:t.name})]}),e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center gap-6",children:[t.feed_logo&&e.jsx("img",{src:t.feed_logo,alt:t.name,className:"w-20 h-20 rounded-lg object-contain bg-white p-1 border shadow-sm"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-black tracking-tight text-foreground font-serif",children:t.name}),e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl leading-relaxed",children:a("_latest_from_source","The latest articles automatically sourced from {sourceName}.").replace("{sourceName}",t.name)})]})]})]})}),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(s=>e.jsx("div",{className:"animate-in fade-in zoom-in-95 duration-500",children:e.jsx(w,{post:s})},s.id)),o&&e.jsxs(e.Fragment,{children:[e.jsx(n,{}),e.jsx(n,{}),e.jsx(n,{}),e.jsx(n,{})]})]}):e.jsxs("div",{className:"text-center py-24 bg-muted/20 rounded-xl border border-dashed flex flex-col items-center",children:[e.jsx(b,{className:"w-16 h-16 text-muted-foreground/30 mb-4"}),e.jsx("h3",{className:"text-xl font-bold text-muted-foreground",children:a("_no_news_from_source","No news found from this source.")}),e.jsx(y,{asChild:!0,variant:"outline",className:"mt-6",children:e.jsx(p,{href:"/",children:a("_back_to_home","Back to Home")})})]}),e.jsx("div",{ref:m,className:"py-12 text-center",children:!o&&!r&&c.length>0&&e.jsx("div",{className:"text-sm text-muted-foreground italic",children:a("_end_of_content","End of content")})})]})]})]})}S.layout=t=>e.jsx(v,{children:t});export{S as default};
