1import{j as e}from"./app-Bn8axf2m.js";import{r as a,H as Y,b as J}from"./vendor-D8BamyIx.js";import{A as Q}from"./AppLayout-DDnh82Xe.js";import W from"./MediaDetails-fXbQIpK8.js";import{B as f}from"./button-BJHJ0j8Y.js";import{I as Z}from"./input-Jv8uXHpu.js";import{S as ee,a as se,b as ae,c as te,d as m}from"./select-CWnhfHEk.js";import{T as re,a as ie,b as H,c as u,d as le,e as p}from"./table-3KFjxIqP.js";import{p as _,V as oe,M as de,F as ne}from"./useMediaCache-BAs_6aAU.js";import{h as V}from"./http-BPRPtlxi.js";import{c as j}from"./utils-DCADjnpI.js";import{S as ce}from"./search-CTuaKws6.js";import{c as R}from"./createLucideIcon-CsuOtgaI.js";import{X as me}from"./x-CrTk-_Ms.js";import{L as ue}from"./loader-circle-Wr5whC3u.js";import{U as pe}from"./upload-CPrINQNm.js";/* empty css */import"./AppLogo-DcmacEfU.js";import"./UserAvatar-xayue2JR.js";import"./index-BYAuPZuj.js";import"./index-CPzEHnIt.js";import"./index-xw87Tvjh.js";import"./dropdown-menu-CW2iYoX1.js";import"./index-DFaUj89F.js";import"./index-DFcVNo6o.js";import"./file-text-DaylnC7C.js";import"./globe-CJdHktb2.js";import"./gauge-CJYVPv0v.js";import"./sparkles-B8Vum2j7.js";import"./shield-check-DX9si8b9.js";import"./FlashMessages-VEWLDp2I.js";import"./info-rA2aT-3L.js";import"./triangle-alert-P9Ytexve.js";import"./circle-check-PhDoMN55.js";import"./card-D0Qy6Ld2.js";import"./label-Cg1Qz0vJ.js";import"./textarea-BtuvhiLj.js";import"./external-link-D5TBzlqN.js";import"./refresh-cw-DJ8Dl8K2.js";import"./trash-2-DOnMnHQN.js";import"./check-s0EwGkyq.js";const xe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],he=R("grid-3x3",xe);const ge=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],fe=R("rows-3",ge),z="__any__";function is({filters:t,can:l,accepted:v,limits:$}){const[b,x]=a.useState([]),[y,B]=a.useState(null),[q,C]=a.useState(!0),[N,d]=a.useState(null),[n,M]=a.useState("grid"),[c,G]=a.useState(t.search??""),[k,O]=a.useState(t.type??""),[T,D]=a.use
1State(!1),[U,S]=a.useState(0),[I,h]=a.useState(null),[P,w]=a.useState(!1),L=a.useRef(null),A=a.useCallback(()=>{C(!0),V.get("/api/media",{params:{search:c||void 0,type:k||void 0,mine:t.mine||void 0,unused:t.unused||void 0,per_page:48}}).then(s=>{x(s.data),B(s.meta),_(s.data)}).catch(()=>h("The media library could not be loaded.")).finally(()=>C(!1))},[c,k,t.mine,t.unused]);a.useEffect(()=>{const s=setTimeout(A,c===(t.search??"")?0:300);return()=>clearTimeout(s)},[A,c,t.search]);const F=a.useCallback(s=>{const o=Array.from(s);if(o.length===0)return;const i=new FormData;o.forEach(r=>i.append("files[]",r)),D(!0),S(0),h(null),V.post("/api/media/upload",i,{onUploadProgress:r=>{r.total&&S(Math.round(r.loaded/r.total*100))}}).then(r=>{_(r.data),x(g=>[...r.data,...g])}).catch(r=>{const g=r.response?.data?.errors;h(g?Object.values(g)[0]?.[0]??"That upload was rejected.":r.response?.data?.message??"That upload failed.")}).finally(()=>{D(!1),S(0)})},[]),K=s=>{_(s),x(o=>o.map(i=>i.id===s.id?s:i)),d(s)},X=s=>{x(o=>o.filter(i=>i.id!==s)),d(null)};return e.jsxs(Q,{wide:!0,title:"Media",description:y?`${y.total} file${y.total===1?"":"s"}`:"Loadingâ¦",actions:l.upload&&e.jsxs(f,{disabled:T,onClick:()=>L.current?.click(),children:[e.jsx(pe,{className:"size-4"}),"Upload"]}),children:[e.jsx(Y,{title:"Media"}),e.jsx("input",{ref:L,type:"file",multiple:!0,hidden:!0,accept:v.map(s=>`.${s}`).join(","),onChange:s=>{s.target.files&&F(s.target.files),s.target.value=""}}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"relative min-w-64 flex-1",children:[e.jsx(ce,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2"}),e.jsx(Z,{value:c,onChange:s=>G(s.target.value),placeholder:"Search filename, alt text or descriptionâ¦",className:"pl-9","aria-label":"Search media"})]}),e.jsxs(ee,{value:k||z,onValueChange:s=>O(s===z?"":s),children:[e.jsx(se,{className:"w-40","aria-label":"Filter by type",children:e.jsx(ae,{placeholder:"All types"})}),e.jsxs(te,{children:[e.jsx(m,{value:z,children:"All types"}),e.jsx(m,{value:"image",children:"Images"}),e.jsx(m,{value:"video",children:"Video"}),e.jsx(m,{value:"audio",children:"Audio"}),e.jsx(m,{value:"document",children:"Documents"})]})]}),e.jsx(f,{variant:t.unused?"default":"outline",title:"Files no article references",onClick:()=>J.get("/admin/media",{...t,unused:t.unused?void 0:"1"},{preserveState:!0,replace:!0}),children:"Unused"}),e.jsxs("div",{className:"flex rounded-md border",children:[e.jsx(f,{variant:n==="grid"?"secondary":"ghost",size:"icon","aria-label":"Grid view","aria-pressed":n==="grid",onClick:()=>M("grid"),children:e.jsx(he,{className:"size-4"})}),e.jsx(f,{variant:n==="list"?"secondary":"ghost",size:"icon","aria-label":"List view","aria-pressed":n==="list",onClick:()=>M("list"),children:e.jsx(fe,{className:"size-4"})})]})]}),I&&e.jsxs("div",{className:"border-destructive/30 bg-destructive/10 text-destructive flex items-start gap-2 rounded-md border px-4 py-3 text-sm",children:[e.jsx("span",{className:"flex-1",children:I}),e.jsx("button",{type:"button",onClick:()=>h(null),"aria-label":"Dismiss",children:e.jsx(me,{className:"size-4"})})]}),T&&e.jsxs("div",{children:[e.jsx("div",{className:"bg-muted h-1.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"bg-primary h-full transition-[width]",style:{width:`${U}%`}})}),e.jsxs("p",{className:"text-muted-foreground mt-1 text-xs",children:["Uploading⦠",U,"%"]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_340px]",children:[e.jsx("div",{className:j("rounded-lg border p-4",P&&"bg-accent/40 ring-primary ring-2 ring-inset"),onDragOver:s=>{s.preventDefault(),l.upload&&w(!0)},onDragLeave:()=>w(!1),onDrop:s=>{s.preventDefault(),w(!1),l.upload&&F(s.dataTransfer.files)},children:q?e.jsxs("div",{className:"text-muted-foreground flex items-center justify-center gap-2 py-20 text-sm",children:[e.jsx(ue,{className:"size-4 animate-spin"}),"Loadingâ¦"]}):b.length===0?e.jsx("p",{className:"text-muted-foreground py-20 text-center text-sm",children:l.upload?"Nothing here yet. Drag files in, or use Upload.":"No media matches these filters."}):n==="grid"?e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5",children:b.map(s=>e.jsxs("button",{type:"button",onClick:()=>d(s),className:j("overflow-hidden rounded-lg border text-left transition-colors",N?.id===s.id?"border-primary ring-primary/30 ring-2":"hover:border-primary/50"),children:[e.jsx("div",{className:"bg-muted flex aspect-square items-center justify-center overflow-hidden",children:s.is_image?e.jsx("img",{src:s.thumb_url??s.url,alt:s.alt??"",loading:"lazy",className:"size-full object-cover"}):e.jsx(E,{kind:s.kind})}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"truncate text-xs font-medium",children:s.filename}),e.jsxs("p",{className:"text-muted-foreground truncate text-xs",children:[s.human_size,s.is_image&&!s.alt&&e.jsxs("span",{className:"text-amber-600 dar
1k:text-amber-400",children:[" ","· no alt"]})]})]})]},s.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(re,{children:[e.jsx(ie,{children:e.jsxs(H,{children:[e.jsx(u,{children:"File"}),e.jsx(u,{children:"Type"}),e.jsx(u,{children:"Size"}),e.jsx(u,{children:"Alt text"}),e.jsx(u,{children:"Used"})]})}),e.jsx(le,{children:b.map(s=>e.jsxs(H,{onClick:()=>d(s),className:j("cursor-pointer",N?.id===s.id&&"bg-accent"),children:[e.jsx(p,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-muted flex size-10 shrink-0 items-center justify-center overflow-hidden rounded",children:s.is_image?e.jsx("img",{src:s.thumb_url??s.url,alt:"",loading:"lazy",className:"size-full object-cover"}):e.jsx(E,{kind:s.kind,className:"size-4"})}),e.jsx("span",{className:"truncate text-sm font-medium",children:s.filename})]})}),e.jsx(p,{className:"text-sm",children:s.extension?.toUpperCase()}),e.jsx(p,{className:"text-muted-foreground text-sm",children:s.human_size}),e.jsx(p,{className:"max-w-xs truncate text-sm",children:s.alt??e.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:"Missing"})}),e.jsx(p,{className:"text-muted-foreground text-sm",children:s.usage_count??0})]},s.id))})]})})}),e.jsx(W,{media:N,limits:$,onUpdated:K,onDeleted:X,onClose:()=>d(null)})]})]})}function E({kind:t,className:l}){const v=t==="video"?oe:t==="audio"?de:ne;return e.jsx(v,{className:j("text-muted-foreground size-8",l)})}export{is 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.