1import{c as He,k as Je,r as d,f as We,J as Xe,l as Q,j as e,g as O,aV as be,B as m,ab as Ye,C as V,d as H,p as J,a as W,aF as Ge,aG as Ze,a1 as C,aH as et,aM as ve,o as we,i as Ne,b as tt,aq as st,ar as at,as as it,at as nt,au as ot,O as rt,Q as $,V as I,W as D,Y as L,I as lt,$ as X,a9 as ct,aQ as Ce,aT as dt,X as mt,aN as ut,a2 as ht,D as b,E as q,a4 as xt,a5 as pt,b6 as Se,a6 as Te}from"./index-CAQ9C6-z.js";import{A as jt}from"./AdminBreadcrumb-DnS-FtUE.js";import{S as gt}from"./switch-CBkylJyN.js";import{C as Pe}from"./checkbox-D5-fZNZW.js";import{S as re,a as le,b as ce,c as de,d as g}from"./select-C1jcuWaT.js";import{T as ft,a as yt,b as ke,c as x,d as bt,e as p}from"./table-BaZ6TUhP.js";import{A as vt,a as wt,b as Nt,c as Ct,d as St,e as Tt,f as Pt,g as kt}from"./alert-dialog-B8z1m0Cj.js";import{F as Dt}from"./file-text-CbHBmfnW.js";import{H as De}from"./heart-U9TM8GMt.js";import{M as Me}from"./message-circle-g2yWsa9c.js";import{C as Mt}from"./chevron-down--E-1bxpl.js";import{C as Et}from"./circle-alert-BkyqRhG-.js";import{U as At}from"./user-BbKRbDSw.js";import{f as Ut}from"./format-DECx0Hkk.js";import{P as Ft}from"./pin-BbHq24xQ.js";import{S as Ot}from"./square-pen-BNHSH3rb.js";import{T as $t}from"./trash-2-CJsVXXEd.js";import{U as It}from"./upload-BTVigLWl.js";import"./index-Q3UH4NY9.js";import"./index-BdQq_4o_.js";import"./chevron-up-BOfZRiUg.js";import"./en-US-K2-Byqu-.js";import"./differenceInCalendarDays-BvXbP6kq.js";/** 2 * @license lucide-react v0.453.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 Ee=He("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]),Lt=xt({title:Te().min(1,"Title is required").max(200,"Title must be 200 characters or less"),content:Te().min(1,"Content is required").max(1e4,"Content must be 10000 characters or less"),category:Se(["discussion","question","announcement","showcase"]),board:Se(["main","all_access"]).default("main"),isPinned:pt().default(!1)}),qt={discussion:"bg-blue-500/10 text-blue-600 dark:text-blue-400",question:"bg-amber-500/10 text-amber-600 dark:text-amber-400",announcement:"bg-primary/10 text-primary",showcase:"bg-pink-500/10 text-pink-600 dark:text-pink-400"},zt={discussion:"Discussion",question:"Question",announcement:"Announcement",showcase:"Showcase"},Y={main:"Main",all_access:"All Access"},Rt={main:"bg-purple-500/10 text-purple-600 dark:text-purple-400",all_access:"bg-cyan-500/10 text-cyan-600 dark:text-cyan-400"},f="festivalbabes:adminPendingCommunityFinalize:v1";function us(){const{toast:l}=Je(),[Ae,z]=d.useState(!1),[M,G]=d.useState(null),[Ue,Z]=d.useState(!1),[E,me]=d.useState(null),[A,v]=d.useState([]),[Kt,U]=d.useState([]),[ue,R]=d.useState([]),[ee,he]=d.useState(!1),[xe,pe]=d.useState(!1),[F,Fe]=d.useState("all"),[w,S]=d.useState(new Set),K=d.useRef(null),{data:T,isLoading:Oe,isError:$e,error:te,refetch:je,isFetching:_}=We({queryKey:["/api/admin/community/posts",F],queryFn:async()=>{const t=new URLSearchParams;F!=="all"&&t.set("board",F);const s=await fetch(`/api/admin/community/posts?${t.toString()}`,{credentials:"include"});if(!s.ok){const i=await s.text().catch(()=>"")||s.statusText;throw new Error(`${s.status}: ${i||"Failed to fetch posts"}`)}return s.json()}});d.useEffect(()=>{let t=!1;return(async()=>{let s=[];try{const a=localStorage.getItem(f);if(!a)return;const n=JSON.parse(a),r=Date.now(),o={};for(const c of Object.keys(n)){const j=n[c];j!=null&&j.expiresAt&&j.expiresAt>r&&(o[c]=j)}Object.keys(o).length===0?localStorage.removeItem(f):localStorage.setItem(f,JSON.stringify(o)),s=Object.values(o)}catch{try{localStorage.removeItem(f)}catch{}return}const i=a=>{try{const n=localStorage.getItem(f);if(!n)return;const r=JSON.parse(n);delete r[a],Object.keys(r).length===0?localStorage.removeItem(f):localStorage.setItem(f,JSON.stringify(r))}catch{}};for(const a of s){if(t)return;try{const n=await fetch("/api/admin/community/upload-complete",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({objectKey:a.objectKey,publicUrl:a.publicUrl,uploadToken:a.uploadToken})});if(t)return;if(n.status===401)continue;if(n.ok)i(a.objectKey),l({title:"Upload finished",description:`We finished saving your earlier upload of ${a.fileName}.`});else{i(a.objectKey);let r="We couldn't finish your earlier upload. Please try again.";try{const o=await n.json();o!=null&&o.message&&(r=o.message)}catch{}l({title:"Upload not recovered",description:`${a.fileName}: ${r}`,variant:"destructive"})}}catch{}}})(),()=>{t=!0}},[]);const Ie=async t=>{var ye;const s={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",mov:"video/quicktime",avi:"video/x-msvideo"},i=((ye=t.name.split(".").pop())==null?void 0:ye.toLowerCase())||"",a=t.type||s[i]||"application/octet-stream",n=await fetch("/api/admin/community/upload-url",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({fileName:t.name,contentType:a,sizeBytes:t.size})});if(!n.ok){const y=await n.json().catch(()=>({message:"Upload failed"}));throw new Error(y.message||"Upload failed")}const{uploadURL:r,objectKey:o,publicUrl:c,contentType:j,uploadToken:fe,expiresAt:Ve}=await n.json();await new Promise((y,N)=>{const u=new XMLHttpRequest;u.timeout=4*60*60*1e3,u.addEventListener("load",()=>{u.status>=200&&u.status<300?y():N(new Error(`Upload to storage failed (HTTP ${u.status}).`))}),u.addEventListener("error",()=>N(new Error("Network error during upload."))),u.addEventListener("abort",()=>N(new Error("Upload cancelled."))),u.addEventListener("timeout",()=>N(new Error("Upload timed out."))),u.open("PUT",r),u.setRequestHeader("Content-Type",j||a),u.send(t)});const B=await fetch("/api/admin/community/upload-complete",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({objectKey:o,publicUrl:c,uploadToken:fe})});if(B.status===401){try{const y=localStorage.getItem(f),N=y?JSON.parse(y):{};N[o]={objectKey:o,publicUrl:c,uploadToken:fe,fileName:t.name,expiresAt:Ve,savedAt:Date.now()},localStorage.setItem(f,JSON.stringify(N))}catch{}throw new Error("Your session expired during upload. Please log in again. We'll finish saving the file automatically.")}if(!B.ok){const y=await B.json().catch(()=>({message:"Upload finalize failed"}));throw new Error(y.message||"Upload finalize failed")}const oe=await B.json();return{url:oe.url,mediaType:oe.mediaType==="videos"?"video":"image",f
6ileSize:oe.fileSize}},Le=async t=>{const s=t.target.files;if(!s||s.length===0)return;he(!0);let i=0;const a=[],n=setInterval(()=>{fetch("/api/auth/heartbeat",{credentials:"include"}).catch(()=>{})},4*60*1e3);try{for(let r=0;r<s.length;r++){const o=s[r];try{const c=await Ie(o);if(!c){a.push(o.name);continue}v(j=>[...j,{url:c.url,mediaType:c.mediaType,fileName:o.name,fileSize:c.fileSize,mimeType:o.type}]),i++}catch(c){a.push(`${o.name}: ${(c==null?void 0:c.message)||"Upload failed"}`)}}i===s.length?l({title:"Upload Complete",description:`Successfully uploaded ${s.length} file(s).`}):i>0?l({title:"Partial Upload",description:`Uploaded ${i} of ${s.length} file(s). Failed: ${a.join(", ")}`}):l({title:"Upload Failed",description:"Could not upload any files. Please try again.",variant:"destructive"})}catch{l({title:"Upload Failed",description:"Something went wrong. Please try again.",variant:"destructive"})}finally{clearInterval(n),he(!1),K.current&&(K.current.value="")}},qe=t=>{const s=A[t];s.id&&R(i=>[...i,s.id]),v(i=>i.filter((a,n)=>n!==t))},ze=async t=>{for(const s of t)try{await fetch(`/api/admin/community/media/${s}`,{method:"DELETE",credentials:"include"})}catch(i){console.error("Error deleting media:",i)}},h=Xe({resolver:ht(Lt),defaultValues:{title:"",content:"",category:"discussion",board:"main",isPinned:!1}}),se=Q({mutationFn:async t=>q("POST","/api/admin/community/posts",{...t,media:A}),onSuccess:()=>{b.invalidateQueries({queryKey:["/api/admin/community/posts"]}),b.invalidateQueries({queryKey:["/api/premium/community"]}),l({title:"Post Created",description:"The community post has been created successfully."}),ie()},onError:()=>{l({title:"Error",description:"Failed to create post. Please try again.",variant:"destructive"})}}),ae=Q({mutationFn:async({id:t,data:s})=>q("PUT",`/api/admin/community/posts/${t}`,{...s,media:A}),onSuccess:async()=>{ue.length>0&&await ze(ue),b.invalidateQueries({queryKey:["/api/admin/community/posts"]}),b.invalidateQueries({queryKey:["/api/premium/community"]}),l({title:"Post Updated",description:"The community post has been updated successfully."}),ie()},onError:()=>{l({title:"Error",description:"Failed to update post. Please try again.",variant:"destructive"})}}),P=Q({mutationFn:async({ids:t,board:s})=>{if(t.length===1)return{movedCount:1,res:await q("PUT",`/api/admin/community/posts/${t[0]}`,{board:s})};const i=await q("POST","/api/admin/community/bulk-move-posts",{ids:t,board:s}),a=await i.json().catch(()=>({}));return{movedCount:typeof(a==null?void 0:a.movedCount)=="number"?a.movedCount:t.length,res:i}},onSuccess:(t,s)=>{b.invalidateQueries({queryKey:["/api/admin/community/posts"]}),b.invalidateQueries({queryKey:["/api/premium/community"]});const i=Y[s.board];l({title:t.movedCount===1?"Post Moved":"Posts Moved",description:`${t.movedCount} post(s) moved to ${i}.`}),S(new Set)},onError:()=>{l({title:"Error",description:"Failed to move post(s). Please try again.",variant:"destructive"})}}),ge=Q({mutationFn:async t=>q("DELETE",`/api/admin/community/posts/${t}`),onSuccess:()=>{b.invalidateQueries({queryKey:["/api/admin/community/posts"]}),b.invalidateQueries({queryKey:["/api/premium/community"]}),l({title:"Post Deleted",description:"The community post has been deleted successfully."}),Z(!1),me(null)},onError:()=>{l({title:"Error",description:"Failed to delete post. Please try again.",variant:"destructive"})}}),Re=()=>{h.reset({title:"",content:"",category:"discussion",board:F==="all_access"?"all_access":"main",isPinned:!1}),G(null),v([]),U([]),R([]),z(!0)},Ke=async t=>{pe(!0),h.reset({title:t.title,content:t.content,category:t.category,board:t.board||"main",isPinned:t.isPinned}),G(t),R([]);try{const s=await fetch(`/api/admin/community/posts/${t.id}/media`,{credentials:"include"});if(s.ok){const a=(await s.json()).map(n=>({id:n.id,url:n.url,mediaType:n.mediaType,fileName:n.fileName,fileSize:n.fileSize,mimeType:n.mimeType}));v(a),U(a)}else v([]),U([])}catch(s){console.error("Error fetching post media:",s),v([]),U([])}finally{pe(!1)}z(!0)},ie=()=>{z(!1),G(null),v([]),U([]),R([]),h.reset()},_e=t=>{me(t),Z(!0)},Be=()=>{E&&ge.mutate(E.id)},Qe=t=>{M?ae.mutate({id:M.id,data:t}):se.mutate(t)},k=(T==null?void 0:T.posts)||[],ne=(T==null?void 0:T.stats)||{totalPosts:0,totalLikes:0,totalComments:0};return Oe?e.jsxs("div",{className:"space-y-6",children:[e.jsx(O,{className:"h-10 w-64"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsx(O,{className:"h-24"}),e.jsx(O,{className:"h-24"}),e.jsx(O,{className:"h-24"})]}),e.jsx(O,{className:"h-[400px] w-full"})]}
6):e.jsxs("div",{className:"space-y-4 sm:space-y-6 p-2 sm:p-0",children:[e.jsx(jt,{items:[{label:"Community Management"}]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl md:text-3xl font-bold font-heading flex items-center gap-2",children:[e.jsx(be,{className:"w-6 h-6 text-purple-500 flex-shrink-0"}),e.jsx("span",{className:"text-gradient-festival",children:"Post Management"})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage community posts, announcements, and discussions"})]}),e.jsxs(m,{onClick:Re,"data-testid":"button-create-post",children:[e.jsx(Ye,{className:"w-4 h-4 mr-2"}),"Create New Post"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs(V,{children:[e.jsxs(H,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(J,{className:"text-sm font-medium",children:"Total Posts"}),e.jsx(Dt,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(W,{children:e.jsx("div",{className:"text-2xl font-bold","data-testid":"stat-total-posts",children:ne.totalPosts})})]}
6),e.jsxs(V,{children:[e.jsxs(H,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(J,{className:"text-sm font-medium",children:"Total Likes"}),e.jsx(De,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(W,{children:e.jsx("div",{className:"text-2xl font-bold","data-testid":"stat-total-likes",children:ne.totalLikes})})]}),e.jsxs(V,{children:[e.jsxs(H,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(J,{className:"text-sm font-medium",children:"Total Comments"}),e.jsx(Me,{className:"w-4 h-4 text-muted-foreground"})]}),e.jsx(W,{children:e.jsx("div",{className:"text-2xl font-bold","data-testid":"stat-total-comments",children:ne.totalComments})})]})]}),e.jsxs(V,{children:[e.jsxs(H,{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 space-y-0",children:[e.jsx(J,{children:"Community Posts"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[w.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm text-muted-foreground","data-testid":"text-selected-count",children:[w.size," selected"]}),e.jsxs(Ge,{children:[e.jsx(Ze,{asChild:!0,children:e.jsxs(m,{variant:"outline",size:"sm",disabled:P.isPending,"data-testid":"button-bulk-move",children:[P.isPending?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(Ee,{className:"w-4 h-4 mr-2"}),"Move to",e.jsx(Mt,{className:"w-4 h-4 ml-1"})]})}),e.jsxs(et,{align:"end",children:[e.jsx(ve,{onClick:()=>P.mutate({ids:Array.from(w),board:"main"}),"data-testid":"button-bulk-move-main",children:"Main"}),e.jsx(ve,{onClick:()=>P.mutate({ids:Array.from(w),board:"all_access"}),"data-testid":"button-bulk-move-all-access",children:"All Access"})]})]}),e.jsx(m,{variant:"ghost",size:"sm",onClick:()=>S(new Set),"data-testid":"button-clear-selection",children:"Clear"})]}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Board:"}),e.jsxs(re,{value:F,onValueChange:t=>{Fe(t),S(new Set)},children:[e.jsx(le,{className:"w-[160px]","data-testid":"select-board-filter",children:e.jsx(ce,{})}),e.jsxs(de,{children:[e.jsx(g,{value:"all",children:"All Boards"}),e.jsx(g,{value:"main",children:"Main"}),e.jsx(g,{value:"all_access",children:"All Access"})]})]})]})]}),e.jsx(W,{children:$e?e.jsxs("div",{className:"text-center py-12","data-testid":"state-posts-error",children:[e.jsx(Et,{className:"w-12 h-12 mx-auto text-destructive/70 mb-4"}),e.jsx("p",{className:"font-medium",children:"Couldn't load posts"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1 max-w-md mx-auto",children:(te==null?void 0:te.message)||"Unknown error"}),e.jsxs(m,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>je(),disabled:_,"data-testid":"button-retry-posts",children:[_?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(we,{className:"w-4 h-4 mr-2"}),"Try again"]})]}):k.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(be,{className:"w-12 h-12 mx-auto text-muted-foreground/50 mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"No posts yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Create your first community post to get started."}),e.jsxs(m,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>je(),disabled:_,"data-testid":"button-refresh-posts",children:[_?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(we,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(ft,{children:[e.jsx(yt,{children:e.jsxs(ke,{children:[e.jsx(x,{className:"w-10",children:e.jsx(Pe,{checked:k.length>0&&k.every(t=>w.has(t.id))?!0:k.some(t=>w.has(t.id))?"indeterminate":!1,onCheckedChange:t=>{S(t===!0?new Set(k.map(s=>s.id)):new Set)},"aria-label":"Select all posts","data-testid":"checkbox-select-all"})}),e.jsx(x,{children:"Title"}),e.jsx(x,{children:"Board"}),e.jsx(x,{children:"Category"}),e.jsx(x,{children:"Author"}),e.jsx(x,{children:"Date"}),e.jsx(x,{className:"text-center",children:"Likes"}),e.jsx(x,{className:"text-center",children:"Comments"}),e.jsx(x,{className:"text-center",children:"Pinned"}),e.jsx(x,{className:"text-right",children:"Actions"})]})}),e.jsx(bt,{children:k.map(t=>{const s=t.board||"main",i=s==="main"?"all_access":"main",a=w.has(t.id);return e.jsxs(ke,{"data-testid":`post-row-${t.id}`,"data-state":a?"selected":void 0,children:[e.jsx(p,{children:e.jsx(Pe,{checked:a,onCheckedChange:n=>{S(r=>{const o=new Set(r);return n===!0?o.add(t.id):o.delete(t.id),o})},"aria-label":`Select ${t.title}`,"data-testid":`checkbox-select-post-${t.id}`})}),e.jsx(p,{className:"font-medium max-w-[200px] truncate",children:t.title}),e.jsx(p,{children:e.jsx(Ne,{className:Rt[s],variant:"secondary","data-testid":`badge-board-${t.id}`,children:Y[s]})}),e.jsx(p,{children:e.jsx(Ne,{className:qt[t.category],variant:"secondary",children:zt[t.category]})}),e.jsx(p,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm",children:t.authorName||"Unknown"})]})}),e.jsx(p,{children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(tt,{className:"w-4 h-4"}),Ut(new Date(t.createdAt),"MMM d, yyyy")]})}),e.jsx(p,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(De,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{children:t.likeCount})]})}),e.jsx(p,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Me,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{children:t.commentCount})]})}),e.jsx(p,{className:"text-center",children:t.isPinned&&e.jsx(Ft,{className:"w-4 h-4 text-primary mx-auto"})}),e.jsx(p,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs(m,{variant:"ghost",size:"sm",onClick:()=>P.mutate({ids:[t.id],board:i}),disabled:P.isPending,title:`Move to ${Y[i]}`,"data-testid":`button-move-post-${t.id}`,children:[e.jsx(Ee,{className:"w-4 h-4 mr-1"}),e.jsxs("span",{className:"hidden sm:inline",children:["Move to ",Y[i]]})]}),e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>Ke(t),disabled:xe,"data-testid":`button-edit-post-${t.id}`,children:xe?e.jsx(C,{className:"w-4 h-4 animate-spin"}):e.jsx(Ot,{className:"w-4 h-4"})}),e.jsx(m,{variant:"ghost",size:"icon",onClick:()=>_e(t),"data-testid":`button-delete-post-${t.id}`,children:e.jsx($t,{className:"w-4 h-4 text-destructive"})})]})})]},t.id)})})]})})})]}),e.jsx(st,{open:Ae,onOpenChange:z,children:e.jsxs(at,{className:"sm:max-w-[600px]",children:[e.jsxs(it,{children:[e.jsx(nt,{children:M?"Edit Post":"Create New Post"}),e.jsx(ot,{children:M?"Update the community post details below.":"Fill in the details to create a new community post."})]}),e.jsx(rt,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(Qe),className:"space-y-4",children:[e.jsx($,{control:h.control,name:"title",render:({field:t})=>e.jsxs(I,{children:[e.jsx(D,{children:"Title"}),e.jsx(L,{children:e.jsx(lt,{placeholder:"Enter post title",...t,"data-testid":"input-post-title"})}),e.jsx(X,{})]})}),e.jsx($,{control:h.control,name:"content",render:({field:t})=>e.jsxs(I,{children:[e.jsx(D,{children:"Content"}),e.jsx(L,{children:e.jsx(ct,{placeholder:"Write your post content...",rows:6,...t,"data-testid":"input-post-content"})}),e.jsx(X,{})]})}),e.jsx($,{control:h.control,name:"category",render:({field:t})=>e.jsxs(I,{children:[e.jsx(D,{children:"Category"}),e.jsxs(re,{onValueChange:t.onChange,defaultValue:t.value,value:t.value,children:[e.jsx(L,{children:e.jsx(le,{"data-testid":"select-post-category",children:e.jsx(ce,{placeholder:"Select a category"})})}),e.jsxs(de,{children:[e.jsx(g,{value:"discussion",children:"Discussion"}),e.jsx(g,{value:"question",children:"Question"}),e.jsx(g,{value:"announcement",children:"Announcement"}),e.jsx(g,{value:"showcase",children:"Showcase"})]})]}),e.jsx(X,{})]})}),e.jsx($,{control:h.control,name:"board",render:({field:t})=>e.jsxs(I,{children:[e.jsx(D,{children:"Board"}),e.jsxs(re,{onValueChange:t.onChange,defaultValue:t.value,value:t.value,children:[e.jsx(L,{children:e.jsx(le,{"data-testid":"select-post-board",children:e.jsx(ce,{placeholder:"Select a board"})})}),e.jsxs(de,{children:[e.jsx(g,{value:"main",children:"Main (all creators)"}),e.jsx(g,{value:"all_access",children:"All Access (AA creators only)"})]})]}),e.jsx(Ce,{children:"Choose which board this post will appear in."}),e.jsx(X,{})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{children:"Media (Photos & Videos)"}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4",children:[e.jsx("input",{ref:K,type:"file",accept:"image/*,video/*",multiple:!0,onChange:Le,className:"hidden","data-testid":"input-media-upload"}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsxs(m,{type:"button",variant:"outline",onClick:()=>{var t;return(t=K.current)==null?void 0:t.click()},disabled:ee,"data-testid":"button-upload-media",children:[ee?e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(It,{className:"w-4 h-4 mr-2"}),ee?"Uploading...":"Upload Photos or Videos"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Supports images and videos up to 50MB"})]}),A.length>0&&e.jsx("div",{className:"mt-4 grid grid-cols-2 sm:grid-cols-3 gap-2",children:A.map((t,s)=>e.jsxs("div",{className:"rounded-lg overflow-hidden border bg-muted",children:[t.mediaType==="video"?e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center",children:[e.jsx(dt,{className:"w-8 h-8 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"Video"})]}):e.jsx("img",{src:t.url,alt:t.fileName||"Uploaded media",loading:"lazy",decoding:"async",className:"aspect-square object-cover w-full"}),e.jsxs("div",{className:"flex items-center justify-between p-2 bg-background border-t",children:[e.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1 mr-2",children:t.fileName}),e.jsxs(m,{type:"button",variant:"destructive",size:"sm",onClick:()=>qe(s),"data-testid":`button-remove-media-${s}`,children:[e.jsx(mt,{className:"w-3 h-3 mr-1"}),"Delete"]})]})]},s))})]})]}),e.jsx($,{control:h.control,name:"isPinned",render:({field:t})=>e.jsxs(I,{className:"flex flex-row items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(D,{className:"text-base",children:"Pin Post"}),e.jsx(Ce,{children:"Pinned posts appear at the top of the community feed."})]}),e.jsx(L,{children:e.jsx(gt,{checked:t.value,onCheckedChange:t.onChange,"data-testid":"switch-post-pinned"})})]})}),e.jsxs(ut,{className:"gap-2 sm:gap-0",children:[e.jsx(m,{type:"button",variant:"outline",onClick:ie,"data-testid":"button-cancel-post",children:"Cancel"}),e.jsxs(m,{type:"submit",disabled:se.isPending||ae.isPending,"data-testid":"button-save-post",children:[(se.isPending||ae.isPending)&&e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}),M?"Update Post":"Create Post"]})]})]})})]})}),e.jsx(vt,{open:Ue,onOpenChange:Z,children:e.jsxs(wt,{children:[e.jsxs(Nt,{children:[e.jsx(Ct,{children:"Delete Post"}),e.jsxs(St,{children:['Are you sure you want to delete "',E==null?void 0:E.title,'"? This action cannot be undone.']})]}),e.jsxs(Tt,{children:[e.jsx(Pt,{"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsxs(kt,{onClick:Be,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90","data-testid":"button-confirm-delete",children:[ge.isPending&&e.jsx(C,{className:"w-4 h-4 mr-2 animate-spin"}),"Delete"]})]})]})})]})}export{us 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.