PageSourceSearch

https://cdn.azmen.com/react/v101/chunks/RequestsPage.js

js azmen.com collected 2026-09-28 06:31:04 UTC 42,118 bytes, 1 lines download raw bytes

1import{r as n,o as st,O as be,S as Z,N as ee,P as fe,M as ge,I as Le,a6 as me,L as pe,a7 as nt,j as e,g as at,b as ot,d as lt,a as $e,a8 as ie}from"../app.js";import{P as We}from"./Pagination.js";import{E as Re,T as Ve}from"./EntityAutocomplete.js";import{g as Me,f as ve,h as we,i as De,j as rt}from"./siteConfig.js";import"./sentry.js";const it=[{value:"movie",label:"Movie",icon:"movie"},{value:"series",label:"Series",icon:"series"},{value:"story",label:"Story",icon:"story"}],ct=[{value:"all",label:"All"},{value:"movie",label:"Movie"},{value:"series",label:"Series"},{value:"story",label:"Story"}],dt={awaiting_moderation:"bg-orange-500/20 text-orange-400",in_progress:"bg-purple-500/20 text-purple-400",completed:"bg-green-500/20 text-green-400",declined:"bg-red-500/20 text-red-400"},ut=["in_progress"],xt=["completed"],Ce=21,Se=10,he="az_request_rate",Oe=5,q="contentRequests",mt=location.hostname==="localhost"||location.hostname==="127.0.0.1",pt=mt?"http://localhost:1597/aznude-fea6a/us-central1/main/app":"https://main-aq7es5tiuq-uc.a.run.app/app",Fe=`${pt}/votes`,Ue=["celebName","contentName"];function Ye(t,a,o){return[...t].sort((b,u)=>{const i=(b[a]||"").toLowerCase(),x=(u[a]||"").toLowerCase();return i<x?o==="asc"?-1:1:i>x?o==="asc"?1:-1:0})}const Be=[{value:"awaiting_moderation",label:"Awaiting Moderation"},{value:"in_progress",label:"In Progress"},{value:"completed",label:"Completed"},{value:"declined",label:"Declined"}],z={celeb:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),e.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),movie:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),e.jsx("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),e.jsx("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),e.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),e.jsx("line",{x1:"2",y1:"7",x2:"7",y2:"7"}),e.jsx("line",{x1:"2",y1:"17",x2:"7",y2:"17"}),e.jsx("line",{x1:"17",y1:"7",x2:"22",y2:"7"}),e.jsx("line",{x1:"17",y1:"17",x2:"22",y2:"17"})]}),story:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("path",{fill:"currentColor",d:"M12 19.37c-1.79 0-3.58-.68-4.95-2.05a7.007 7.007 0 0 1 0-9.9 7.007 7.007 0 0 1 9.9 0 7.007 7.007 0 0 1 0 9.9A6.97 6.97 0 0 1 12 19.37m0-12.5c-1.41 0-2.82.54-3.89 1.61a5.517 5.517 0 0 0 0 7.78 5.507 5.507 0 0 0 7.78 0 5.517 5.517 0 0 0 0-7.78A5.5 5.5 0 0 0 12 6.87"}),e.jsx("path",{fill:"currentColor",d:"M8.25 22.39c-.09 0-.19-.02-.28-.05-2.25-.9-4.07-2.49-5.29-4.59a10.6 10.6 0 0 1-1.341-6.73c.05-.41.43-.7.84-.65s.7.43.65.84c-.26 2.02.14 4.02 1.15 5.78a9.1 9.1 0 0 0 4.54 3.94c.38.16.57.59.42.98-.11.3-.4.48-.69.48M5.85 5.23c-.22 0-.44-.1-.59-.29-.26-.33-.2-.8.13-1.05C7.3 2.4 9.58 1.61 12 1.61c2.36 0 4.61.76 6.5 2.2A.749.749 0 1 1 17.59 5 9.1 9.1 0 0 0 12 3.11c-2.08 0-4.05.68-5.69 1.96-.14.11-.3.16-.46.16m9.9 17.16c-.3 0-.58-.18-.7-.47a.76.76 0 0 1 .42-.98c1.93-.78 3.5-2.14 4.54-3.94a9.04 9.04 0 0 0 1.15-5.78c-.05-.41.24-.79.65-.84.4-.05.79.24.84.65.3 2.35-.16 4.68-1.34 6.73-1.21 2.1-3.04 3.68-5.29 4.59-.08.02-.17.04-.27.04"})]}),series:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"7",width:"20",height:"15",rx:"2",ry:"2"}),e.jsx("polyline",{points:"17 2 12 7 7 2"})]}),search:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),upvote:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})}),close:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),edit:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),comment:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),shield:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),link:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),trash:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})},ht={voteCount:"number",celebName:"text",contentName:"text",status:"generic",createdAt:"date",score:"number"};function bt({field:t,dir:a,active:o}){const b=ht[t]||"generic",u=o?1:.5;if(b==="text"){const i=a==="desc"?"Z":"A",x=a==="desc"?"A":"Z";return e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"currentColor",opacity:u,children:[e.jsx("path",{d:"M6 3v18M3 18l3 3 3-3",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("text",{x:"14",y:"12",fontSize:"11",fontWeight:"700",fontFamily:"Arial,sans-serif",children:i}),e.jsx("text",{x:"14",y:"24",fontSize:"11",fontWeight:"700",fontFamily:"Arial,sans-serif",children:x})]})}return b==="number"?a==="asc"?e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",opacity:u,children:[e.jsx("path",{d:"M6 3v18M3 18l3 3 3-3",strokeLinejoin:"round"}),e.jsx("line",{x1:"14",y1:"7",x2:"19",y2:"7"}),e.jsx("line",{x1:"14",y1:"13",x2:"23",y2:"13"}),e.jsx("line",{x1:"14",y1:"19",x2:"27",y2:"19"})]}):e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",opacity:u,children:[e.jsx("path",{d:"M6 3v18M3 18l3 3 3-3",strokeLinejoin:"round"}),e.jsx("line",{x1:"14",y1:"7",x2:"27",y2:"7"}),e.jsx("line",{x1:"14",y1:"13",x2:"23",y2:"13"}),e.jsx("line",{x1:"14",y1:"19",x2:"19",y2:"19"})]}):b==="date"?a==="asc"?e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",opacity:u,children:[e.jsx("path",{d:"M6 22V4M3 7l3-3 3 3"}),e.jsx("path",{d:"M16 6h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H16a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",strokeWidth:"1.8"}),e.jsx("line",{x1:"18",y1:"4",x2:"18",y2:"8",strokeWidth:"1.8"}),e.jsx("line",{x1:"24",y1:"4",x2:"24",y2:"8",strokeWidth:"1.8"}),e.jsx("line",{x1:"14",y1:"12",x2:"28",y2:"12",strokeWidth:"1.8"})]}):e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",opacity:u,children:[e.jsx("path",{d:"M6 4v18M3 19l3 3 3-3"}),e.jsx("path",{d:"M16 6h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H16a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",strokeWidth:"1.8"}),e.jsx("line",{x1:"18",y1:"4",x2:"18",y2:"8",strokeWidth:"1.8"}),e.jsx("line",{x1:"24",y1:"4",x2:"24",y2:"8",strokeWidth:"1.8"}),e.jsx("line",{x1:"14",y1:"12",x2:"28",y2:"12",strokeWidth:"1.8"})]}):a==="asc"?e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",opacity:u,children:[e.jsx("path",{d:"M6 22V4M3 7l3-3 3 3"}),e.jsx("path",{d:"M13 4h16l-6 7v6l-4 3V11z"})]}):e.jsxs("svg",{width:"20",height:"18",viewBox:"0 0 30 26",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",opacity:u,children:[e.jsx("path",{d:"M6 4v18M3 19l3 3 3-3"}),e.jsx("path",{d:"M13 4h16l-6 7v6l-4 3V11z"})]})}async function ze(){const t=$e.currentUser;if(!t)return{};try{return{Authorization:`Bearer ${await t.getIdToken()}`}}catch{return{}}}function ft(){try{const t=JSON.parse(localStorage.getItem(he)||"{}"),a=new Date().toISOString().slice(0,10);return t.date!==a?!0:(t.count||0)<Oe}catch{return!0}}function jt(){const t=new Date().toISOString().slice(0,10);try{const a=JSON.parse(localStorage.getItem(he)||"{}");a.date!==t?localStorage.setItem(he,JSON.stringify({date:t,count:1})):(a.count=(a.count||0)+1,localStorage.setItem(he,JSON.stringify(a)))}catch{localStorage.setItem(he,JSON.stringify({date:t,count:1}))}}function He(t){return t?(t.toDate?t.toDate():new Date(t)).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):""}function yt(t){if(!t||t<1e3)return String(t||0);if(t<1e6){const o=t/1e3;return(o>=10?Math.floor(o):o.toFixed(1).replace(/\.0$/,""))+"k"}const a=t/1e6;return(a>=10?Math.floor(a):a.toFixed(1).replace(/\.0$/,""))+"m"}function Je(t){return(t||"").replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function gt(t){const a=t.replace(/\D/g,"").slice(0,6);return a.length<=2?a:a.length<=4?a.slice(0,2)+":"+a.slice(2):a.slice(0,2)+":"+a.slice(2,4)+":"+a.slice(4)}function Qe(t){return!t.contentType||!t.contentName?"":t.contentName}function Ze(t){return t.contentType!=="series"||!t.season&&!t.episode?"":`S${t.season||"?"}E${t.episode||"?"}`}function qe(t){return!t.contentType||t.contentType!=="movie"&&t.contentType!=="series"?"":t.timestamp||""}function Ge(t){return t==="movie"?"Movie":t==="series"?"Series":t==="story"?"Story":"Celeb"}function Ke(t){return t&&z[t]?z[t]:z.celeb}function ue({label:t,field:a,sortField:o,sortDir:b,onSort:u,className:i=""}){const x=o===a,p=typeof u=="function",v=()=>{p&&(x?u(a,b==="asc"?"desc":"asc"):u(a,a==="celebName"||a==="contentName"?"asc":"desc"))};return e.jsx("th",{className:`py-3 pr-3 pl-4 font-semibold text-sm transition-colors ${p?"cursor-pointer select-none hover:text-white":""} ${x?"text-[#ccc]":"text-[#888]"} ${i}`,onClick:v,children:e.jsxs("span",{className:"flex items-center gap-1 text-[15px]",children:[t,p&&e.jsx("span",{className:"flex-shrink-0 flex",children:e.jsx(bt,{field:a,dir:b,active:x})})]})})}function Xe({status:t}){const a=dt[t]||"bg-gray-500/20 text-gray-400";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${a}`,children:Je(t)})}function et({requestId:t,voteCount:a,onVote:o,voted:b=!1}){const u=x=>{x.stopPropagation(),o(t)},i=(a||0)>0;return e.jsxs("button",{onClick:u,className:`flex flex-col items-center gap-0.5 px-3 py-2 rounded border transition-colors min-w-[48px] ${b?"border-primary bg-primary/10 text-primary":"border-[#333] text-[#888] hover:border-[#555] hover:text-white"} cursor-pointer`,children:[e.jsx("span",{className:b?"text-primary":"",children:z.upvote}),i&&e.jsx("span",{className:"text-sm font-semibold",children:yt(a)})]})}function Te({value:t,onChange:a,options:o,className:b,label:u}){const[i,x]=n.useState(!1),p=n.useRef(null),v=o.find(l=>l.value===t);return n.useEffect(()=>{if(!i)return;const l=M=>{p.current&&!p.current.contains(M.target)&&x(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)}
1,[i]),e.jsxs("div",{className:`sort-dropdown-wrapper ${b||""}`,ref:p,children:[e.jsxs("button",{type:"button",className:"sort-button",onClick:()=>x(!i),children:[u&&e.jsxs("span",{className:"mr-1",children:[u,":"]}),v?.label||"Sort",e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M7 10l5 5 5-5H7z"})})]}),e.jsx("div",{className:`sort-dropdown ${i?"":"sort-button-off"}`,children:e.jsx("ul",{className:"browse-filter-group",children:o.map(l=>e.jsx("li",{className:"browse-filter-item",onClick:()=>{a(l.value),x(!1)},children:e.jsx("span",{"data-value":l.value,className:l.value===t?"active":"",children:l.label})},l.value))})})]})}function xe({active:t,onClick:a,children:o}){return e.jsx("button",{type:"button",onClick:a,className:`flex items-center gap-1.5 px-3 py-1.5 rounded border cursor-pointer transition-colors text-[14px] font-semibold ${t?"border-primary bg-primary/10 text-primary":"border-[#333] text-[#888] hover:border-[#555] hover:text-white"}`,children:o})}function je({requests:t,onVote:a,onClick:o,showDate:b=!0,sortField:u,sortDir:i,onSort:x,loading:p=!1,votedMap:v={},onApprove:l,onDecline:M,onComplete:w,onAdminEdit:T,busyId:N=null}){const y=[120,95,140,110,85,130],k=!!(l||M||w||T);return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full border-collapse min-w-[600px]",style:{tableLayout:"fixed"},children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#333] text-left",children:[e.jsx(ue,{label:"Votes",field:"voteCount",sortField:u,sortDir:i,onSort:x,className:"w-[82px] !pl-4"}),e.jsx(ue,{label:"Celeb",field:"celebName",sortField:u,sortDir:i,onSort:x,className:"w-[18%]"}),e.jsx(ue,{label:"Content",field:"contentName",sortField:u,sortDir:i,onSort:x}),e.jsx(ue,{label:"Status",field:"status",sortField:u,sortDir:i,onSort:x,className:"w-[163px]"}),b&&e.jsx(ue,{label:"Date",field:"createdAt",sortField:u,sortDir:i,onSort:x,className:"w-[110px] hidden md:table-cell"}),k&&e.jsx("th",{className:"py-3 pr-3 pl-4 font-semibold text-[15px] text-[#888] w-[180px]",children:"Actions"})]})}),e.jsx("tbody",{children:p?Array.from({length:6}).map((c,E)=>e.jsxs("tr",{className:"border-b border-[#333]/50 animate-pulse",children:[e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("div",{className:"w-[48px] h-[48px] rounded bg-[#333]"})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("div",{className:"h-4 rounded bg-[#333]",style:{width:y[E%y.length]}})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("div",{className:"h-4 rounded bg-[#333] w-[100px]"})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("div",{className:"h-5 rounded bg-[#333] w-[72px]"})}),b&&e.jsx("td",{className:"py-3 pl-4 hidden md:table-cell",children:e.jsx("div",{className:"h-3 rounded bg-[#333] w-[80px]"})}),k&&e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("div",{className:"h-7 rounded bg-[#333] w-[160px]"})})]},`sk-${E}`)):t.map(c=>{const E=Qe(c),R=Ze(c),I=qe(c);return e.jsxs("tr",{onClick:()=>o(c),className:"border-b border-[#333]/50 hover:bg-white/[0.03] cursor-pointer transition-colors",children:[e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx(et,{requestId:c.id,voteCount:c.voteCount,onVote:a,voted:!!v[c.id]})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx("span",{className:"text-white text-[14px] font-medium",children:c.celebName||"-"})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:E?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ve,{content:Ge(c.contentType),children:e.jsx("span",{className:"text-[#888] flex-shrink-0 flex",children:Ke(c.contentType)})}),e.jsxs("span",{children:[e.jsx("span",{className:"text-white text-[14px] block",children:E}),(R||I)&&e.jsxs("span",{className:"text-[#999] text-xs flex gap-2",children:[R&&e.jsx("span",{children:R}),I&&e.jsx("span",{children:I})]})]})]}):e.jsx("span",{className:"text-[#555] text-sm",children:"-"})}),e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsx(Xe,{status:c.status})}),b&&e.jsx("td",{className:"py-3 pl-4 text-xs text-[#555] hidden md:table-cell",children:He(c.createdAt)}),k&&e.jsx("td",{className:"py-3 pr-3 pl-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[l&&c.status==="awaiting_moderation"&&e.jsx("button",{onClick:h=>{h.stopPropagation(),l(c)},disabled:N===c.id,className:`px-3 py-1.5 rounded border border-green-500/40 text-green-400 hover:bg-green-500/10 text-xs font-medium transition-colors ${N===c.id?"opacity-50 cursor-not-allowed":""}`,children:"Approve"}),w&&c.status==="in_progress"&&e.jsx("button",{onClick:h=>{h.stopPropagation(),w(c)},disabled:N===c.id,className:`px-3 py-1.5 rounded border border-blue-500/40 text-blue-400 hover:bg-blue-500/10 text-xs font-medium transition-colors ${N===c.id?"opacity-50 cursor-not-allowed":""}`,children:"Complete"}),M&&(c.status==="awaiting_moderation"||c.status==="in_progress")&&e.jsx("button",{onClick:h=>{h.stopPropagation(),M(c)},disabled:N===c.id,className:`px-3 py-1.5 rounded border border-red-500/40 text-red-400 hover:bg-red-500/10 text-xs font-medium transition-colors ${N===c.id?"opacity-50 cursor-not-allowed":""}`,children:"Decline"})]})})]},c.id)})})]})})}function tt({request:t,onClose:a,onVote:o,user:b,onEdit:u,onApprove:i,onDecline:x,onComplete:p,onAdminEdit:v,votedMap:l={}}){if(!t)return null;const M=Qe(t),w=Ze(t),T=qe(t),N=b&&t.createdBy===b.uid,y=[{label:"Status",value:e.jsx(Xe,{status:t.status})},{label:"Submitted",value:e.jsx("span",{className:"text-[#ccc] text-sm",children:He(t.createdAt)})}];return w&&y.push({label:"Episode",value:e.jsx("span",{className:"text-[#ccc] text-sm",children:w})}),T&&y.push({label:"Timestamp",value:e.jsx("span",{className:"text-[#ccc] text-sm",children:T})}),(i||x||p||v)&&(t.voteCount||0)>0&&y.push({label:"Votes",value:e.jsx("span",{className:"text-[#ccc] text-sm",children:t.voteCount})}),(i||x||p||v)&&(t.score||0)>0&&y.push({label:"Score",value:e.jsx("span",{className:"text-[#ccc] text-sm",children:t.score})}),e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:a,children:[e.jsx("div",{className:"absolute inset-0 bg-black/70"}),e.jsxs("div",{className:"relative bg-[#1a1a1a] rounded-lg border border-[#333] max-w-lg w-full max-h-[80vh] overflow-y-auto",onClick:k=>k.stopPropagation(),children:[e.jsxs("div",{className:"px-6 pt-6 pb-4",children:[e.jsx("button",{onClick:a,className:"absolute top-5 right-5 text-[#888] hover:text-white transition-colors",children:z.close}),t.celebName&&e.jsx("h2",{className:"text-white text-xl font-semibold m-0 pr-8",children:t.celebName}),M&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx(Ve,{content:Ge(t.contentType),children:e.jsx("span",{className:"text-[#666] flex",children:Ke(t.contentType)})}),e.jsx("span",{className:"text-[#aaa] text-[14px]",children:M})]})]}),e.jsx("div",{className:"px-6 py-4 border-t border-[#333]/60",children:e.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:y.map((k,c)=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[#666] text-xs uppercase tracking-wide block mb-1",children:k.label}),k.value]},c))})}),t.comment&&e.jsxs("div",{className:"px-6 py-4 border-t border-[#333]/60",children:[e.jsx("span",{className:"text-[#666] text-xs uppercase tracking-wide block mb-2",children:"Comment"}),e.jsx("p",{className:"text-[#ccc] text-sm whitespace-pre-wrap leading-relaxed m-0",children:t.comment})]}),t.status==="declined"&&t.declineReason&&e.jsxs("div",{className:"mx-6 mb-4 bg-red-500/10 border border-red-500/30 rounded p-4",children:[e.jsx("span",{className:"text-red-400 text-xs font-medium block mb-1.5",children:"Decline Reason"}),e.jsx("p",{className:"text-[#ccc] text-sm leading-relaxed m-0",children:t.declineReason})]}),t.status==="completed"&&t.completedLink&&e.jsxs("div",{className:"mx-6 mb-4 bg-green-500/10 border border-green-500/30 rounded p-4",children:[e.jsx("span",{className:"text-green-400 text-xs font-medium block mb-1.5",children:"Completed!"}),e.jsx("a",{href:t.completedLink,className:"text-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:"View on site →"})]}),e.jsxs("div",{className:"px-6 py-4 border-t border-[#333]/60 flex items-center gap-3 flex-wrap",children:[e.jsx(et,{requestId:t.id,voteCount:t.voteCount,onVote:o,voted:!!l[t.id]}),e.jsx("span",{className:"text-[#555] text-xs",children:"Vote to help us prioritize"}),N&&u&&t.status==="awaiting_moderation"&&e.jsxs("button",{onClick:()=>u(t),className:"ml-auto px-4 py-2 rounded border border-[#333] hover:border-[#555] text-white text-sm font-medium transition-colors flex items-center gap-2",children:[z.edit," Edit"]}),(i||x||p||v)&&e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[i&&t.status==="awaiting_moderation"&&e.jsx("button",{onClick:()=>i(t),className:"px-4 py-2 rounded border border-green-500/40 text-green-400 hover:bg-green-500/10 text-sm font-medium transition-colors",children:"Approve Request"}),p&&t.status==="in_progress"&&e.jsx("button",{onClick:()=>p(t),className:"px-4 py-2 rounded border border-blue-500/40 text-blue-400 hover:bg-blue-500/10 text-sm font-medium transition-colors",children:"Mark Completed"}),x&&(t.status==="awaiting_moderation"||t.status==="in_progress")&&e.jsx("button",{onClick:()=>x(t),className:"px-4 py-2 rounded border border-red-500/40 text-red-400 hover:bg-red-500/10 text-sm font-medium transition-colors",children:"Decline Request"}),v&&e.jsxs("button",{onClick:()=>v(t),className:"px-4 py-2 rounded border border-[#444] text-[#ccc] hover:border-[#666] hover:bg-white/5 text-sm font-medium transition-colors flex items-center gap-2",children:[z.edit," Edit"]})]})]})]})]})}function vt({user:t,onSubmit:a,editingRequest:o,onCancelEdit:b}){const u=we()||De()?ve()||"f":rt()?"m":"f",[i,x]=n.useState(o?.celebName||""),[p,v]=n.useState(o?.celebId||null),[l,M]=n.useState(o?.contentType||null),[w,T]=n.useState(o?.contentName||""),[N,y]=n.useState(o?.contentId||null),[k,c]=n.useState(o?.season||""),[E,R]=n.useState(o?.episode||""),[I,h]=n.useState(o?.timestamp||""),[j,C]=n.useState(o?.comment||""),[D,F]=n.useState(!1),[te,P]=n.useState("");n.useEffect(()=>{o&&(x(o.celebName||""),v(o.celebId||null),M(o.contentType||null),T(o.contentName||""),y(o.contentId||null),
1c(o.season||""),R(o.episode||""),h(o.timestamp||""),C(o.comment||""))},[o]);const $=d=>{l===d?(M(null),T(""),y(null),c(""),R(""),h("")):(M(d),T(""),y(null),c(""),R(""),h(""))},O=d=>{x(d),p&&v(null)},G=d=>{T(d),N&&y(null)},K=d=>{x(d.name||d.value||""),v(d.firebaseId||d.id||null)},W=d=>{T(d.name||d.value||""),y(d.movieId||d.seriesId||d.storyId||d.id||null)};if(!t)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[#888] mb-4 text-[14px]",children:"You need to be logged in to submit a request."}),e.jsx("a",{href:"/signin.html",className:"btn-primary-tw px-6 py-2.5 text-sm",children:"Log In"})]});const X=async d=>{if(d.preventDefault(),P(""),!i.trim()&&(!l||!w.trim())){P("Provide at least a celeb name or a content name.");return}if(l&&!w.trim()){P(`${l==="series"?"Series":l==="story"?"Story":"Movie"} name is required when content type is selected.`);return}if(!o&&!ft()){P(`You can only submit ${Oe} requests per day.`);return}F(!0);try{const m={celebName:i.trim()||null,comment:j.trim(),contentType:l||null,updatedAt:ie()};if(p&&p!=="freetext"&&(m.celebId=p),l&&(m.contentName=w.trim(),N&&N!=="freetext"&&(m.contentId=N),l==="series"&&(m.season=k.trim(),m.episode=E.trim()),(l==="movie"||l==="series")&&I.trim()&&(m.timestamp=I.trim())),!o){m.createdBy=t.uid,m.createdByName=t.displayName||t.email||"Anonymous",m.createdAt=ie(),m.voteCount=0,m.score=0,m.status="awaiting_moderation",m.site=Me();const U=ve();U&&(m.sexuality=U)}await a(m,o?.id),o||(jt(),x(""),v(null),M(null),T(""),y(null),c(""),R(""),h(""),C(""))}catch(m){P(m.message||"Failed to submit. Please try again.")}finally{F(!1)}},S=l==="series"?"series":l==="story"?"story":"movie";return e.jsxs("div",{children:[te&&e.jsxs("div",{className:"alert-bar mb-4 !bg-red-500/10 !border-red-500/30 !text-red-400",children:[e.jsx("div",{className:"flex-1",children:te}),e.jsx("button",{type:"button",onClick:()=>P(""),className:"alert-bar-close !text-red-400","aria-label":"Dismiss",children:"×"})]}),e.jsx("form",{onSubmit:X,children:e.jsxs("fieldset",{disabled:D,className:"border-none p-0 m-0 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Celeb Name (optional)"}),e.jsx(Re,{entityType:"celebrity",value:i,entityId:p,onChange:O,onSelect:K,onClear:()=>{x(""),v(null)},gender:u,isAzFans:we(),allowFreeText:!0})]}),!De()&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Content (optional)"}),e.jsx("div",{className:"flex gap-2 mt-1",children:it.map(d=>e.jsxs("button",{type:"button",onClick:()=>$(d.value),className:`!flex !mb-0 items-center gap-1.5 px-3 py-1.5 rounded border cursor-pointer transition-colors text-[14px] font-semibold ${l===d.value?"border-primary bg-primary/10 text-primary":"border-[#333] text-[#888] hover:border-[#555] hover:text-white"}`,children:[z[d.icon]," ",d.label]},d.value))})]}),l==="story"&&e.jsx("p",{className:"text-[#666] text-sm leading-relaxed !mt-1",children:"A story covers real-world appearances, events, and candid moments. Think red carpet arrivals, award show outfits, paparazzi shots, vacation sightings, or any public appearance."}),l&&e.jsx("div",{children:e.jsx(Re,{entityType:S,value:w,entityId:N,onChange:G,onSelect:W,onClear:()=>{T(""),y(null)},gender:u,isAzFans:we(),allowFreeText:!0})}),l==="series"&&e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Season (optional)"}),e.jsx("input",{type:"text",value:k,onChange:d=>c(d.target.value),placeholder:"e.g. 3",className:"form-input-dark",maxLength:10})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Episode (optional)"}),e.jsx("input",{type:"text",value:E,onChange:d=>R(d.target.value),placeholder:"e.g. 7",className:"form-input-dark",maxLength:10})]})]}),(l==="movie"||l==="series")&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Timestamp (optional)"}),e.jsx("input",{type:"text",value:I,onChange:d=>h(gt(d.target.value)),placeholder:"00:00:00",className:"form-input-dark placeholder-[#444]",maxLength:8})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[14px] mb-2",children:"Comment (optional)"}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex absolute left-3 top-3 text-[#555] pointer-events-none",children:z.comment}),e.jsx("textarea",{value:j,onChange:d=>C(d.target.value),placeholder:"Any extra context or details...",className:"form-input-dark !pl-[35px] pr-3 resize-none h-24",maxLength:1e3})]})]}),e.jsxs("div",{className:"flex gap-3 pt-1",children:[o&&e.jsx("button",{type:"button",onClick:b,className:"flex-1 py-2.5 rounded border border-[#333] hover:border-[#555] text-white text-sm font-medium transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:D,className:`btn-primary-tw flex-1 py-3 text-base ${D?"opacity-50 cursor-not-allowed":""}`,children:D?"Submitting...":o?"Save Changes":"Submit Request"})]})]})})]})}function Nt({onToast:t,onVote:a,votedMap:o,currentUser:b,syncVotes:u}){const[i,x]=n.useState([]),[p,v]=n.useState(!0),[l,M]=n.useState("awaiting_moderation"),[w,T]=n.useState(1),[N,y]=n.useState(""),[k,c]=n.useState(""),[E,R]=n.useState("createdAt"),[I,h]=n.useState("desc"),[j,C]=n.useState(null),[D,F]=n.useState(null),[te,P]=n.useState(""),[$,O]=n.useState(null),[G,K]=n.useState(""),[W,X]=n.useState(null),[S,d]=n.useState("awaiting_moderation"),[m,U]=n.useState(""),[se,Y]=n.useState(""),[oe,H]=n.useState(null),J=n.useCallback(async()=>{v(!0);try{const s=Ue.includes(E),f=s?"voteCount":E,_=s?"desc":I;let Q;l==="all"?Q=ge(be(Z,q),fe(f,_)):Q=ge(be(Z,q),ee("status","==",l),fe(f,_));let de=(await Le(Q)).docs.map(V=>({id:V.id,...V.data()}));s&&(de=Ye(de,E,I)),x(de),T(1),u&&await u(de.map(V=>V.id))}catch(s){console.error("Mod fetch failed:",s)}finally{v(!1)}},[l,E,I,u]);n.useEffect(()=>{J()},[J]),n.useEffect(()=>{const s=setTimeout(()=>{c(N),T(1)},300);return()=>clearTimeout(s)},[N]);const B=n.useMemo(()=>
1{if(!k.trim())return i;const s=k.toLowerCase().trim();return i.filter(f=>[f.celebName,f.contentName,f.comment,f.createdByName].filter(Boolean).join(" ").toLowerCase().includes(s))},[i,k]),ne=Math.max(1,Math.ceil(B.length/Ce)),ae=n.useMemo(()=>{const s=(w-1)*Ce;return B.slice(s,s+Ce)},[B,w]),ye=n.useCallback((s,f)=>{R(s),h(f)},[]),ce=async s=>{if(!s)return;const f=l==="awaiting_moderation"&&i.length===1&&i[0].id===s.id;C(s.id);try{await me(pe(Z,q,s.id),{status:"in_progress",updatedAt:ie()}),t("Request approved · now in progress"),H(null),f?M("in_progress"):J()}catch(_){console.error("Approve failed:",_),t("Failed to approve")}finally{C(null)}},le=s=>{H(null),F(s.id),P("")},Ne=async()=>{if(D){C(D);try{await me(pe(Z,q,D),{status:"declined",declineReason:te.trim(),updatedAt:ie()}),t("Request declined"),F(null),P(""),J()}catch(s){console.error("Decline failed:",s),t("Failed to decline")}finally{C(null)}}},r=s=>{H(null),O(s.id),K("")},g=async()=>{if(!(!$||!G.trim())){C($);try{await me(pe(Z,q,$),{status:"completed",completedLink:G.trim(),updatedAt:ie()}),t("Request marked completed"),O(null),K(""),J()}catch(s){console.error("Complete failed:",s),t("Failed to complete")}finally{C(null)}}},L=s=>{H(null),X(s.id),d(s.status||"awaiting_moderation"),U(s.completedLink||""),Y(s.declineReason||"")},A=async()=>{if(W&&!(S==="completed"&&!m.trim())){C(W);try{await me(pe(Z,q,W),{status:S,completedLink:S==="completed"?m.trim():null,declineReason:S==="declined"?se.trim():null,updatedAt:ie()}),t("Request updated"),X(null),J()}catch(s){console.error("Edit failed:",s),t("Failed to update")}finally{C(null)}}};return e.jsxs("div",{children:[D&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>F(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/70"}),e.jsxs("div",{className:"relative bg-[#1a1a1a] rounded border border-[#333] max-w-md w-full p-5",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{className:"text-white font-semibold mb-3",children:"Decline Reason"}),e.jsx("textarea",{value:te,onChange:s=>P(s.target.value),placeholder:"Why is this request being declined?",className:"form-input-dark resize-none h-24 mb-3",maxLength:500}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>F(null),className:"flex-1 py-2 rounded border border-[#333] hover:border-[#555] text-white text-sm font-medium transition-colors",children:"Cancel"}),e.jsx("button",{onClick:Ne,disabled:j===D,className:`btn-primary-tw flex-1 py-2 text-sm ${j===D?"opacity-50 cursor-not-allowed":""}`,children:j===D?"Declining...":"Decline Request"})]})]})]}),$&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>O(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/70"}),e.jsxs("div",{className:"relative bg-[#1a1a1a] rounded border border-[#333] max-w-md w-full p-5",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{className:"text-white font-semibold mb-3",children:"Mark as Completed"}),e.jsx("label",{className:"text-[14px] mb-2 block text-[#888]",children:"Link to the published content"}),e.jsx("input",{type:"url",value:G,onChange:s=>K(s.target.value),placeholder:"https://www.aznude.com/...",className:"form-input-dark mb-3"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>O(null),className:"flex-1 py-2 rounded border border-[#333] hover:border-[#555] text-white text-sm font-medium transition-colors",children:"Cancel"}),e.jsx("button",{onClick:g,disabled:j===$||!G.trim(),className:`btn-primary-tw flex-1 py-2 text-sm ${j===$||!G.trim()?"opacity-50 cursor-not-allowed":""}`,children:j===$?"Saving...":"Mark Completed"})]})]})]}),W&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:()=>X(null),children:[e.jsx("div",{className:"absolute inset-0 bg-black/70"}),e.jsxs("div",{className:"relative bg-[#1a1a1a] rounded border border-[#333] max-w-md w-full p-5",onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{className:"text-white font-semibold mb-3",children:"Edit Request"}),e.jsx("label",{className:"text-[14px] mb-2 block text-[#888]",children:"Status"}),e.jsx("div",{className:"mb-3",children:e.jsx(Te,{value:S,onChange:d,options:Be})}),S==="completed"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"text-[14px] mb-2 block text-[#888]",children:"Link to the published content"}),e.jsx("input",{type:"url",value:m,onChange:s=>U(s.target.value),placeholder:"https://www.aznude.com/...",className:"form-input-dark mb-3"})]}),S==="declined"&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"text-[14px] mb-2 block text-[#888]",children:"Decline Reason"}),e.jsx("textarea",{value:se,onChange:s=>Y(s.target.value),placeholder:"Why is this request being declined?",className:"form-input-dark resize-none h-24 mb-3",maxLength:500})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>X(null),className:"flex-1 py-2 rounded border border-[#333] hover:border-[#555] text-white text-sm font-medium transition-colors",children:"Cancel"}),e.jsx("button",{onClick:A,disabled:j===W||S==="completed"&&!m.trim(),className:`btn-primary-tw flex-1 py-2 text-sm ${j===W||S==="completed"&&!m.trim()?"opacity-50 cursor-not-allowed":""}`,children:j===W?"Saving...":"Save Changes"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx("div",{className:"flex absolute left-3 top-1/2 -translate-y-1/2 text-[#555] pointer-events-none",children:z.search}),e.jsx("input",{type:"text",value:N,onChange:s=>y(s.target.value),placeholder:"Search by name, content, user...",className:"form-input-dark !pl-[35px] pr-3"})]}
1),e.jsx(Te,{value:l,onChange:M,options:[{value:"all",label:"All"},...Be],className:"ml-0"})]}),p?e.jsx(je,{requests:[],onVote:a,onClick:H,sortField:E,sortDir:I,onSort:ye,loading:!0,votedMap:o,onApprove:ce,onDecline:le,onComplete:r,onAdminEdit:L,busyId:j}):B.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-[#888] text-sm",children:k?"No requests matching your search.":`No ${l==="all"?"":Je(l).toLowerCase()+" "}requests.`})}):e.jsxs("div",{children:[e.jsxs("p",{className:"text-[#555] text-xs mb-2",children:[B.length," request",B.length!==1?"s":"",k&&B.length!==i.length?` (of ${i.length})`:""," ",ne>1?`· Page ${w} of ${ne}`:""]}),e.jsx(je,{requests:ae,onVote:a,onClick:H,sortField:E,sortDir:I,onSort:ye,votedMap:o,onApprove:ce,onDecline:le,onComplete:r,onAdminEdit:L,busyId:j}),ne>1&&e.jsx(We,{currentPage:w,totalPages:ne,onPageChange:T})]}),oe&&e.jsx(tt,{request:oe,onClose:()=>H(null),onVote:a,user:b,onApprove:ce,onDecline:le,onComplete:r,onAdminEdit:L,votedMap:o})]})}function Mt(){const[t,a]=n.useState(null),[o,b]=n.useState(!1),[u,i]=n.useState(()=>{try{return localStorage.getItem("az_is_admin")==="true"}catch{return!1}}),[x,p]=n.useState([]),[v,l]=n.useState(!0),[M,w]=n.useState(1),[T,N]=n.useState(1),[y,k]=n.useState([]),[c,E]=n.useState(!1),[R,I]=n.useState(!1),[h,j]=n.useState("active"),[C,D]=n.useState("all"),[F,te]=n.useState("voteCount"),[P,$]=n.useState("desc"),[O,G]=n.useState(""),[K,W]=n.useState(""),[X,S]=n.useState(null),[d,m]=n.useState(null),[U,se]=n.useState(""),[Y,oe]=n.useState({}),H=n.useRef(0);n.useLayoutEffect(()=>{const r=document.getElementById("requests-skeleton");r&&r.remove()},[]),n.useEffect(()=>{const r=st($e,async g=>{if(a(g),b(!0),g)try{const A=(await at(ot(lt,`users/${g.uid}/isAdmin`))).val()===!0;i(A);try{localStorage.setItem("az_is_admin",A?"true":"false")}catch{}}catch{i(!1)}else{i(!1);try{localStorage.removeItem("az_is_admin")}catch{}}});return()=>r()},[]),n.useEffect(()=>{const r=setTimeout(()=>W(O),300);return()=>clearTimeout(r)},[O]);const J=n.useCallback(async r=>{if(r.length)try{const g={"Content-Type":"application/json",...await ze()},L=await fetch(`${Fe}/status/batch`,{method:"POST",headers:g,body:JSON.stringify({requestIds:r})});if(!L.ok)return;const A=await L.json();A.votes&&oe(s=>({...s,...A.votes}))}catch{}},[]),B=n.useCallback(async(r=1)=>{l(!0);try{const g=be(Z,q),L=K.trim().length>0,A=[];A.push(ee("site","==",Me()));const s=ve();s&&A.push(ee("sexuality","==",s));const f=h==="completed"?xt:ut;A.push(ee("status","in",f)),(C==="movie"||C==="series"||C==="story")&&A.push(ee("contentType","==",C));const _=Ue.includes(F),Q=_?fe("voteCount","desc"):fe(F,P),Ee=ge(g,...A,Q);let V=(await Le(Ee)).docs.map(re=>({id:re.id,...re.data()}));if(L){const re=K.toLowerCase().trim();V=V.filter(ke=>
1[ke.celebName,ke.contentName,ke.comment].filter(Boolean).join(" ").toLowerCase().includes(re))}_&&(V=Ye(V,F,P));const Ae=Math.max(1,Math.ceil(V.length/Se)),_e=Math.min(r,Ae),Ie=(_e-1)*Se,Pe=V.slice(Ie,Ie+Se);N(Ae),p(Pe),w(_e),await J(Pe.map(re=>re.id))}catch(g){console.error("Failed to fetch requests:",g)}finally{l(!1)}},[C,F,P,K,h]);n.useEffect(()=>{B(1)},[B]);const ne=n.useCallback(async()=>{if(t){E(!0);try{const r=[ee("createdBy","==",t.uid),ee("site","==",Me())],g=ve();g&&r.push(ee("sexuality","==",g));const L=ge(be(Z,q),...r,fe("createdAt","desc")),s=(await Le(L)).docs.map(f=>({id:f.id,...f.data()}));k(s),await J(s.map(f=>f.id)),I(!0)}catch(r){console.error("Failed to fetch my requests:",r)}finally{E(!1)}}},[t]);n.useEffect(()=>{t&&!R&&ne()},[t,R,ne]),n.useEffect(()=>{if(!U)return;const r=setTimeout(()=>se(""),3e3);return()=>clearTimeout(r)},[U]);const ae=n.useCallback(r=>{const g=!!Y[r],L=g?-1:1;H.current++,oe(s=>({...s,[r]:!g}));const A=s=>s.map(f=>f.id===r?{...f,voteCount:(f.voteCount||0)+L}:f);p(A),k(A),S(s=>s&&s.id===r?{...s,voteCount:(s.voteCount||0)+L}:s),ze().then(s=>fetch(`${Fe}/${r}`,{method:"POST",headers:{"Content-Type":"application/json",...s}})).then(s=>{if(!s.ok)throw new Error(`Vote API ${s.status}`)}).catch(s=>{console.error("[Vote] FAILED:",s),oe(_=>({..._,[r]:g}));const f=_=>_.map(Q=>Q.id===r?{...Q,voteCount:(Q.voteCount||0)-L}:Q);p(f),k(f),S(_=>_&&_.id===r?{..._,voteCount:(_.voteCount||0)-L}:_)}).finally(()=>{H.current--})},[Y]),ye=n.useCallback(async(r,g)=>{g?(await me(pe(Z,q,g),r),m(null),j("my"),se("Request updated!")):(await nt(be(Z,q),r),j("my"),se("Request submitted! It will be visible once approved by our team.")),B(1),t&&I(!1)},[B,t]),ce=n.useCallback(r=>{S(null),m(r),j("submit")},[]),le=n.useCallback((r,g)=>{te(r),$(g)},[]),Ne=r=>e.jsx("div",{className:"space-y-2",children:Array.from({length:r}).map((g,L)=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded border border-[#333] animate-pulse",children:[e.jsx("div",{className:"w-[48px] h-[48px] rounded bg-[#333]"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 rounded bg-[#333] mb-2",style:{width:`${30+L%3*15}%`}}),e.jsx("div",{className:"h-3 rounded bg-[#333] w-[20%]"})]})]},L))});return e.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 mt-6",children:[U&&e.jsx("div",{className:"fixed top-4 right-4 z-[60] bg-green-500/90 text-white px-4 py-2.5 rounded text-sm font-medium shadow-lg",children:U}),e.jsx("h1",{className:"text-[22px] font-semibold mb-1",children:"Content Requests"}),e.jsx("p",{className:"text-[#888] text-sm mb-4",children:"Request a celeb, movie, series, or story to be added. Vote on requests to help us prioritize."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[e.jsx(xe,{active:h==="active",onClick:()=>{j("active"),m(null),w(1),N(1),p([])},children:"Active Requests"}),e.jsx(xe,{active:h==="completed",onClick:()=>{j("completed"),m(null),w(1),N(1),p([])},children:"Completed Requests"}),t&&(y.length>0||h==="my")&&e.jsx(xe,{active:h==="my",onClick:()=>{j("my"),m(null)},children:"My Requests"}),e.jsx(xe,{active:h==="submit",onClick:()=>j("submit"),children:"Submit Request"}),u&&e.jsxs(xe,{active:h==="mod",onClick:()=>j("mod"),children:[z.shield," Moderation"]})]}),h==="submit"&&e.jsx(vt,{user:t,onSubmit:ye,editingRequest:d,onCancelEdit:()=>{m(null),j("active")}}),(h==="active"||h==="completed")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-4",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx("div",{className:"flex absolute left-3 top-1/2 -translate-y-1/2 text-[#555] pointer-events-none",children:z.search}),e.jsx("input",{type:"text",value:O,onChange:r=>G(r.target.value),placeholder:"Search requests...",className:"form-input-dark !pl-[35px] pr-3"})]}),e.jsx(Te,{value:C,onChange:D,options:ct,label:"Type"})]}),v?e.jsx(je,{requests:[],onVote:ae,onClick:S,sortField:F,sortDir:P,onSort:le,loading:!0,votedMap:Y}):x.length===0?e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-[#888] text-sm",children:"No requests found."})}):e.jsxs("div",{children:[e.jsx(je,{requests:x,onVote:ae,onClick:S,sortField:F,sortDir:P,onSort:le,votedMap:Y}),e.jsx(We,{currentPage:M,totalPages:T,onPageChange:r=>B(r)})]})]}),h==="my"&&t&&e.jsx(e.Fragment,{children:c?Ne(3):y.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-[#888] text-sm",children:"You haven't submitted any requests yet."}),e.jsx("button",{onClick:()=>j("submit"),className:"btn-primary-tw mt-3 px-5 py-2 text-sm",children:"Submit Your First Request"})]}):e.jsxs("div",{children:[e.jsxs("p",{className:"text-[#555] text-xs mb-2",children:[y.length," request",y.length!==1?"s":""]}),e.jsx(je,{requests:y,onVote:ae,onClick:S,sortField:null,sortDir:null,onSort:null,votedMap:Y})]})}),h==="mod"&&u&&e.jsx(Nt,{onToast:se,onVote:ae,votedMap:Y,currentUser:t,syncVotes:J}),X&&e.jsx(tt,{request:X,onClose:()=>S(null),onVote:ae,user:t,onEdit:ce,votedMap:Y})]})}
1export{Mt 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.