import{u as S,r as t,j as e,H as T,O as L,g as A,d as D}from"./vendor-laZsiqLO.js";import{G as F}from"./GuestLayout-Bncnlxxo.js";import{S as G}from"./separator-DMopkgTA.js";import{S as c}from"./skeleton-uyR1XZG9.js";import{A as n}from"./AdSlot-HY9FvbmL.js";import{T as E}from"./TimeDisplay-B9_xEULj.js";import{R as H}from"./RightSidebarFooter-BO77c1r9.js";import{u as I}from"./useTranslation-BW0o-tkY.js";import P from"./HeroSlider-QPQRYLoB.js";import R from"./GridItem-DWdVTTVi.js";import C from"./HighlightedFeedTabs-CDp9Lbjc.js";import"./SiteLogo-DML5Oulk.js";import"./button-B8f8jW4H.js";import"./utils-RgT4yCq8.js";import"./dropdown-menu-CpMN0BZ0.js";import"./input-CT5MkJwj.js";import"./sheet-Cp4V1hdh.js";import"./useFlashMessages-CQoLOBuv.js";import"./avatar-1RNhlzAH.js";import"./carousel-C9slTU5h.js";import"./badge-CJ9RzXvO.js";import"./tabs-BIlCaUeu.js";import"./FeedItem-DbzhW-Au.js";import"./VoteButtons-DwvWCLSs.js";function B({auth:r,heroSlider:i,subHeroPosts:m,ads:l}){const{t:d}=I(),{site_settings:p}=S().props,b=p?.site_name||"Titan News",f=p?.og_title||`${b} - Global Perspectives`,[N,v]=t.useState(null),[x,w]=t.useState([]),[_,y]=t.useState({featured:0,editor_picks:0,hot_news:0}),[g,k]=t.useState(!0);t.useEffect(()=>{(async()=>{try{const a=await D.get("/api/home-data");v(a.data.latest),w(a.data.trending),y(a.data.tab_counts)}catch{console.error("Failed to load home data")}finally{k(!1)}})()},[]);const u=l?.home_mobile_top,h=l?.home_sidebar_top,j=l?.home_sidebar_bottom,o=s=>s&&s.is_active;return e.jsxs(e.Fragment,{children:[e.jsx(T,{title:f}),e.jsx("div",{className:"bg-background min-h-screen pb-12",children:e.jsxs("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-6 max-w-[1280px]",children:[o(u)&&e.jsx("div",{className:"lg:hidden mb-6 flex justify-center",children:e.jsx(n,{ad:u,className:"w-full max-w-[320px]"})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8",children:[e.jsxs("div",{className:"lg:col-span-9 space-y-8",children:[i&&i.length>0?e.jsx(P,{posts:i}):e.jsx("div",{className:"h-[450px] w-full rounded-xl bg-muted animate-pulse"}),m.length>0?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:m.map(s=>e.jsx(R,{post:s},s.id))}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[1,2,3,4].map(s=>e.jsx("div",{className:"aspect-[4/3] rounded-md bg-muted animate-pulse"},s))}),e.jsx(G,{className:"my-6"}),e.jsx("div",{className:"space-y-6",children:e.jsx(C,{initialLatestData:N,auth:r,tabCounts:_})})]}),e.jsxs("aside",{className:"lg:col-span-3 hidden lg:block h-full ps-6 border-s border-border relative",children:[e.jsxs("div",{className:"space-y-8 mb-8",children:[o(h)&&e.jsx("div",{className:"flex justify-center bg-card border rounded-md p-4 shadow-sm",children:e.jsxs("div",{className:"w-full",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mb-2 uppercase tracking-widest",children:d("_advertisement","Advertisement")}),e.jsx(n,{ad:h,className:"w-full"})]})}),(g||x.length>0)&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(L,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"font-bold text-lg",children:d("_trending_now","Trending Now")})]}),e.jsx("div",{className:"space-y-4",children:g?e.jsx(e.Fragment,{children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"flex gap-3 pl-8 relative",children:[e.jsx(c,{className:"absolute left-0 top-0 w-6 h-6"}),e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx(c,{className:"h-4 w-full"}),e.jsx(c,{className:"h-3 w-16"})]})]},s))}):x.map((s,a)=>e.jsxs("div",{className:"group relative ps-8",children:[e.jsx("span",{className:"absolute start-0 top-0 text-2xl font-bold text-muted-foreground/40 leading-none",children:a+1}),e.jsxs(A,{href:s.route_url,className:"block",prefetch:"true",children:[e.jsx("h4",{className:"text-sm font-semibold leading-snug group-hover:text-primary transition-colors line-clamp-2",children:s.title}),e.jsx("div",{className:"mt-1",children:e.jsx(E,{date:s.created_at})})]})]},s.id))})]})]}),e.jsxs("div",{className:"space-y-6 pb-6 pt-6 mt-auto bg-gradient-to-t from-background via-background to-background/95 backdrop-blur-sm border-t border-border/50",children:[o(j)&&e.jsxs("div",{className:"bg-card border rounded-lg p-2 shadow-sm",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground text-center mb-1 uppercase tracking-widest",children:d("_advertisement","Advertisement")}),e.jsx(n,{ad:j,className:"w-full"})]}),e.jsx("div",{className:"-mt-6",children:e.jsx(H,{})})]})]})]})]})})]})}B.layout=r=>e.jsx(F,{children:r});export{B as default};
