import{u as o}from"./useQuery-DBBZzyro.js";import{aD as l,j as r,W as c,a4 as n,g as d,o as u}from"./index-BQMU2Aro.js";import{f as m}from"./date-utils-BcQETFuH.js";const h=()=>o({queryKey:["blog-categories"],queryFn:async()=>{const{data:e,error:a}=await l.from("blog_categories").select("*").order("sort_order",{ascending:!0});if(a)throw a;return e}}),b=e=>o({queryKey:["blog-posts",e],queryFn:async()=>{let a=l.from("blog_posts").select(`
*,
category:blog_categories(*)
`).eq("is_published",!0).order("published_at",{ascending:!1});if(e&&e!=="all"){const{data:t}=await l.from("blog_categories").select("id").eq("slug",e).single();t&&(a=a.eq("category_id",t.id))}const{data:s,error:i}=await a;if(i)throw i;return s}}),y=e=>o({queryKey:["blog-post",e],queryFn:async()=>{const{data:a,error:s}=await l.from("blog_posts").select(`
*,
category:blog_categories(*)
`).eq("slug",e).eq("is_published",!0).single();if(s)throw s;return a},enabled:!!e}),p=(e,a)=>o({queryKey:["related-posts",e,a],queryFn:async()=>{let s=l.from("blog_posts").select(`
*,
category:blog_categories(*)
`).eq("is_published",!0).neq("id",e).limit(3);a&&(s=s.eq("category_id",a));const{data:i,error:t}=await s.order("published_at",{ascending:!1});if(t)throw t;return i},enabled:!!e}),j=({post:e,featured:a=!1})=>{const s=e.published_at?m(new Date(e.published_at),"MMM d, yyyy"):m(new Date(e.created_at),"MMM d, yyyy");return a?r.jsx(c,{to:`/blog/${e.slug}`,className:"group block bg-card rounded-2xl overflow-hidden border border-border hover-lift",children:r.jsxs("div",{className:"grid md:grid-cols-2 gap-0",children:[r.jsx("div",{className:"aspect-[16/10] md:aspect-auto md:h-full overflow-hidden",children:e.featured_image_url?r.jsx("img",{src:e.featured_image_url,alt:e.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}):r.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/10 to-info/10 flex items-center justify-center",children:r.jsx("span",{className:"text-4xl text-primary/30",children:"📝"})})}),r.jsxs("div",{className:"p-6 md:p-8 flex flex-col justify-center",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsx(n,{variant:"secondary",className:"bg-accent/10 text-accent border-0",children:"Featured"}),e.category&&r.jsx(n,{variant:"outline",className:"text-muted-foreground",children:e.category.name})]}),r.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground mb-3 group-hover:text-primary transition-colors line-clamp-2",children:e.title}),e.excerpt&&r.jsx("p",{className:"text-muted-foreground mb-4 line-clamp-3",children:e.excerpt}),r.jsxs("div",{className:"flex items-center justify-between mt-auto pt-4",children:[r.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[r.jsx("span",{children:s}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(d,{className:"h-4 w-4"}),e.reading_time_minutes," min read"]})]}),r.jsxs("span",{className:"flex items-center gap-1 text-primary font-medium group-hover:gap-2 transition-all",children:["Read more ",r.jsx(u,{className:"h-4 w-4"})]})]})]})]})}):r.jsxs(c,{to:`/blog/${e.slug}`,className:"group block bg-card rounded-xl overflow-hidden border border-border hover-lift h-full",children:[r.jsx("div",{className:"aspect-[16/10] overflow-hidden",children:e.featured_image_url?r.jsx("img",{src:e.featured_image_url,alt:e.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"}):r.jsx("div",{className:"w-full h-full bg-gradient-to-br from-primary/10 to-info/10 flex items-center justify-center",children:r.jsx("span",{className:"text-3xl text-primary/30",children:"📝"})})}),r.jsxs("div",{className:"p-5",children:[e.category&&r.jsx(n,{variant:"outline",className:"text-muted-foreground mb-3 text-xs",children:e.category.name}),r.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2 group-hover:text-primary transition-colors line-clamp-2",children:e.title}),e.excerpt&&r.jsx("p",{className:"text-sm text-muted-foreground mb-4 line-clamp-2",children:e.excerpt}),r.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[r.jsx("span",{children:s}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(d,{className:"h-3.5 w-3.5"}),e.reading_time_minutes," min"]})]})]})]})};export{j as B,b as a,y as b,p as c,h as u};