1import{a as o,c as Y,j as e}from"./vendor-react-query-CuRL5XEm.js";import{f as H,m as xe,n as me,L as be,B as d,Z as j,M as ge,U as ue,N as pe,aV as we,w as fe,x as je,D as ve,b as Ne,c as ke,d as ye,e as Pe}from"./index-BpjVR8sT.js";import{A as Se,a as Ce,b as Me}from"./avatar-C5GGe1NZ.js";import{m as Q,d as J,a as W}from"./bulkMediaDownload-CF2F8mfa.js";import{at as De,a7 as $e,a8 as Ae,D as S,ai as Ee,C as Ie,_ as X,a as Te,bp as Le,o as _e}from"./vendor-icons-DgNAkMED.js";import"./vendor-radix-CY-GV1m3.js";const T=60,I=200,ee=g=>g.title?.trim()||`Post ${g.id}`,te=g=>({type:g,id:0,name:"",postCount:0,owner:{id:"",username:"",profileImageUrl:null,isAdmin:!1,hasPaidBadge:!1,customTag:null,leveling:null},items:[],total:0,limit:T,offset:0,page:1,totalPages:0}),ze={collection:te("collection"),series:te("series")};function Ke(){const[g,se]=H("/collections/:id"),[ae,le]=H("/series/:id"),[,ie]=xe(),[L]=me(),m=ae?"series":"collection",h=Number.parseInt((g?se?.id:le?.id)||"",10),C=!Number.isFinite(h)||h<=0,n=(()=>{const t=Number.parseInt((L.get("page")||"1").trim(),10);return Number.isFinite(t)&&t>0?t:1})(),_=m==="collection"?`/collections/${h}`:`/series/${h}`,M=m==="collection"?`/api/post-organizers/collections/${h}`:`/api/post-organizers/series/${h}`,z=m==="collection"?"Collection":"Album",re=m==="collection"?$e:Ae,[i,D]=o.useState(null),[x,F]=o.useState("posts"),[b,O]=o.useState(!1),[v,u]=o.useState([]),[p,N]=o.useState(!1),oe=t=>{const s=new URLSearchParams(L.toString());t>1?s.set("page",String(t)):s.delete("page");const r=s.toString();return r?`${_}?${r}`:_},k=(t,s=!1)=>{typeof window<"u"&&window.scrollTo({top:0,behavior:s?"auto":"smooth"}),ie(oe(t),s?{replace:!0}:void 0)},{data:a=ze[m],isLoading:$,isError:U}=Y({queryKey:["/api/post-organizers",m,h,n],queryFn:async()=>{const t=(n-1)*T,s=await fetch(`${M}?limit=${T}&offset=${t}`,{credentials:"include"});if(!s.ok)throw new Error("Organizer not found");return s.json()},enabled:!C,staleTime:1e4}),B=C||U,R=!C&&!$&&!U&&Number(a.total||0)>a.items.length,q=async()=>{const t=await fetch(`${M}?limit=${I}&offset=0`,{credentials:"include"});if(!t.ok)throw new Error("Organizer media unavailable");const s=await t.json(),r=Math.max(1,Number(s.totalPages||1));if(r<=1)return s;const c=await Promise.all(Array.from({length:r-1},async(f,P)=>{const he=(P+1)*I,G=await fetch(`${M}?limit=${I}&offset=${he}`,{credentials:"include"});return G.ok?await G.json():null})),w=new Map;for(const f of s.items)w.set(f.id,f);for(const f of c)if(f)for(const P of f.items)w.set(P.id,P);return{...s,items:Array.from(w.values())}},ne=R&&x==="media",{data:A,isFetching:K}=Y({queryKey:["/api/post-organizers",m,h,"all-items"],queryFn:q,enabled:ne,staleTime:1e4}),V=A?.items??a.items,l=o.useMemo(()=>Q(V,ee),[V]),E=o.useMemo(()=>new Set(v),[v]),y=o.useMemo(()=>l.filter(t=>E.has(t.key)),[l,E]);o.useEffect(()=>{if(a.totalPages>0&&n>a.totalPages){k(a.totalPages,!0);return}a.totalPages===0&&n!==1&&k(1,!0)},[n,a.totalPages]),o.useEffect(()=>{i&&(l.some(t=>t.key===i.key)||D(null))},[l,i]),o.useEffect(()=>{x!=="media"&&(O(!1),u([]))},[x]),o.useEffect(()=>{u(t=>{const s=t.filter(r=>l.some(c=>c.key===r));return s.length===t.length?t:s})},[l]);const Z=t=>{u(s=>s.includes(t)?s.filter(r=>r!==t):[...s,t])},ce=async()=>{if(!(y.length===0||p)){N(!0);try{await W(y)}finally{N(!1)}}},de=async()=>{if(!(l.length===0||p)){N(!0);try{const t=R&&!A?Q((await q()).items,ee):l;await W(t)}finally{N(!1)}}};return e.jsx(be,{children:e.jsxs("div",{className:"mx-auto w-full max-w-5xl px-3 py-4 sm:px-4 md:py-5",children:[e.jsx("div",{className:"mb-3",children:e.jsxs(d,{type:"button",variant:"ghost",onClick:()=>window.history.back(),className:"h-9 rounded-xl border border-white/10 bg-white/[0.04] px-3 text-xs font-semibold text-white/78 hover:bg-white/[0.08] hover:text-white",children:[e.jsx(De,{className:"mr-1.5 h-3.5 w-3.5"}),"Back"]})}),e.jsx("section",{className:"mb-4 rounded-[1.1rem] bg-[#0c0c10] p-3.5 sm:p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1.5 inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-[0.18em] text-white/45",children:[e.jsx(re,{className:"h-3.5 w-3.5 text-amber-300"}),z]}),$?e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{className:"h-8 w-56 bg-white/10"}),e.jsx(j,{className:"h-4 w-40 bg-white/10"})]}):B?e.jsx("h1",{className:"text-xl font-black tracking-tight text-white sm:text-2xl",children:"Not found"}):e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"break-words text-xl font-black tracking-tight text-white sm:text-2xl",children:a.name}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5",children:[e.jsxs(ge,{href:`/user/${encodeURIComponent(a.owner.username)}`,className:"inline-flex items-center gap-1.5 rounded-full border border-white/10 bg-white/[0.04] py-0.5 pl-0.5 pr-2.5 text-xs font-semibold text-white/82 transition-colors hover:bg-white/[0.08] hover:text-white",children:[e.jsxs(Se,{className:"h-6 w-6 border border-white/10 bg-[#151515]",children:[e.jsx(Ce,{src:a.owner.profileImageUrl||void 0}),e.jsx(Me,{className:"bg-[#151515] text-[11px] text-white",children:a.owner.username[0]?.toUpperCase()||"U"})]}),e.jsxs("span",{children:["Made by @",a.owner.username]})]}),e.jsx(ue,{leveling:a.owner.leveling,hasPaidBadge:a.owner.hasPaidBadge,customTag:a.owner.customTag??null,isAdmin:a.owner.isAdmin,...pe(a.owner),size:"xs"})]})]})]}),e.jsxs("div",{className:"inline-flex w-fit items-center rounded-full border border-amber-300/20 bg-amber-400/[0.10] px-3 py-1.5 text-xs font-black uppercase tracking-[0.16em] text-amber-100",children:[Number(a.total||0).toLocaleStr
1ing()," posts"]})]})}),$?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-4",children:Array.from({length:8}).map((t,s)=>e.jsxs("div",{className:"space-y-3",children:[e.jsx(j,{className:"aspect-[3/4] w-full rounded-xl bg-white/8"}),e.jsx(j,{className:"h-4 w-3/4 bg-white/8"}),e.jsx(j,{className:"h-3 w-1/2 bg-white/8"})]},`organizer-skeleton-${s}`))}):B?e.jsx("div",{className:"rounded-[1.1rem] bg-[#0c0c10] px-5 py-8 text-center",children:e.jsxs("p",{className:"text-base font-semibold text-white",children:["This ",z.toLowerCase()," is unavailable."]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"inline-flex rounded-2xl border border-white/[0.08] bg-[#09090b] p-1",children:[e.jsxs("button",{type:"button",onClick:()=>F("posts"),className:`inline-flex items-center gap-1.5 rounded-xl px-3 py-1.5 text-[11px] font-black uppercase tracking-[0.16em] transition-colors ${x==="posts"?"bg-white text-black":"text-white/48 hover:bg-white/[0.06] hover:text-white/78"}`,children:["Posts",e.jsx("span",{className:x==="posts"?"text-black/60":"text-white/32",children:Number(a.total||0).toLocaleString()})]}),e.jsxs("button",{type:"button",onClick:()=>F("media"),className:`inline-flex items-center gap-1.5 rounded-xl px-3 py-1.5 text-[11px] font-black uppercase tracking-[0.16em] transition-colors ${x==="media"?"bg-white text-black":"text-white/48 hover:bg-white/[0.06] hover:text-white/78"}`,children:["Media",e.jsx("span",{className:x==="media"?"text-black/60":"text-white/32",children:l.length.toLocaleString()})]})]}),e.jsxs(d,{type:"button",onClick:de,disabled:l.length===0||p||K,className:"h-9 rounded-lg bg-amber-500 px-3 text-[10px] font-black uppercase tracking-[0.14em] text-black hover:bg-amber-400 disabled:cursor-not-allowed disabled:bg-white/[0.06] disabled:text-white/35",children:[e.jsx(S,{className:"mr-1.5 h-3.5 w-3.5"}),K&&!A?"Loading":p?"Downloading":"Download All"]})]}),x==="posts"?a.items.length===0?e.jsx("div",{className:"rounded-[1.1rem] bg-[#0c0c10] px-5 py-8 text-center",children:e.jsx("p",{className:"text-base font-semibold text-white",children:"No live posts here."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-4",children:a.items.map((t,s)=>e.jsx(we,{image:t,entryIndex:s},t.id))}),a.totalPages>1?e.jsxs("div",{className:"mt-8 flex items-center justify-center gap-2",children:[e.jsxs(d,{type:"button",variant:"ghost",onClick:()=>k(n-1),disabled:n===1,className:"h-10 rounded-xl border border-white/10 bg-white/[0.04] px-3 text-xs font-bold text-white/78 hover:bg-white/[0.08] hover:text-white disabled:opacity-40",children:[e.jsx(Ee,{className:"mr-1.5 h-4 w-4"}),"Previous"]}),e.jsxs("span",{className:"rounded-xl border border-white/10 bg-white/[0.04] px-3 py-2.5 text-xs font-black text-white/70",children:[n," / ",a.totalPages]}),e.jsxs(d,{type:"button",variant:"ghost",onClick:()=>k(n+1),disabled:n===a.totalPages,className:"h-10 rounded-xl border border-white/10 bg-white/[0.04] px-3 text-xs font-bold text-white/78 hover:bg-white/[0.08] hover:text-white disabled:opacity-40",children:["Next",e.jsx(Ie,{className:"ml-1.5 h-4 w-4"})]})]}):null]}):l.length===0?e.jsx("div",{className:"rounded-[1.1rem] bg-[#0c0c10] px-5 py-8 text-center",children:e.jsx("p",{className:"text-base font-semibold text-white",children:"No media here."})}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.08] bg-white/[0.03] px-3 py-1 text-[10px] font-black uppercase tracking-[0.16em] text-white/45",children:[l.length.toLocaleString()," media"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(d,{type:"button",variant:"ghost",onClick:()=>{O(t=>!t),b&&u([])},className:`h-9 rounded-lg px-3 text-[10px] font-black uppercase tracking-[0.14em] ${b?"border border-amber-300/35 bg-amber-500/12 text-amber-100":"border border-white/[0.06] bg-white/[0.03] text-white/50 hover:bg-white/[0.06] hover:text-white"}`,"aria-pressed":b,children:b?"Done":"Select"}),b?e.jsxs(e.Fragment,{children:[e.jsx(d,{type:"button",variant:"ghost",onClick:()=>{v.length===l.length?u([]):u(l.map(t=>t.key))},className:"h-9 rounded-lg border border-white/[0.06] bg-white/[0.03] px-3 text-[10px] font-black uppercase tracking-[0.14em] text-white/55 hover:bg-white/[0.06] hover:text-white",children:v.length===l.length?"Clear":"All"}),e.jsxs(d,{type:"button",onClick:ce,disabled:y.length===0||p,className:"h-9 rounded-lg bg-amber-500 px-3 text-[10px] font-black uppercase tracking-[0.14em] text-black hover:bg-amber-400 disabled:cursor-not-allowed disabled:bg-white/[0.06] disabled:text-white/35",children:[e.jsx(S,{className:"mr-1.5 h-3.5 w-3.5"}),p?"Downloading":`Download ${y.length||""}`]}
1)]}):null]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2.5 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:l.map((t,s)=>{const r=t.isVideo?fe(t.url,{width:640,height:640,fit:"cover"}):je(t.url,{width:640,height:640,fit:"cover"}),c=E.has(t.key);return e.jsxs("div",{className:`group relative overflow-hidden rounded-[1.1rem] border bg-[#09090b] text-left shadow-[0_18px_44px_rgba(0,0,0,0.3)] transition-colors hover:bg-[#111114] ${c?"border-amber-300/65 ring-2 ring-amber-300/18":"border-white/[0.08] hover:border-white/[0.18]"}`,children:[e.jsxs("button",{type:"button",onClick:()=>{if(b){Z(t.key);return}D(t)},className:"block w-full text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-amber-300/45",children:[e.jsxs("span",{className:"relative block aspect-square overflow-hidden bg-[#050506]",children:[t.isVideo?r?e.jsx("img",{src:r,alt:t.title,loading:s<8?"eager":"lazy",decoding:"async",className:"h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.02]"}):e.jsx("span",{className:"flex h-full w-full items-center justify-center",children:e.jsx(X,{className:"h-9 w-9 text-white/46"})}):e.jsx("img",{src:r||t.url,alt:t.title,loading:s<8?"eager":"lazy",decoding:"async",className:"h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.02]"}),e.jsx("span",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-[linear-gradient(180deg,rgba(0,0,0,0),rgba(0,0,0,0.72))]"}),t.isVideo?e.jsx("span",{className:"absolute left-2 top-2 inline-flex h-8 w-8 items-center justify-center rounded-full border border-white/12 bg-black/65 text-white",children:e.jsx(X,{className:"h-4 w-4"})}):null]}),e.jsxs("span",{className:"block min-w-0 px-3 py-2.5",children:[e.jsx("span",{className:"block truncate text-xs font-black text-white/82",children:t.title}),e.jsxs("span",{className:"mt-0.5 block text-[10px] font-semibold uppercase tracking-[0.14em] text-white/34",children:["#",t.mediaIndex+1]})]})]}),b?e.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),w.stopPropagation(),Z(t.key)},className:`absolute left-2 top-2 inline-flex h-8 min-w-8 items-center justify-center rounded-full border px-2 text-[10px] font-black uppercase tracking-[0.12em] shadow-[0_10px_28px_rgba(0,0,0,0.36)] transition-all duration-200 ${c?"border-amber-200/70 bg-amber-400 text-black":"border-white/14 bg-black/70 text-white/80 hover:border-white/28 hover:bg-black/85 hover:text-white"}`,"aria-pressed":c,"aria-label":`${c?"Deselect":"Select"} ${t.title}`,children:c?e.jsx(Te,{className:"h-4 w-4"}):e.jsx(Le,{className:"h-4 w-4"})}):null,e.jsx("button",{type:"button",onClick:()=>{J(t)},className:"absolute right-2 top-2 inline-flex h-8 w-8 items-center justify-center rounded-full border border-white/12 bg-black/68 text-white transition-colors hover:bg-white hover:text-black focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300/45","aria-label":`Download ${t.title}`,children:e.jsx(S,{className:"h-4 w-4"})})]},t.key)})})]})]}),e.jsx(ve,{open:!!i,onOpenChange:t=>!t&&D(null),children:e.jsxs(Ne,{className:"max-h-[90vh] max-w-6xl overflow-hidden border border-white/10 bg-[#070708] p-0 text-white shadow-[0_28px_90px_rgba(0,0,0,0.7)]",children:[e.jsxs(ke,{className:"sr-only",children:[e.jsx(ye,{children:i?.title||"Media"}),e.jsx(Pe,{children:"Collection media preview"})]}),i?e.jsxs("div",{className:"flex max-h-[90vh] flex-col",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-white/10 px-4 py-3 sm:px-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-black text-white",children:i.title}),e.jsx("div",{className:"mt-0.5 text-xs font-semibold text-white/42",children:i.postTitle})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{asChild:!0,variant:"ghost",className:"h-10 rounded-xl border border-white/10 bg-white/[0.04] px-3 text-xs font-black uppercase tracking-[0.12em] text-white/72 hover:bg-white/[0.08] hover:text-white",children:e.jsxs("a",{href:i.url,target:"_blank",rel:"noreferrer noopener",children:[e.jsx(_e,{className:"mr-2 h-4 w-4"}),"Open"]})}),e.jsxs(d,{type:"button",onClick:()=>{J(i)},className:"h-10 rounded-xl bg-[#ff9900] px-3 text-xs font-black uppercase tracking-[0.12em] text-black hover:bg-[#ffb13b]",children:[e.jsx(S,{className:"mr-2 h-4 w-4"}),"Download"]})]})]}),e.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center bg-black p-3 sm:p-5",children:i.isVideo?e.jsx("video",{src:i.url,controls:!0,className:"max-h-[72vh] w-full max-w-full rounded-xl bg-black object-contain"}):e.jsx("img",{src:i.url,alt:i.title,className:"max-h-[72vh] max-w-full rounded-xl object-contain"})})]}):null]})})]})})}export{Ke 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.