import{r,j as e,a as V}from"./app-BwDemWQz.js";import{X as Ne,P as we,A as ke,I as ae,D as se,j as te,k as re,l as A,o as le,f as Me}from"./AppLayout-3zbhnyYw.js";import{B as i}from"./Button-B-KWyoQR.js";import{I as Se}from"./Input-BJaxI6jp.js";import{P as Ce}from"./Pagination-BlNwi_HH.js";import{C as ze,a as De}from"./Card-DJ3wHKN-.js";import{T as Fe,a as Ie,b as H,c as q}from"./Tabs-BWJM2jyE.js";import{D as Pe}from"./DeleteModal-DqFQpSwl.js";import{u as Ue}from"./useDeleteHandler-C9Bb7ZON.js";import{u as Te}from"./LanguageContext-zkEAKPTE.js";import{U as D}from"./upload-B-3i7Erd.js";import{c as E}from"./createLucideIcon-BASx8f0E.js";import{C as Ve,S as Ae,a as Oe,b as Ee,c as Le,d as ie}from"./Select-CfDsuz_M.js";import{s as O}from"./index-CkDmAPFS.js";import{G as _e,L as $e}from"./list-oyye9I97.js";import{S as Be}from"./search-sQ0SJSXK.js";import{m as Re}from"./proxy-DQ767J20.js";import{P as de}from"./play-81q2q0ID.js";import{C as Ge}from"./chevron-left-BxYqeqJW.js";import{E as He}from"./ellipsis-vertical-MSJbXZp-.js";import{E as oe}from"./eye-C30qcgue.js";import{D as ne}from"./download-Bp5_-seZ.js";import{T as ce}from"./trash-2-DJCIoKoz.js";/* empty css            */import"./index-DxJALBsh.js";import"./Label-1lm7x8-L.js";import"./zap-BsHQ4DWF.js";import"./rocket-Dt03WmgU.js";import"./users-g1HvrzO9.js";import"./globe-C_ZhZ5i9.js";import"./index-B0gxmCHE.js";/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const qe=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],We=E("file-image",qe);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ye=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z",key:"1tzo1f"}]],Qe=E("file-play",Ye);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ze=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],Je=E("file",Ze);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ke=[["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"}]],Xe=E("folder-open",Ke),ea=({label:M,field:j,accept:N="image/*,video/*",multiple:x=!0,onChange:p,hint:F="You can upload images or videos. Max size: 20MB per file.",maxFileSize:I=20*1024*1024,value:L=[]})=>{const[h,y]=r.useState(L||[]),[g,S]=r.useState(!1),[_,$]=r.useState([]),d=r.useRef(null),k=s=>{const t=[],l=[];return Array.from(s).forEach((o,P)=>{if(o.size>I){t.push(`${o.name}: File size exceeds 20MB limit`);return}const z=o.type.startsWith("image/"),U=o.type.startsWith("video/");if(!z&&!U){t.push(`${o.name}: Only images and videos are allowed`);return}l.push(o)}),$(t),l},B=s=>{const t=s.target.files;if(!t)return;const l=k(t),o=x?[...h,...l]:l.slice(0,1);y(o),p&&p(x?o:o[0]),d.current&&(d.current.value="")},v=s=>{const t=h.filter((l,o)=>o!==s);y(t),p&&p(x?t:null)},u=()=>{y([]),$([]),p&&p(x?[]:null),d.current&&(d.current.value="")},f=s=>{s.preventDefault(),s.stopPropagation(),s.type==="dragenter"||s.type==="dragover"?S(!0):s.type==="dragleave"&&S(!1)},w=s=>{if(s.preventDefault(),s.stopPropagation(),S(!1),s.dataTransfer.files&&s.dataTransfer.files[0]){const t=k(s.dataTransfer.files),l=x?[...h,...t]:t.slice(0,1);y(l),p&&p(x?l:l[0])}},C=s=>s.type.startsWith("image/")?e.jsx(We,{className:"w-4 h-4 text-primary"}):s.type.startsWith("video/")?e.jsx(Qe,{className:"w-4 h-4 text-purple-500"}):e.jsx(Je,{className:"w-4 h-4 text-gray-500"}),W=s=>{if(s===0)return"0 Bytes";const t=1024,l=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(s)/Math.log(t));return parseFloat((s/Math.pow(t,o)).toFixed(2))+" "+l[o]};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-100",children:M}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-xl p-8 transition-colors ${g?"border-primary bg-primary/5 dark:bg-primary/10":"border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500"}`,onDragEnter:f,onDragLeave:f,onDragOver:f,onDrop:w,children:[e.jsx("input",{ref:d,id:j,type:"file",accept:N,multiple:x,onChange:B,className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"}),e.jsxs("div",{className:"text-center",children:[e.jsx(D,{className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-500"}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[e.jsx("span",{className:"font-medium text-primary hover:text-primary/80 cursor-pointer",children:"Click to upload"})," or drag and drop"]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:x?"Images and videos up to 20MB each":"Image or video up to 20MB"})]})]})]}),_.length>0&&e.jsx("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-3",children:e.jsx("div",{className:"text-sm text-red-600 dark:text-red-400 space-y-1",children:_.map((s,t)=>e.jsxs("p",{children:["• ",s]},t))})}),h.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:["Selected Files (",h.length,")"]}),x&&h.length>1&&e.jsx(i,{type:"button",variant:"outline",size:"sm",onClick:u,className:"text-red-600 hover:text-red-700 border-red-200 hover:border-red-300",children:"Clear All"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-2 max-h-60 overflow-y-auto",children:h.map((s,t)=>e.jsxs("div",{className:"flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"flex items-center space-x-3 min-w-0 flex-1",children:[C(s),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:s.name}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:W(s.size)})]})]}),e.jsx(i,{type:"button",variant:"ghost",size:"sm",onClick:()=>v(t),className:"ml-2 h-8 w-8 p-0 text-gray-400 hover:text-red-500 dark:text-gray-500 dark:hover:text-red-400",children:e.jsx(Ne,{className:"w-4 h-4"})})]},`${s.name}-${t}`))})]}),x&&h.length>0&&e.jsxs(i,{type:"button",variant:"outline",onClick:()=>{var s;return(s=d.current)==null?void 0:s.click()},className:"w-full border-dashed border-gray-300 dark:border-gray-600 text-gray-600 dark:text-gray-400 hover:border-gray-400 dark:hover:border-gray-500",children:[e.jsx(we,{className:"w-4 h-4 mr-2"}),"Add More Files"]}),F&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:F})]})};function Pa({platforms:M,media:j}){var ee;const[N,x]=r.useState("grid"),[p,F]=r.useState("all"),[I,L]=r.useState("facebook"),[h,y]=r.useState("all"),[g,S]=r.useState(""),[_,$]=r.useState(2),[d,k]=r.useState({isOpen:!1,item:null,currentIndex:0}),[B,v]=r.useState(!1),[u,f]=r.useState([]);r.useRef(null);const[w,C]=r.useState(!1),[W,s]=r.useState(0),[t,l]=r.useState([]),[o,P]=r.useState(!1),[z,U]=r.useState(null),[me,Y]=r.useState(j.data||[]);r.useEffect(()=>{Y(j.data)},[j]);const Q=Te(),m=me.filter(a=>!(p==="images"&&a.isVideo||p==="videos"&&!a.isVideo||g&&!a.title.toLowerCase().includes(g.toLowerCase()))),Z=a=>{const n=m.findIndex(c=>c.id===a.id);k({isOpen:!0,item:a,currentIndex:n})},xe=()=>{k({isOpen:!1,item:null,currentIndex:0})},J=a=>{const n=a==="next"?(d.currentIndex+1)%m.length:(d.currentIndex-1+m.length)%m.length,c=m[n];k({...d,item:c,currentIndex:n})},he=a=>{const n=Array.isArray(a)?a:a?[a]:[];f(n)},ge=a=>{L(a),V.get(O("user.gallery.index"),{slug:a})},ue=()=>{if(!u||u.length===0){alert("Please select at least one file to upload");return}if(!h){alert("Please select a platform");return}C(!0),s(0),l(u.map(b=>({name:b.name,status:"uploading",progress:0})));const a=new FormData;u.forEach((b,T)=>{a.append(`media[${T}]`,b)}),a.append("platform_id",h);const n=document.querySelector('meta[name="csrf-token"]'),c=n?n.getAttribute("content"):null;c?a.append("_token",c):console.warn("CSRF token not found, using alternative method"),V.post(O("user.gallery.store"),{media:u,platform_id:h},{forceFormData:!0,onSuccess:()=>{l(u.map(b=>({name:b.name,status:"completed",progress:100}))),setTimeout(()=>{V.reload({only:["media"]}),C(!1),v(!1),f([]),s(0),l([])},1e3)},onError:b=>{console.error("Upload failed:",b),l(u.map(be=>({name:be.name,status:"error",progress:0})));const T=Object.values(b).flat(),ve=T.length>0?T.join("\\n"):"Upload failed. Please try again.";alert(ve),C(!1)}})},K=a=>{U(a),P(!0)},{handleDelete:pe,isDeleting:fe}=Ue("user.gallery.item.delete",a=>{Y(n=>n.filter(c=>c.id!==a)),P(!1),U(null)}),X=a=>{fetch(a.thumbnail).then(n=>n.blob()).then(n=>{const c=document.createElement("a");c.href=window.URL.createObjectURL(n),c.download=a.title||"file",document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(c.href)}).catch(()=>alert("Download failed"))},ye=a=>{S(a.target.value),V.get(O("user.gallery.index"),{search:g},{preserveState:!0,preserveScroll:!0})},R=({item:a})=>e.jsx(ze,{className:"overflow-hidden hover:shadow-md transition-shadow",children:e.jsxs(De,{className:"p-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:a.thumbnail||"/placeholder.svg",alt:a.title,className:"w-full h-24 object-cover"}),a.isVideo&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:a.thumbnail,muted:!0,playsInline:!0,loop:!0,autoPlay:!0})}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsx(i,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 bg-black/20 hover:bg-black/40 text-white rounded-full",children:e.jsx(He,{className:"h-4 w-4"})})}),e.jsxs(re,{align:"end",className:"w-32",children:[e.jsxs(A,{className:"flex items-center gap-2",onClick:()=>Z(a),children:[e.jsx(oe,{className:"h-4 w-4"}),"Preview"]}),e.jsxs(A,{className:"flex items-center gap-2",onClick:()=>X(a),children:[e.jsx(ne,{className:"h-4 w-4"}),"Download"]}),e.jsxs(A,{className:"flex items-center gap-2 text-red-600",onClick:()=>K(a),children:[e.jsx(ce,{className:"h-4 w-4"}),"Delete"]})]})]})})]}),e.jsxs("div",{className:"p-4",children:[e.jsx("h3",{className:"font-medium text-sm mb-1 truncate",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.type})]})]})}),G=({item:a})=>e.jsxs("div",{className:"flex items-center gap-4 p-4 border-b border-gray-200 dark:border-zinc-800 md:flex-nowrap flex-wrap hover:bg-muted/50 transition-colors",children:[e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsx("img",{src:a.thumbnail||"/placeholder.svg",alt:a.title,className:"w-16 h-12 object-cover rounded"}),a.isVideo&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx("div",{className:"bg-black/50 rounded-full p-1",children:e.jsx(de,{className:"h-3 w-3 text-white fill-white"})})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-sm truncate",children:a.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.type})]}),e.jsxs("div",{className:"text-xs text-muted-foreground md:text-right text-left w-full md:w-auto",children:[e.jsxs("p",{className:"mb-2",children:["Size: ",a.size]}),e.jsxs("p",{children:["Date: ",a.date]})]}),e.jsxs("div",{className:"flex gap-2 w-full md:w-auto justify-start md:justify-end",children:[e.jsx(i,{size:"sm",variant:"outline",className:"h-8 w-8 p-0 bg-blue-500 hover:bg-blue-600 text-white border-blue-500",onClick:()=>Z(a),children:e.jsx(oe,{className:"h-4 w-4"})}),e.jsx(i,{size:"sm",variant:"outline",className:"h-8 w-8 p-0 bg-green-500 hover:bg-green-600 text-white border-green-500",onClick:()=>X(a),children:e.jsx(ne,{className:"h-4 w-4"})}),e.jsx(i,{size:"sm",variant:"outline",className:"h-8 w-8 p-0 bg-red-500 hover:bg-red-600 text-white border-red-500",onClick:()=>K(a),children:e.jsx(ce,{className:"h-4 w-4"})})]})]}),je=[{label:"Home",href:O("user.home")},{label:"Gallery"}];return e.jsx(ke,{breadcrumbs:je,children:e.jsxs("div",{className:"flex-1 p-6 overflow-auto bg-gray-50 dark:bg-black",children:[e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{children:e.jsx(ae,{className:"h-6 w-6 text-primary"})}),e.jsx("h1",{className:"text-xl sm:text-2xl dark:text-gray-200 font-bold",children:Q("Media Gallery")})]}),e.jsx("p",{className:"text-gray-500 dark:text-gray-200",children:Q("Upload, organize and manage your media files for social media posts")})]}),e.jsxs(Fe,{defaultValue:"all",onValueChange:F,className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4 mb-6",children:[e.jsxs(Ie,{className:"inline-flex bg-white rounded-lg p-1 shadow-sm gap-1 ltr:flex-row rtl:flex-row-reverse",children:[e.jsx(H,{value:"all",className:"data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-secondary data-[state=active]:text-white data-[state=active]:shadow-sm rounded-md px-4 py-2 text-sm font-medium transition-colors",children:"All"}),e.jsx(H,{value:"images",className:"data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-secondary data-[state=active]:text-white data-[state=active]:shadow-sm rounded-md px-4 py-2 text-sm font-medium transition-colors",children:"Images"}),e.jsx(H,{value:"videos",className:"data-[state=active]:bg-gradient-to-r data-[state=active]:from-primary data-[state=active]:to-secondary data-[state=active]:text-white data-[state=active]:shadow-sm rounded-md px-4 py-2 text-sm font-medium transition-colors",children:"Videos"})]}),e.jsxs("div",{className:"flex items-center flex-wrap gap-3",children:[e.jsxs("div",{className:"flex border border-gray-300 dark:border-gray-600 rounded-lg overflow-hidden",children:[e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>x("grid"),className:`h-9 px-3 rounded-none dark:text-gray-100 ${N==="grid"?"bg-gray-200 dark:bg-gray-700 dark:text-gray-100":"hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:e.jsx(_e,{className:"h-4 w-4"})}),e.jsx(i,{variant:"ghost",size:"sm",onClick:()=>x("list"),className:`h-9 px-3 rounded-none dark:text-gray-100 ${N==="list"?"bg-gray-200 dark:bg-gray-700":"hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:e.jsx($e,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Be,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400"}),e.jsx(Se,{placeholder:"Search",value:g,onChange:a=>ye(a),className:"pl-10 w-64"})]}),e.jsxs(i,{variant:"white",onClick:()=>{v(!0),f([]),y("all")},className:"bg-gradient-to-r from-primary to-secondary hover:from-secondary hover:to-primary text-white border-0 shadow-sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Upload Media"]}),e.jsxs(se,{children:[e.jsx(te,{asChild:!0,children:e.jsxs(i,{variant:"outline",className:"min-w-[140px] justify-between",children:[((ee=M.find(a=>a.slug===I))==null?void 0:ee.name)||"Select Platform",e.jsx(Ve,{className:"h-4 w-4"})]})}),e.jsx(re,{align:"end",className:"w-[140px]",children:M.map(a=>e.jsx(A,{onClick:()=>ge(a.slug),className:I===a.slug?"bg-gray-100 dark:bg-gray-800":"",children:a.name},a.slug))})]})]})]}),e.jsxs(Re.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.6,delay:.2},children:[e.jsx(q,{value:"all",className:"mt-0",children:e.jsx("div",{className:"mb-8",children:m.length===0?e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-xl border border-gray-200 dark:border-zinc-800 p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-gradient-to-br from-primary/10 to-secondary/10 rounded-xl flex items-center justify-center mb-4",children:e.jsx(Xe,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})}),e.jsxs("div",{className:"space-y-2 mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"No media files yet"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-sm mx-auto",children:g?"No media files match your search criteria. Try adjusting your search terms.":"Upload your first media files to get started. You can add images and videos for your social media posts."})]}),!g&&e.jsxs(i,{variant:"white",onClick:()=>{v(!0),f([]),y("all")},className:"bg-gradient-to-r from-primary to-secondary hover:from-secondary hover:to-primary text-white border-0 shadow-sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Upload Your First Media"]})]})}):N==="grid"?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:m.map(a=>e.jsx(R,{item:a},a.id))}):e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-lg border border-gray-200 dark:border-zinc-800 overflow-hidden",children:m.map(a=>e.jsx(G,{item:a},a.id))})})}),e.jsx(q,{value:"images",className:"mt-0",children:e.jsx("div",{className:"mb-8",children:m.length===0?e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-xl border border-gray-200 dark:border-zinc-800 p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-gradient-to-br from-primary/10 to-secondary/10 rounded-xl flex items-center justify-center mb-4",children:e.jsx(ae,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})}),e.jsxs("div",{className:"space-y-2 mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"No images found"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-sm mx-auto",children:g?"No images match your search criteria. Try adjusting your search terms.":"Upload your first images to create engaging visual content for your social media posts."})]}),!g&&e.jsxs(i,{variant:"white",onClick:()=>{v(!0),f([]),y("all")},className:"bg-gradient-to-r from-primary to-secondary hover:from-secondary hover:to-primary text-white border-0 shadow-sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Upload Images"]})]})}):N==="grid"?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:m.map(a=>e.jsx(R,{item:a},a.id))}):e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-lg border border-gray-200 dark:border-zinc-800 overflow-hidden",children:m.map(a=>e.jsx(G,{item:a},a.id))})})}),e.jsx(q,{value:"videos",className:"mt-0",children:e.jsx("div",{className:"mb-8",children:m.length===0?e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-xl border border-gray-200 dark:border-zinc-800 p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 bg-gradient-to-br from-primary/10 to-secondary/10 rounded-xl flex items-center justify-center mb-4",children:e.jsx(de,{className:"h-8 w-8 text-gray-400 dark:text-gray-500"})}),e.jsxs("div",{className:"space-y-2 mb-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"No videos found"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 max-w-sm mx-auto",children:g?"No videos match your search criteria. Try adjusting your search terms.":"Upload your first videos to create dynamic content for your social media posts."})]}),!g&&e.jsxs(i,{variant:"white",onClick:()=>{v(!0),f([]),y("all")},className:"bg-gradient-to-r from-primary to-secondary hover:from-secondary hover:to-primary text-white border-0 shadow-sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Upload Videos"]})]})}):N==="grid"?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4",children:m.map(a=>e.jsx(R,{item:a},a.id))}):e.jsx("div",{className:"bg-white dark:bg-zinc-900 rounded-lg border border-gray-200 dark:border-zinc-800 overflow-hidden",children:m.map(a=>e.jsx(G,{item:a},a.id))})})})]})]}),e.jsx(Ce,{links:j.links,currentPage:j.current_page,lastPage:j.last_page,only:["media"],className:"mt-4"}),e.jsx(le,{isOpen:d.isOpen,onClose:xe,title:"Detail Image",showSubmit:!1,width:"w-[48rem]",children:d.item&&e.jsxs("div",{className:"flex gap-4 h-[40vh]",children:[e.jsxs("div",{className:"flex-1 flex items-center justify-center relative bg-gray-50 rounded-lg overflow-hidden",children:[e.jsx(i,{variant:"ghost",size:"sm",className:"absolute left-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0 bg-black/20 hover:bg-black/40 text-white rounded-full z-10",onClick:()=>J("prev"),children:e.jsx(Ge,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-full h-full flex items-center justify-center p-3",children:e.jsx("img",{src:d.item.thumbnail||"/placeholder.svg",alt:d.item.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-sm"})}),e.jsx(i,{variant:"ghost",size:"sm",className:"absolute right-2 top-1/2 -translate-y-1/2 h-7 w-7 p-0 bg-black/20 hover:bg-black/40 text-white rounded-full z-10",onClick:()=>J("next"),children:e.jsx(Me,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"w-64 flex flex-col justify-between py-2",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"File Name"}),e.jsx("span",{className:"text-xs text-right max-w-32 truncate font-medium",children:d.item.title})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Resolution"}),e.jsx("span",{className:"text-xs font-medium",children:"2400 x 1600"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"File Type"}),e.jsx("span",{className:"text-xs font-medium",children:"Image"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Size"}),e.jsx("span",{className:"text-xs font-medium",children:d.item.size})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-xs font-medium text-gray-600 dark:text-gray-400",children:"Date"}),e.jsx("span",{className:"text-xs font-medium",children:d.item.date})]})]})}),e.jsxs("div",{className:"flex gap-2 justify-end pt-4",children:[e.jsx(i,{variant:"outline",size:"sm",className:"text-gray-600 hover:text-gray-800 bg-transparent border-gray-300",children:"Delete"}),e.jsx(i,{size:"sm",className:"bg-cyan-500 hover:bg-cyan-600 text-white px-4",children:"Download"})]})]})]})}),e.jsx(le,{isDataSubmitting:w,isOpen:B,onClose:()=>{w||(v(!1),f([]),s(0),l([]))},title:"Upload Media",showSubmit:!0,width:"w-[56rem]",maxHeight:"max-h-[85vh]",onSubmit:ue,submitText:w?`Uploading ${u.length} file(s)...`:`Upload ${u.length} file(s)`,children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ea,{label:"Select Media Files (Images & Videos)",accept:"image/*,video/*",field:"media_files",multiple:!0,onChange:he,value:u,hint:"Support: JPG, PNG, GIF, MP4, MOV, AVI. Max 20MB per file. You can select multiple files at once."}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"Select Platform *"}),e.jsxs(Ae,{value:h,onValueChange:a=>y(a),disabled:w,children:[e.jsx(Oe,{className:"w-full bg-white dark:bg-zinc-800 border-gray-300 dark:border-zinc-600",children:e.jsx(Ee,{placeholder:"Choose a platform"})}),e.jsxs(Le,{children:[e.jsx(ie,{value:"all",children:"All Platforms"},"all"),M.map(a=>e.jsx(ie,{value:a.id.toString(),children:a.name},a.id))]})]}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:'Choose "All Platforms" to make files accessible across all platforms, or select a specific platform'})]}),w&&t.length>0&&e.jsxs("div",{className:"space-y-3 border-t border-gray-200 dark:border-zinc-800 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100",children:"Upload Progress"}),e.jsxs("span",{className:"text-sm text-gray-500 dark:text-gray-400",children:[t.filter(a=>a.status==="completed").length," / ",t.length," completed"]})]}),e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto border border-gray-200 dark:border-zinc-800 rounded-lg p-2",children:t.map((a,n)=>e.jsxs("div",{className:"flex items-center space-x-3 p-2 bg-gray-50 dark:bg-gray-800 rounded",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${a.status==="completed"?"bg-green-500":a.status==="error"?"bg-red-500":"bg-blue-500 animate-pulse"}`}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate flex-1",children:a.name}),e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:a.status==="completed"?"Done":a.status==="error"?"Error":"Uploading..."})]},n))})]})]})}),e.jsx(Pe,{isOpen:o,onClose:()=>P(!1),title:"Delete this Media?",description:"Are you really sure you want to delete this media?",onConfirm:()=>pe(z==null?void 0:z.id),isDeleting:fe})]})})}export{Pa as default};
