PageSourceSearch

https://southernfm.com.au/assets/Noticeboard-Bh9espQE.js

js southernfm.com.au collected 2026-09-24 21:13:52 UTC 27,460 bytes, 21 lines download raw bytes

1import{q as Z,r as i,j as e,T as Os,B as l,aW as ls,f as Bs,W as je,ac as _,y,h as g,D as P,c as A,d as E,e as F,aO as D,aP as cs,s as d,ab as c}from"./index-CysU2Jg9.js";import{u as Vs}from"./use-auth-B4_mJ4CN.js";import{I as M}from"./input-UNMuvhAA.js";import{T as ds}from"./textarea-BId7pPGh.js";import{C as Ls}from"./calendar-CQCZlNur.js";import{P as Hs,a as Ws,b as Ks}from"./popover-BAh12zBB.js";import{B as Gs}from"./badge-f1jASh_g.js";import{v as ms,u as ps}from"./upload-rules-Qd9pVdD-.js";import{p as Js}from"./prepare-image-upload-Bby_BZou.js";import{S as I,a as z,b as T,c as U,d as f}from"./select-D_KGIcT1.js";import{o as us,T as Ne,n as xs,m as Xs,P as Qs}from"./MemberDashboard-nLuHpg9t.js";import{C as Ys}from"./calendar-1a5dmTGo.js";import{I as hs}from"./image-plus-CS-lngD0.js";import{S as Zs}from"./send-2tuXyMJR.js";import{C as et}from"./check-CMDL-7uT.js";import{D as st}from"./download-DFjGv9mm.js";import{f as q}from"./format-DEp8I5i1.js";import"./startOfMonth-CefLwR_S.js";import"./subDays-D3OfSCfl.js";import"./chevron-left-DZiAb83u.js";import"./chevron-right-C4GdRsTP.js";import"./index-CQ2ZrIkQ.js";import"./wind-CwxRb_eO.js";import"./arrow-left-DtRFkuOL.js";import"./user-Bpl3Gv-J.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const gs=Z("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const tt=Z("PinOff",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const fs=Z("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const js=Z("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]),at=["👍","❤️","😂","🎉","😮","😢"],Y="resource-files",ve=m=>!m||m<=0?"":m<1024*1024?`${Math.round(m/1024)} KB`:`${(m/(1024*1024)).toFixed(1)} MB`,At=()=>{const{user:m,hasPermission:Ns}=Vs(),[vs,we]=i.useState([]),[ye,ee]=i.useState(!1),[R,be]=i.useState(""),[Ce,ke]=i.useState(""),[Se,_e]=i.useState(!1),[N,Pe]=i.useState(),[se,te]=i.useState([]),[ae,re]=i.useState([]),[ne,Ae]=i.useState("none"),[b,Ee]=i.useState(!1),[Fe,De]=i.useState(!1),[Me,Ie]=i.useState(!1),$=i.useRef(null),O=i.useRef(null),[ie,ws]=i.useState(""),[C,ys]=i.useState("all"),[v,ze]=i.useState([]),[bs,Te]=i.useState(!1),[B,Ue]=i.useState(""),[qe,Re]=i.useState("slate"),[$e,Oe]=i.useState(!1),[oe,V]=i.useState(null),[L,Be]=i.useState(""),[Ve,Le]=i.useState(""),[le,ce]=i.useState([]),[de,me]=i.useState([]),[pe,He]=i.useState("none"),[We,Ke]=i.useState(!1),[Ge,Je]=i.useState(!1),[Xe,Qe]=i.useState(!1),H=i.useRef(null),W=i.useRef(null),[k,K]=i.useState(null),[Ye,Ze]=i.useState(!1),[j,ue]=i.useState(null),[G,Cs]=i.useState([]),[ks,es]=i.useState(!1),[xe,J]=i.useState(null),x=Ns("manage_critical"),S=s=>v.find(t=>t.id===s)??null,ss=async s=>{const t=[...new Set(s.map(r=>r.author_id))],n=new Map;if(t.length>0){const{data:r}=await d.rpc("get_public_profiles",{_user_ids:t});
21(r??[]).forEach(o=>n.set(o.user_id,o.display_name))}return s.map(r=>({...r,reactions:r.reactions??{},images:Array.isArray(r.images)?r.images:[],attachments:Array.isArray(r.attachments)?r.attachments:[],category_id:r.category_id??null,pinned:!!r.pinned,author_name:n.get(r.author_id)??"Unknown"}))},X=async()=>{const{data:s}=await d.from("announcement_categories").select("id,name,color,sort_order").order("sort_order").order("name");ze(s??[])},w=async()=>{const{data:s=[]}=await d.from("announcements").select("*").eq("is_active",!0).eq("approved",!0).order("pinned",{ascending:!1}).order("pinned_at",{ascending:!1,nullsFirst:!1}).order("created_at",{ascending:!1}).limit(200);we(await ss(s??[]))},he=async()=>{if(!x)return;const{data:s}=await d.from("announcements").select("*").eq("is_active",!0).eq("approved",!1).order("created_at",{ascending:!1});Cs(await ss(s??[]))};i.useEffect(()=>{m&&(w(),he(),X())},[m,x]);const Ss=async()=>{if(!B.trim())return;Oe(!0);const{error:s}=await d.from("announcement_categories").insert({name:B.trim(),color:qe,sort_order:v.length});Oe(!1),s?c.error("Failed to add category",{description:s.message}):(Ue(""),Re("slate"),X())},ts=async(s,t)=>{const{error:n}=await d.from("announcement_categories").update(t).eq("id",s);n?c.error("Failed to update category",{description:n.message}):X()},_s=async s=>{const{error:t}=await d.from("announcement_categories").delete().eq("id",s);t?c.error("Failed to delete category",{description:t.message}):(c.success("Category deleted"),X(),w())},as=async s=>{const t=ms("post-images",s);if(t)return c.error("Image upload rejected",{description:t}),null;const n=s.name.split(".").pop(),r=`noticeboard/${Date.now()}-${Math.random().toString(36).slice(2)}.${n}`,o=await Js(s),{error:u}=await d.storage.from("post-images").upload(r,o);return u?(c.error("Image upload failed",{description:ps("post-images",u,s)}),null):d.storage.from("post-images").getPublicUrl(r).data.publicUrl},rs=async s=>{const t=ms(Y,s);if(t)return c.error("Attachment rejected",{description:t}),null;const n=(s.name.split(".").pop()||"").toLowerCase(),r=`noticeboard/${Date.now()}-${Math.random().toString(36).slice(2)}.${n}`,{error:o}=await d.storage.from(Y).upload(r,s);return o?(c.error("Attachment upload failed",{description:ps(Y,o,s)}),null):{url:d.storage.from(Y).getPublicUrl(r).data.publicUrl,name:s.name,type:n||null,size:s.size}},Ps=async s=>{const t=Array.from(s.target.files??[]);if(!t.length)return;De(!0);const n=[];for(const r of t){const o=await as(r);o&&n.push(o)}te(r=>[...r,...n]),De(!1),$.current&&($.current.value="")},As=async s=>{const t=Array.from(s.target.files??[]);if(!t.length)return;Ie(!0);const n=[];for(const r of t){const o=await rs(r);o&&n.push(o)}re(r=>[...r,...n]),Ie(!1),O.current&&(O.current.value="")},Es=async s=>{const t=Array.from(s.target.files??[]);if(!t.length)return;Je(!0);const n=[];for(const r of t){const o=await rs(r);o&&n.push(o)}me(r=>[...r,...n]),Je(!1),W.current&&(W.current.value="")},Fs=async s=>{const t=Array.from(s.target.files??[]);if(!t.length)return;Ke(!0);const n=[];for(const r of t){const o=await as(r);o&&n.push(o)}ce(r=>[...r,...n]),Ke(!1),H.current&&(H.current.value="")},Ds=async()=>{if(!R.trim()||!m)return;if(!N&&!b){c.error("Please pick an expiry date, or mark the post as never expiring");return}_e(!0);const{error:s}=await d.from("announcements").insert({title:R.trim(),content:Ce.trim()||null,author_id:m.id,is_critical:!1,approved:x,expires_at:b?null:N.toISOString(),images:se,attachments:ae,category_id:ne==="none"?null:ne});_e(!1),s?c.error("Failed to post",{description:s.message}):(c.success(x?"Posted!":"Submitted for approval"),be(""),ke(""),Pe(void 0),Ee(!1),te([]),re([]),Ae("none"),ee(!1),w())},Ms=async s=>{J(s.id);const{error:t}=await d.from("announcements").update({approved:!0}).eq("id",s.id);J(null),t?c.error("Failed to approve",{description:t.message}):(c.success("Approved"),he(),w())},Is=async s=>{J(s.id);const{error:t}=await d.from("announcements").update({is_active:!1}).eq("id",s.id);J(null),t?c.error("Failed to decline",{description:t.message}
21):(c.success("Declined"),he())},zs=async()=>{if(!oe||!L.trim())return;Qe(!0);const{error:s}=await d.from("announcements").update({title:L.trim(),content:Ve.trim()||null,images:le,attachments:de,category_id:pe==="none"?null:pe}).eq("id",oe.id);Qe(!1),s?c.error("Failed to update"):(c.success("Updated!"),V(null),w())},Ts=async()=>{if(!k)return;Ze(!0);const{error:s}=await d.from("announcements").update({is_active:!1}).eq("id",k.id);Ze(!1),s?c.error("Failed to delete"):(c.success("Deleted"),K(null),w())},Us=async s=>{const t=!s.pinned,{error:n}=await d.from("announcements").update({pinned:t,pinned_at:t?new Date().toISOString():null}).eq("id",s.id);n?c.error("Failed to update pin",{description:n.message}):(c.success(t?"Pinned to top":"Unpinned"),w())},qs=async(s,t)=>{if(m)try{const{data:n,error:r}=await d.rpc("toggle_reaction",{_announcement_id:s,_emoji:t});r||we(o=>o.map(u=>u.id===s?{...u,reactions:n??{}}:u))}catch{}},ns=s=>s.author_id===(m==null?void 0:m.id),Rs=s=>ns(s)||x,$s=s=>ns(s)||x;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-card border border-border rounded-xl p-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-4",children:[e.jsxs("h3",{className:"font-display text-lg font-bold text-foreground flex items-center gap-2",children:[e.jsx(Os,{className:"h-5 w-5 text-primary shrink-0"}),"Station Noticeboard"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[x&&e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>es(!0),className:"relative",children:[e.jsx(ls,{className:"h-4 w-4 mr-1"}),"Approvals",G.length>0&&e.jsx(Gs,{variant:"destructive",className:"ml-2 h-5 min-w-5 px-1.5 text-[10px]",children:G.length})]}),x&&e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>Te(!0),children:[e.jsx(js,{className:"h-4 w-4 mr-1"}),"Categories"]}),e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>ee(!ye),children:[e.jsx(us,{className:"h-4 w-4 mr-1"}),"Post"]})]})]}),!x&&e.jsx("p",{className:"text-xs text-muted-foreground -mt-2 mb-3",children:"Posts will be reviewed before appearing on the noticeboard."}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Bs,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(M,{placeholder:"Search notices, attachments…",value:ie,onChange:s=>ws(s.target.value),className:"pl-8 h-9"})]}),e.jsxs(I,{value:C,onValueChange:ys,children:[e.jsx(z,{className:"h-9 w-full sm:w-[200px]",children:e.jsx(T,{placeholder:"All categories"})}),e.jsxs(U,{children:[e.jsx(f,{value:"all",children:"All categories"}),e.jsx(f,{value:"uncategorised",children:"Uncategorised"}),v.map(s=>e.jsx(f,{value:s.id,children:s.name},s.id))]})]})]}),ye&&e.jsxs("div",{className:"bg-muted/50 rounded-lg p-4 mb-4 space-y-2",children:[e.jsx(M,{placeholder:"What's on your mind?",value:R,onChange:s=>be(s.target.value)}),e.jsx(ds,{placeholder:"Details (optional)",value:Ce,onChange:s=>ke(s.target.value),rows:2}),e.jsxs(I,{value:ne,onValueChange:Ae,children:[e.jsx(z,{className:"h-9",children:e.jsx(T,{placeholder:"Category (optional)"})}),e.jsxs(U,{children:[e.jsx(f,{value:"none",children:"No category"}),v.map(s=>e.jsx(f,{value:s.id,children:s.name},s.id))]})]}),ae.length>0&&e.jsx("div",{className:"space-y-1.5",children:ae.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs bg-background border border-border rounded-md px-2 py-1.5",children:[e.jsx(je,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx("span",{className:"text-muted-foreground",children:ve(s.size)}),e.jsx("button",{type:"button",onClick:()=>re(n=>n.filter((r,o)=>o!==t)),"aria-label":"Remove attachment",children:e.jsx(_,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-destructive"})})]},s.url))}),se.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap",children:se.map((s,t)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:s,alt:`Attachment ${t+1}`,className:"h-16 w-16 object-cover rounded-md border border-border"}),e.jsx("button",{type:"button",onClick:()=>te(n=>n.filter((r,o)=>o!==t)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full p-0.5 shadow-md hover:scale-110 transition-transform","aria-label":"Remove image",children:e.jsx(_,{className:"h-3 w-3"})})]},s))}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(Hs,{children:[e.jsx(Ws,{asChild:!0,children:e.jsxs(l,{variant:"outline",size:"sm",disabled:b,className:y("justify-start text-left font-normal text-xs",!N&&"text-muted-foreground"),children:[e.jsx(Ys,{className:"mr-1.5 h-3.5 w-3.5"}),b?"Never expires":N?`Expires ${q(N,"PPP")}`:"Pick expiry date (required)"]})}),e.jsx(Ks,{className:"w-auto p-0",align:"start",children:e.jsx(Ls,{mode:"single",selected:N,onSelect:Pe,disabled:s=>s<new Date,initialFocus:!0,className:"p-3 pointer-events-auto"})})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",className:"h-3.5 w-3.5 accent-primary",checked:b,onChange:s=>Ee(s.target.checked)}),"Doesn't expire"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>{var s;return(s=$.current)==null?void 0:s.click()},disabled:Fe,children:[Fe?e.jsx(g,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"}),"Add photos"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>{var s;return(s=O.current)==null?void 0:s.click()},disabled:Me,children:[Me?e.jsx(g,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(gs,{className:"mr-1.5 h-3.5 w-3.5"}),"Attach documents"]}),e.jsx("input",{ref:$,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Ps}),e.jsx("input",{ref:O,type:"file",multiple:!0,className:"hidden",onChange:As})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(l,{size:"sm",variant:"ghost",onClick:()=>ee(!1),children:"Cancel"}),e.jsxs(l,{size:"sm",onClick:Ds,disabled:!R.trim()||!N&&!b||Se,children:[Se?e.jsx(g,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(Zs,{className:"h-3.5 w-3.5 mr-1"}),"Post"]})]})]}),(()=>{const s=Date.now(),t=a=>!!a.expires_at&&new Date(a.expires_at).getTime()<s,n=ie.trim().toLowerCase(),r=a=>{var h;return C==="uncategorised"&&a.category_id||C!=="all"&&C!=="uncategorised"&&a.category_id!==C?!1:n?[a.title,a.content??"",a.author_name??"",((h=S(a.category_id))==null?void 0:h.name)??"",...a.attachments.map(ge=>ge.name)].join(" ").toLowerCase().includes(n):!0},o=vs.filter(r),u=o.filter(a=>!t(a)),Q=o.filter(a=>t(a)),is=a=>e.jsxs("div",{className:y("border-b border-border pb-4 last:border-0 last:pb-0",a.pinned&&"bg-primary/5 border border-primary/20 rounded-lg p-3 -mx-1 last:pb-3"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[a.pinned&&e.jsxs("div",{className:"flex items-center gap-1 text-[11px] font-semibold text-primary uppercase tracking-wide mb-1",children:[e.jsx(fs,{className:"h-3 w-3 fill-current"}),"Pinned"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-semibold text-sm text-foreground",children:a.title}),S(a.category_id)&&e.jsx("span",{className:y("text-[10px] font-semibold uppercase tracking-wide px-2 py-0.5 rounded-full",Xs(S(a.category_id).color,S(a.category_id).name)),children:S(a.category_id).name})]}),a.content&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 whitespace-pre-wrap",children:a.content}),a.attachments.length>0&&e.jsx("div",{className:"mt-2 space-y-1.5",children:a.attachments.map(p=>e.jsxs("a",{href:p.url,target:"_blank",rel:"noreferrer",download:p.name,className:"flex items-center gap-2 text-xs bg-muted/50 border border-border rounded-md px-2 py-1.5 hover:border-primary/40 transition-colors",children:[e.jsx(je,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"truncate flex-1 font-medium text-foreground",children:p.name}),e.jsx("span",{className:"text-muted-foreground",children:ve(p.size)}),e.jsx(st,{className:"h-3.5 w-3.5 text-muted-foreground"})]},p.url))}),a.images.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap mt-2",children:a.images.map((p,h)=>e.jsx("button",{type:"button",onClick:()=>ue({images:a.images,index:h}),className:"block rounded-md overflow-hidden border border-border hover:opacity-90 transition-opacity focus:outline-none focus:ring-2 focus:ring-primary","aria-label":`View image ${h+1}`,children:e.jsx("img",{src:p,alt:`${a.title} - image ${h+1}`,className:"h-20 w-20 object-cover",loading:"lazy"})},p))}
21),e.jsxs("p",{className:"text-xs text-muted-foreground/60 mt-1",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:a.author_name})," · ",q(new Date(a.created_at),"d MMM · h:mm a"),a.expires_at&&e.jsxs("span",{className:"ml-1 text-amber-600",children:["· ",t(a)?"Expired":"Expires"," ",q(new Date(a.expires_at),"d MMM")]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[$s(a)&&e.jsx(l,{variant:"ghost",size:"icon",className:y("h-7 w-7",a.pinned&&"text-primary hover:text-primary"),onClick:()=>Us(a),title:a.pinned?"Unpin":"Pin to top",children:a.pinned?e.jsx(tt,{className:"h-3.5 w-3.5"}):e.jsx(fs,{className:"h-3.5 w-3.5"})}),Rs(a)&&e.jsxs(e.Fragment,{children:[e.jsx(l,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{V(a),Be(a.title),Le(a.content??""),ce(a.images),me(a.attachments),He(a.category_id??"none")},children:e.jsx(Qs,{className:"h-3.5 w-3.5"})}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:text-destructive",onClick:()=>K(a),children:e.jsx(Ne,{className:"h-3.5 w-3.5"})})]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-2 flex-wrap",children:at.map(p=>{var os;const h=((os=a.reactions)==null?void 0:os[p])??[],ge=h.includes((m==null?void 0:m.id)??""),fe=h.length;return e.jsxs("button",{onClick:()=>qs(a.id,p),className:`text-xs px-2 py-1 rounded-full border transition-colors cursor-pointer ${ge?"border-primary/30 bg-primary/10 text-primary":fe>0?"border-border bg-muted/50 text-foreground hover:border-primary/20":"border-transparent text-muted-foreground hover:bg-muted/50 opacity-40 hover:opacity-100"}`,children:[p," ",fe>0&&e.jsx("span",{className:"ml-0.5",children:fe})]},p)})})]},a.id);return u.length===0&&Q.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:ie.trim()||C!=="all"?"No notices match your search.":"No announcements yet. Be the first to post!"}):e.jsxs(e.Fragment,{children:[u.length>0?e.jsx("div",{className:"space-y-4",children:u.map(is)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No active announcements."}),Q.length>0&&e.jsxs("details",{className:"mt-6 group border-t border-border pt-4",children:[e.jsxs("summary",{className:"cursor-pointer text-sm font-medium text-muted-foreground hover:text-foreground select-none flex items-center gap-2",children:[e.jsx("span",{className:"transition-transform group-open:rotate-90",children:"▸"}),"Expired posts (",Q.length,")"]}),e.jsx("div",{className:"space-y-4 mt-4 opacity-75",children:Q.map(is)})]})]})})()]}),e.jsx(P,{open:ks,onOpenChange:es,children:e.jsxs(A,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(E,{children:[e.jsxs(F,{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"h-5 w-5 text-primary"}),"Pending Noticeboard Posts"]}),e.jsx(D,{children:"Review submitted posts. Approved posts appear in the noticeboard for everyone."})]}),e.jsx("div",{className:"space-y-3 py-2",children:G.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No posts awaiting approval."}):G.map(s=>e.jsxs("div",{className:"border border-border rounded-lg p-3 space-y-2 bg-muted/30",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-sm text-foreground",children:s.title}),s.content&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 whitespace-pre-wrap",children:s.content}),s.images.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap mt-2",children:s.images.map((t,n)=>e.jsx("img",{src:t,alt:`Attachment ${n+1}`,className:"h-16 w-16 object-cover rounded-md border border-border"},t))}),e.jsxs("p",{className:"text-xs text-muted-foreground/70 mt-2",children:[e.jsx("span",{className:"font-medium",children:s.author_name})," · ",q(new Date(s.created_at),"d MMM · h:mm a"),s.expires_at&&e.jsxs("span",{className:"ml-1 text-amber-600",children:["· Expires ",q(new Date(s.expires_at),"d MMM")]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsxs(l,{size:"sm",variant:"outline",onClick:()=>Is(s),disabled:xe===s.id,className:"text-destructive hover:text-destructive",children:[e.jsx(_,{className:"h-3.5 w-3.5 mr-1"}),"Decline"]}),e.jsxs(l,{size:"sm",onClick:()=>Ms(s),disabled:xe===s.id,children:[xe===s.id?e.jsx(g,{className:"h-3.5 w-3.5 mr-1 animate-spin"}):e.jsx(et,{className:"h-3.5 w-3.5 mr-1"}),"Approve"]})]})]},s.id))})]})}),e.jsx(P,{open:!!oe,onOpenChange:()=>V(null),children:e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(F,{children:"Edit Post"}),e.jsx(D,{children:"Update your noticeboard post."})]}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsx(M,{value:L,onChange:s=>Be(s.target.value)}),e.jsx(ds,{value:Ve,onChange:s=>Le(s.target.value),rows:3}),e.jsxs(I,{value:pe,onValueChange:He,children:[e.jsx(z,{className:"h-9",children:e.jsx(T,{placeholder:"Category (optional)"})}),e.jsxs(U,{children:[e.jsx(f,{value:"none",children:"No category"}),v.map(s=>e.jsx(f,{value:s.id,children:s.name},s.id))]})]}),de.length>0&&e.jsx("div",{className:"space-y-1.5",children:de.map((s,t)=>e.jsxs("div",{className:"flex items-center gap-2 text-xs bg-muted/40 border border-border rounded-md px-2 py-1.5",children:[e.jsx(je,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx("span",{className:"text-muted-foreground",children:ve(s.size)}),e.jsx("button",{type:"button",onClick:()=>me(n=>n.filter((r,o)=>o!==t)),"aria-label":"Remove attachment",children:e.jsx(_,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-destructive"})})]},s.url))}),le.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap",children:le.map((s,t)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:s,alt:`Attachment ${t+1}`,className:"h-16 w-16 object-cover rounded-md border border-border"}),e.jsx("button",{type:"button",onClick:()=>ce(n=>n.filter((r,o)=>o!==t)),className:"absolute -top-1.5 -right-1.5 bg-destructive text-destructive-foreground rounded-full p-0.5 shadow-md hover:scale-110 transition-transform","aria-label":"Remove image",children:e.jsx(_,{className:"h-3 w-3"})})]},s))}),e.jsxs(l,{variant:"outline",size:"sm",className:"text-xs",onClick:()=>{var s;return(s=H.current)==null?void 0:s.click()},disabled:We,children:[We?e.jsx(g,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(hs,{className:"mr-1.5 h-3.5 w-3.5"}),"Add photos"]}),e.jsxs(l,{variant:"outline",size:"sm",className:"text-xs ml-2",onClick:()=>{var s;return(s=W.current)==null?void 0:s.click()},disabled:Ge,children:[Ge?e.jsx(g,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(gs,{className:"mr-1.5 h-3.5 w-3.5"}),"Attach documents"]}),e.jsx("input",{ref:W,type:"file",multiple:!0,className:"hidden",onChange:Es}),e.jsx("input",{ref:H,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:Fs})]}),e.jsxs(cs,{children:[e.jsx(l,{variant:"outline",onClick:()=>V(null),children:"Cancel"}),e.jsxs(l,{onClick:zs,disabled:Xe||!L.trim(),children:[Xe&&e.jsx(g,{className:"h-4 w-4 animate-spin mr-2"}),"Save"]})]})]})}),e.jsx(P,{open:!!k,onOpenChange:()=>K(null),children:e.jsxs(A,{children:[e.jsxs(E,{children:[e.jsx(F,{children:"Delete Post"}),e.jsxs(D,{children:['Are you sure you want to delete "',k==null?void 0:k.title,'"?']})]}),e.jsxs(cs,{children:[e.jsx(l,{variant:"outline",onClick:()=>K(null),children:"Cancel"}),e.jsxs(l,{variant:"destructive",onClick:Ts,disabled:Ye,children:[Ye?e.jsx(g,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}),e.jsx(P,{open:!!j,onOpenChange:()=>ue(null),children:e.jsxs(A,{className:"max-w-4xl p-2 sm:p-4 bg-background/95",children:[e.jsxs(E,{className:"sr-only",children:[e.jsx(F,{children:"Image preview"}),e.jsx(D,{children:"Attached noticeboard image"})]}),j&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("img",{src:j.images[j.index],alt:"Full size",className:"max-h-[75vh] w-auto object-contain rounded-md"})}),j.images.length>1&&e.jsx("div",{className:"flex gap-2 justify-center flex-wrap",children:j.images.map((s,t)=>e.jsx("button",{type:"button",onClick:()=>ue({...j,index:t}
21),className:y("rounded-md overflow-hidden border-2 transition-all",t===j.index?"border-primary":"border-transparent opacity-60 hover:opacity-100"),children:e.jsx("img",{src:s,alt:"",className:"h-12 w-12 object-cover"})},s))})]})]})}),e.jsx(P,{open:bs,onOpenChange:Te,children:e.jsxs(A,{className:"max-w-lg",children:[e.jsxs(E,{children:[e.jsxs(F,{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5 text-primary"})," Noticeboard categories"]}),e.jsx(D,{children:"Group notices (e.g. Meeting Minutes) so members can filter them."})]}),e.jsxs("div",{className:"space-y-3 py-1",children:[v.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No categories yet."}),v.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(M,{value:s.name,onChange:t=>ze(n=>n.map(r=>r.id===s.id?{...r,name:t.target.value}:r)),onBlur:()=>ts(s.id,{name:s.name}),className:"h-9 flex-1"}),e.jsxs(I,{value:s.color,onValueChange:t=>ts(s.id,{color:t}),children:[e.jsx(z,{className:"h-9 w-[130px]",children:e.jsx(T,{})}),e.jsx(U,{children:xs.map(t=>e.jsx(f,{value:t.key,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:y("h-3 w-3 rounded-full",t.swatch)}),t.label]})},t.key))})]}),e.jsx(l,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>_s(s.id),"aria-label":"Delete category",children:e.jsx(Ne,{className:"h-3.5 w-3.5"})})]},s.id)),e.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-3",children:[e.jsx(M,{placeholder:"New category name",value:B,onChange:s=>Ue(s.target.value),className:"h-9 flex-1"}),e.jsxs(I,{value:qe,onValueChange:Re,children:[e.jsx(z,{className:"h-9 w-[130px]",children:e.jsx(T,{})}),e.jsx(U,{children:xs.map(s=>e.jsx(f,{value:s.key,children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:y("h-3 w-3 rounded-full",s.swatch)}),s.label]})},s.key))})]}),e.jsx(l,{size:"sm",onClick:Ss,disabled:$e||!B.trim(),children:$e?e.jsx(g,{className:"h-4 w-4 animate-spin"}):e.jsx(us,{className:"h-4 w-4"})})]})]})]})})]})};export{At 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.