1import{r as i,s as l,j as e,C as S,e as q,a7 as x,B as f,L as d,a5 as z,l as k,a as A,N as C,bf as T,f as L,S as B,H as E,A as M,P as F,an as P,bg as $,F as D}from"./index-D6S94l3r.js";import{S as H}from"./sparkles-B5OgSXSk.js";function I({newsArticleId:r}){const[a,s]=i.useState(null);return i.useEffect(()=>{(async()=>{const{data:n}=await l.from("quizzes").select("id, slug, title, description, cover_image_url").eq("news_article_id",r).eq("is_published",!0).order("updated_at",{ascending:!1}).limit(1).maybeSingle();s(n)})()},[r]),a?e.jsx(S,{className:"my-6 border-primary/30 bg-primary/5",children:e.jsxs(q,{className:"p-4 sm:p-6 flex flex-col sm:flex-row gap-4 items-center",children:[a.cover_image_url&&e.jsx("div",{className:"w-full sm:w-48 aspect-video sm:aspect-square rounded-md overflow-hidden flex-shrink-0",children:e.jsx(x,{src:a.cover_image_url,alt:a.title,className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary text-sm font-semibold mb-1",children:[e.jsx(H,{className:"h-4 w-4"})," Take the quiz"]}),e.jsx("h3",{className:"text-xl font-bold mb-1",children:a.title}),a.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:a.description}),e.jsx(f,{asChild:!0,children:e.jsx(d,{to:`/quizzes/${a.slug}`,children:"Start quiz"})})]})]})}):null}function G(){const{slug:r}=z(),a=k(),[s,n]=i.useState(null),[m,p]=i.useState([]),[g,j]=i.useState(!0);i.useEffect(()=>{r&&_()},[r]);const u=()=>{l.rpc("record_not_found",{p_path:window.location.pathname,p_referrer:document.referrer||null}).then(({error:t})=>{t&&console.warn("Failed to log 404:",t.message)}),a("/not-found")},_=async()=>{try{const{data:t,error:c}=await l.from("news_articles").select("*").eq("slug",r).eq("is_published",!0).single();if(c){if(c.code==="PGRST116"){u();return}throw c}n(t);const{data:N}=await l.from("news_article_tags").select("news_tags(id, name, slug, color)").eq("article_id",t.id),v=(N||[]).map(y=>y.news_tags).filter(Boolean);p(v)}catch(t){console.error("Error fetching article:",t),u()}finally{j(!1)}};if(g)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(A,{className:"h-8 w-8 animate-spin text-primary"})});if(!s)return null;const b=s.meta_title||s.title,h=s.meta_description||s.excerpt,o=s.published_at?C(new Date(s.published_at),"do MMMM yyyy"):null,w=[T({title:s.title,description:h,slug:s.slug,imageUrl:s.featured_image_url,publishedAt:s.published_at,updatedAt:s.updated_at??s.published_at,authorName:s.author_name}),L([{name:"News",href:"/news"},{name:s.title,href:`/news/${s.slug}`}])];return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(B,{title:b,description:h,canonicalPath:`/news/${s.slug}`,ogType:"article",ogImage:s.featured_image_url||void 0,jsonLd:w}),e.jsx(E,{}),e.jsxs("main",{children:[s.featured_image_url&&e.jsxs("div",{className:"relative h-64 md:h-96 overflow-hidden",children:[e.jsx(x,{src:s.featured_image_url,alt:s.featured_image_alt||s.title,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background/80 to-transparent"})]}),e.jsx("article",{className:"container mx-auto px-4 py-8",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx(f,{variant:"ghost",size:"sm",asChild:!0,className:"mb-6",children:e.jsxs(d,{to:"/news",children:[e.jsx(M,{className:"h-4 w-4 mr-2"}),"Back to News"]})}),e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-foreground mb-4",children:s.title}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-muted-foreground",children:[o&&e.jsx("time",{dateTime:s.published_at||void 0,children:o}),o&&s.author_name&&e.jsx("span",{children:"â¢"}),s.author_name&&e.jsxs("span",{children:["By ",s.author_name]})]}),m.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:m.map(t=>e.jsx(d,{to:`/news/tag/${t.slug}`,children:e.jsx(F,{variant:"secondary",className:"hover:bg-accent cursor-pointer",style:t.color?{backgroundColor:t.color,color:"#fff"}:void 0,children:t.name})},t.id))})]}),e.jsx("div",{className:"prose prose-lg dark:prose-invert max-w-none mb-8",dangerouslySetInnerHTML:{__html:P(s.content)}}),s.id&&e.jsx(I,{newsArticleId:s.id}),e.jsxs("div",{className:"border-t border-border pt-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:"Share this article"}
1),e.jsx($,{title:s.title,description:s.excerpt})]})]})})]}),e.jsx(D,{})]})}export{G 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.