import{J as _,r as c,j as t}from"./app-BBZbvTSO.js";import M from"./FieldBase-C0gzKbbb.js";import{c as k,B as j}from"./button-CZmOQP7j.js";import{C as S,c as T,e as I}from"./card-LUGiYPFK.js";import{T as O,a as B,b as E,c as L}from"./tooltip-CRkL5R4V.js";import{MediaLibraryModal as $}from"./MediaFieldSelectModal-JGV1H8zK.js";import{B as z}from"./badge-BR_GnIty.js";import{X as H}from"./index-C0VDnRYN.js";import{b as w,F as P,a as R}from"./file-rNzbEzLm.js";import{F as U}from"./file-image-DFth2BDy.js";import{F as V}from"./file-text-DfpLAAwR.js";/* empty css            */import"./label-BPDCCRHl.js";import"./index-13DH8-b5.js";import"./utils-YhN_nlHn.js";import"./input-error-Bz7f2c6i.js";import"./index-CbDI-tXU.js";import"./Combination-9YgcTppv.js";import"./index-hDbW6ayQ.js";import"./floating-ui.dom-DtF1XweH.js";import"./index-AiAmtg3H.js";import"./index-C1VwruLz.js";import"./dialog-D_v2qgP5.js";import"./tabs-DQOAKbqS.js";import"./index-Dbn6AP0q.js";import"./index-IvSACaye.js";import"./index-BosTFUDi.js";import"./dropdown-menu-DkvU_mzU.js";import"./search-bar-FrEZMnbC.js";import"./input-dmj4QjAp.js";import"./pagination-tuDq0xKj.js";import"./chevron-left-CbuOobkA.js";import"./chevron-right-fDICdnKB.js";import"./alert-dialog-Ct4MX6gw.js";import"./AssetGrid-CipfNuNT.js";import"./checkbox-B0_9jnY6.js";import"./index-BCYyBCUm.js";import"./check-yuW7wFtQ.js";import"./AssetDetailsModal-UyBE7M0a.js";import"./textarea-DorjplNc.js";import"./download-grDUn2Jg.js";import"./lock-C-nUbAQc.js";import"./copy-MGAttPaC.js";import"./AssetActionMenu-D0cCgiLZ.js";import"./ellipsis-vertical-DoJR9-bA.js";import"./eye-v-dyI3tg.js";import"./trash-O7-xigMm.js";import"./AssetTable-BIkMwJ85.js";import"./table-BDtwArHp.js";import"./format-C_TaVLmE.js";import"./AssetUploader-Dc0DPvOY.js";import"./scroll-area-hNGxDuJk.js";import"./circle-alert-bp8tLLkJ.js";import"./image-BEhzBCM8.js";import"./Select-BSWSW26d.js";import"./calendar-DoGBS4zB.js";import"./plus-D8fMMvfS.js";import"./layout-grid-CF44vN4j.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const J=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],X=k("FolderOpen",J);function Qe({field:s,value:r,onChange:m,processing:d,errors:b}){var u,h,f;const{project:p}=_().props,l=((u=s.options)==null?void 0:u.multiple)||((f=(h=s.options)==null?void 0:h.media)==null?void 0:f.type)===2,[N,x]=c.useState(!1),[n,o]=c.useState([]);c.useEffect(()=>{if(!r){o([]);return}if(!l){const e=Array.isArray(r)?r[0]:r;if(!e){o([]);return}fetch(route("assets.api.show",[p.id,e])).then(i=>i.json()).then(i=>{o([i])}).catch(i=>{console.error("Failed to load asset:",i),o([])});return}if(!Array.isArray(r)||r.length===0){o([]);return}Promise.all(r.map(e=>fetch(route("assets.api.show",[p.id,e])).then(i=>i.json()))).then(e=>{o(e)}).catch(e=>{console.error("Failed to load assets:",e),o([])})},[r,l,p.id]);const v=()=>{x(!0)},y=()=>{x(!1)},F=e=>{o(e),l?m(s,e.map(i=>i.id)):m(s,e.length>0?e[0].id:null)},A=e=>{const i=n.filter(a=>a.id!==e.id);o(i),l?m(s,i.map(a=>a.id)):m(s,i.length>0?i[0].id:null)},C=e=>{if(!e||!e.extension)return t.jsx(w,{className:"h-8 w-8 text-muted-foreground"});const i=e.extension.toLowerCase();return["jpg","jpeg","png","gif","webp","svg","bmp"].includes(i)?t.jsx(U,{className:"h-8 w-8 text-blue-500"}):["mp4","webm","ogg","mov","avi","wmv","flv"].includes(i)?t.jsx(P,{className:"h-8 w-8 text-purple-500"}):["mp3","wav","ogg","aac","flac"].includes(i)?t.jsx(R,{className:"h-8 w-8 text-green-500"}):["pdf","doc","docx","xls","xlsx","ppt","pptx","txt"].includes(i)?t.jsx(V,{className:"h-8 w-8 text-yellow-500"}):t.jsx(w,{className:"h-8 w-8 text-muted-foreground"})};return t.jsx(M,{field:s,value:r,onChange:m,processing:d,errors:b,children:t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5",children:t.jsxs(j,{type:"button",variant:"outline",disabled:d,onClick:v,className:"w-full",children:[t.jsx(X,{className:"h-4 w-4 mr-2"}),n.length===0?`Select ${l?"files":"a file"}`:`Change ${l?"files":"a file"}`]})}),n.length>0&&t.jsx("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5",children:n.map((e,i)=>{var a,g;return t.jsxs(S,{className:"overflow-hidden p-0",children:[t.jsxs("div",{className:"relative h-40 bg-muted flex items-center justify-center group",children:[e.thumbnail_url?t.jsx("img",{src:e.thumbnail_url,alt:((a=e.metadata)==null?void 0:a.alt_text)||e.original_filename,className:"h-full w-full object-cover"}):C(e),t.jsx("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors"}),t.jsx("div",{className:"absolute top-2 right-2",children:t.jsx(j,{type:"button",variant:"destructive",size:"icon",className:"h-7 w-7 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>A(e),children:t.jsx(H,{className:"h-4 w-4"})})})]}),t.jsx(T,{children:t.jsx(O,{children:t.jsxs(B,{children:[t.jsx(E,{asChild:!0,children:t.jsx("div",{className:"truncate font-medium text-sm",title:e.original_filename,children:e.original_filename})}),t.jsx(L,{children:e.original_filename})]})})}),t.jsxs(I,{className:"px-3 py-2 border-t flex justify-between text-xs text-muted-foreground",children:[t.jsx(z,{variant:"outline",className:"h-5 text-xs flex items-center gap-1",children:((g=e.extension)==null?void 0:g.toUpperCase())||"FILE"}),t.jsx("span",{children:e.formatted_size||"Unknown size"})]})]},`${e.id}-${i}`)})}),t.jsx($,{isOpen:N,onClose:y,project:p,onSelect:F,currentlySelected:n,allowMultiple:l})]})})}export{Qe as default};
