1import{E as y,bh as b,bi as g,r as d,j as t,bj as N,L as k,B as v,d as w,l as C,u as L,s as R}from"./index-BCH4IFx8.js";import{u as P}from"./useOrganizationSlug-DcRVJD25.js";import{u as B,d as E,E as S,R as q}from"./useRaceFeedComments-UpmC3DGR.js";import{P as F,a as O}from"./PostComments-CogSbcEm.js";import{C as U,a as A}from"./card-DaE3Hwfn.js";import{A as H}from"./arrow-left-CX5CfIFs.js";import{C as M}from"./copy-CIGjrFWu.js";import"./chevron-left-BfsUvDbz.js";import"./sanitized-html-DPAQvfI8.js";import"./purify.es-C5KSVp3G.js";import"./thumbs-up-lKUbd0LV.js";import"./thumbs-down-Bw1mgNVr.js";import"./textarea-C9Po2OuC.js";import"./avatar-z3FeZlZg.js";import"./index-7Wu8hD2L.js";import"./send-CJD-Z0Nl.js";import"./pen-DnmiT5dx.js";import"./trash-2-CrxPrdNf.js";import"./eye-EzNZygao.js";import"./eye-off-UCwc6mQx.js";import"./formatDistanceToNow-nzxXZqmT.js";import"./en-US-CGO0aXMi.js";import"./differenceInCalendarMonths-D2gXU8RP.js";import"./endOfMonth--R-WtYph.js";import"./differenceInMilliseconds-CVPzdaho.js";function T(r,l){return C({queryKey:["public-race-feed-post",r,l],queryFn:async()=>{if(!r||!l)return null;const{data:s,error:o}=await R.from("race_feed_posts").select("id, organization_id, event_id, author_user_id, author_name, content, title, body_html, content_format, image_url, link_url, category, is_pinned, is_published, published_at, created_at, updated_at").eq("id",r).eq("organization_id",l).eq("is_published",!0).maybeSingle();if(o)throw o;return s??null},enabled:!!r&&!!l})}const ue=()=>{const{orgSlug:r,postId:l}=y(),{data:s,isLoading:o}=P(r),{setOrganizationFromSlug:c,branding:a}=b(),{data:e,isLoading:u}=T(l,s==null?void 0:s.id),{data:p={}}=B(s==null?void 0:s.id),{data:x={}}=E(s==null?void 0:s.id),{data:h=[]}=g();d.useEffect(()=>{r&&c(r)},[r,c]),d.useEffect(()=>{e!=null&&e.title&&(document.title=e.title)},[e==null?void 0:e.title]);const f=h.some(n=>n.id===(s==null?void 0:s.id)&&(n.role==="admin"||n.role==="super_admin")),m=r?`/org/${r}/login`:"/auth",i=e?p[e.id]:void 0,_=(e==null?void 0:e.content_format)==="html"&&!!(e!=null&&e.body_html),j=()=>{navigator.clipboard.writeText(window.location.href),L.success("Link copied")};return t.jsx(N,{children:t.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-[680px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs(k,{to:r?`/org/${r}/feed`:"/",className:"inline-flex items-center gap-1 text-sm hover:underline",children:[t.jsx(H,{className:"h-4 w-4"})," Back to feed"]}),t.jsxs(v,{variant:"ghost",size:"sm",onClick:j,children:[t.jsx(M,{className:"h-3.5 w-3.5 mr-1"})," Copy link"]})]}),o||u?t.jsx("div",{className:"flex justify-center py-12",children:t.jsx(w,{className:"h-6 w-6 animate-spin",style:{color:(a==null?void 0:a.primary_color)||"hsl(var(--primary))"}})}):e?t.jsx(U,{children:t.jsxs(A,{className:"p-0",children:[t.jsxs("div",{className:"flex items-center gap-3 border-b p-4",children:[(a==null?void 0:a.logo_url)&&t.jsx("img",{src:a.logo_url,alt:"",className:"h-8 w-8 rounded object-contain"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-sm font-semibold truncate",children:(s==null?void 0:s.name)||e.author_name||"Race Update"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(e.published_at).toLocaleString()})]})]}),t.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[e.title&&t.jsx("h1",{className:"text-xl md:text-2xl font-bold",children:e.title}),_?t.jsx(S,{html:e.body_html}):t.jsx(q,{content:e.content,fallbackImageUrl:e.image_url}),e.link_url&&t.jsx("a",{href:e.link_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline break-all",style:a!=null&&a.primary_color?{color:a.primary_color}:{},children:e.link_url})]}),t.jsxs("div",{className:"flex items-center gap-1 border-t p-3 flex-wrap",children:[t.jsx(F,{postId:e.id,likeCount:(i==null?void 0:i.like_count)??0,dislikeCount:(i==null?void 0:i.dislike_count)??0,myReaction:x[e.id]??null,loginUrl:m}),t.jsx(O,{postId:e.id,commentCount:(i==null?void 0:i.comment_count)??0,loginUrl:m,canModerate:f})]})]})}):t.jsx("div",{className:"text-center py-16 opacity-70",children:t.jsx("p",{children:"This update is no longer available."})})]})})};export{ue 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.