1import{r as o,j as t,b as ge,d as ye,g as Oe,N as Be,c as Xe,p as Mt,o as Tt,a as et}from"../app.js";import{s as Ot}from"./authActions.js";import{S as F}from"./sentry.js";import{f as Me,g as Bt,u as _t,i as $t}from"./helpers.js";import{r as Pt,s as qt,g as zt}from"./firebaseStorage.js";import{E as Te}from"./EntityAutocomplete.js";import{F as Wt,C as Yt,a as Dt,T as Ht,A as be,u as Gt}from"./AddEntityModal.js";import{L as Jt,s as Kt,p as Vt,l as Zt}from"./Lightbox.js";import"./profileHelpers.js";const Qt=/permission[_ ]denied/i;function Xt(m){const r=m?.files;if(!r)return[];const p=Array.isArray(r)?r:Object.values(r),u=[],O=new Set;for(const C of p){const w=typeof C=="string"?C:C?.fileId;typeof w=="string"&&w&&!O.has(w)&&(O.add(w),u.push(w))}return u}function es(m){return m?.code==="PERMISSION_DENIED"||Qt.test(String(m?.message||""))}async function ts(m,r){return Promise.all(m.map(async p=>{try{const u=await r(p);return u?.exists()?{id:p,status:"ok",record:u.val()}:{id:p,status:"missing"}}catch(u){return{id:p,status:es(u)?"denied":"error",error:u}}}))}function ss(m){return m.map((r,p)=>{const u=r.status==="ok"&&r.record?r.record:{},O=typeof u.downloadURL=="string"&&u.downloadURL?u.downloadURL:null;let C="unreadable";return O?C="ok":(r.status==="ok"||r.status==="missing")&&(C="archived"),{id:r.id,number:p+1,state:C,available:C==="ok",downloadURL:O,fileType:u.fileType||null,fileSize:u.fileSize||null}})}function ns(m){const r=m.filter(p=>p.status==="denied"||p.status==="error");return r.length===0?null:{error:r[0].error,status:r.every(p=>p.status===r[0].status)?r[0].status:"mixed",fileIds:r.map(p=>p.id),total:m.length}}function rs(m,r){return m.state==="unreadable"?"Couldnât load · try reloading":m.state==="archived"||r?"Archived · no preview":"No preview"}function as({siteCount:m,fileCount:r,unpreviewableCount:p}){return m===0?null:r===0?"This upload doesnât list any original files. This is what the site shows for it:":p>0?"Some original files canât be previewed here. This is what the site shows for this upload:":null}function is(m,r){return m.length===0?null:m.filter(u=>!u.markedForRemoval).length===0&&r.length===0?"You cannot remove all files without adding new ones.":null}function os({user:m,uploadData:r,uploadFiles:p,siteMedia:u=[],siteTitle:O="",varValues:C,isAzFans:w=!1,keepExistingEdits:we=!1}){const G=e=>e&&(e.includes("/")||e.startsWith("http")),X=e=>e&&(e.startsWith("video/")||e.includes("video")),ie=e=>e&&(e.startsWith("image/")||e.includes("image")),E=r.gender==="male"?"m":"f",h=r.type||"movie",J=(r.celebName||"").split("|").filter(Boolean),A=(r.celebIds||"").split("|").filter(Boolean),N=(r.appearance||"").split("|"),oe=()=>J.map((e,s)=>{const n=A[s]||"";return{id:`existing-${s}-${Date.now()}`,name:e==="az-undetermined"?"Unknown Celebrity":e,firebaseId:n,thumb:G(n)?n:"",appearance:N[s]&&N[s]!=="-1"?N[s]:"",isOriginal:!0,isUnknown:e==="az-undetermined"}}),ve=()=>{if(h==="movie"){const e=r.movieId||"";return{name:r.movieName||"",id:e,thumb:G(e)?e:"",isUnknown:r.movieName==="az-undetermined"}}if(h==="series"){const e=r.seriesId||"";return{name:r.seriesName||"",id:e,thumb:G(e)?e:"",isUnknown:r.seriesName==="az-undetermined"}}if(h==="story"){const e=r.storyId||"";return{name:r.storyName||"",id:e,thumb:G(e)?e:"",isUnknown:!1}}return{name:"",id:"",thumb:"",isUnknown:!1}},_=r.categories?r.categories.split("|").map(e=>e.trim()).filter(Boolean):[],W=r.tags?r.tags.split(",").map(e=>e.trim()).filter(Boolean):[],d=we&&r.editRequest?.changes||null,[f,Y]=o.useState(()=>{const e=d?.filesRemoved?.map(s=>s.fileId)||[];return p.map(s=>({...s,markedForRemoval:e.includes(s.id),replacementFile:null,replacementPreview:null,replacementProgress:0}))}),[v,B]=o.useState([]),[$,le]=o.useState(()=>new Set),U=e=>le(s=>s.has(e)?s:new Set(s).add(e)),M=e=>e.available&&!$.has(e.id)&&(ie(e.fileType)||X(e.fileType)),[T,de]=o.useState(()=>new Set),[k,je]=o.useState(null),Ne=o.useMemo(()=>f.filter(M),[f,$]),tt=o.useMemo(()=>Ne.map(e=>X(e.fileType)?{mp4:e.downloadURL,thumbnail:e.downloadURL}:{src:e.downloadURL,thumbnail:e.downloadURL}),[Ne]),st=e=>{const s=Ne.findIndex(n=>n.id===e);s!==-1&&je({items:tt,start:s})},nt=e=>je({...Kt(u,T,e),title:O,status:"published"}),_e=as({siteCount:u.length-T.size,fileCount:f.length,unpreviewableCount:f.filter(e=>!M(e)).length}),[I,ce]=o.useState(()=>{const e=oe();return d?.celebsModified&&d.celebsModified.forEach(s=>{const n=e.findIndex(a=>a.firebaseId===s.originalId);n!==-1&&s.appearanceChanged&&(e[n]={...e[n],appearance:s.newAppearance})}),e}),[D,ke]=o.useState(()=>{if(!d?.celebsRemoved?.length)return new Set;const e=d.celebsRemoved.map(n=>n.id),s=new Set;return A.forEach((n,a)=>{e.includes(n)&&s.add(a)}),s}),[K,P]=o.useState(null),[q,V]=o.useState(()=>d?.celebsAdded?.length?d.celebsAdded.map(e=>({id:`restored-${Date.now()}-${Math.random()}`,name:e.name,firebaseId:e.id,appearance:e.appearance||"",thumb:"",disabled:!0})):[]),[rt,ee]=o.useState(!1),[S,at]=o.useState(d?.typeChanged?d.typeChanged.to:h),[j]=o.useState(ve),[te,Z]=o.use
1State(!!d?.entityRemoved),[y,z]=o.useState(()=>d?.entityAdded?{name:d.entityAdded.name,id:d.entityAdded.id,yor:d.entityAdded.yor||"",thumb:""}:{name:"",id:"",yor:"",thumb:""}),it=e=>{at(e),e!==h?(Z(!0),z({name:"",id:"",yor:"",thumb:""})):(Z(!1),z({name:"",id:"",yor:"",thumb:""}))},[me,ot]=o.useState(()=>{if(!d?.categoriesAdded&&!d?.categoriesRemoved)return _;let e=[..._];return d.categoriesRemoved&&(e=e.filter(s=>!d.categoriesRemoved.includes(s))),d.categoriesAdded&&(e=[...e,...d.categoriesAdded.filter(s=>!e.includes(s))]),e}),[pe,lt]=o.useState(()=>{if(!d?.tagsAdded&&!d?.tagsRemoved)return W;let e=[...W];return d.tagsRemoved&&(e=e.filter(s=>!d.tagsRemoved.includes(s))),d.tagsAdded&&(e=[...e,...d.tagsAdded.filter(s=>!e.includes(s))]),e}),[b,dt]=o.useState(d?.genderChanged?d.genderChanged.to==="male"?"m":"f":E),ct=e=>{e!==b&&(dt(e),e===E?(ke(new Set),ce(oe()),V([]),P(null),ee(!1),Z(!1),z({name:"",id:"",yor:"",thumb:""})):(ke(new Set(I.map((s,n)=>n))),V([]),P(null),ee(!1),Z(!0),z({name:"",id:"",yor:"",thumb:""})))}
1,[mt,H]=o.useState(!1),[ls,Q]=o.useState(null),[$e,Ce]=o.useState(null),[Pe,qe]=o.useState(null),[pt,Se]=o.useState(!1),[ut,Re]=o.useState(!1),[ht,Ie]=o.useState(!1),[Ee,ze]=o.useState(!1),[We,se]=o.useState(""),[Ye,ds]=o.useState(""),De=o.useRef(null),Le=e=>{se(e),setTimeout(()=>{De.current?.scrollIntoView({behavior:"smooth",block:"center"})},100)},He=!w&&S!=="story",xt=e=>{Y(s=>s.map(n=>n.id===e?{...n,markedForRemoval:!n.markedForRemoval}:n))},ft=e=>{const s=document.createElement("input");s.type="file",s.accept="video/*",s.onchange=n=>{const a=n.target.files[0];if(!a)return;const l=Gt(a,{videoOnly:!0});if(l){Le(l);return}const c=URL.createObjectURL(a);Y(x=>x.map(g=>g.id===e?{...g,replacementFile:a,replacementPreview:c,markedForRemoval:!1}:g))},s.click()},bt=e=>{Y(s=>s.map(n=>(n.id===e&&n.replacementPreview&&URL.revokeObjectURL(n.replacementPreview),n.id===e?{...n,replacementFile:null,replacementPreview:null,replacementProgress:0}:n)))},gt=e=>{ke(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n}),K===e&&P(null)},yt=(e,s)=>{ce(n=>{const a=[...n];return a[e]={...a[e],appearance:s},a})},wt=e=>e&&e.startsWith("-")&&!e.includes("/"),vt=async e=>{try{const s=b==="m"?"m":"f",n=new URLSearchParams({q:e.trim(),type:"celebs",gender:s});let a={};try{if(typeof getSearchTokenFor=="function"&&typeof PRIMARY_BASE<"u"){const g=await getSearchTokenFor(PRIMARY_BASE);a={"x-st":g.token,...g.sid?{"x-sid":g.sid}:{}}}}catch{}const l=await fetch(`${PRIMARY_BASE}/exp/fetch-for-upload?${n}`,{method:"GET",headers:{...a},credentials:typeof IS_LOCAL<"u"&&IS_LOCAL?"omit":"include"});if(!l.ok)return null;const c=await l.json();return!Array.isArray(c)||c.length===0?null:c.find(g=>g.text?.toLowerCase()===e.toLowerCase())||c[0]}catch(s){return F.captureException(s,{tags:{area:"edit-upload",op:"fetchCelebFromSearch"}}),null}},jt=async e=>{const s=I[e];if(!(!s||!s.firebaseId)){qe(e);try{let n=null;if(wt(s.firebaseId)){const a=ge(ye),l=await Oe(Be(a,`celebs/${s.firebaseId}`));l.exists()&&(n=l.val())}else{const a=await vt(s.name);if(a){const l=a.dob?new Date(a.dob):null,c=l?`${String(l.getMonth()+1).padStart(2,"0")}/${String(l.getDate()).padStart(2,"0")}/${l.getFullYear()}`:"";n={name:a.text||s.name,dateOfBirth:c,photoURL:s.thumb||"",country:a.country||"",imdbUrl:"",socials:[],shoeSize:"",_fromSearch:!0}}}n?(n._firebaseId=s.firebaseId,n._appearance=s.appearance,n._celebIndex=e,Ce(n),P(e),H(!0)):se("Could not load celebrity details. The record may not exist.")}catch(n){F.captureException(n,{tags:{area:"edit-upload",op:"fetchCelebRecord"},extra:{firebaseId:s.firebaseId}}),se("Failed to load celebrity details. Please try again.")}finally{qe(null)}}},Nt=e=>{const s=K;s!==null&&(ce(n=>{const a=[...n];return a[s]={...a[s],name:e.name,firebaseId:e.firebaseId,thumb:e.thumb||a[s].thumb,appearance:e.appearance||a[s].appearance,isUnknown:!1,detailsEdited:!0,_editedRecord:e._editedRecord,_originalRecord:e._originalRecord},a}),H(!1),Ce(null),P(null),Q(null))},Ge=(e,s)=>{ce(n=>{const a=[...n];return a[e]={...a[e],name:s.name,firebaseId:s.firebaseId||s.id,thumb:s.thumb||"",appearance:a[e].appearance,isUnknown:!1,swapped:!0},a}),P(null)},kt=e=>{K!==null&&Ge(K,e),H(!1),Q(null)},Ct=e=>{V(s=>s.some(n=>n.firebaseId===e.firebaseId)?s:[...s,{...e,appearance:""}]),ee(!1)},St=e=>{V(s=>[...s,{...e,appearance:""}]),H(!1),Q(null)},Rt=e=>{V(s=>s.filter((n,a)=>a!==e))},It=(e,s)=>{V(n=>{const a=[...n];return a[e]={...a[e],appearance:s},a})},Et=e=>{z({name:e.name,id:e.id,yor:e.yor||"",thumb:e.thumb||""})},Ue=e=>{z({name:e.name,id:e.id,yor:e.yor||"",thumb:e.thumb||""}),Se(!1),Re(!1),Ie(!1)},Fe=()=>{z({name:"",id:"",yor:"",thumb:""})},Lt=()=>{const e=f.some(L=>L.markedForRemoval),s=f.some(L=>L.replacementFile),n=v.length>0,a=D.size>0,l=q.length>0,c=I.some(L=>L.swapped),x=I.some(L=>L.detailsEdited),g=I.some((L,ae)=>{const Ae=N[ae]&&N[ae]!=="-1"?N[ae]:"";return L.appearance!==Ae}),ne=te||!!y.id,re=S!==h,ue=b!==E,he=JSON.stringify([...me].sort())!==JSON.stringify([..._].sort()),xe=JSON.stringify([...pe].sort())!==JSON.stringify([...W].sort());return e||s||n||a||l||c||g||x||ne||re||ue||he||xe},Ut=async e=>{e.preventDefault(),ze(!0),se("");try{if(F.addBreadcrumb({category:"edit-upload",message:"Edit request submit started",level:"info",data:{uploadId:r.id}}),!Lt())throw new Error("No changes detected. Modify something before submitting.");const s=is(f,v);if(s)throw new Error(s);const n=I.filter((i,R)=>!D.has(R)),a=I.some(i=>i.isUnknown);if(n.length===0&&q.length===0&&!a)throw new Error("At least one celebrity must remain on the upload.");let l=[];v.length>0&&(l=await Ft(v));let c=[];for(const i of f.filter(R=>R.replacementFile)){const R=await Je(i.replacementFile,r.id);c.push({originalFileId:i.id,originalDownloadURL:i.downloadURL,originalFileType:i.fileType,newFileId:R.fileId,newDownloadURL:R.downloadURL,newFileType:i.replacementFile.type,newFileSize:Me(i.replacementFile.size)})}const x={},g=f.filter(i=>i.markedForRemoval&&!i.replacementFile).map(i=>({fileId:i.id,downloadURL:i.downloadURL,fileType:i.fileType}));g.length>0&&(x.filesRemoved=g),l.length>0&&(x.filesAdded=l),c.length>0&&(x.filesReplaced=c);const ne=[];D.forEach(i=>
1{I[i]&&ne.push({name:J[i],id:A[i]})}),ne.length>0&&(x.celebsRemoved=ne),q.length>0&&(x.celebsAdded=q.map(i=>({name:i.name,id:i.firebaseId,appearance:i.appearance||""})));const re=[];I.forEach((i,R)=>{if(D.has(R))return;const Ke=N[R]&&N[R]!=="-1"?N[R]:"",Ve=i.swapped,Ze=i.appearance!==Ke,Qe=i.detailsEdited;if(Ve||Ze||Qe){const fe={originalName:J[R],originalId:A[R],newName:i.name,newId:i.firebaseId,newAppearance:i.appearance||"",...Ve?{swapped:!0}:{},...Ze?{appearanceChanged:!0,originalAppearance:Ke}:{}};Qe&&i._editedRecord&&i._originalRecord&&(fe.detailsEdited=!0,fe.editedRecord=i._editedRecord,fe.originalRecord={name:i._originalRecord.name,dateOfBirth:i._originalRecord.dateOfBirth,country:i._originalRecord.country,photoURL:i._originalRecord.photoURL,imdbUrl:i._originalRecord.imdbUrl,socials:i._originalRecord.socials,shoeSize:i._originalRecord.shoeSize}),re.push(fe)}}),re.length>0&&(x.celebsModified=re),b!==E&&(x.genderChanged={from:E==="m"?"male":"female",to:b==="m"?"male":"female"}),S!==h&&(x.typeChanged={from:h,to:S}),te&&(x.entityRemoved={type:h,name:j.name,id:j.id}),y.id&&(x.entityAdded={type:S,name:y.name,id:y.id,yor:y.yor});const ue=me.filter(i=>!_.includes(i)),he=_.filter(i=>!me.includes(i));ue.length>0&&(x.categoriesAdded=ue),he.length>0&&(x.categoriesRemoved=he);const xe=pe.filter(i=>!W.includes(i)),L=W.filter(i=>!pe.includes(i));xe.length>0&&(x.tagsAdded=xe),L.length>0&&(x.tagsRemoved=L);const ae=await Bt(),Ae={createdOn:Date.now(),status:"pending",ip:ae,original:{celebNames:r.celebName||"",celebIds:r.celebIds||"",appearances:r.appearance||"",type:h,entityName:j.name,entityId:j.id,categories:r.categories||"",tags:r.tags||"",website:r.website||"",gender:r.gender||"",genderShort:E},changes:x},At=ge(ye,`uploads/${r.id}/editRequest`);await Xe(At,Ae),F.addBreadcrumb({category:"edit-upload",message:"Edit request saved",level:"info",data:{uploadId:r.id}}),window.location.href="/profile.html#edit-requests"}catch(s){F.captureException(s,{tags:{area:"edit-upload",op:"submit"},extra:{uploadId:r.id}}),Le(s.message),ze(!1)}},Je=async(e,s)=>{const a=`Uploads/${`${Date.now()}-${e.name}`}`,l=Pt(qt,a);await _t(l,e,{contentType:e.type});const c=await zt(l),x=ge(ye,"files"),g=Mt(x);return await Xe(g,{uploadedBy:m.uid,downloadURL:c,createdOn:Date.now(),uploadId:s,fileType:e.type,fileSize:Me(e.size),fileURL:a}),{fileId:g.key,downloadURL:c,fileType:e.type,fileSize:Me(e.size)}},Ft=async e=>{const s=[];for(const n of e){const a=await Je(n.file,r.id);s.push(a),B(l=>l.map(c=>c.id===n.id?{...c,isDone:!0,progress:100}:c))}return s};return Ye?t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:[t.jsx("div",{className:"alert-bar !bg-green-500/10 !border-green-500/30 !text-green-400 mb-6",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("svg",{className:"inline-block mr-2 align-middle",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),t.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),Ye]})}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-primary-tw inline-block py-2.5 px-6 text-sm",children:"Back to My Uploads"})]}):t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 pb-10",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("h1",{className:"text-[22px] font-semibold",children:"Edit Upload"}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm",children:"â Back"})]}),t.jsx("p",{className:"text-[#888] text-sm mb-5",children:"Make your changes below. All edits are submitted as a request and will be reviewed within 72 hours."}),We&&t.jsxs("div",{ref:De,className:"alert-bar mb-5 !bg-red-500/10 !border-red-500/30 !text-red-400",tabIndex:"0",children:[t.jsx("div",{className:"flex-1",children:We}),t.jsx("button",{type:"button",onClick:()=>se(""),className:"alert-bar-close !text-red-400","aria-label":"Dismiss",children:"Ã"})]}),t.jsx("form",{onSubmit:Ut,onKeyDown:e=>e.key==="Enter"&&e.preventDefault(),children:t.jsxs("fieldset",{disabled:Ee,className:"border-none p-0 m-0 space-y-6",children:[!w&&t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{d:"M12 8v8"}),t.jsx("path",{d:"M8 12h8"})]}),"Gender"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:[{value:"f",label:"Female"},{value:"m",label:"Male"}].map(e=>t.jsxs("label",{className:`inline-flex items-center gap-2 px-3 py-1.5 rounded border cursor-pointer transition-colors text-[15px] font-semibold ${b===e.value?"border-primary bg-primary/10 text-primary":"border-[#333] text-[#888] hover:border-[#555] hover:text-white"}`,children:[t.jsx("input",{className:"hidden",type:"radio",value:e.value,checked:b===e.value,onChange:()=>ct(e.value)}),e.label]},e.value))}),b!==E&&t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsxs("p",{className:"text-primary text-[12px] font-semibold",children:["Changing from ",E==="m"?"male":"female"," to ",b==="m"?"male":"female"]}),t.jsx("span",{className:"text-[11px] text-[#888]",children:"All celebs, entities, and categories will be reset"})]})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Current Files"]}),f.length===0?t.jsx("p",{className:"text-[#888] text-sm",children:"No files found for this upload."}):t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-3",children:f.map(e=>{const s=X(e.fileType),n=ie(e.fileType),a=e.markedForRemoval,l=!!e.replacementFile;return t.jsxs("div",{className:`relative rounded border overflow-hidden transition-all ${a?"border-red-500/50 opacity-50 grayscale":l?"border-green-500/50":"border-[#333]"}`,children:[t.jsx("button",{type:"button",className:`w-full aspect-[4/3] bg-[#111] flex items-center justify-center overflow-hidden border-none p-0 ${M(e)?"cursor-pointer":"cursor-default"}`,onClick:()=>st(e.id),disabled:!M(e),children:l?t.jsx("div",{className:"w-full h-full flex items-center justify-center bg-green-500/5",children:t.jsx("span",{className:"text-green-400 text-xs font-semibold px-2 text-center",children:"Replacement queued"})}):M(e)?n?t.jsx("img",{src:e.downloadURL,alt:"Upload file",className:"w-full h-full object-cover",loading:"lazy",onError:()=>U(e.id)}):t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("video",{src:e.downloadURL,preload:"metadata",muted:!0,playsInl
1ine:!0,className:"w-full h-full object-cover",onLoadedData:c=>{c.target.currentTime=.1},onError:()=>U(e.id)}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 pointer-events-none",children:t.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"#fff",children:t.jsx("path",{d:"M8 5v14l11-7z"})})})]}):t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-2 text-center",children:[t.jsxs("span",{className:"text-[11px] font-semibold text-[#999]",children:["Original file ",e.number]}),t.jsx("span",{className:"text-[10px] text-[#666]",children:rs(e,$.has(e.id))})]})}),a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 pointer-events-none",children:t.jsx("span",{className:"text-red-400 text-xs font-bold uppercase tracking-wider",children:"Removed"})}),t.jsx("div",{className:"px-2 py-1.5 bg-[#1a1a1a] text-[10px] text-[#888] truncate",children:e.state==="ok"?t.jsxs(t.Fragment,{children:[e.fileType?.split("/")[1]||"file"," · ",e.fileSize||"?"]}):e.state==="unreadable"?"Unavailable":"Archived"}),t.jsxs("div",{className:"flex border-t border-[#333]",children:[t.jsx("button",{type:"button",className:`flex-1 py-1.5 text-[11px] font-semibold transition-colors cursor-pointer border-none ${a?"bg-[#222] text-green-400 hover:bg-green-500/10":"bg-[#222] text-red-400 hover:bg-red-500/10"}`,onClick:()=>xt(e.id),children:a?"Undo":"Remove"}),s&&!a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px bg-[#333]"}),l?t.jsx("button",{type:"button",className:"flex-1 py-1.5 text-[11px] font-semibold bg-[#222] text-[#888] hover:bg-[#2a2a2a] transition-colors cursor-pointer border-none",onClick:()=>bt(e.id),children:"Cancel"}):t.jsx("button",{type:"button",className:"flex-1 py-1.5 text-[11px] font-semibold bg-[#222] text-primary hover:bg-primary/10 transition-colors cursor-pointer border-none",onClick:()=>ft(e.id),children:"Replace"})]})]})]},e.id)})}),_e&&t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"text-[12px] text-[#888] mb-2",children:_e}),t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:u.map((e,s)=>T.has(s)?null:t.jsx("button",{type:"button",className:"aspect-[4/3] bg-[#111] rounded border border-[#333] overflow-hidden p-0 cursor-pointer flex items-center justify-center",onClick:()=>nt(s),children:e.thumbnail?t.jsx("img",{src:e.thumbnail,alt:"On the site",className:"w-full h-full object-cover",loading:"lazy",onError:()=>de(n=>new Set(n).add(s))}):t.jsx("span",{className:"text-[10px] text-[#666]",children:"Video"})},`${e.src||e.mp4}-${s}`))})]})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t.jsx("polyline",{points:"17 8 12 3 7 8"}),t.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Add New Files"]}),t.jsx(Wt,{files:v,onChange:B,onError:Le})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Celebrities"]}),I.length>0&&t.jsxs("div",{className:"space-y-2 mb-4",children:[t.jsx("label",{className:"text-[13px] text-[#888] uppercase tracking-wider font-semibold",children:"Current"}),I.map((e,s)=>{const n=D.has(s),a=K===s;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded border transition-all ${n?"border-red-500/30 bg-red-500/5 opacity-60":e.swapped||e.detailsEdited?"border-primary/30 bg-primary/5":"border-[#333] bg-[#1a1a1a]"}`,children:[e.thumb&&t.jsx("img",{src:e.thumb,alt:e.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`text-[15px] font-semibold ${n?"line-through text-[#888]":"text-white"}`,children:e.name}),e.swapped&&t.jsx("span",{className:"text-primary text-[11px] font-semibold uppercase",children:"Swapped"}),e.detailsEdited&&!e.swapped&&t.jsx("span",{className:"text-primary text-[11px] font-semibold uppercase",children:"Details Edited"})]}),He&&!n&&!e.isUnknown&&t.jsx("input",{type:"text",placeholder:"Role name (optional)",className:"form-input-dark text-[13px] !py-1 mt-1.5 w-full max-w-[250px]",value:e.appearance,onChange:l=>yt(s,l.target.value)})]}),!e.isUnknown&&b===E&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!n&&t.jsx("button",{type:"button",className:"px-3 py-1 rounded text-[12px] font-semibold border border-primary/30 text-primary bg-transparent hover:bg-primary/10 transition-colors cursor-pointer disabled:opacity-50",onClick:()=>
1jt(s),disabled:Pe===s,children:Pe===s?"Loading...":"Edit"}),!n&&t.jsx("button",{type:"button",className:"px-3 py-1 rounded text-[12px] font-semibold border border-[#444] text-[#aaa] bg-transparent hover:bg-[#2a2a2a] transition-colors cursor-pointer",onClick:()=>P(a?null:s),children:a?"Cancel":"Swap"}),t.jsx("button",{type:"button",className:`px-3 py-1 rounded text-[12px] font-semibold transition-colors cursor-pointer border ${n?"border-green-500/30 text-green-400 bg-transparent hover:bg-green-500/10":"border-red-500/30 text-red-400 bg-transparent hover:bg-red-500/10"}`,onClick:()=>gt(s),children:n?"Undo":"Remove"})]})]}),a&&t.jsxs("div",{className:"mt-2 ml-[52px]",children:[t.jsx("p",{className:"text-[12px] text-[#888] mb-1.5",children:"Search for a different celebrity to swap in:"}),t.jsx(Te,{entityType:"celebrity",value:"",entityId:"",onChange:()=>{},onSelect:l=>Ge(s,l),onAddClick:()=>{Q(s),H(!0)},gender:b,existingSelections:[...I.filter((l,c)=>c!==s&&!D.has(c)).map(l=>l.firebaseId),...q.map(l=>l.firebaseId)],isAzFans:w,autoFocus:!0})]})]},e.id)})]}),q.length>0&&t.jsxs("div",{className:"space-y-2 mb-4",children:[t.jsx("label",{className:"text-[13px] text-green-400 uppercase tracking-wider font-semibold",children:"Adding"}),q.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-green-500/30 bg-green-500/5",children:[e.thumb&&t.jsx("img",{src:e.thumb,alt:e.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[15px] font-semibold text-white",children:e.name}),t.jsx("span",{className:"text-green-400 text-[11px] font-semibold uppercase",children:"New"})]}),He&&t.jsx("input",{type:"text",placeholder:"Role name (optional)",className:"form-input-dark text-[13px] !py-1 mt-1.5 w-full max-w-[250px]",value:e.appearance,onChange:n=>It(s,n.target.value)})]}),t.jsx("button",{type:"button",className:"shrink-0 w-8 h-8 flex items-center justify-center rounded border border-[#333] text-[#888] hover:text-red-400 hover:border-red-500/50 transition-colors bg-transparent cursor-pointer",onClick:()=>Rt(s),children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.firebaseId||`new-${s}`))]}),rt?t.jsxs("div",{className:"mb-2",children:[t.jsx(Te,{entityType:"celebrity",value:"",entityId:"",onChange:()=>{},onSelect:Ct,onAddClick:()=>{Q(null),H(!0)},gender:b,existingSelections:[...I.filter((e,s)=>!D.has(s)).map(e=>e.firebaseId),...q.map(e=>e.firebaseId)],isAzFans:w,autoFocus:!0}),t.jsx("button",{type:"button",className:"btn-ghost text-[12px] mt-2",onClick:()=>ee(!1),children:"Cancel"})]}):t.jsx("button",{type:"button",className:"btn-ghost text-sm",onClick:()=>ee(!0),children:"+ Add Celebrity"})]}),!w&&t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),t.jsx("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),t.jsx("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),t.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"})]}),"Content Type"]}),t.jsxs("div",{className:"mb-4",children:[t.jsx(Yt,{value:S,onChange:it,hideLabel:!0}),S!==h&&t.jsxs("p",{className:"text-primary text-[12px] mt-2 font-semibold",children:["Changing from ",h," to ",S]})]}),!te&&j.name&&t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-[#333] bg-[#1a1a1a] mb-3",children:[j.thumb&&t.jsx("img",{src:j.thumb,alt:j.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("span",{className:"text-[13px] text-[#888] uppercase tracking-wider font-semibold block mb-0.5",children:["Current ",h]}),t.jsx("span",{className:"text-[15px] font-semibold text-white",children:j.isUnknown?`Unknown ${h}`:j.name})]}),t.jsx("button",{type:"button",className:"shrink-0 px-3 py-1 rounded text-[12px] font-semibold border border-red-500/30 text-red-400 bg-transparent hover:bg-red-500/10 transition-colors cursor-pointer",onClick:()=>Z(!0),children:"Remove"})]}),te&&j.name&&t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-red-500/30 bg-red-500/5 mb-3",children:[j.thumb&&t.jsx("img",{src:j.thumb,alt:j.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111] opacity-40 grayscale"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-red-400 text-[15px] font-semibold line-through",children:j.name}),t.jsx("span",{className:"text-red-400 text-[11px] ml-2 font-semibold uppercase",children:"Removed"})]}),S===h&&b===E&&t.jsx("button",{type:"button",className:"shrink-0 px-3 py-1 rounded text-[12px] font-semibold border border-green-500/30 text-green-400 bg-transparent hover:bg-green-500/10 transition-colors cursor-pointer",onClick:()=>{Z(!1),Fe()},children:"Undo"})]}),y.id?t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-green-500/30 bg-green-500/5 mb-3",children:[y.thumb&&t.jsx("img",{src:y.thumb,alt:y.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("span",{className:"text-green-400 text-[11px] font-semibold uppercase block mb-0.5",children:["New ",S]}),t.jsx("span",{className:"text-[15px] font-semibold text-white",children:y.name}),y.yor&&t.jsxs("span",{className:"text-[#888] text-[13px] ml-1",children:["(",y.yor,")"]})]}),t.jsx("button",{type:"button",className:"shrink-0 w-8 h-8 flex items-center justify-center rounded border border-[#333] text-[#888] hover:text-red-400 hover:border-red-500/50 transition-colors bg-transparent cursor-pointer",onClick:Fe,children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):(te||j.isUnknown)&&t.jsx("div",{className:"mt-2",children:t.jsx(Te,{entityType:S,value:y.name,entityId:y.id,entityYear:y.yor,entityThumb:y.thumb,onChange:e=>z({...y,name:e}),onSelect:Et,onAddClick:()=>{S==="movie"?Se(!0):S==="series"?Re(!0):S==="story"&&Ie(!0)},onClear:Fe,gender:b,visible:!0})})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-3",children:"Categories"}),t.jsx(Dt,{gender:b,categories:me,onChange:ot,isAzFans:w,hideLabel:!0})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-3",children:"Tags"}),t.jsx(Ht,{tags:pe,onChange:lt,hideLabel:!0})]}),t.jsx("button",{type:"submit",className:"btn-primary-tw w-full py-3.5 text-base",disabled:Ee,children:Ee?"Submitting Edit Request...":"Submit Edit Request"})]})}),k&&k.items.length>0&&t.jsx(Jt,{items:k.items,startIndex:k.start,onClose:()=>je(null),title:k.title,status:k.status}),t.jsx(be,{entityType:"celebrity",isOpen:mt,onClose:()=>{H(!1),Q(null),P(null),Ce(null)},onAdd:$e?Nt:K!==null?kt:St,gender:b,varValues:C,isAzFans:w,initialData:$e}
1),!w&&t.jsxs(t.Fragment,{children:[t.jsx(be,{entityType:"movie",isOpen:pt,onClose:()=>Se(!1),onAdd:Ue,gender:b,varValues:C}),t.jsx(be,{entityType:"series",isOpen:ut,onClose:()=>Re(!1),onAdd:Ue,gender:b,varValues:C}),t.jsx(be,{entityType:"story",isOpen:ht,onClose:()=>Ie(!1),onAdd:Ue,gender:b})]})]})}const ys=()=>{const m=document.querySelector('meta[name="website"]')?.content==="azfans",[r,p]=o.useState(null),[u,O]=o.useState(null),[C,w]=o.useState([]),[we,G]=o.useState([]),[X,ie]=o.useState(""),[E,h]=o.useState(!0),[J,A]=o.useState(""),[N,oe]=o.useState(null),[ve,_]=o.useState(!1),[W,d]=o.useState(!1),f=new URLSearchParams(window.location.search).get("id");if(o.useEffect(()=>{if(!f){A("No upload ID provided. Please navigate here from your uploads page."),h(!1);return}const Y=Tt(et,async v=>{if(!v){window.location.href="/signin.html?next="+encodeURI(window.location.href);return}try{const B=await v.getIdTokenResult(!0);if(F.setUser({id:v.uid,email:v.email}),F.setContext("firebaseClaims",B?.claims||{}),B.claims.isBanned)return localStorage.removeItem("azn_id"),Ot(et);if($t(v.uid)){A("Your account has been restricted from uploading content."),h(!1);return}p(v);const $=ge(ye),le=await Oe(Be($,`uploads/${f}`));if(!le.exists()){A("Upload not found. It may have been removed."),h(!1);return}const U=le.val();if(U.createdBy!==v.uid){A("You do not have permission to edit this upload."),h(!1);return}U.editRequest&&U.editRequest.status==="pending"&&oe(U.editRequest),O({id:f,...U});const M=await ts(Xt(U),k=>Oe(Be($,`files/${k}`))),T=ns(M);T&&F.captureException(T.error,{tags:{area:"edit-upload",op:"fetchFile",status:T.status},extra:{uploadId:f,fileIds:T.fileIds,failed:T.fileIds.length,total:T.total}});const de=M.filter(k=>k.status==="missing").length;if(de>0&&F.addBreadcrumb({category:"edit-upload",level:"info",message:"File records gone",data:{uploadId:f,archived:de,total:M.length}}),w(ss(M)),U.status==="published")try{const k=Vt(f,U);G(Zt(k)),ie(k.title||"")}catch(k){F.captureException(k,{tags:{area:"edit-upload",op:"siteMedia"},extra:{uploadId:f}})}h(!1)}catch(B){F.captureException(B,{tags:{area:"edit-upload",op:"loadUpload"},extra:{uploadId:f}}),A("Failed to load upload data. Please try again."),h(!1)}});return()=>Y()},[f]),E)return t.jsx("div",{className:"max-w-[900px] mx-auto px-4",children:t.jsx("div",{className:"flex justify-center py-15",children:t.jsx("div",{className:"spinner"})})});if(J)return t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:[t.jsx("div",{className:"alert-bar !bg-red-500/10 !border-red-500/30 !text-red-400",children:t.jsx("div",{className:"flex-1",children:J})}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm mt-4 inline-block",children:"â Back to My Uploads"})]});if(N&&!ve){const Y=N.createdOn?new Date(N.createdOn).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"Unknown date",v=N.changes?Object.keys(N.changes):[];return t.jsx("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:t.jsxs("div",{className:"card-dark",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx("span",{className:"w-10 h-10 rounded-sm bg-amber-500/10 border border-amber-500/20 flex items-center justify-center text-amber-400 shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-1",children:"Pending Edit Request"}),t.jsxs("p",{className:"text-[#999] text-sm",children:["This upload already has a pending edit request submitted on ",t.jsx("span",{className:"text-[#ccc]",children:Y}),"."]}),v.length>0&&t.jsxs("p",{className:"text-[#777] text-[13px] mt-1",children:["Changes: ",v.map(B=>B.replace(/([A-Z])/g," $1").replace(/^./,$=>
1$.toUpperCase()).trim()).join(", ")]})]})]}),t.jsx("p",{className:"text-[#aaa] text-sm mb-5",children:"You can continue where you left off or discard your previous changes and start over."}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm",children:"â Back to Uploads"}),t.jsx("button",{type:"button",className:"btn-primary-tw text-sm",onClick:()=>{d(!0),_(!0)},children:"Continue Editing"}),t.jsx("button",{type:"button",className:"btn-ghost text-sm",onClick:()=>{d(!1),_(!0)},children:"Start Fresh"})]})]})})}return t.jsx(os,{user:r,uploadData:u,uploadFiles:C,siteMedia:we,siteTitle:X,varValues,isAzFans:m,keepExistingEdits:W})};export{ys 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.