1import{_ as X}from"./B7l4yWHa.js";import{d as Z,V as ee,J as le,a8 as te,a6 as u,q as a,w as i,ad as M,g as e,ag as N,a as ae,k as c,o as d,a7 as n,al as I,ae as oe,ah as ne,as as ie,f as se,b2 as re,aY as p,a_ as S,aj as de,ak as L,af as z,an as _,b3 as ue,b4 as ce,c as fe}from"./BP6NBX35.js";import{_ as me,a as pe}from"./BFs_889x.js";import{_ as ge}from"./DgjtetjL.js";import{_ as _e}from"./DaNDEX8h.js";import{_ as ve}from"./INHh-i-X.js";import{_ as he}from"./amt4sM3L.js";import{u as ye}from"./D09z7RCR.js";import"./D8YBwAnd.js";import"./C52t83hA.js";import"./iguLBGtK.js";import"./BXpMjtjA.js";import"./C4H7s2Uj.js";import"./D4k11_F0.js";import"./B4oQ6xKi.js";import"./DdBfrqcB.js";import"./BRn5Mej5.js";const be={class:"flex flex-col h-full"},xe={class:"flex items-center gap-2 px-4 py-3 border-b border-default"},Ue={class:"ml-auto text-sm text-muted"},we={class:"flex-1 overflow-auto p-4"},ke={key:0,class:"flex items-center justify-center h-40"},Me={key:1,class:"flex flex-col items-center justify-center h-40 gap-2 text-muted"},Ce={key:2,class:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-3"},Ae=["onClick"],Ve={key:1,class:"w-full h-full flex items-center justify-center"},$e={class:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex flex-col items-center justify-center gap-2 p-2"},Ie={class:"text-white text-xs text-center truncate w-full"},ze={class:"flex gap-1"},De={key:2,class:"absolute top-1 right-1"},Te={class:"flex items-center justify-between px-4 py-3 border-t border-default"},je={class:"text-sm text-muted"},Be={class:"flex justify-end gap-2 mt-4"},Ne={class:"flex flex-col gap-4"},Se={key:0,class:"flex justify-center"},Le=["href"],Fe={class:"flex items-center gap-2"},Ee={class:"flex justify-end gap-2"},F=24,il=Z({__name:"index",setup(Re){ee({title:"Media - Admin"});const D=ae().public.apiBaseUrl,r=ye(),C=c(""),b=c(1),g=c(new Set);le(b,t=>r.setPage(t));const E=ue(t=>r.setSearch(t),300);te(()=>{r.setLimit(F)});function R(t){g.value.has(t)?g.value.delete(t):g.value.add(t),g.value=new Set(g.value)}const x=c(null);function H(){x.value?.click()}async function P(t){const l=t.target.files;if(l?.length){for(const $ of Array.from(l))await r.upload($);x.value&&(x.value.value="")}}const v=c(!1),U=c(null),A=c(!1);function O(t){U.value=t,v.value=!0}async function q(){if(U.value){A.value=!0;try{await r.remove(U.value.id),v.value=!1}finally{A.value=!1}}}const h=c(!1),s=c(null),f=ce({slug:"",alt:""}),V=c(!1);function W(t){s.value=t,f.slug=t.slug,f.alt=t.alt??"",h.value=!0}const J=fe(()=>{const t=s.value;if(!t)return"";const l=[];return t.width&&t.height&&l.push(`${t.width}x${t.height}`),l.push(t.mimeType),l.push(t.size>=1024*1024?`${(t.size/1024/1024).toFixed(1)} MB`:`${Math.round(t.size/1024)} KB`),l.join(" · ")});async function K(){if(s.value){V.value=!0;try{await r.update(s.value.id,{slug:f.slug,alt:f.alt||null}),h.value=!1}finally{V.value=!1}}}return(t,l)=>{const $=X,m=de,Q=pe,y=ge,w=oe,T=re,Y=_e,G=me,j=ve,k=he;return d(),u(N,null,[a(G,{id:"media"},{header:i(()=>[a(Q,{title:"Media Library"},{leading:i(()=>[a($)]),right:i(()=>[a(m,{icon:"i-lucide-upload",loading:e(r).uploading.value,onClick:H},{default:i(()=>[...l[8]||(l[8]=[_(" Upload ",-1)])]),_:1},8,["loading"]),n("input",{ref_key:"fileInput",ref:x,type:"file",accept:"image/*,video/*",multiple:"",class:"hidden",onChange:P},null,544)]),_:1})]),body:i(()=>[n("div",be,[n("div",xe,[a(y,{modelValue:e(C),"onUpdate:modelValue":[l[0]||(l[0]=o=>M(C)?C.value=o:null),e(E)],icon:"i-lucide-search",placeholder:"Search by filename, slug, alt...",class:"max-w-xs"},null,8,["modelValue","onUpdate:modelValue"]),n("p",Ue,I(e(r).total.value)+" files",1)]),n("div",we,[e(r).loading.value?(d(),u("div",ke,[a(w,{name:"i-lucide-loader-2",class:"animate-spin size-8 text-muted"})])):e(r).items.value.length?(d(),u("div",Ce,[(d(!0),u(N,null,ne(e(r).items.value,o=>(d(),u("div",{key:o.id,class:ie(["group relative aspect-square rounded-lg overflow-hidden border border-default bg-elevated cursor-pointer",{"ring-2 ring-primary":e(g).has(o.id)}]),onClick:B=>R(o.id)},[o.mimeType.startsWith("image/")?(d(),se(T,{key:0,src:("mediaUrl"in t?t.mediaUrl:e(S))(e(D),o.slug,{w:e(p).AVATAR.w,h:e(p).AVATAR.h,fit:"cover",format:"webp"})||void 0,alt:o.filename,width:e(p).AVATAR.w,height:e(p).AVATAR.h,loading:"lazy",class:"w-full h-full object-cover"},null,8,["src","alt","width","height"])):(d(),u("div",Ve,[a(w,{name:"i-lucide-file-video",class:"size-8 text-muted"})])),n("div",$e,[n("p",Ie,I(o.slug||o.filename),1),n("div",ze,[a(m,{icon:"i-lucide-pencil",color:"primary",size:"xs","aria-label":t.$t("common.edit"),onClick:L(B=>W(o),["stop"])},null,8,["aria-label","onClick"]),a(m,{icon:"i-lucide-trash-2",color:"error",size:"xs","aria-label":t.$t("common.delete"),onClick:L(B=>O(o),["stop"])},null,8,["aria-label","onClick"])])]),e(g).has(o.id)?(d(),u("div",De,[a(w,{name:"i-lucide-check-circle-2",class:"size-5 text-primary"})])):z("",!0)],10,Ae))),128))])):(d(),u("div",Me,[a(w,{name:"i-lucide-image-off",class:"size-12"}),l[9]||(l[9]=n("p",{class:"text-sm"},"No media files yet",-1))]))]),n("div",Te,[a(Y,{page:e(b),"onUpdate:page":l[1]||(l[1]=o=>M(b)?b.value=o:null),"items-per-page":F,total:e(r).total.value},null,8,["page","total"])])])]),_:1}),a(j,{open:e(v),"onUpdate:open":l[3]||(l[3]=o=>M(v)?v.value=o:null),title:"Delete File"},{body:i(()=>[n("p",je,[l[10]||(l[10]=_(" Delete ",-1)),n("strong",null,I(e(U)?.filename),1),l[11]||(l[11]=_("? This cannot be undone. ",-1))]),n("div",Be,[a(m,{color:"neutral",variant:"outline",onClick:l[2]||(l[2]=()=>{v.value=!1})},{default:i(()=>[...l[12]||(l[12]=[_("Cancel",-1)])]),_:1}
1),a(m,{color:"error",loading:e(A),onClick:q},{default:i(()=>[...l[13]||(l[13]=[_("Delete",-1)])]),_:1},8,["loading"])])]),_:1},8,["open"]),a(j,{open:e(h),"onUpdate:open":l[7]||(l[7]=o=>M(h)?h.value=o:null),title:"Edit Media"},{body:i(()=>[n("div",Ne,[e(s)?(d(),u("div",Se,[e(s).mimeType.startsWith("image/")?(d(),u("a",{key:0,href:e(s).originalUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the full-size original in a new tab"},[a(T,{src:("mediaUrl"in t?t.mediaUrl:e(S))(e(D),e(s).slug,{w:e(p).THUMBNAIL_MEDIUM.w,h:e(p).THUMBNAIL_MEDIUM.h,fit:"cover",format:"webp"})||void 0,alt:e(s).alt??e(s).filename,width:e(p).THUMBNAIL_MEDIUM.w,height:e(p).THUMBNAIL_MEDIUM.h,class:"max-h-40 object-contain rounded",loading:"lazy"},null,8,["src","alt","width","height"])],8,Le)):z("",!0)])):z("",!0),a(k,{label:"Full size",description:e(J)},{default:i(()=>[n("div",Fe,[a(y,{"model-value":e(s)?.originalUrl,readonly:"",class:"flex-1 font-mono text-xs"},null,8,["model-value"]),a(m,{icon:"i-lucide-external-link",color:"neutral",variant:"outline",to:e(s)?.originalUrl,target:"_blank",rel:"noopener noreferrer",external:"","aria-label":"Open the full-size original in a new tab"},null,8,["to"])])]),_:1},8,["description"]),a(k,{label:"ID"},{default:i(()=>[a(y,{"model-value":e(s)?.id,disabled:"",readonly:"",class:"font-mono text-xs"},null,8,["model-value"])]),_:1}),a(k,{label:"Slug",description:"Lowercase Latin, hyphens instead of spaces"},{default:i(()=>[a(y,{modelValue:e(f).slug,"onUpdate:modelValue":l[4]||(l[4]=o=>e(f).slug=o),placeholder:"e.g. my-photo"},null,8,["modelValue"])]),_:1}),a(k,{label:"Alt text"},{default:i(()=>[a(y,{modelValue:e(f).alt,"onUpdate:modelValue":l[5]||(l[5]=o=>e(f).alt=o),placeholder:"Describe the image"},null,8,["modelValue"])]),_:1}),n("div",Ee,[a(m,{color:"neutral",variant:"outline",onClick:l[6]||(l[6]=()=>{h.value=!1})},{default:i(()=>[...l[14]||(l[14]=[_("Cancel",-1)])]),_:1}),a(m,{loading:e(V),onClick:K},{default:i(()=>[...l[15]||(l[15]=[_("Save",-1)])]),_:1},8,["loading"])])])]),_:1},8,["open"])],64)}}});export{il 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.