1import{X as O,Y as V,r as n,n as G,j as e,L as b,h as X,S as E,B as Y,i as d,$ as A,af as C,K as F,R as j,A as q,ag as M,ac as J,s as x,ah as Q,U as W,H as Z}from"./index-CysU2Jg9.js";import{P as ee}from"./PostAudioPlayer-n4Y-enA1.js";import{A as te}from"./arrow-left-DtRFkuOL.js";import{C as se}from"./calendar-1a5dmTGo.js";import{C as re}from"./calendar-days-mMnEc9j3.js";import"./ReplayPlayer-1ZerhWuv.js";import"./dropdown-menu-8XAQKpvV.js";import"./index-CQ2ZrIkQ.js";import"./chevron-right-C4GdRsTP.js";import"./check-CMDL-7uT.js";import"./pause-CdN-OsTZ.js";import"./ellipsis-CuwOZwGw.js";import"./download-DFjGv9mm.js";import"./list-ordered-BEe8_dZS.js";const be=()=>{var L;const{slug:h}=O(),w=V(),y=w.state??{},[t,R]=n.useState(null),[r,D]=n.useState(null),[N,v]=n.useState([]),[I,_]=n.useState("More posts"),[T,k]=n.useState(!0),[u,c]=n.useState(null),p=n.useRef(null),S=n.useRef(null);n.useEffect(()=>{(async()=>{if(!h){k(!1);return}const{data:a,error:o}=await x.from("posts").select("id, title, content, excerpt, slug, category, post_type, featured_image, featured_image_position, featured_image_zoom, audio_url, audio_tracks, created_at, show_id, archived").eq("slug",h).eq("published",!0).eq("private",!1).maybeSingle();if(o&&console.error("Failed to load post",o),a&&a.post_type!=="community-news"){R(a),Q(a.id,a.show_id).catch(()=>{});const l=async()=>{const{data:i,error:m}=await x.from("posts").select("id, title, slug, excerpt, content, featured_image, created_at, audio_url, audio_tracks").neq("id",a.id).neq("post_type","community-news").eq("published",!0).eq("private",!1).order("created_at",{ascending:!1}).limit(4);m&&console.error("Failed to load fallback related posts",m),i&&(v(i),_("Latest from Southern FM"))};if(a.show_id){const{data:i,error:m}=await x.from("shows").select("name, slug, archived").eq("id",a.show_id).maybeSingle();m&&console.error("Failed to load post's show",m),i&&D(i);const{data:f,error:$}=await x.from("posts").select("id, title, slug, excerpt, content, featured_image, created_at, audio_url, audio_tracks").eq("show_id",a.show_id).neq("id",a.id).eq("published",!0).eq("private",!1).order("created_at",{ascending:!1}).limit(4);$&&console.error("Failed to load related posts",$),f&&f.length>0?(v(f),_(i?`More from ${i.name}`:"More from this show")):await l()}else await l()}k(!1)})()},[h]),n.useEffect(()=>{const s=p.current;if(!s)return;s.querySelectorAll("img").forEach(o=>{o.tabIndex=0,o.setAttribute("role","button"),o.getAttribute("aria-label")||o.setAttribute("aria-label",o.alt||"Enlarge image")})},[t==null?void 0:t.content]),n.useEffect(()=>{var a;if(!u)return;(a=S.current)==null||a.focus();const s=o=>{o.key==="Escape"&&c(null)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[u]);const P=n.useMemo(()=>G((t==null?void 0:t.content)??""),[t==null?void 0:t.content]);if(T)return e.jsx(b,{children:e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx(X,{className:"h-6 w-6 animate-spin text-muted-foreground"})})});if(!t)return e.jsxs(b,{children:[e.jsx(E,{title:"Post Not Found - 88.3 Southern FM",description:"This post may have been removed or doesn't exist.",path:w.pathname,noindex:!0}),e.jsxs("div",{className:"page-content w-full py-24 text-center",children:[e.jsx("h1",{className:"font-display text-3xl font-bold mb-4 text-foreground",children:"Post Not Found"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"This post may have been removed or doesn't exist."}),e.jsx(Y,{asChild:!0,children:e.jsx(d,{to:"/posts",children:"Back to Posts"})})]})]});const z=t.post_type==="show-post"||t.post_type==="show-podcast"?"Show Post":"Station Post",g=A(t.audio_tracks,t.audio_url),B=g.length>0,U=s=>{var l;const o=s.target.closest("img");if(o&&((l=p.current)!=null&&l.contains(o))){const i=o.src;i&&(s.preventDefault(),s.stopPropagation(),c(i))}},H=s=>{var l;if(s.key!=="Enter"&&s.key!==" ")return;const o=s.target.closest("img");if(o&&((l=p.current)!=null&&l.contains(o))){const i=o.src;i&&(s.preventDefault(),c(i))}},K=[{to:"/program-guide",icon:re,title:"Program Guide",desc:"See what's on across the week"},{to:"/posts",icon:M,title:"All Posts & Podcasts",desc:"Browse the latest from our shows"},{to:"/get-involved",icon:W,title:"Get Involved",desc:"Volunteer, present, or join in"},{to:"/support",icon:Z,title:"Support Us",desc:"Help keep community radio on air"}];return e.jsxs(b,{children:[e.jsx(E,{title:`${t.title}
1 - 88.3 Southern FM`,ogTitle:t.title,description:((L=t.excerpt)==null?void 0:L.trim())||P.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,155)||`Read "${t.title}" on 88.3 Southern FM.`,path:`/post/${t.slug}`,type:"article",image:t.featured_image??void 0,jsonLd:{"@context":"https://schema.org","@type":"Article",headline:t.title,datePublished:t.created_at,image:t.featured_image?[t.featured_image]:void 0,publisher:{"@type":"Organization",name:"88.3 Southern FM",logo:{"@type":"ImageObject",url:`${C}/images/sfm-logo-colour.svg`}},mainEntityOfPage:`${C}/post/${t.slug}`}}),e.jsxs("div",{className:"pb-10",children:[e.jsx("section",{className:"relative bg-secondary",children:e.jsxs("div",{className:"relative page-content w-full py-10 md:py-12",children:[e.jsxs(d,{to:y.from??(r&&!r.archived?`/show/${r.slug}`:"/posts"),className:"inline-flex items-center gap-1 text-secondary-foreground/70 hover:text-secondary-foreground text-sm mb-4 transition-colors",children:[e.jsx(te,{className:"h-4 w-4"})," ",y.fromLabel??(r&&!r.archived?`Back to ${r.name}`:"Back to Posts")]}),e.jsxs("div",{className:t.featured_image?"md:grid md:grid-cols-5 md:gap-8 md:items-center":"",children:[e.jsxs("div",{className:t.featured_image?"md:col-span-3":"",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("span",{className:`text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full ${t.post_type==="community-news"?"bg-accent text-accent-foreground":"bg-primary/20 text-secondary-foreground"}`,children:z}),B&&e.jsxs("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full bg-secondary-foreground/15 text-secondary-foreground border border-secondary-foreground/30 flex items-center gap-0.5",children:[e.jsx(F,{className:"h-3 w-3"}),"Podcast"]}),(t.archived||r&&r.archived)&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-100 border border-amber-300/40",children:"From the Archives"})]}),e.jsx("h1",{className:"font-display text-xl md:text-2xl font-bold text-secondary-foreground mb-2",children:t.title}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-secondary-foreground/70 text-sm mt-3",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(se,{className:"h-4 w-4"}),new Date(t.created_at).toLocaleDateString("en-AU",{weekday:"long",year:"numeric",month:"long",day:"numeric"})]}),r&&!r.archived&&e.jsxs(d,{to:`/show/${r.slug}`,className:"flex items-center gap-1 hover:text-secondary-foreground transition-colors",children:[e.jsx(j,{className:"h-4 w-4"})," ",r.name]}),r&&r.archived&&e.jsxs("span",{className:"flex items-center gap-1 opacity-80",children:[e.jsx(j,{className:"h-4 w-4"})," ",r.name]})]})]}),t.featured_image&&e.jsx("div",{className:"mt-6 md:mt-0 md:col-span-2",children:e.jsx("div",{className:"rounded-2xl overflow-hidden aspect-[16/9] bg-muted shadow-lg",children:e.jsx("img",{src:t.featured_image,alt:t.title,className:"w-full h-full object-cover",style:{objectPosition:`50% ${t.featured_image_position??50}%`,transform:`scale(${t.featured_image_zoom??1})`,transformOrigin:`50% ${t.featured_image_position??50}%`}})})})]})]})}),e.jsx("section",{className:"page-content w-full py-10",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8 lg:gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-8 md:space-y-6",children:[g.length>0&&e.jsx(ee,{tracks:g,postId:t.id,showId:t.show_id}),e.jsx("article",{className:"md:bg-card md:border md:border-border md:rounded-2xl md:shadow-sm md:p-10",children:t.content?e.jsx("div",{ref:p,onClick:U,onKeyDown:H,className:"prose prose-neutral max-w-none text-foreground leading-relaxed text-left cursor-default [&_img]:rounded-lg [&_img]:focus-visible:outline [&_img]:focus-visible:outline-2 [&_img]:focus-visible:outline-primary",dangerouslySetInnerHTML:{__html:P}}):t.excerpt?e.jsx("p",{className:"text-muted-foreground leading-relaxed text-left",children:t.excerpt}):e.jsx("p",{className:"text-muted-foreground italic",children:"No content for this post."})})]}),e.jsxs("aside",{className:"space-y-8 md:space-y-6",children:[r&&!r.archived&&e.jsxs("div",{className:"md:bg-card md:border md:border-border md:rounded-2xl md:p-5 border-t border-border pt-6 md:border-t-0 md:pt-5",children:[e.jsx("h2",{className:"font-display text-sm font-bold uppercase tracking-wide text-muted-foreground mb-3",children:"About the show"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary flex-shrink-0",children:e.jsx(j,{className:"h-5 w-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-display font-bold text-foreground leading-tight",children:r.name}),e.jsxs(d,{to:`/show/${r.slug}`,className:"text-xs text-primary hover:underline inline-flex items-center gap-1 mt-1","aria-label":`Visit ${r.name} show page`,children:["Visit show page ",e.jsx(q,{className:"h-3 w-3"})]})]})]})]}),N.length>0&&e.jsxs("div",{className:"md:bg-card md:border md:border-border md:rounded-2xl md:p-5 border-t border-border pt-6 md:border-t-0 md:pt-5",children:[e.jsx("h2",{className:"font-display text-sm font-bold uppercase tracking-wide text-muted-foreground mb-4",children:I}),e.jsx("div",{className:"space-y-4",children:N.map(s=>{const a=A(s.audio_tracks,s.audio_url).length>0;return e.jsx(d,{to:`/post/${s.slug}`,className:"group block",children:e.jsxs("div",{className:"flex gap-3",children:[s.featured_image?e.jsx("img",{src:s.featured_image,alt:"",loading:"lazy",className:"h-16 w-16 rounded-lg object-cover flex-shrink-0 group-hover:opacity-90 transition-opacity"}):e.jsx("div",{className:"h-16 w-16 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:a?e.jsx(F,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(M,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground leading-snug line-clamp-2 group-hover:text-primary transition-colors",children:s.title}),e.jsx("p",{className:"text-[11px] text-muted-foreground mt-1",children:new Date(s.created_at).toLocaleDateString("en-AU",{day:"numeric",month:"short",year:"numeric"})})]})]})},s.id)})}),e.jsxs(d,{to:r&&!r.archived?`/show/${r.slug}`:"/posts",className:"mt-5 inline-flex items-center gap-1 text-xs font-semibold text-primary hover:underline",children:["See all ",e.jsx(q,{className:"h-3 w-3"})]})]})]})]})}),e.jsx("section",{className:"page-content w-full pt-4 pb-12",children:e.jsxs("div",{className:"border-t border-border pt-10",children:[e.jsx("h2",{className:"font-display text-2xl font-bold text-foreground mb-6",children:"Explore Southern FM"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:K.map(s=>{const a=s.icon;return e.jsxs(d,{to:s.to,className:"group bg-card border border-border rounded-2xl p-5 hover:border-primary/40 hover:shadow-md transition-all",children:[e.jsx("span",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center text-primary mb-3",children:e.jsx(a,{className:"h-5 w-5"})}),e.jsx("p",{className:"font-display font-bold text-foreground group-hover:text-primary transition-colors",children:s.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1 leading-snug",children:s.desc})]},s.to)})})]})})]}),u&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/90 flex items-center justify-center p-4",onClick:()=>c(null),children:[e.jsx("button",{ref:S,className:"absolute top-4 right-4 text-white/80 hover:text-white p-2",onClick:()=>c(null),"aria-label":"Close",children:e.jsx(J,{className:"h-8 w-8"})}),e.jsx("img",{src:u,alt:"",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:s=>s.stopPropagation()})]})]})};export{be 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.