1import{d as K,b as g,w as X,g as R,n as N,D as Z,v as l,i as s,t as o,f as a,N as k,F as y,p as V,l as x,j as m,x as w,z as G,m as f,_ as A,a as z}from"./index.16ba4ea0.js";const ee={class:"space-y-4 text-white"},te={class:"text-xs text-zinc-400 font-medium"},se={class:"flex items-center justify-between mb-6 px-2"},le={key:0,class:"space-y-4"},ne={class:"flex items-center justify-between"},ae={class:"block text-sm font-medium text-zinc-300"},oe={key:0,class:"text-xs text-blue-400 font-medium bg-blue-500/10 px-2 py-0.5 rounded border border-blue-500/20"},re={key:0,class:"flex flex-wrap gap-2 p-2.5 bg-zinc-800 rounded-lg border border-zinc-700"},ie=["onClick"],ue={key:1,class:"p-2 text-xs text-zinc-400 flex items-center gap-2"},de={key:2,class:"max-h-48 overflow-y-auto bg-zinc-800 rounded border border-zinc-700 divide-y divide-zinc-700"},ce=["onClick"],ge={class:"font-medium text-white"},ve={class:"text-xs text-zinc-400 font-mono ml-2"},me={key:0,class:"text-xs text-blue-400 flex items-center gap-1"},xe={key:1,class:"text-xs text-green-400 flex items-center gap-1"},fe={key:1,class:"space-y-4"},pe={class:"block text-sm font-medium text-zinc-300"},be={key:0,class:"p-2 text-xs text-zinc-400 flex items-center gap-2"},ye={key:1,class:"max-h-48 overflow-y-auto bg-zinc-800 rounded border border-zinc-700 divide-y divide-zinc-700"},he=["onClick"],ke={class:"font-medium text-white"},we={class:"text-xs text-zinc-400 font-mono ml-2"},_e={key:2,class:"p-3 rounded bg-zinc-800 border border-green-500/50"},Se={class:"font-bold text-white text-base"},ze={class:"text-xs text-zinc-400 font-mono"},Te={key:2,class:"space-y-4"},Ce={class:"grid grid-cols-1 md:grid-cols-2 gap-4"},Ie={class:"p-4 bg-zinc-800 rounded border border-zinc-700 space-y-2"},Me={class:"text-xs text-red-400 block font-semibold"},Ne={class:"flex flex-wrap gap-1.5 max-h-36 overflow-y-auto"},je={class:"p-4 bg-zinc-800 rounded border border-green-500/50"},$e={class:"font-bold text-lg text-white"},Re={class:"text-xs text-zinc-400 font-mono mt-1"},Ve={key:3,class:"space-y-4"},Ae={class:"bg-zinc-800 p-4 rounded border border-zinc-700 space-y-3"},Le={class:"text-sm font-mono text-green-300 list-disc list-inside space-y-1 mt-1 max-h-40 overflow-y-auto"},Pe={key:4,class:"space-y-4 text-center py-4"},Be={class:"text-sm text-zinc-300"},Ee={key:5,class:"rounded-md border border-red-500/50 bg-red-950/30 px-3 py-2 text-sm text-red-200"},De={key:6,class:"rounded-md border border-green-500/50 bg-green-950/30 px-3 py-2 text-sm text-green-200"},Oe={class:"flex justify-between items-center mt-8 pt-4 border-t border-zinc-800"},qe={key:1},Ge={class:"flex items-center gap-3"},He=K({__name:"TaxonomyMergeModal",props:{open:{type:Boolean},kind:{},source:{},executeMergeHandler:{type:Function}},emits:["update:open","success"],setup(p,{emit:U}){const b=p,E=U,u=g(1),T=g(""),j=g(""),r=g([]),d=g(null),_=g([]),S=g([]),L=g(!1),P=g(!1),$=g(!1),C=g(""),I=g("");let D,O;const F=n=>{switch(n){case 1:return"Select items to merge";case 2:return"Select what to merge into";case 3:return"Review your selection";case 4:return"What will happen";case 5:return"Confirm";default:return""}},h=n=>{if(!n)return{id:"",name:"",slug:""};const e=String(n.tag_id||n.performer_id||n.id||""),i=n.name||n.content_preview||n.slug||e,c=n.slug||n.name||"";return{id:e,name:i,slug:c}},B=n=>r.value.some(e=>String(e.id)===String(n)),H=n=>{const e=h(n);B(e.id)?q(e.id):r.value.push(e)},q=n=>{r.value=r.value.filter(e=>String(e.id)!==String(n))},W=n=>{d.value=h(n)};X(()=>b.open,n=>{if(n)if(u.value=1,T.value="",j.value="",d.value=null,_.value=[],S.value=[],C.value="",I.value="",b.source){const e=h(b.source);r.value=[e],T.value=e.name}else r.value=[]});const Q=()=>{clearTimeout(D),D=setTimeout(async()=>{const n=T.value.trim();if(!n){_.value=[];return}L.value=!0;try{if(b.kind==="tag"){const e=await z.tags.getPendingTags({query:n,limit:10,status:"all"});_.value=(e.tags||[]).filter(i=>i.status!=="rejected").map(h)}else{const e=await z.performers.getPerformers({query:n,page:1,limit:10,force:!0,contextPage:"manage"});_.value=(e.performers||[]).filter(i=>i.status!==!1&&i.status!=="inactive"&&i.status!=="rejected").map(h)}}catch(e){console.error("Source search failed:",e)}finally{L.value=!1}},250)},Y=()=>{clearTimeout(O),O=setTimeout(async()=>{const n=j.value.trim();if(!n){S.value=[];return}P.value=!0;try{const e=r.value.map(i=>String(i.id));if(b.kind==="tag"){const i=await z.tags.getPendingTags({query:n,limit:10,status:"all"});S.value=(i.tags||[]).filter(c=>
1c.status!=="rejected"&&!e.includes(String(c.id))).map(h)}else{const i=await z.performers.getPerformers({query:n,page:1,limit:10,force:!0,contextPage:"manage"});S.value=(i.performers||[]).filter(c=>c.status!==!1&&c.status!=="inactive"&&c.status!=="rejected"&&!e.includes(String(c.id))).map(h)}}catch(e){console.error("Target search failed:",e)}finally{P.value=!1}},250)},J=async()=>{var n;if(!(!r.value.length||!d.value)){$.value=!0,C.value="",I.value="";try{if(b.executeMergeHandler)await b.executeMergeHandler(r.value,d.value);else{const e=r.value.map(t=>t.id),i=d.value.id,c=d.value.slug,M={sourceIds:e.length>1?e:void 0,sourceId:e.length===1?e[0]:void 0,targetId:i,sourceSlug:(n=r.value[0])==null?void 0:n.slug,targetSlug:c};b.kind==="tag"?await z.taxonomy.createTagAlias(M):await z.taxonomy.createPerformerAlias(M)}I.value=`Successfully merged ${r.value.length} item(s) into "${d.value.name}"!`,E("success",{sources:r.value,target:d.value}),setTimeout(()=>{E("update:open",!1)},1e3)}catch(e){C.value=(e==null?void 0:e.message)||String(e)}finally{$.value=!1}}};return(n,e)=>(l(),R(Z,{"model-value":p.open,"onUpdate:modelValue":e[5]||(e[5]=i=>n.$emit("update:open",i)),wide:"",title:`Merge ${p.kind==="tag"?"Tags":"Performers"}`},{default:N(()=>{var i,c,M;return[s("div",ee,[s("p",te,"Step "+o(u.value)+" of 5: "+o(F(u.value)),1),s("div",se,[(l(),a(y,null,k(5,t=>(l(),a(y,{key:t},[s("div",{class:V(["w-8 h-8 rounded-full flex items-center justify-center font-bold text-xs transition-colors",t===u.value?"bg-blue-600 text-white ring-2 ring-blue-400":t<u.value?"bg-green-600 text-white":"bg-zinc-800 text-zinc-500"])},o(t<u.value?"\u2713":t),3),t<5?(l(),a("div",{key:0,class:V(["flex-1 h-0.5 mx-1",t<u.value?"bg-green-600":"bg-zinc-800"])},null,2)):x("",!0)],64))),64))]),u.value===1?(l(),a("div",le,[s("div",ne,[s("label",ae," Search & Select "+o(p.kind==="tag"?"Tag(s)":"Performer(s)")+" to merge: ",1),r.value.length>0?(l(),a("span",oe,o(r.value.length)+" Selected ",1)):x("",!0)]),r.value.length>0?(l(),a("div",re,[(l(!0),a(y,null,k(r.value,t=>(l(),a("span",{key:t.id,class:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium bg-blue-900/50 text-blue-200 border border-blue-500/30"},[s("span",null,o(t.name||t.content_preview),1),s("button",{type:"button",onClick:v=>q(t.id),class:"text-blue-300 hover:text-white ml-0.5"},[m(w,{name:"close",class:"h-3 w-3"})],8,ie)]))),128))])):x("",!0),m(G,{modelValue:T.value,"onUpdate:modelValue":e[0]||(e[0]=t=>T.value=t),placeholder:`Type to search & add ${p.kind==="tag"?"tags":"performers"}...`,onInput:Q},null,8,["modelValue","placeholder"]),L.value?(l(),a("div",ue,[m(w,{name:"loading",class:"h-4 w-4 animate-spin text-blue-500"}),e[6]||(e[6]=f(" Searching... ",-1))])):_.value.length?(l(),a("div",de,[(l(!0),a(y,null,k(_.value,t=>(l(),a("button",{key:t.id,type:"button",onClick:v=>H(t),class:V(["w-full text-left p-3 hover:bg-zinc-700 transition-colors flex items-center justify-between",B(t.id)?"bg-blue-900/40 text-blue-300 font-semibold":""])},[s("div",null,[s("span",ge,o(t.name||t.slug),1),s("span",ve,"("+o(t.slug)+")",1)]),B(t.id)?(l(),a("span",xe,[m(w,{name:"check",class:"h-3.5 w-3.5"}),e[8]||(e[8]=f(" Selected ",-1))])):(l(),a("span",me,[m(w,{name:"plus",class:"h-3.5 w-3.5"}),e[7]||(e[7]=f(" Add ",-1))]))],10,ce))),128))])):x("",!0)])):u.value===2?(l(),a("div",fe,[s("label",pe," Search & Select canonical target "+o(p.kind==="tag"?"Tag":"Performer")+" to merge into: ",1),m(G,{modelValue:j.value,"onUpdate:modelValue":e[1]||(e[1]=t=>j.value=t),placeholder:"Search canonical target...",onInput:Y},null,8,["modelValue"]),P.value?(l(),a("div",be,[m(w,{name:"loading",class:"h-4 w-4 animate-spin text-blue-500"}),e[9]||(e[9]=f(" Searching... ",-1))])):S.value.length?(l(),a("div",ye,[(l(!0),a(y,null,k(S.value,t=>{var v;return l(),a("button",{key:t.id,type:"button",onClick:Ue=>W(t),class:V(["w-full text-left p-3 hover:bg-zinc-700 transition-colors flex items-center justify-between",((v=d.value)==null?void 0:v.id)===t.id?"bg-blue-900/40 text-blue-300 font-semibold":""])},[s("div",null,[s("span",ke,o(t.name),1),s("span",we,"("+o(t.slug)+")",1)])],10,he)}),128))])):x("",!0),d.value?(l(),a("div",_e,[e[10]||(e[10]=s("span",{class:"text-xs text-green-400 block font-semibold"},"MERGING INTO CANONICAL TARGET:",-1)),s("div",Se,o(d.value.name),1),s("div",ze,"slug: "+o(d.value.slug),1)])):x("",!0)])):u.value===3?(l(),a("div",Te,[e[12]||(e[12]=s("h3",{class:"text-base font-semibold text-zinc-200"},"Review Your Selection",-1)),s("div",Ce,[s("div",Ie,[s("span",Me,"MERGING "+o(r.value.length)+" ITEM(S)",1),s("div",Ne,[(l(!0),a(y,null,k(r.value,t=>(l(),a("span",{key:t.id,class:"px-2 py-1 bg-red-950/40 text-red-200 text-xs font-medium rounded border border-red-500/30"},o(t.name||t.content_preview),1))),128))])]),s("div",je,[e[11]||(e[11]=s("span",{class:"text-xs text-green-400 block font-semibold mb-1"},"INTO CANONICAL TARGET",-1)),s("div",$e,o((i=d.value)==null?void 0:i.name),1),s("div",Re,"slug: "+o((c=d.value)==null?void 0:c.slug),1)])])])):u.value===4?(l(),a("div",Ve,[e[14]||(e[14]=s("h3",{class:"text-base font-semibold text-zinc-200"},"What will happen",-1)),s("div",Ae,[s("div",null,[e[13]||(e[13]=s("span",{class:"text-xs text-zinc-400 block font-semibold mb-1"},"OLD URL(S) WILL REDIRECT TO CANONICAL URL",-1)),s("ul",Le,[p.kind==="tag"?(l(!0),a(y,{key:0},k(r.value,t=>{var v;return l(),a("li",{key:t.id}," /t/"+o(t.slug||t.id)+" \u2192 /t/"+o((v=d.value)==null?void 0:v.slug),1)}),128)):(l(!0),a(y,{key:1},k(r.value,t=>{var v;return l(),a("li",{key:t.id}," /p/"+o(t.slug||t.id)+" \u2192 /p/"+o((v=d.value)==null?void 0:v.slug),1)}),128))])])])])):u.value===5?(l(),a("div",Pe,[m(w,{name:"source-branch",class:"h-12 w-12 text-blue-400 mx-auto animate-bounce"}),e[17]||(e[17]=s("h3",{class:"text-lg font-bold text-white"},"Confirm Batch Merge?",-1)),s("p",Be,[s("strong",null,o(r.value.length)+" "+o(p.kind==="tag"?"tag(s)":"performer(s)"),1),e[15]||(e[15]=f(" will be merged into ",-1)),s("strong",null,o((M=d.value)==null?void 0:M.name),1),e[16]||(e[16]=f(". Visitors using old URLs will be automatically redirected. ",-1))])])):x("",!0),C.value?(l(),a("div",Ee,o(C.value),1)):x("",!0),I.value?(l(),a("div",De,o(I.value),1)):x("",!0),s("div",Oe,[u.value>1?(l(),R(A,{key:0,theme:"transparent",onClick:e[2]||(e[2]=t=>u.value--),class:"!inline-flex !items-center !justify-center !gap-1.5 !px-3.5 !py-1.5 text-zinc-300 hover:text-white"},{default:N(()=>[m(w,{name:"arrow-left",class:"h-4 w-4 shrink-0"}),e[18]||(e[18]=s("span",null,"Back",-1))]),_:1})):(l(),a("div",qe)),s("div",Ge,[m(A,{theme:"transparent",onClick:e[3]||(e[3]=t=>n.$emit("update:open",!1)),class:"!inline-flex !items-center !justify-center !px-3.5 !py-1.5 text-zinc-400 hover:text-white"},{default:N(()=>[...e[19]||(e[19]=[f(" Cancel ",-1)])]),_:1}),u.value<5?(l(),R(A,{key:0,theme:"blue",class:"!inline-flex !items-center !justify-center !px-4 !py-1.5 text-white",disabled:u.value===1&&r.value.length===0||u.value===2&&!d.value,onClick:e[4]||(e[4]=t=>u.value++)},{default:N(()=>[...e[20]||(e[20]=[f(" Next ",-1)])]),_:1},8,["disabled"])):(l(),R(A,{key:1,theme:"green",class:"!inline-flex !items-center !justify-center !px-4 !py-1.5 text-white",loading:$.value,onClick:J},{default:N(()=>[f(o($.value?"Merging...":"Confirm Batch Merge"),1)]),_:1},8,["loading"]))])])])]}),_:1},8,["model-value","title"]))}});
1export{He as _};
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.