@unciatech/file-manager 0.0.20 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -19
- package/dist/index.mjs +18 -19
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {c,b,a,s,d,f as f$1,l,E as E$1,F,p,k,z,q as q$1,n,o,m,r,j,y as y$1,x,K,L,G,C,H,e,A,w,B,h,I,J,D,i,t,u,v}from'./chunk-4DQRTTKI.mjs';import wi,{createContext,forwardRef,useMemo,useContext,useState,useRef,useEffect,useCallback,Component}from'react';import {useParams,useSearchParams,useRouter,usePathname}from'next/navigation';import {toast}from'sonner';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {Slot,Dialog,DropdownMenu,Checkbox,Label,ScrollArea}from'radix-ui';import*as Me from'@radix-ui/react-tooltip';import {Command}from'cmdk';import*as q from'@radix-ui/react-context-menu';var Mo=(e,t)=>{let a=[...e];return t.forEach(o=>{a.some(n=>n.id===o.id)?a=a.filter(n=>n.id!==o.id):a.push(o);}),a},sa=(e,t)=>{let a=[...e];return t.forEach(o=>{a.some(n=>n.id===o.id)?a=a.filter(n=>n.id!==o.id):a.push(o);}),a};function la(e){let{mode:t,selectionMode:a$1,files:o,folders:r,selectedFiles:n,selectedFolders:s,currentFolder:u,setSelectedFiles:l,setSelectedFolders:v,setCurrentFolder:m,setFiles:x,setFolders:c$1,setPagination:F,loadData:w,isInSelectionMode:M,provider:C,onFilesSelected:N,onClose:D,basePath:k,setIsLoading:b$1,setFileDetailsModalFile:S}=e,j=useRouter(),J=useCallback((P,z,O=false)=>{let V=[P];if(O||z&&(z.metaKey||z.ctrlKey)){l(K=>Mo(K,V));return}if(M()&&t!==d.MODAL){l(K=>Mo(K,V));return}if(t===d.MODAL){a$1==="single"?(l([P]),N==null||N([P]),D==null||D()):l(K=>Mo(K,V));return}S(P);},[t,a$1,M,l,N,D,S]),te=useCallback((P,z,O=false)=>{let V=P?P.id:null;if((O||z&&(z.metaKey||z.ctrlKey))&&P){v(K=>sa(K,[P]));return}if(M()&&P){v(K=>sa(K,[P]));return}if(t===d.PAGE){b$1(true);let K=k!=null?k:"/media",he=V===null?K:`${K}/${V}`;j.push(he);}else {b$1(true),l([]),v([]);let K=new URLSearchParams(window.location.search);V===null?K.delete("folderId"):K.set("folderId",String(V)),K.set("page","1");let he=`${window.location.pathname}?${K.toString()}`;j.push(he,{scroll:false});}},[M,t,j,v,l,k,b$1]),ve=useCallback(()=>{l([]),v([]);},[l,v]),d$1=useCallback(P=>{P?(l(o),v(t===d.PAGE?r:[])):(l([]),v([]));},[o,r,t,l,v]),I=useCallback(async(P=false)=>{await w(P);},[w]),g=useCallback(async P=>{var z;try{await C.uploadFiles(P,(z=u==null?void 0:u.id)!=null?z:null),await I(!0),l([]),toast.success("Upload Successful",{description:`${P.length} file(s) uploaded successfully`});}catch(O){let V=O instanceof Error?O.message:"Failed to upload files";toast.error("Upload Failed",{description:V}),console.error("Upload failed:",O);}},[u,C,I,l]),R=useCallback(async P=>{var z;try{await C.createFolder(P,(z=u==null?void 0:u.id)!=null?z:null),await I(!0),l([]),toast.success("Folder Created",{description:`Folder "${P}" created successfully`});}catch(O){let V=O instanceof Error?O.message:"Failed to create folder";toast.error("Create Folder Failed",{description:V}),console.error("Failed to create folder:",O);}},[u,C,I,l]),T=useCallback(async P=>{try{n.length>0&&await C.moveFiles(n.map(O=>O.id),P),s.length>0&&await C.moveFolders(s.map(O=>O.id),P),await I(!0),l([]),v([]);let z=n.length+s.length;toast.success("Move Successful",{description:`${z} item(s) moved successfully`});}catch(z){let O=z instanceof Error?z.message:"Failed to move items";toast.error("Move Failed",{description:O}),console.error("Failed to move items:",z);}},[n,s,C,I,l,v]),A=useCallback(async(P,z)=>{try{c$1(O=>O.map(V=>V.id===P?b(a({},V),{name:z}):V)),await C.renameFolder(P,z),await I(!0),toast.success("Folder Renamed",{description:`Folder renamed to "${z}"`});}catch(O){let V=O instanceof Error?O.message:"Failed to rename folder";toast.error("Rename Failed",{description:V}),console.error("Failed to rename folder:",O);}},[C,I]),de=useCallback(async(P,z)=>{try{x(O=>O.map(V=>{if(V.id===P){let Ve=z,{metaData:K}=Ve,he=c(Ve,["metaData"]);return b(a(a({},V),he),{metaData:K?a(a({},V.metaData),K):V.metaData})}return V})),await C.updateFileMetaData(P,z),await I(!0);}catch(O){let V=O instanceof Error?O.message:"Failed to update metadata";toast.error("Update Failed",{description:V}),console.error("Failed to update metadata:",O);}},[C,I]),yt=useCallback(async()=>{try{n.length>0&&await C.deleteFiles(n.map(z=>z.id)),s.length>0&&await C.deleteFolders(s.map(z=>z.id)),await I(!0),l([]),v([]);let P=n.length+s.length;toast.success("Delete Successful",{description:`${P} item(s) deleted successfully`});}catch(P){let z=P instanceof Error?P.message:"Failed to delete items";toast.error("Delete Failed",{description:z}),console.error("Failed to delete items:",P);}},[n,s,C,I,l,v]);return {handleFileClick:J,handleFolderClick:te,handleClearSelection:ve,handleSelectAllGlobal:d$1,uploadFiles:g,createFolder:R,bulkMove:T,renameFolder:A,updateFileMetadata:de,bulkDelete:yt,refreshData:I}}function ua(e){let{mode:t,selectionMode:a$1,initialFolderId:o,acceptedFileTypesForModal:r,allowedFileTypes:n,provider:s,onFilesSelected:u,onClose:l,basePath:v}=e,m=useParams(),x=useSearchParams(),c=useRouter(),F=usePathname(),w=Math.max(1,parseInt(x.get("page")||"1",10)),M=Math.max(1,parseInt(x.get("limit")||"24",10)),C=x.get("query")||"",N=useMemo(()=>{if(t===d.PAGE&&(m!=null&&m.path)){let L=Array.isArray(m.path)?m.path[0]:m.path;return typeof L=="string"&&/^\d+$/.test(L)?Number(L):null}if(t===d.MODAL){let L=x.get("folderId");if(L&&/^\d+$/.test(L))return Number(L)}return o!=null?o:null},[t,m,x,o]),[D,k]=useState([]),[b$1,S]=useState([]),[j,J]=useState([]),[te,ve]=useState([]),[d$1,I]=useState(null),[g,R]=useState(true),[T,A]=useState({currentPage:w,totalPages:1,totalFiles:0,filesPerPage:M}),de=useRef(null);de.current=d$1;let[yt,P]=useState(C),[z,O]=useState(C);useEffect(()=>{let L=setTimeout(()=>{O(yt);},300);return ()=>clearTimeout(L)},[yt]);let V=useRef(N),Ve=useCallback((L,ae)=>{let re=new URLSearchParams(x.toString());re.set("page",L.toString()),re.set("limit",ae.toString()),c.push(`${F}?${re.toString()}`,{scroll:false});},[c,F]);useEffect(()=>{A(L=>b(a({},L),{currentPage:w,filesPerPage:M})),P(C);},[w,M,C]),useEffect(()=>{N!==V.current&&(t===d.PAGE&&Ve(1,M),V.current=N);},[N,M,Ve,t]);let K=T.currentPage,he=T.filesPerPage;useEffect(()=>{let L=false,ae=async()=>{if(N&&(!de.current||de.current.id!==N))try{R(!0);let ne=await s.getFolder(N);if(L)return;I(ne),await re(ne);}catch(ne){let Jt=ne instanceof Error?ne.message:"Failed to load folder";if(toast.error("Load Folder Failed",{description:Jt}),console.error("Failed to fetch current folder",ne),L)return;I(null),L||R(false);}else N===null&&de.current!==null?(I(null),await re(null)):de.current?await re(de.current):await re(null);},re=async ne=>{var Jt;if(!L){R(true);try{let mt=[];t===d.MODAL?mt=r:mt=n;let Lt=await s.getItems((Jt=ne==null?void 0:ne.id)!=null?Jt:null,mt,K,he,z);if(L)return;S(Lt.folders),k(Lt.files),A(Lt.pagination);}catch(mt){let Lt=mt instanceof Error?mt.message:"Failed to load data";toast.error("Load Data Failed",{description:Lt}),console.error("Failed to load data:",mt);}finally{L||R(false);}}};return ae(),()=>{L=true;}},[N,s,t,r,n,K,he,z]),useEffect(()=>{ve([]),J([]);},[d$1]);let[zr,Rr]=useState(false),[Tr,Er]=useState(false),[Lr,_r]=useState(false),[Ar,Or]=useState(false),[Br,Vr]=useState(false),[Gr,Ur]=useState(null),[Hr,$r]=useState(null),Kr=useCallback(async(L=false)=>{var ae;L||R(true);try{let re=[];t===d.MODAL?re=r:re=n;let ne=await s.getItems((ae=d$1==null?void 0:d$1.id)!=null?ae:null,re,K,he,z);S(ne.folders),k(ne.files),A(ne.pagination);}catch(re){let ne=re instanceof Error?re.message:"Failed to load data";toast.error("Load Data Failed",{description:ne}),console.error("Failed to load data:",re);}finally{L||R(false);}},[d$1,t,r,n,s,K,he,z]),Wr=()=>j.length>0||te.length>0,jr=()=>d$1,Qr=useMemo(()=>()=>{let L=D.length+(t===d.PAGE?b$1.length:0),ae=j.length+te.length;return ae===0?false:ae===L?true:"indeterminate"},[D.length,b$1.length,j.length,te.length,t]),Yr=useCallback(L=>{A(ae=>b(a({},ae),{currentPage:L})),t===d.PAGE&&Ve(L,he);},[Ve,he,t]),qr=useCallback(L=>{P(L);let ae=new URLSearchParams(x.toString());L.trim()?(ae.set("query",L),ae.set("page","1")):ae.delete("query"),c.push(`${F}?${ae.toString()}`,{scroll:false});},[c,F,x]);return {files:D,folders:b$1,selectedFiles:j,selectedFolders:te,currentFolder:d$1,isLoading:g,pagination:T,isUploadModalOpen:zr,isCreateFolderModalOpen:Tr,isSearchModalOpen:Lr,isMoveFileModalOpen:Ar,isRenameFolderModalOpen:Br,fileDetailsModalFile:Hr,folderToRename:Gr,setFiles:k,setFolders:S,setSelectedFiles:J,setSelectedFolders:ve,setCurrentFolder:I,setPagination:A,setIsUploadModalOpen:Rr,setIsCreateFolderModalOpen:Er,setIsSearchModalOpen:_r,setIsMoveFileModalOpen:Or,setIsRenameFolderModalOpen:Vr,setFileDetailsModalFile:$r,setFolderToRename:Ur,loadData:Kr,setIsLoading:R,isInSelectionMode:Wr,getCurrentFolder:jr,getSelectionState:Qr,handlePageChange:Yr,searchQuery:yt,updateSearchQuery:qr,mode:t,selectionMode:a$1,acceptedFileTypesForModal:r,provider:s,onFilesSelected:u,onClose:l,basePath:v}}var ma=createContext(void 0);function no({children:e,mode:t=d.PAGE,selectionMode:a=f$1.SINGLE,allowedFileTypes:o,onFilesSelected:r,onClose:n,acceptedFileTypesForModal:s,initialFolderId:u=null,provider:l,basePath:v="/media",maxUploadFiles:m=50,maxUploadSize:x=100*1024*1024}){let c=ua({mode:t,selectionMode:a,initialFolderId:u,acceptedFileTypesForModal:s,allowedFileTypes:o,provider:l,onFilesSelected:r,onClose:n,basePath:v}),F=la(c),w=useMemo(()=>({files:c.files,folders:c.folders,selectedFiles:c.selectedFiles,selectedFolders:c.selectedFolders,currentFolder:c.currentFolder,isLoading:c.isLoading,pagination:c.pagination,isUploadModalOpen:c.isUploadModalOpen,isCreateFolderModalOpen:c.isCreateFolderModalOpen,isSearchModalOpen:c.isSearchModalOpen,isMoveFileModalOpen:c.isMoveFileModalOpen,isRenameFolderModalOpen:c.isRenameFolderModalOpen,fileDetailsModalFile:c.fileDetailsModalFile,folderToRename:c.folderToRename,mode:c.mode,selectionMode:c.selectionMode,allowedFileTypes:o,acceptedFileTypesForModal:c.acceptedFileTypesForModal,maxUploadFiles:m,maxUploadSize:x,setIsUploadModalOpen:c.setIsUploadModalOpen,setIsCreateFolderModalOpen:c.setIsCreateFolderModalOpen,setIsSearchModalOpen:c.setIsSearchModalOpen,setIsMoveFileModalOpen:c.setIsMoveFileModalOpen,setSelectedFiles:c.setSelectedFiles,setSelectedFolders:c.setSelectedFolders,setIsRenameFolderModalOpen:c.setIsRenameFolderModalOpen,setFileDetailsModalFile:c.setFileDetailsModalFile,setFolderToRename:c.setFolderToRename,handleFileClick:F.handleFileClick,handleFolderClick:F.handleFolderClick,handleClearSelection:F.handleClearSelection,handleSelectAllGlobal:F.handleSelectAllGlobal,handlePageChange:c.handlePageChange,searchQuery:c.searchQuery,updateSearchQuery:c.updateSearchQuery,uploadFiles:F.uploadFiles,createFolder:F.createFolder,bulkMove:F.bulkMove,renameFolder:F.renameFolder,updateFileMetadata:F.updateFileMetadata,bulkDelete:F.bulkDelete,refreshData:F.refreshData,isInSelectionMode:c.isInSelectionMode,getCurrentFolder:c.getCurrentFolder,getSelectionState:c.getSelectionState,onClose:c.onClose,onFilesSelected:c.onFilesSelected,provider:l,basePath:c.basePath}),[c,F,l,o,m,x]);return jsx(ma.Provider,{value:w,children:e})}function E(){let e=useContext(ma);if(e===void 0)throw new Error("useFileManager must be used within a FileManagerProvider");return e}function f(...e){return twMerge(clsx(e))}var pa=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("nav",a({"data-slot":"pagination",role:"navigation","aria-label":"pagination",className:f("mx-auto flex w-full justify-center",e)},t))};function fa(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("ul",a({"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e)},t))}function Ut(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("li",a({"data-slot":"pagination-item",className:f("",e)},t))}var ga=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsxs("span",b(a({"data-slot":"pagination-ellipsis","aria-hidden":true,className:f("flex h-9 w-9 items-center justify-center",e)},t),{children:[jsx(z,{className:"h-4 w-4"}),jsx("span",{className:"sr-only",children:"More pages"})]}))};var mn=cva("cursor-pointer group whitespace-nowrap focus-visible:outline-hidden inline-flex items-center justify-center has-data-[arrow=true]:justify-between whitespace-nowrap text-sm font-medium ring-offset-background transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-60 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90 data-[state=open]:bg-primary/90",mono:"bg-zinc-950 text-white dark:bg-zinc-300 dark:text-black hover:bg-zinc-950/90 dark:hover:bg-zinc-300/90 data-[state=open]:bg-zinc-950/90 dark:data-[state=open]:bg-zinc-300/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 data-[state=open]:bg-destructive/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/90 data-[state=open]:bg-secondary/90",outline:"bg-background text-accent-foreground border border-input hover:bg-accent data-[state=open]:bg-accent",dashed:"text-accent-foreground border border-input border-dashed bg-background hover:bg-accent hover:text-accent-foreground data-[state=open]:text-accent-foreground",ghost:"text-accent-foreground hover:bg-accent hover:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",dim:"text-muted-foreground hover:text-foreground data-[state=open]:text-foreground",foreground:"",inverse:""},appearance:{default:"",ghost:""},underline:{solid:"",dashed:""},underlined:{solid:"",dashed:""},size:{lg:"h-10 px-4 text-sm gap-1.5 [&_svg:not([class*=size-])]:size-4",md:"h-9 px-3 gap-1.5 text-sm [&_svg:not([class*=size-])]:size-4",sm:"h-8 px-2.5 gap-1.25 text-xs [&_svg:not([class*=size-])]:size-3.5",xs:"h-7 px-2 gap-1 text-xs [&_svg:not([class*=size-])]:size-3.5",icon:"size-9 [&_svg:not([class*=size-])]:size-4 shrink-0"},autoHeight:{true:"",false:""},radius:{md:"rounded-md",full:"rounded-full"},mode:{default:"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",icon:"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 shrink-0",link:"text-primary h-auto p-0 bg-transparent rounded-none hover:bg-transparent data-[state=open]:bg-transparent",input:`
|
|
1
|
+
import {c,b,a,s,d,f as f$1,l,E as E$1,F,p,k,z,q as q$1,n,o,m,r,j,y as y$1,x,K,L,G,C,H,e,A,w,B,h,I,J,D,i,t,u,v}from'./chunk-4DQRTTKI.mjs';import Fi,{createContext,forwardRef,useMemo,useContext,useState,useRef,useEffect,useCallback,Component}from'react';import {useParams,useSearchParams,useRouter,usePathname}from'next/navigation';import {toast}from'sonner';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {clsx}from'clsx';import {twMerge}from'tailwind-merge';import {cva}from'class-variance-authority';import {Slot,Dialog,DropdownMenu,Checkbox,Label,ScrollArea}from'radix-ui';import*as Me from'@radix-ui/react-tooltip';import {Command}from'cmdk';import*as q from'@radix-ui/react-context-menu';var Mo=(e,t)=>{let a=[...e];return t.forEach(o=>{a.some(n=>n.id===o.id)?a=a.filter(n=>n.id!==o.id):a.push(o);}),a},sa=(e,t)=>{let a=[...e];return t.forEach(o=>{a.some(n=>n.id===o.id)?a=a.filter(n=>n.id!==o.id):a.push(o);}),a};function la(e){let{mode:t,selectionMode:a$1,files:o,folders:r,selectedFiles:n,selectedFolders:s,currentFolder:m,setSelectedFiles:l,setSelectedFolders:v,setCurrentFolder:u,setFiles:x,setFolders:c$1,setPagination:w,loadData:F,isInSelectionMode:M,provider:C,onFilesSelected:N,onClose:D,basePath:k,setIsLoading:b$1,setFileDetailsModalFile:S}=e,j=useRouter(),J=useCallback((P,z,O=false)=>{let V=[P];if(O||z&&(z.metaKey||z.ctrlKey)){l(K=>Mo(K,V));return}if(M()&&t!==d.MODAL){l(K=>Mo(K,V));return}if(t===d.MODAL){a$1==="single"?(l([P]),N==null||N([P]),D==null||D()):l(K=>Mo(K,V));return}S(P);},[t,a$1,M,l,N,D,S]),te=useCallback((P,z,O=false)=>{let V=P?P.id:null;if((O||z&&(z.metaKey||z.ctrlKey))&&P){v(K=>sa(K,[P]));return}if(M()&&P){v(K=>sa(K,[P]));return}if(t===d.PAGE){b$1(true);let K=k!=null?k:"/media",he=V===null?K:`${K}/${V}`;j.push(he);}else {b$1(true),l([]),v([]);let K=new URLSearchParams(window.location.search);V===null?K.delete("folderId"):K.set("folderId",String(V)),K.set("page","1");let he=`${window.location.pathname}?${K.toString()}`;j.push(he,{scroll:false});}},[M,t,j,v,l,k,b$1]),ve=useCallback(()=>{l([]),v([]);},[l,v]),d$1=useCallback(P=>{P?(l(o),v(t===d.PAGE?r:[])):(l([]),v([]));},[o,r,t,l,v]),I=useCallback(async(P=false)=>{await F(P);},[F]),g=useCallback(async P=>{var z;try{await C.uploadFiles(P,(z=m==null?void 0:m.id)!=null?z:null),await I(!0),l([]),toast.success("Upload Successful",{description:`${P.length} file(s) uploaded successfully`});}catch(O){let V=O instanceof Error?O.message:"Failed to upload files";toast.error("Upload Failed",{description:V}),console.error("Upload failed:",O);}},[m,C,I,l]),R=useCallback(async P=>{var z;try{await C.createFolder(P,(z=m==null?void 0:m.id)!=null?z:null),await I(!0),l([]),toast.success("Folder Created",{description:`Folder "${P}" created successfully`});}catch(O){let V=O instanceof Error?O.message:"Failed to create folder";toast.error("Create Folder Failed",{description:V}),console.error("Failed to create folder:",O);}},[m,C,I,l]),T=useCallback(async P=>{try{n.length>0&&await C.moveFiles(n.map(O=>O.id),P),s.length>0&&await C.moveFolders(s.map(O=>O.id),P),await I(!0),l([]),v([]);let z=n.length+s.length;toast.success("Move Successful",{description:`${z} item(s) moved successfully`});}catch(z){let O=z instanceof Error?z.message:"Failed to move items";toast.error("Move Failed",{description:O}),console.error("Failed to move items:",z);}},[n,s,C,I,l,v]),A=useCallback(async(P,z)=>{try{c$1(O=>O.map(V=>V.id===P?b(a({},V),{name:z}):V)),await C.renameFolder(P,z),await I(!0),toast.success("Folder Renamed",{description:`Folder renamed to "${z}"`});}catch(O){let V=O instanceof Error?O.message:"Failed to rename folder";toast.error("Rename Failed",{description:V}),console.error("Failed to rename folder:",O);}},[C,I]),de=useCallback(async(P,z)=>{try{x(O=>O.map(V=>{if(V.id===P){let Ve=z,{metaData:K}=Ve,he=c(Ve,["metaData"]);return b(a(a({},V),he),{metaData:K?a(a({},V.metaData),K):V.metaData})}return V})),await C.updateFileMetaData(P,z),await I(!0);}catch(O){let V=O instanceof Error?O.message:"Failed to update metadata";toast.error("Update Failed",{description:V}),console.error("Failed to update metadata:",O);}},[C,I]),yt=useCallback(async()=>{try{n.length>0&&await C.deleteFiles(n.map(z=>z.id)),s.length>0&&await C.deleteFolders(s.map(z=>z.id)),await I(!0),l([]),v([]);let P=n.length+s.length;toast.success("Delete Successful",{description:`${P} item(s) deleted successfully`});}catch(P){let z=P instanceof Error?P.message:"Failed to delete items";toast.error("Delete Failed",{description:z}),console.error("Failed to delete items:",P);}},[n,s,C,I,l,v]);return {handleFileClick:J,handleFolderClick:te,handleClearSelection:ve,handleSelectAllGlobal:d$1,uploadFiles:g,createFolder:R,bulkMove:T,renameFolder:A,updateFileMetadata:de,bulkDelete:yt,refreshData:I}}function ma(e){let{mode:t,selectionMode:a$1,initialFolderId:o,acceptedFileTypesForModal:r,allowedFileTypes:n,provider:s,onFilesSelected:m,onClose:l,basePath:v}=e,u=useParams(),x=useSearchParams(),c=useRouter(),w=usePathname(),F=Math.max(1,parseInt(x.get("page")||"1",10)),M=Math.max(1,parseInt(x.get("limit")||"24",10)),C=x.get("query")||"",N=useMemo(()=>{if(t===d.PAGE&&(u!=null&&u.path)){let L=Array.isArray(u.path)?u.path[0]:u.path;return typeof L=="string"&&/^\d+$/.test(L)?Number(L):null}if(t===d.MODAL){let L=x.get("folderId");if(L&&/^\d+$/.test(L))return Number(L)}return o!=null?o:null},[t,u,x,o]),[D,k]=useState([]),[b$1,S]=useState([]),[j,J]=useState([]),[te,ve]=useState([]),[d$1,I]=useState(null),[g,R]=useState(true),[T,A]=useState({currentPage:F,totalPages:1,totalFiles:0,filesPerPage:M}),de=useRef(null);de.current=d$1;let[yt,P]=useState(C),[z,O]=useState(C);useEffect(()=>{let L=setTimeout(()=>{O(yt);},300);return ()=>clearTimeout(L)},[yt]);let V=useRef(N),Ve=useCallback((L,ae)=>{let re=new URLSearchParams(x.toString());re.set("page",L.toString()),re.set("limit",ae.toString()),c.push(`${w}?${re.toString()}`,{scroll:false});},[c,w]);useEffect(()=>{A(L=>b(a({},L),{currentPage:F,filesPerPage:M})),P(C);},[F,M,C]),useEffect(()=>{N!==V.current&&(t===d.PAGE&&Ve(1,M),V.current=N);},[N,M,Ve,t]);let K=T.currentPage,he=T.filesPerPage;useEffect(()=>{let L=false,ae=async()=>{if(N&&(!de.current||de.current.id!==N))try{R(!0);let ne=await s.getFolder(N);if(L)return;I(ne),await re(ne);}catch(ne){let Jt=ne instanceof Error?ne.message:"Failed to load folder";if(toast.error("Load Folder Failed",{description:Jt}),console.error("Failed to fetch current folder",ne),L)return;I(null),L||R(false);}else N===null&&de.current!==null?(I(null),await re(null)):de.current?await re(de.current):await re(null);},re=async ne=>{var Jt;if(!L){R(true);try{let ut=[];t===d.MODAL?ut=r:ut=n;let Lt=await s.getItems((Jt=ne==null?void 0:ne.id)!=null?Jt:null,ut,K,he,z);if(L)return;S(Lt.folders),k(Lt.files),A(Lt.pagination);}catch(ut){let Lt=ut instanceof Error?ut.message:"Failed to load data";toast.error("Load Data Failed",{description:Lt}),console.error("Failed to load data:",ut);}finally{L||R(false);}}};return ae(),()=>{L=true;}},[N,s,t,r,n,K,he,z]),useEffect(()=>{ve([]),J([]);},[d$1]);let[zr,Rr]=useState(false),[Tr,Er]=useState(false),[Lr,_r]=useState(false),[Ar,Or]=useState(false),[Br,Vr]=useState(false),[Gr,Ur]=useState(null),[Hr,$r]=useState(null),Kr=useCallback(async(L=false)=>{var ae;L||R(true);try{let re=[];t===d.MODAL?re=r:re=n;let ne=await s.getItems((ae=d$1==null?void 0:d$1.id)!=null?ae:null,re,K,he,z);S(ne.folders),k(ne.files),A(ne.pagination);}catch(re){let ne=re instanceof Error?re.message:"Failed to load data";toast.error("Load Data Failed",{description:ne}),console.error("Failed to load data:",re);}finally{L||R(false);}},[d$1,t,r,n,s,K,he,z]),Wr=()=>j.length>0||te.length>0,jr=()=>d$1,Qr=useMemo(()=>()=>{let L=D.length+(t===d.PAGE?b$1.length:0),ae=j.length+te.length;return ae===0?false:ae===L?true:"indeterminate"},[D.length,b$1.length,j.length,te.length,t]),Yr=useCallback(L=>{A(ae=>b(a({},ae),{currentPage:L})),t===d.PAGE&&Ve(L,he);},[Ve,he,t]),qr=useCallback(L=>{P(L);let ae=new URLSearchParams(x.toString());L.trim()?(ae.set("query",L),ae.set("page","1")):ae.delete("query"),c.push(`${w}?${ae.toString()}`,{scroll:false});},[c,w,x]);return {files:D,folders:b$1,selectedFiles:j,selectedFolders:te,currentFolder:d$1,isLoading:g,pagination:T,isUploadModalOpen:zr,isCreateFolderModalOpen:Tr,isSearchModalOpen:Lr,isMoveFileModalOpen:Ar,isRenameFolderModalOpen:Br,fileDetailsModalFile:Hr,folderToRename:Gr,setFiles:k,setFolders:S,setSelectedFiles:J,setSelectedFolders:ve,setCurrentFolder:I,setPagination:A,setIsUploadModalOpen:Rr,setIsCreateFolderModalOpen:Er,setIsSearchModalOpen:_r,setIsMoveFileModalOpen:Or,setIsRenameFolderModalOpen:Vr,setFileDetailsModalFile:$r,setFolderToRename:Ur,loadData:Kr,setIsLoading:R,isInSelectionMode:Wr,getCurrentFolder:jr,getSelectionState:Qr,handlePageChange:Yr,searchQuery:yt,updateSearchQuery:qr,mode:t,selectionMode:a$1,acceptedFileTypesForModal:r,provider:s,onFilesSelected:m,onClose:l,basePath:v}}var ua=createContext(void 0);function no({children:e,mode:t=d.PAGE,selectionMode:a=f$1.SINGLE,allowedFileTypes:o,onFilesSelected:r,onClose:n,acceptedFileTypesForModal:s,initialFolderId:m=null,provider:l,basePath:v="/media",maxUploadFiles:u=50,maxUploadSize:x=100*1024*1024}){let c=ma({mode:t,selectionMode:a,initialFolderId:m,acceptedFileTypesForModal:s,allowedFileTypes:o,provider:l,onFilesSelected:r,onClose:n,basePath:v}),w=la(c),F=useMemo(()=>({files:c.files,folders:c.folders,selectedFiles:c.selectedFiles,selectedFolders:c.selectedFolders,currentFolder:c.currentFolder,isLoading:c.isLoading,pagination:c.pagination,isUploadModalOpen:c.isUploadModalOpen,isCreateFolderModalOpen:c.isCreateFolderModalOpen,isSearchModalOpen:c.isSearchModalOpen,isMoveFileModalOpen:c.isMoveFileModalOpen,isRenameFolderModalOpen:c.isRenameFolderModalOpen,fileDetailsModalFile:c.fileDetailsModalFile,folderToRename:c.folderToRename,mode:c.mode,selectionMode:c.selectionMode,allowedFileTypes:o,acceptedFileTypesForModal:c.acceptedFileTypesForModal,maxUploadFiles:u,maxUploadSize:x,setIsUploadModalOpen:c.setIsUploadModalOpen,setIsCreateFolderModalOpen:c.setIsCreateFolderModalOpen,setIsSearchModalOpen:c.setIsSearchModalOpen,setIsMoveFileModalOpen:c.setIsMoveFileModalOpen,setSelectedFiles:c.setSelectedFiles,setSelectedFolders:c.setSelectedFolders,setIsRenameFolderModalOpen:c.setIsRenameFolderModalOpen,setFileDetailsModalFile:c.setFileDetailsModalFile,setFolderToRename:c.setFolderToRename,handleFileClick:w.handleFileClick,handleFolderClick:w.handleFolderClick,handleClearSelection:w.handleClearSelection,handleSelectAllGlobal:w.handleSelectAllGlobal,handlePageChange:c.handlePageChange,searchQuery:c.searchQuery,updateSearchQuery:c.updateSearchQuery,uploadFiles:w.uploadFiles,createFolder:w.createFolder,bulkMove:w.bulkMove,renameFolder:w.renameFolder,updateFileMetadata:w.updateFileMetadata,bulkDelete:w.bulkDelete,refreshData:w.refreshData,isInSelectionMode:c.isInSelectionMode,getCurrentFolder:c.getCurrentFolder,getSelectionState:c.getSelectionState,onClose:c.onClose,onFilesSelected:c.onFilesSelected,provider:l,basePath:c.basePath}),[c,w,l,o,u,x]);return jsx(ua.Provider,{value:F,children:e})}function E(){let e=useContext(ua);if(e===void 0)throw new Error("useFileManager must be used within a FileManagerProvider");return e}function f(...e){return twMerge(clsx(e))}var pa=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("nav",a({"data-slot":"pagination",role:"navigation","aria-label":"pagination",className:f("mx-auto flex w-full justify-center",e)},t))};function fa(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("ul",a({"data-slot":"pagination-content",className:f("flex flex-row items-center gap-1",e)},t))}function Ut(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("li",a({"data-slot":"pagination-item",className:f("",e)},t))}var ga=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsxs("span",b(a({"data-slot":"pagination-ellipsis","aria-hidden":true,className:f("flex h-9 w-9 items-center justify-center",e)},t),{children:[jsx(z,{className:"h-4 w-4"}),jsx("span",{className:"sr-only",children:"More pages"})]}))};var un=cva("cursor-pointer group whitespace-nowrap focus-visible:outline-hidden inline-flex items-center justify-center has-data-[arrow=true]:justify-between whitespace-nowrap text-sm font-medium ring-offset-background transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-60 [&_svg]:shrink-0",{variants:{variant:{primary:"bg-primary text-primary-foreground hover:bg-primary/90 data-[state=open]:bg-primary/90",mono:"bg-zinc-950 text-white dark:bg-zinc-300 dark:text-black hover:bg-zinc-950/90 dark:hover:bg-zinc-300/90 data-[state=open]:bg-zinc-950/90 dark:data-[state=open]:bg-zinc-300/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90 data-[state=open]:bg-destructive/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/90 data-[state=open]:bg-secondary/90",outline:"bg-background text-accent-foreground border border-input hover:bg-accent data-[state=open]:bg-accent",dashed:"text-accent-foreground border border-input border-dashed bg-background hover:bg-accent hover:text-accent-foreground data-[state=open]:text-accent-foreground",ghost:"text-accent-foreground hover:bg-accent hover:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",dim:"text-muted-foreground hover:text-foreground data-[state=open]:text-foreground",foreground:"",inverse:""},appearance:{default:"",ghost:""},underline:{solid:"",dashed:""},underlined:{solid:"",dashed:""},size:{lg:"h-10 px-4 text-sm gap-1.5 [&_svg:not([class*=size-])]:size-4",md:"h-9 px-3 gap-1.5 text-sm [&_svg:not([class*=size-])]:size-4",sm:"h-8 px-2.5 gap-1.25 text-xs [&_svg:not([class*=size-])]:size-3.5",xs:"h-7 px-2 gap-1 text-xs [&_svg:not([class*=size-])]:size-3.5",icon:"size-9 [&_svg:not([class*=size-])]:size-4 shrink-0"},autoHeight:{true:"",false:""},radius:{md:"rounded-md",full:"rounded-full"},mode:{default:"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",icon:"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 shrink-0",link:"text-primary h-auto p-0 bg-transparent rounded-none hover:bg-transparent data-[state=open]:bg-transparent",input:`
|
|
2
2
|
justify-start font-normal hover:bg-background [&_svg]:transition-colors [&_svg]:hover:text-foreground data-[state=open]:bg-background
|
|
3
3
|
focus-visible:border-ring focus-visible:outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/30
|
|
4
4
|
[[data-state=open]>&]:border-ring [[data-state=open]>&]:outline-hidden [[data-state=open]>&]:ring-[3px]
|
|
5
5
|
[[data-state=open]>&]:ring-ring/30
|
|
6
6
|
aria-invalid:border-destructive/60 aria-invalid:ring-destructive/10 dark:aria-invalid:border-destructive dark:aria-invalid:ring-destructive/20
|
|
7
7
|
in-data-[invalid=true]:border-destructive/60 in-data-[invalid=true]:ring-destructive/10 dark:in-data-[invalid=true]:border-destructive dark:in-data-[invalid=true]:ring-destructive/20
|
|
8
|
-
`},placeholder:{true:"text-muted-foreground",false:""}},compoundVariants:[{variant:"ghost",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"dashed",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"secondary",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"input",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"icon",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{size:"xs",autoHeight:true,className:"h-auto min-h-7"},{size:"md",autoHeight:true,className:"h-auto min-h-9"},{size:"sm",autoHeight:true,className:"h-auto min-h-8"},{size:"lg",autoHeight:true,className:"h-auto min-h-10"},{variant:"primary",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"mono",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"secondary",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"outline",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"dashed",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"destructive",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"primary",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"mono",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"secondary",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"outline",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"dashed",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"destructive",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"primary",mode:"link",underline:"solid",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"primary",mode:"link",underline:"dashed",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"primary",mode:"link",underlined:"solid",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"primary",mode:"link",underlined:"dashed",className:"font-medium text-primary hover:text-primary/90 [&_svg]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"inverse",mode:"link",underline:"solid",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"inverse",mode:"link",underline:"dashed",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"inverse",mode:"link",underlined:"solid",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"inverse",mode:"link",underlined:"dashed",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"foreground",mode:"link",underline:"solid",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"foreground",mode:"link",underline:"dashed",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"foreground",mode:"link",underlined:"solid",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"foreground",mode:"link",underlined:"dashed",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"primary",appearance:"ghost",className:"bg-transparent text-primary/90 hover:bg-primary/5 data-[state=open]:bg-primary/5"},{variant:"destructive",appearance:"ghost",className:"bg-transparent text-destructive/90 hover:bg-destructive/5 data-[state=open]:bg-destructive/5"},{variant:"ghost",mode:"icon",className:"text-muted-foreground"},{size:"xs",mode:"icon",className:"w-7 h-7 p-0 [[&_svg:not([class*=size-])]:size-3.5"},{size:"sm",mode:"icon",className:"w-8 h-8 p-0 [[&_svg:not([class*=size-])]:size-3.5"},{size:"md",mode:"icon",className:"w-9 h-9 p-0 [&_svg:not([class*=size-])]:size-4"},{size:"icon",className:"w-9 h-9 p-0 [&_svg:not([class*=size-])]:size-4"},{size:"lg",mode:"icon",className:"w-10 h-10 p-0 [&_svg:not([class*=size-])]:size-4"},{mode:"input",placeholder:true,variant:"outline",className:"font-normal text-muted-foreground"},{mode:"input",variant:"outline",size:"sm",className:"gap-1.25"},{mode:"input",variant:"outline",size:"md",className:"gap-1.5"},{mode:"input",variant:"outline",size:"lg",className:"gap-1.5"}],defaultVariants:{variant:"primary",mode:"default",size:"md",radius:"md",appearance:"default"}});function y(F){var w=F,{className:e,selected:t,variant:a$1,radius:o,appearance:r,mode:n,size:s,autoHeight:u,underlined:l,underline:v,asChild:m=false,placeholder:x=false}=w,c$1=c(w,["className","selected","variant","radius","appearance","mode","size","autoHeight","underlined","underline","asChild","placeholder"]);let M=m?Slot.Slot:"button";return jsx(M,a(a({"data-slot":"button",className:f(mn({variant:a$1,size:s,radius:o,appearance:r,mode:n,autoHeight:u,placeholder:x,underlined:l,underline:v,className:e}),m&&c$1.disabled&&"pointer-events-none opacity-50")},t&&{"data-state":"open"}),c$1))}function fn(e,t){let a=[];if(t<=7)for(let o=1;o<=t;o++)a.push(o);else e<=4?a.push(1,2,3,4,5,"ellipsis",t):e>=t-3?a.push(1,"ellipsis",t-4,t-3,t-2,t-1,t):a.push(1,"ellipsis",e-1,e,e+1,"ellipsis",t);return a}function va({className:e}){let{pagination:t,handlePageChange:a,files:o$1,folders:r}=E(),{currentPage:n,totalPages:s}=t,u=((o$1==null?void 0:o$1.length)||0)+((r==null?void 0:r.length)||0);if(s<=1||u===0)return null;let l=fn(n,s);return jsx(pa,{className:e,children:jsxs(fa,{children:[jsx(Ut,{children:jsx(y,{variant:"ghost",radius:"full",asChild:true,disabled:n===1,onClick:()=>n>1&&a(n-1),children:jsxs("span",{children:[jsx(p,{className:"rtl:rotate-180"})," Previous"]})})}),l.map((v,m)=>v==="ellipsis"?jsx(Ut,{children:jsx(ga,{})},`ellipsis-${n}-${s}-${m}`):jsx(Ut,{children:jsx(y,{variant:v===n?"outline":"ghost",mode:"icon",size:"icon",radius:"full",asChild:true,onClick:()=>a(v),disabled:v===n,children:jsx("span",{children:v})})},v)),jsx(Ut,{children:jsx(y,{variant:"ghost",radius:"full",asChild:true,disabled:n===s,onClick:()=>n<s&&a(n+1),children:jsxs("span",{children:["Next ",jsx(o,{className:"rtl:rotate-180"})]})})})]})})}function xa({children:e,className:t}){return jsx("div",{className:f("p-4 flex md:flex-row gap-2",t),children:e})}var xn=cva("flex flex-col fixed outline-0 z-50 border border-border bg-background shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-2xl",{variants:{variant:{default:"left-[50%] top-[50%] max-w-lg translate-x-[-50%] translate-y-[-50%] w-full p-6 max-h-[90dvh]",fullscreen:"top-5 left-5 right-5 bottom-5"}},defaultVariants:{variant:"default"}});function we(t){var e=c(t,[]);return jsx(Dialog.Root,a({"data-slot":"dialog"},e))}function bn(t){var e=c(t,[]);return jsx(Dialog.Portal,a({"data-slot":"dialog-portal"},e))}function Ge(t){var e=c(t,[]);return jsx(Dialog.Close,a({"data-slot":"dialog-close"},e))}function hn(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Overlay,a({"data-slot":"dialog-overlay",className:f("fixed inset-0 z-50 bg-black/30 [backdrop-filter:blur(4px)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e)},t))}function Fe(s$1){var u=s$1,{className:e,children:t,showCloseButton:a$1=true,overlay:o=true,variant:r}=u,n=c(u,["className","children","showCloseButton","overlay","variant"]);return jsxs(bn,{children:[o&&jsx(hn,{}),jsxs(Dialog.Content,b(a({"data-slot":"dialog-content",className:f(xn({variant:r}),e)},n),{children:[t,a$1&&jsxs(Ge,{className:"cursor-pointer outline-0 absolute end-5 top-5 rounded-full opacity-60 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[jsx(s,{className:"size-4 text-gray-600 dark:text-zinc-400"}),jsx("span",{className:"sr-only",children:"Close"})]})]}))]})}var Le=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"dialog-header",className:f("flex flex-col space-y-1 text-center sm:text-start mb-5",e)},t))},_e=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"dialog-footer",className:f("flex flex-col-reverse sm:flex-row sm:justify-end pt-5 sm:space-x-2.5",e)},t))};function Ne(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Title,a({"data-slot":"dialog-title",className:f("text-lg font-semibold leading-none tracking-tight",e)},t))}function Je(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Description,a({"data-slot":"dialog-description",className:f("text-sm text-muted-foreground",e)},t))}var Cn=cva("flex items-stretch w-full gap-2 group-[.toaster]:w-(--width)",{variants:{variant:{secondary:"",primary:"",destructive:"",success:"",info:"",mono:"",warning:""},icon:{primary:"",destructive:"",success:"",info:"",warning:""},appearance:{solid:"",outline:"",light:"",stroke:"text-foreground"},size:{lg:"rounded-lg p-4 gap-3 text-base [&>[data-slot=alert-icon]>svg]:size-6 *:data-slot=alert-icon:mt-0.5 [&_[data-slot=alert-close]]:mt-1",md:"rounded-lg p-3.5 gap-2.5 text-sm [&>[data-slot=alert-icon]>svg]:size-5 *:data-slot=alert-icon:mt-0 [&_[data-slot=alert-close]]:mt-0.5",sm:"rounded-md px-3 py-2.5 gap-2 text-xs [&>[data-slot=alert-icon]>svg]:size-4 *:data-alert-icon:mt-0.5 [&_[data-slot=alert-close]]:mt-0.25 [&_[data-slot=alert-close]_svg]:size-3.5"}},compoundVariants:[{variant:"secondary",appearance:"solid",className:"bg-muted text-foreground"},{variant:"primary",appearance:"solid",className:"bg-primary text-primary-foreground"},{variant:"destructive",appearance:"solid",className:"bg-destructive text-destructive-foreground"},{variant:"success",appearance:"solid",className:"bg-[var(--color-success,var(--color-green-500))] text-[var(--color-success-foreground,var(--color-white))]"},{variant:"info",appearance:"solid",className:"bg-[var(--color-info,var(--color-violet-600))] text-[var(--color-info-foreground,var(--color-white))]"},{variant:"warning",appearance:"solid",className:"bg-[var(--color-warning,var(--color-yellow-500))] text-[var(--color-warning-foreground,var(--color-white))]"},{variant:"mono",appearance:"solid",className:"bg-zinc-950 text-white dark:bg-zinc-300 dark:text-black *:data-slot-[alert=close]:text-white"},{variant:"secondary",appearance:"outline",className:"border border-border bg-background text-foreground [&_[data-slot=alert-close]]:text-foreground"},{variant:"primary",appearance:"outline",className:"border border-border bg-background text-primary [&_[data-slot=alert-close]]:text-foreground"},{variant:"destructive",appearance:"outline",className:"border border-border bg-background text-destructive [&_[data-slot=alert-close]]:text-foreground"},{variant:"success",appearance:"outline",className:"border border-border bg-background text-[var(--color-success,var(--color-green-500))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"info",appearance:"outline",className:"border border-border bg-background text-[var(--color-info,var(--color-violet-600))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"warning",appearance:"outline",className:"border border-border bg-background text-[var(--color-warning,var(--color-yellow-500))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"mono",appearance:"outline",className:"border border-border bg-background text-foreground [&_[data-slot=alert-close]]:text-foreground"},{variant:"secondary",appearance:"light",className:"bg-muted border border-border text-foreground"},{variant:"primary",appearance:"light",className:"text-foreground bg-[var(--color-primary-soft,var(--color-blue-50))] border border-[var(--color-primary-alpha,var(--color-blue-100))] [&_[data-slot=alert-icon]]:text-primary dark:bg-[var(--color-primary-soft,var(--color-blue-950))] dark:border-[var(--color-primary-alpha,var(--color-blue-900))]"},{variant:"destructive",appearance:"light",className:"bg-[var(--color-destructive-soft,var(--color-red-50))] border border-[var(--color-destructive-alpha,var(--color-red-100))] text-foreground [&_[data-slot=alert-icon]]:text-destructive dark:bg-[var(--color-destructive-soft,var(--color-red-950))] dark:border-[var(--color-destructive-alpha,var(--color-red-900))] "},{variant:"success",appearance:"light",className:"bg-[var(--color-success-soft,var(--color-green-50))] border border-[var(--color-success-alpha,var(--color-green-200))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-success-foreground,var(--color-green-600))] dark:bg-[var(--color-success-soft,var(--color-green-950))] dark:border-[var(--color-success-alpha,var(--color-green-900))]"},{variant:"info",appearance:"light",className:"bg-[var(--color-info-soft,var(--color-violet-50))] border border-[var(--color-info-alpha,var(--color-violet-100))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-info-foreground,var(--color-violet-600))] dark:bg-[var(--color-info-soft,var(--color-violet-950))] dark:border-[var(--color-info-alpha,var(--color-violet-900))]"},{variant:"warning",appearance:"light",className:"bg-[var(--color-warning-soft,var(--color-yellow-50))] border border-[var(--color-warning-alpha,var(--color-yellow-200))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-warning-foreground,var(--color-yellow-600))] dark:bg-[var(--color-warning-soft,var(--color-yellow-950))] dark:border-[var(--color-warning-alpha,var(--color-yellow-900))]"},{variant:"mono",icon:"primary",className:"[&_[data-slot=alert-icon]]:text-primary"},{variant:"mono",icon:"warning",className:"[&_[data-slot=alert-icon]]:text-[var(--color-warning-foreground,var(--color-yellow-600))]"},{variant:"mono",icon:"success",className:"[&_[data-slot=alert-icon]]:text-[var(--color-success-foreground,var(--color-green-600))]"},{variant:"mono",icon:"destructive",className:"[&_[data-slot=alert-icon]]:text-destructive"},{variant:"mono",icon:"info",className:"[&_[data-slot=alert-icon]]:text-[var(--color-info-foreground,var(--color-violet-600))]"}],defaultVariants:{variant:"secondary",appearance:"solid",size:"md"}});function ba(v){var m=v,{className:e,variant:t,size:a$1,icon:o,appearance:r,close:n=false,onClose:s$1,children:u}=m,l=c(m,["className","variant","size","icon","appearance","close","onClose","children"]);return jsxs("div",b(a({"data-slot":"alert",role:"alert",className:f(Cn({variant:t,size:a$1,icon:o,appearance:r}),e)},l),{children:[u,n&&jsx("button",{onClick:s$1,"aria-label":"Dismiss","data-slot":"alert-close",className:f("group shrink-0 size-4 cursor-pointer"),children:jsx(s,{className:"opacity-60 group-hover:opacity-100 size-4"})})]}))}function ha(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-title",className:f("grow tracking-tight",e)},t))}function ya(o){var r=o,{children:e,className:t}=r,a$1=c(r,["children","className"]);return jsx("div",b(a({"data-slot":"alert-icon",className:f("shrink-0",t)},a$1),{children:e}))}function Ca(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-description",className:f("text-sm [&_p]:leading-relaxed [&_p]:mb-2",e)},t))}function wa(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-content",className:f("space-y-2 [&_[data-slot=alert-title]]:font-semibold",e)},t))}function Fn(a$1){var o=a$1,{delayDuration:e=0}=o,t=c(o,["delayDuration"]);return jsx(Me.Provider,a({"data-slot":"tooltip-provider",delayDuration:e},t))}function Fa(t){var e=c(t,[]);return jsx(Fn,{children:jsx(Me.Root,a({"data-slot":"tooltip"},e))})}function Na(t){var e=c(t,[]);return jsx(Me.Trigger,a({"data-slot":"tooltip-trigger"},e))}function Ma(r){var n=r,{className:e,sideOffset:t=0,children:a$1}=n,o=c(n,["className","sideOffset","children"]);return jsx(Me.Portal,{children:jsxs(Me.Content,b(a({"data-slot":"tooltip-content",sideOffset:t,className:f("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e)},o),{children:[a$1,jsx(Me.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]}))})}function ee(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(e)/Math.log(t));return Number.parseFloat((e/Math.pow(t,o)).toFixed(2))+" "+a[o]}var ka=(e={})=>{let{maxFiles:t=Number.POSITIVE_INFINITY,maxSize:a$1=Number.POSITIVE_INFINITY,accept:o="*",multiple:r=false,initialFiles:n=[],onFilesChange:s,onFilesAdded:u,onError:l}=e,[v,m]=useState({files:n.map(d=>({file:d,id:d.id,preview:d.url})),isDragging:false,errors:[]}),x=useRef(null);useEffect(()=>()=>{v.files.forEach(d=>{d.preview&&d.file instanceof File&&URL.revokeObjectURL(d.preview);});},[v.files]);let c=useCallback(d=>{if(d instanceof File){if(d.size>a$1)return `File "${d.name}" exceeds the maximum size of ${ee(a$1)}.`}else if(d.size>a$1)return `File "${d.name}" exceeds the maximum size of ${ee(a$1)}.`;if(o!=="*"){let I=o.split(",").map(A=>A.trim()),g=d instanceof File?d.type||"":d.type,R=`.${d.name.split(".").pop()}`;if(!I.some(A=>{if(A.startsWith("."))return R.toLowerCase()===A.toLowerCase();if(A.endsWith("/*")){let de=A.split("/")[0];return g.startsWith(`${de}/`)}return g===A}))return `File "${d.name}" is not an accepted file type.`}return null},[o,a$1]),F=useCallback(d=>d instanceof File?URL.createObjectURL(d):d.url,[]),w=useCallback(d=>d instanceof File?`${d.name}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`:d.id.toString(),[]),M=useCallback(()=>{m(d=>{for(let g of d.files)g.preview&&g.file instanceof File&&g.file.type.startsWith("image/")&&URL.revokeObjectURL(g.preview);x.current&&(x.current.value="");let I=b(a({},d),{files:[],errors:[]});return s==null||s(I.files),I});},[s]),C=useCallback(d=>{if(!d||d.length===0)return;let I=Array.from(d),g=[];m(R=>b(a({},R),{errors:[]})),r||M(),m(R=>{if(r&&t!==Number.POSITIVE_INFINITY&&R.files.length+I.length>t)return g.push(`You can only upload a maximum of ${t} files.`),l==null||l(g),b(a({},R),{errors:g});let T=[];for(let A of I){if(r&&R.files.some(P=>P.file.name===A.name&&P.file.size===A.size))continue;if(A.size>a$1){g.push(r?`Some files exceed the maximum size of ${ee(a$1)}.`:`File exceeds the maximum size of ${ee(a$1)}.`);continue}let de=c(A);de?g.push(de):T.push({file:A,id:w(A),preview:F(A)});}if(T.length>0){u==null||u(T);let A=r?[...R.files,...T]:T;return s==null||s(A),b(a({},R),{files:A,errors:g})}else if(g.length>0)return l==null||l(g),b(a({},R),{errors:g});return R}),x.current&&(x.current.value="");},[t,r,a$1,c,F,w,M,s,u,l]),N=useCallback(d=>{m(I=>{let g=I.files.find(T=>T.id===d);g&&g.preview&&g.file instanceof File&&g.file.type.startsWith("image/")&&URL.revokeObjectURL(g.preview);let R=I.files.filter(T=>T.id!==d);return s==null||s(R),b(a({},I),{files:R,errors:[]})});},[s]),D=useCallback(()=>{m(d=>b(a({},d),{errors:[]}));},[]),k=useCallback(d=>{d.preventDefault(),d.stopPropagation(),m(I=>b(a({},I),{isDragging:true}));},[]),b$1=useCallback(d=>{d.preventDefault(),d.stopPropagation(),!d.currentTarget.contains(d.relatedTarget)&&m(I=>b(a({},I),{isDragging:false}));},[]),S=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),j=useCallback(d=>{var I;if(d.preventDefault(),d.stopPropagation(),m(g=>b(a({},g),{isDragging:false})),!((I=x.current)!=null&&I.disabled)&&d.dataTransfer.files&&d.dataTransfer.files.length>0)if(r)C(d.dataTransfer.files);else {let g=d.dataTransfer.files[0];C([g]);}},[C,r]),J=useCallback(d=>{d.target.files&&d.target.files.length>0&&C(d.target.files);},[C]),te=useCallback(()=>{x.current&&x.current.click();},[]),ve=useCallback((d={})=>b(a({},d),{type:"file",onChange:J,accept:d.accept||o,multiple:d.multiple!==void 0?d.multiple:r,ref:x}),[o,r,J]);return [v,{addFiles:C,removeFile:N,clearFiles:M,clearErrors:D,handleDragEnter:k,handleDragLeave:b$1,handleDragOver:S,handleDrop:j,handleFileChange:J,openFileDialog:te,getInputProps:ve}]};function Io(e){return jsxs("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",color:"currentColor"},e),{children:[jsx("path",{d:"M13.0059 21.25C13.0059 21.8023 12.5581 22.25 12.0059 22.25C11.4536 22.25 11.0059 21.8023 11.0059 21.25L11.0059 16.75L10.4116 16.75C10.236 16.7501 10.0203 16.7503 9.84387 16.7282L9.84053 16.7278C9.71408 16.712 9.13804 16.6402 8.86368 16.0746C8.58872 15.5078 8.89065 15.0076 8.95597 14.8994L8.95841 14.8954C9.05062 14.7424 9.18477 14.5715 9.29511 14.4309L9.31885 14.4007C9.61348 14.0249 9.99545 13.5406 10.3759 13.1496C10.5657 12.9545 10.783 12.7533 11.0139 12.5944C11.2191 12.4532 11.5693 12.25 12 12.25C12.4307 12.25 12.7809 12.4532 12.9861 12.5944C13.217 12.7533 13.4343 12.9545 13.6241 13.1496C14.0046 13.5406 14.3865 14.0249 14.6812 14.4007L14.7049 14.4309C14.8152 14.5715 14.9494 14.7424 15.0416 14.8954L15.044 14.8994C15.1093 15.0076 15.4113 15.5078 15.1363 16.0746C14.862 16.6402 14.2859 16.712 14.1595 16.7278L14.1561 16.7282C13.9797 16.7503 13.764 16.7501 13.5884 16.75L13.0059 16.75L13.0059 21.25Z",fill:"currentColor",fillRule:"evenodd"}),jsx("path",{d:"M1.25 12.5C1.25 9.85827 3.03106 7.63322 5.45825 6.9592C5.65424 6.90478 5.75224 6.87756 5.80872 6.81971C5.8652 6.76186 5.88991 6.66386 5.93931 6.46785C6.62272 3.75655 9.07671 1.75002 12 1.75002C15.2149 1.75002 17.8628 4.17733 18.2112 7.29925C18.2385 7.54461 18.2522 7.66731 18.3147 7.7383C18.3772 7.80929 18.4989 7.83881 18.7423 7.89787C21.0422 8.4559 22.75 10.5285 22.75 13C22.75 15.8995 20.3995 18.25 17.5 18.25H16.4006C15.942 18.25 15.7126 18.25 15.6826 18.2119C15.6679 18.1933 15.6641 18.1839 15.6617 18.1604C15.6567 18.1121 15.8519 17.9223 16.2425 17.5427C17.2326 16.5804 17.255 14.9976 16.2927 14.0075C15.6442 13.1982 15.0315 12.3422 14.2379 11.6663C13.6086 11.1303 12.8426 10.75 12 10.75C11.1574 10.75 10.3914 11.1303 9.76209 11.6663C8.96846 12.3422 8.35575 13.1982 7.7073 14.0075C6.74496 14.9976 6.76745 16.5804 7.75753 17.5427C8.14807 17.9223 8.34334 18.1121 8.33832 18.1604C8.33587 18.1839 8.33206 18.1933 8.31739 18.2119C8.28737 18.25 8.05801 18.25 7.59942 18.25H7C3.82436 18.25 1.25 15.6757 1.25 12.5Z",fill:"currentColor"})]}))}var xe=forwardRef((n,r)=>{var s$1=n,{className:e,iconClassName:t,label:a$1="Close"}=s$1,o=c(s$1,["className","iconClassName","label"]);return jsxs(y,b(a({ref:r,variant:"outline",size:"icon",radius:"full",type:"button",className:f("border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-gray-500 dark:text-zinc-400","hover:text-red-600 hover:border-red-300 hover:bg-red-50","dark:hover:text-red-400 dark:hover:border-red-700 dark:hover:bg-red-900/40","active:scale-95 transition-all duration-200",e)},o),{children:[jsx(s,{className:f("size-5 transition-colors text-inherit",t)}),jsx("span",{className:"sr-only",children:a$1})]}))});xe.displayName="CloseButton";function Sa({file:e}){var r;let[t,a]=useState(false),o=e.previewUrl||e.url;return o&&!t?jsx("img",{src:o,alt:((r=e==null?void 0:e.name)==null?void 0:r.substring(0,10))||"image",className:"w-full h-full object-contain rounded-md drop-shadow-md",onError:()=>a(true)}):jsx(i,{})}function za({file:e}){return e.caption?jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400 line-clamp-2 mb-2",children:[e.height," x ",e.width]}):null}function Ra({file:e,className:t}){let[a,o]=useState(false);return e.previewUrl&&!a?jsxs("div",{className:"relative w-full h-full",children:[jsx("img",{src:e.previewUrl,className:"w-full h-full object-contain rounded-md",alt:e.name,onError:()=>o(true)}),jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx("div",{className:"bg-black/60 rounded-full p-2 backdrop-blur-xs",children:jsx(D,{className:"size-5 text-white fill-white"})})})]}):e.url&&!a?jsxs("div",{className:"relative w-full h-full",children:[jsx("video",{src:`${e.url}#t=0.001`,className:"w-full h-full object-contain rounded-md",preload:"metadata",muted:true,playsInline:true,onError:()=>o(true)}),jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx("div",{className:"bg-black/60 rounded-full p-2 backdrop-blur-xs",children:jsx(D,{className:"size-5 text-white fill-white"})})})]}):jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent",children:jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:"video",className:t})})})})}function Ta({file:e}){var t;return (t=e.metaData)!=null&&t.duration?jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400 mb-2",children:["Duration: ",Math.floor(e.metaData.duration/60),":",(e.metaData.duration%60).toString().padStart(2,"0")]}):null}function Ea({file:e,className:t}){return jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent",children:jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:"audio",className:t})})})})}function La({file:e}){var t;return (t=e.metaData)!=null&&t.duration?jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400 mb-2",children:["Duration: ",Math.floor(e.metaData.duration/60),":",(e.metaData.duration%60).toString().padStart(2,"0")]}):null}function _a({file:e,className:t}){let a=I(e.mime,e.ext);return jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent relative",children:e.previewUrl?jsx("img",{src:e.previewUrl,alt:e.name,className:"w-full h-full object-contain rounded-md drop-shadow-md"}):jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:a,className:t})})})})}function Aa({file:e}){var t;return (t=e.metaData)!=null&&t.pageCount?jsxs("p",{className:"text-xs text-blue-600 dark:text-blue-400 mb-2",children:["Pages: ",e.metaData.pageCount]}):null}function Oa({file:e}){let t=I(e.mime,e.ext);return jsx(J,{type:t})}var Ba={images:{component:Sa,metadataComponent:za},videos:{component:Ra,metadataComponent:Ta},files:{component:_a,metadataComponent:Aa},audios:{component:Ea,metadataComponent:La},default:{component:Oa}};function Xe(e){let t=H(e.mime,e.ext);return Ba[t]||Ba.default}function Mt(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("kbd",a({"data-slot":"kbd",className:f("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e)},t))}function kt(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("kbd",a({"data-slot":"kbd-group",className:f("inline-flex items-center gap-1",e)},t))}function Ga(){let{isUploadModalOpen:e,setIsUploadModalOpen:t,uploadFiles:a$1,allowedFileTypes:o,maxUploadFiles:r,maxUploadSize:n}=E(),s=K(o),u=L(o),[l,v]=useState([]),[{isDragging:m,errors:x},{removeFile:c,clearFiles:F$1,handleDragEnter:w,handleDragLeave:M,handleDragOver:C,handleDrop:N,openFileDialog:D,getInputProps:k}]=ka({maxFiles:r,maxSize:n,accept:s,multiple:true,onFilesChange:g=>{let R=g.map(T=>{let A=l.find(de=>de.id===T.id);return A?a(a({},A),T):b(a({},T),{progress:100,status:"completed"})});v(R);}}),b$1=g=>{c(g);},S=g=>{v(R=>R.map(T=>T.id===g?b(a({},T),{progress:0,status:"uploading",error:void 0}):T));},j=()=>{let g=l.filter(R=>R.status==="completed");if(g.length>0){let R=g.map(T=>({name:T.file.name,size:T.file.size,type:H(T.file.type,T.file.name.split(".").pop()),lastModified:T.file instanceof File?T.file.lastModified:Date.now(),file:T.file,metadata:{}}));a$1(R),J();}},J=()=>{t(false),F$1(),v([]);},te=(g,R)=>{let T={id:"temp",name:g.name,size:g.size,mime:g.type,ext:g.name.split(".").pop()||"",url:R||"",createdAt:new Date(g.lastModified),updatedAt:new Date(g.lastModified),folderId:null,metaData:{}},{component:A}=Xe(T);return jsx(A,{file:T,metaData:T.metaData})},ve=l.filter(g=>g.status==="completed").length,d=l.filter(g=>g.status==="uploading").length,I=ve>0&&d===0;return jsx(we,{open:e,onOpenChange:t,children:jsxs(Fe,{className:"p-0 max-w-4xl max-h-[80vh] flex flex-col",variant:"default",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{children:["Upload Files",jsx(kt,{className:"ml-2",children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + U"]})})]}),jsx(xe,{onClick:()=>t(false)})]})}),jsx(Je,{})]}),jsxs("div",{className:"p-6 overflow-y-auto flex-1",children:[jsxs("div",{className:f("relative rounded-lg border-dashed border-[2.5px] bg-gray-100 dark:bg-zinc-800 border-gray-300 dark:border-zinc-600 px-6 py-16 text-center transition-colors mb-4",m?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),onDragEnter:w,onDragLeave:M,onDragOver:C,onDrop:N,children:[jsx("input",b(a({},k()),{className:"sr-only"})),jsxs("div",{className:"flex flex-col items-center",children:[jsx("div",{className:f("flex h-12 w-12 items-center justify-center rounded-full transition-colors",m?"border-primary bg-primary/10":"border-muted-foreground/25"),children:jsx(Io,{className:"mb-3 text-zinc-400 dark:text-zinc-500"})}),jsxs("div",{className:"space-y-2",children:[jsxs("p",{className:"text-sm font-medium",children:["Drop files here or"," ",jsx("button",{type:"button",onClick:D,className:"cursor-pointer text-blue-600 dark:text-blue-400 underline-offset-4 underline",children:"browse files"})]}),jsxs("p",{className:"text-xs text-muted-foreground",children:[u," \u2022 Max size: ",ee(n)," \u2022 Max files: ",r]})]})]})]}),l.length>0&&jsx("div",{className:"space-y-4",children:jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:l.map(g=>jsxs("div",{className:"relative group",children:[jsx(xe,{onClick:()=>b$1(g.id),className:"absolute -inset-e-2 -top-2 z-10 size-6 rounded-full opacity-0 transition-opacity group-hover:opacity-100",iconClassName:"size-3"}),jsxs("div",{className:"relative overflow-hidden rounded-lg border bg-card transition-colors",children:[jsx("div",{className:"relative aspect-square bg-muted border-b border-slate-200 dark:border-zinc-800",children:jsx("div",{className:"flex h-full items-center justify-center p-4",children:jsx("div",{className:"w-[75%] h-[75%] flex items-center justify-center",children:g.status==="uploading"?jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[jsxs("svg",{className:"size-12 -rotate-90 absolute",viewBox:"0 0 48 48",children:[jsx("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted-foreground/20"}),jsx("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${2*Math.PI*20}`,strokeDashoffset:`${2*Math.PI*20*(1-g.progress/100)}`,className:"text-primary transition-all duration-300",strokeLinecap:"round"})]}),g.file instanceof File&&te(g.file,g.preview)]}):g.file instanceof File&&te(g.file,g.preview)})})}),jsx("div",{className:"p-3",children:jsxs("div",{className:"space-y-1",children:[jsx("p",{className:"truncate text-xs font-medium",children:g.file.name}),jsxs("div",{className:"relative flex items-center justify-between gap-2",children:[jsx("span",{className:"text-[11px] text-blue-600 dark:text-blue-400 font-semibold tracking-tight",children:ee(g.file.size)}),g.status==="error"&&g.error&&jsxs(Fa,{children:[jsx(Na,{asChild:true,children:jsx(y,{onClick:()=>S(g.id),variant:"ghost",size:"icon",className:"absolute end-0 -top-1.25 size-6 text-destructive hover:bg-destructive/10 hover:text-destructive",children:jsx(F,{className:"size-3 opacity-100"})})}),jsx(Ma,{children:"Upload failed. Retry"})]})]})]})})]})]},g.id))})}),x.length>0&&jsxs(ba,{variant:"destructive",appearance:"light",className:"mt-5",children:[jsx(ya,{children:jsx(G,{})}),jsxs(wa,{children:[jsx(ha,{children:"File upload error(s)"}),jsx(Ca,{children:x.map((g,R)=>jsx("p",{className:"last:mb-0",children:g},R))})]})]})]}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",radius:"full",variant:"outline",onClick:J,className:"w-full md:w-auto",children:"Cancel"})}),jsxs(y,{type:"button",radius:"full",onClick:j,disabled:!I,className:"w-full md:w-auto",children:["Upload ",ve>0&&`(${ve})`]})]})]})})}var On=cva(`
|
|
8
|
+
`},placeholder:{true:"text-muted-foreground",false:""}},compoundVariants:[{variant:"ghost",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"dashed",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"secondary",mode:"default",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"input",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{variant:"outline",mode:"icon",className:"[&_svg:not([role=img]):not([class*=text-]):not([class*=opacity-])]:opacity-60"},{size:"xs",autoHeight:true,className:"h-auto min-h-7"},{size:"md",autoHeight:true,className:"h-auto min-h-9"},{size:"sm",autoHeight:true,className:"h-auto min-h-8"},{size:"lg",autoHeight:true,className:"h-auto min-h-10"},{variant:"primary",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"mono",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"secondary",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"outline",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"dashed",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"destructive",mode:"default",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"primary",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"mono",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"secondary",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"outline",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"dashed",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"destructive",mode:"icon",appearance:"default",className:"shadow-xs shadow-black/5"},{variant:"primary",mode:"link",underline:"solid",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"primary",mode:"link",underline:"dashed",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"primary",mode:"link",underlined:"solid",className:"font-medium text-primary hover:text-primary/90 [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"primary",mode:"link",underlined:"dashed",className:"font-medium text-primary hover:text-primary/90 [&_svg]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"inverse",mode:"link",underline:"solid",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"inverse",mode:"link",underline:"dashed",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"inverse",mode:"link",underlined:"solid",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"inverse",mode:"link",underlined:"dashed",className:"font-medium text-inherit [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"foreground",mode:"link",underline:"solid",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-solid"},{variant:"foreground",mode:"link",underline:"dashed",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 hover:underline hover:underline-offset-4 hover:decoration-dashed decoration-1"},{variant:"foreground",mode:"link",underlined:"solid",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-solid"},{variant:"foreground",mode:"link",underlined:"dashed",className:"font-medium text-foreground [&_svg:not([role=img]):not([class*=text-])]:opacity-60 underline underline-offset-4 decoration-dashed decoration-1"},{variant:"primary",appearance:"ghost",className:"bg-transparent text-primary/90 hover:bg-primary/5 data-[state=open]:bg-primary/5"},{variant:"destructive",appearance:"ghost",className:"bg-transparent text-destructive/90 hover:bg-destructive/5 data-[state=open]:bg-destructive/5"},{variant:"ghost",mode:"icon",className:"text-muted-foreground"},{size:"xs",mode:"icon",className:"w-7 h-7 p-0 [[&_svg:not([class*=size-])]:size-3.5"},{size:"sm",mode:"icon",className:"w-8 h-8 p-0 [[&_svg:not([class*=size-])]:size-3.5"},{size:"md",mode:"icon",className:"w-9 h-9 p-0 [&_svg:not([class*=size-])]:size-4"},{size:"icon",className:"w-9 h-9 p-0 [&_svg:not([class*=size-])]:size-4"},{size:"lg",mode:"icon",className:"w-10 h-10 p-0 [&_svg:not([class*=size-])]:size-4"},{mode:"input",placeholder:true,variant:"outline",className:"font-normal text-muted-foreground"},{mode:"input",variant:"outline",size:"sm",className:"gap-1.25"},{mode:"input",variant:"outline",size:"md",className:"gap-1.5"},{mode:"input",variant:"outline",size:"lg",className:"gap-1.5"}],defaultVariants:{variant:"primary",mode:"default",size:"md",radius:"md",appearance:"default"}});function y(w){var F=w,{className:e,selected:t,variant:a$1,radius:o,appearance:r,mode:n,size:s,autoHeight:m,underlined:l,underline:v,asChild:u=false,placeholder:x=false}=F,c$1=c(F,["className","selected","variant","radius","appearance","mode","size","autoHeight","underlined","underline","asChild","placeholder"]);let M=u?Slot.Slot:"button";return jsx(M,a(a({"data-slot":"button",className:f(un({variant:a$1,size:s,radius:o,appearance:r,mode:n,autoHeight:m,placeholder:x,underlined:l,underline:v,className:e}),u&&c$1.disabled&&"pointer-events-none opacity-50")},t&&{"data-state":"open"}),c$1))}function fn(e,t){let a=[];if(t<=7)for(let o=1;o<=t;o++)a.push(o);else e<=4?a.push(1,2,3,4,5,"ellipsis",t):e>=t-3?a.push(1,"ellipsis",t-4,t-3,t-2,t-1,t):a.push(1,"ellipsis",e-1,e,e+1,"ellipsis",t);return a}function va({className:e}){let{pagination:t,handlePageChange:a,files:o$1,folders:r}=E(),{currentPage:n,totalPages:s}=t,m=((o$1==null?void 0:o$1.length)||0)+((r==null?void 0:r.length)||0);if(s<=1||m===0)return null;let l=fn(n,s);return jsx(pa,{className:e,children:jsxs(fa,{children:[jsx(Ut,{children:jsx(y,{variant:"ghost",radius:"full",asChild:true,disabled:n===1,onClick:()=>n>1&&a(n-1),children:jsxs("span",{children:[jsx(p,{className:"rtl:rotate-180"})," Previous"]})})}),l.map((v,u)=>v==="ellipsis"?jsx(Ut,{children:jsx(ga,{})},`ellipsis-${n}-${s}-${u}`):jsx(Ut,{children:jsx(y,{variant:v===n?"outline":"ghost",mode:"icon",size:"icon",radius:"full",asChild:true,onClick:()=>a(v),disabled:v===n,children:jsx("span",{children:v})})},v)),jsx(Ut,{children:jsx(y,{variant:"ghost",radius:"full",asChild:true,disabled:n===s,onClick:()=>n<s&&a(n+1),children:jsxs("span",{children:["Next ",jsx(o,{className:"rtl:rotate-180"})]})})})]})})}function xa({children:e,className:t}){return jsx("div",{className:f("p-4 flex md:flex-row gap-2",t),children:e})}var xn=cva("flex flex-col fixed outline-0 z-50 border border-border bg-background shadow-lg shadow-black/5 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 rounded-2xl",{variants:{variant:{default:"left-[50%] top-[50%] max-w-lg translate-x-[-50%] translate-y-[-50%] w-full p-6 max-h-[90dvh]",fullscreen:"top-5 left-5 right-5 bottom-5"}},defaultVariants:{variant:"default"}});function Fe(t){var e=c(t,[]);return jsx(Dialog.Root,a({"data-slot":"dialog"},e))}function bn(t){var e=c(t,[]);return jsx(Dialog.Portal,a({"data-slot":"dialog-portal"},e))}function Ge(t){var e=c(t,[]);return jsx(Dialog.Close,a({"data-slot":"dialog-close"},e))}function hn(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Overlay,a({"data-slot":"dialog-overlay",className:f("fixed inset-0 z-50 bg-black/30 [backdrop-filter:blur(4px)] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e)},t))}function we(s$1){var m=s$1,{className:e,children:t,showCloseButton:a$1=true,overlay:o=true,variant:r}=m,n=c(m,["className","children","showCloseButton","overlay","variant"]);return jsxs(bn,{children:[o&&jsx(hn,{}),jsxs(Dialog.Content,b(a({"data-slot":"dialog-content",className:f(xn({variant:r}),e)},n),{children:[t,a$1&&jsxs(Ge,{className:"cursor-pointer outline-0 absolute end-5 top-5 rounded-full opacity-60 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[jsx(s,{className:"size-4 text-gray-600 dark:text-zinc-400"}),jsx("span",{className:"sr-only",children:"Close"})]})]}))]})}var Le=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"dialog-header",className:f("flex flex-col space-y-1 text-center sm:text-start mb-5",e)},t))},_e=a$1=>{var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"dialog-footer",className:f("flex flex-col-reverse sm:flex-row sm:justify-end pt-5 sm:space-x-2.5",e)},t))};function Ne(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Title,a({"data-slot":"dialog-title",className:f("text-lg font-semibold leading-none tracking-tight",e)},t))}function Je(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dialog.Description,a({"data-slot":"dialog-description",className:f("text-sm text-muted-foreground",e)},t))}var Cn=cva("flex items-stretch w-full gap-2 group-[.toaster]:w-(--width)",{variants:{variant:{secondary:"",primary:"",destructive:"",success:"",info:"",mono:"",warning:""},icon:{primary:"",destructive:"",success:"",info:"",warning:""},appearance:{solid:"",outline:"",light:"",stroke:"text-foreground"},size:{lg:"rounded-lg p-4 gap-3 text-base [&>[data-slot=alert-icon]>svg]:size-6 *:data-slot=alert-icon:mt-0.5 [&_[data-slot=alert-close]]:mt-1",md:"rounded-lg p-3.5 gap-2.5 text-sm [&>[data-slot=alert-icon]>svg]:size-5 *:data-slot=alert-icon:mt-0 [&_[data-slot=alert-close]]:mt-0.5",sm:"rounded-md px-3 py-2.5 gap-2 text-xs [&>[data-slot=alert-icon]>svg]:size-4 *:data-alert-icon:mt-0.5 [&_[data-slot=alert-close]]:mt-0.25 [&_[data-slot=alert-close]_svg]:size-3.5"}},compoundVariants:[{variant:"secondary",appearance:"solid",className:"bg-muted text-foreground"},{variant:"primary",appearance:"solid",className:"bg-primary text-primary-foreground"},{variant:"destructive",appearance:"solid",className:"bg-destructive text-destructive-foreground"},{variant:"success",appearance:"solid",className:"bg-[var(--color-success,var(--color-green-500))] text-[var(--color-success-foreground,var(--color-white))]"},{variant:"info",appearance:"solid",className:"bg-[var(--color-info,var(--color-violet-600))] text-[var(--color-info-foreground,var(--color-white))]"},{variant:"warning",appearance:"solid",className:"bg-[var(--color-warning,var(--color-yellow-500))] text-[var(--color-warning-foreground,var(--color-white))]"},{variant:"mono",appearance:"solid",className:"bg-zinc-950 text-white dark:bg-zinc-300 dark:text-black *:data-slot-[alert=close]:text-white"},{variant:"secondary",appearance:"outline",className:"border border-border bg-background text-foreground [&_[data-slot=alert-close]]:text-foreground"},{variant:"primary",appearance:"outline",className:"border border-border bg-background text-primary [&_[data-slot=alert-close]]:text-foreground"},{variant:"destructive",appearance:"outline",className:"border border-border bg-background text-destructive [&_[data-slot=alert-close]]:text-foreground"},{variant:"success",appearance:"outline",className:"border border-border bg-background text-[var(--color-success,var(--color-green-500))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"info",appearance:"outline",className:"border border-border bg-background text-[var(--color-info,var(--color-violet-600))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"warning",appearance:"outline",className:"border border-border bg-background text-[var(--color-warning,var(--color-yellow-500))] [&_[data-slot=alert-close]]:text-foreground"},{variant:"mono",appearance:"outline",className:"border border-border bg-background text-foreground [&_[data-slot=alert-close]]:text-foreground"},{variant:"secondary",appearance:"light",className:"bg-muted border border-border text-foreground"},{variant:"primary",appearance:"light",className:"text-foreground bg-[var(--color-primary-soft,var(--color-blue-50))] border border-[var(--color-primary-alpha,var(--color-blue-100))] [&_[data-slot=alert-icon]]:text-primary dark:bg-[var(--color-primary-soft,var(--color-blue-950))] dark:border-[var(--color-primary-alpha,var(--color-blue-900))]"},{variant:"destructive",appearance:"light",className:"bg-[var(--color-destructive-soft,var(--color-red-50))] border border-[var(--color-destructive-alpha,var(--color-red-100))] text-foreground [&_[data-slot=alert-icon]]:text-destructive dark:bg-[var(--color-destructive-soft,var(--color-red-950))] dark:border-[var(--color-destructive-alpha,var(--color-red-900))] "},{variant:"success",appearance:"light",className:"bg-[var(--color-success-soft,var(--color-green-50))] border border-[var(--color-success-alpha,var(--color-green-200))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-success-foreground,var(--color-green-600))] dark:bg-[var(--color-success-soft,var(--color-green-950))] dark:border-[var(--color-success-alpha,var(--color-green-900))]"},{variant:"info",appearance:"light",className:"bg-[var(--color-info-soft,var(--color-violet-50))] border border-[var(--color-info-alpha,var(--color-violet-100))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-info-foreground,var(--color-violet-600))] dark:bg-[var(--color-info-soft,var(--color-violet-950))] dark:border-[var(--color-info-alpha,var(--color-violet-900))]"},{variant:"warning",appearance:"light",className:"bg-[var(--color-warning-soft,var(--color-yellow-50))] border border-[var(--color-warning-alpha,var(--color-yellow-200))] text-foreground [&_[data-slot=alert-icon]]:text-[var(--color-warning-foreground,var(--color-yellow-600))] dark:bg-[var(--color-warning-soft,var(--color-yellow-950))] dark:border-[var(--color-warning-alpha,var(--color-yellow-900))]"},{variant:"mono",icon:"primary",className:"[&_[data-slot=alert-icon]]:text-primary"},{variant:"mono",icon:"warning",className:"[&_[data-slot=alert-icon]]:text-[var(--color-warning-foreground,var(--color-yellow-600))]"},{variant:"mono",icon:"success",className:"[&_[data-slot=alert-icon]]:text-[var(--color-success-foreground,var(--color-green-600))]"},{variant:"mono",icon:"destructive",className:"[&_[data-slot=alert-icon]]:text-destructive"},{variant:"mono",icon:"info",className:"[&_[data-slot=alert-icon]]:text-[var(--color-info-foreground,var(--color-violet-600))]"}],defaultVariants:{variant:"secondary",appearance:"solid",size:"md"}});function ba(v){var u=v,{className:e,variant:t,size:a$1,icon:o,appearance:r,close:n=false,onClose:s$1,children:m}=u,l=c(u,["className","variant","size","icon","appearance","close","onClose","children"]);return jsxs("div",b(a({"data-slot":"alert",role:"alert",className:f(Cn({variant:t,size:a$1,icon:o,appearance:r}),e)},l),{children:[m,n&&jsx("button",{onClick:s$1,"aria-label":"Dismiss","data-slot":"alert-close",className:f("group shrink-0 size-4 cursor-pointer"),children:jsx(s,{className:"opacity-60 group-hover:opacity-100 size-4"})})]}))}function ha(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-title",className:f("grow tracking-tight",e)},t))}function ya(o){var r=o,{children:e,className:t}=r,a$1=c(r,["children","className"]);return jsx("div",b(a({"data-slot":"alert-icon",className:f("shrink-0",t)},a$1),{children:e}))}function Ca(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-description",className:f("text-sm [&_p]:leading-relaxed [&_p]:mb-2",e)},t))}function Fa(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"alert-content",className:f("space-y-2 [&_[data-slot=alert-title]]:font-semibold",e)},t))}function wn(a$1){var o=a$1,{delayDuration:e=0}=o,t=c(o,["delayDuration"]);return jsx(Me.Provider,a({"data-slot":"tooltip-provider",delayDuration:e},t))}function wa(t){var e=c(t,[]);return jsx(wn,{children:jsx(Me.Root,a({"data-slot":"tooltip"},e))})}function Na(t){var e=c(t,[]);return jsx(Me.Trigger,a({"data-slot":"tooltip-trigger"},e))}function Ma(r){var n=r,{className:e,sideOffset:t=0,children:a$1}=n,o=c(n,["className","sideOffset","children"]);return jsx(Me.Portal,{children:jsxs(Me.Content,b(a({"data-slot":"tooltip-content",sideOffset:t,className:f("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e)},o),{children:[a$1,jsx(Me.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]}))})}function ee(e){if(e===0)return "0 Bytes";let t=1024,a=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(e)/Math.log(t));return Number.parseFloat((e/Math.pow(t,o)).toFixed(2))+" "+a[o]}var ka=(e={})=>{let{maxFiles:t=Number.POSITIVE_INFINITY,maxSize:a$1=Number.POSITIVE_INFINITY,accept:o="*",multiple:r=false,initialFiles:n=[],onFilesChange:s,onFilesAdded:m,onError:l}=e,[v,u]=useState({files:n.map(d=>({file:d,id:d.id,preview:d.url})),isDragging:false,errors:[]}),x=useRef(null);useEffect(()=>()=>{v.files.forEach(d=>{d.preview&&d.file instanceof File&&URL.revokeObjectURL(d.preview);});},[v.files]);let c=useCallback(d=>{if(d instanceof File){if(d.size>a$1)return `File "${d.name}" exceeds the maximum size of ${ee(a$1)}.`}else if(d.size>a$1)return `File "${d.name}" exceeds the maximum size of ${ee(a$1)}.`;if(o!=="*"){let I=o.split(",").map(A=>A.trim()),g=d instanceof File?d.type||"":d.type,R=`.${d.name.split(".").pop()}`;if(!I.some(A=>{if(A.startsWith("."))return R.toLowerCase()===A.toLowerCase();if(A.endsWith("/*")){let de=A.split("/")[0];return g.startsWith(`${de}/`)}return g===A}))return `File "${d.name}" is not an accepted file type.`}return null},[o,a$1]),w=useCallback(d=>d instanceof File?URL.createObjectURL(d):d.url,[]),F=useCallback(d=>d instanceof File?`${d.name}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`:d.id.toString(),[]),M=useCallback(()=>{u(d=>{for(let g of d.files)g.preview&&g.file instanceof File&&g.file.type.startsWith("image/")&&URL.revokeObjectURL(g.preview);x.current&&(x.current.value="");let I=b(a({},d),{files:[],errors:[]});return s==null||s(I.files),I});},[s]),C=useCallback(d=>{if(!d||d.length===0)return;let I=Array.from(d),g=[];u(R=>b(a({},R),{errors:[]})),r||M(),u(R=>{if(r&&t!==Number.POSITIVE_INFINITY&&R.files.length+I.length>t)return g.push(`You can only upload a maximum of ${t} files.`),l==null||l(g),b(a({},R),{errors:g});let T=[];for(let A of I){if(r&&R.files.some(P=>P.file.name===A.name&&P.file.size===A.size))continue;if(A.size>a$1){g.push(r?`Some files exceed the maximum size of ${ee(a$1)}.`:`File exceeds the maximum size of ${ee(a$1)}.`);continue}let de=c(A);de?g.push(de):T.push({file:A,id:F(A),preview:w(A)});}if(T.length>0){m==null||m(T);let A=r?[...R.files,...T]:T;return s==null||s(A),b(a({},R),{files:A,errors:g})}else if(g.length>0)return l==null||l(g),b(a({},R),{errors:g});return R}),x.current&&(x.current.value="");},[t,r,a$1,c,w,F,M,s,m,l]),N=useCallback(d=>{u(I=>{let g=I.files.find(T=>T.id===d);g&&g.preview&&g.file instanceof File&&g.file.type.startsWith("image/")&&URL.revokeObjectURL(g.preview);let R=I.files.filter(T=>T.id!==d);return s==null||s(R),b(a({},I),{files:R,errors:[]})});},[s]),D=useCallback(()=>{u(d=>b(a({},d),{errors:[]}));},[]),k=useCallback(d=>{d.preventDefault(),d.stopPropagation(),u(I=>b(a({},I),{isDragging:true}));},[]),b$1=useCallback(d=>{d.preventDefault(),d.stopPropagation(),!d.currentTarget.contains(d.relatedTarget)&&u(I=>b(a({},I),{isDragging:false}));},[]),S=useCallback(d=>{d.preventDefault(),d.stopPropagation();},[]),j=useCallback(d=>{var I;if(d.preventDefault(),d.stopPropagation(),u(g=>b(a({},g),{isDragging:false})),!((I=x.current)!=null&&I.disabled)&&d.dataTransfer.files&&d.dataTransfer.files.length>0)if(r)C(d.dataTransfer.files);else {let g=d.dataTransfer.files[0];C([g]);}},[C,r]),J=useCallback(d=>{d.target.files&&d.target.files.length>0&&C(d.target.files);},[C]),te=useCallback(()=>{x.current&&x.current.click();},[]),ve=useCallback((d={})=>b(a({},d),{type:"file",onChange:J,accept:d.accept||o,multiple:d.multiple!==void 0?d.multiple:r,ref:x}),[o,r,J]);return [v,{addFiles:C,removeFile:N,clearFiles:M,clearErrors:D,handleDragEnter:k,handleDragLeave:b$1,handleDragOver:S,handleDrop:j,handleFileChange:J,openFileDialog:te,getInputProps:ve}]};function Io(e){return jsxs("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",color:"currentColor"},e),{children:[jsx("path",{d:"M13.0059 21.25C13.0059 21.8023 12.5581 22.25 12.0059 22.25C11.4536 22.25 11.0059 21.8023 11.0059 21.25L11.0059 16.75L10.4116 16.75C10.236 16.7501 10.0203 16.7503 9.84387 16.7282L9.84053 16.7278C9.71408 16.712 9.13804 16.6402 8.86368 16.0746C8.58872 15.5078 8.89065 15.0076 8.95597 14.8994L8.95841 14.8954C9.05062 14.7424 9.18477 14.5715 9.29511 14.4309L9.31885 14.4007C9.61348 14.0249 9.99545 13.5406 10.3759 13.1496C10.5657 12.9545 10.783 12.7533 11.0139 12.5944C11.2191 12.4532 11.5693 12.25 12 12.25C12.4307 12.25 12.7809 12.4532 12.9861 12.5944C13.217 12.7533 13.4343 12.9545 13.6241 13.1496C14.0046 13.5406 14.3865 14.0249 14.6812 14.4007L14.7049 14.4309C14.8152 14.5715 14.9494 14.7424 15.0416 14.8954L15.044 14.8994C15.1093 15.0076 15.4113 15.5078 15.1363 16.0746C14.862 16.6402 14.2859 16.712 14.1595 16.7278L14.1561 16.7282C13.9797 16.7503 13.764 16.7501 13.5884 16.75L13.0059 16.75L13.0059 21.25Z",fill:"currentColor",fillRule:"evenodd"}),jsx("path",{d:"M1.25 12.5C1.25 9.85827 3.03106 7.63322 5.45825 6.9592C5.65424 6.90478 5.75224 6.87756 5.80872 6.81971C5.8652 6.76186 5.88991 6.66386 5.93931 6.46785C6.62272 3.75655 9.07671 1.75002 12 1.75002C15.2149 1.75002 17.8628 4.17733 18.2112 7.29925C18.2385 7.54461 18.2522 7.66731 18.3147 7.7383C18.3772 7.80929 18.4989 7.83881 18.7423 7.89787C21.0422 8.4559 22.75 10.5285 22.75 13C22.75 15.8995 20.3995 18.25 17.5 18.25H16.4006C15.942 18.25 15.7126 18.25 15.6826 18.2119C15.6679 18.1933 15.6641 18.1839 15.6617 18.1604C15.6567 18.1121 15.8519 17.9223 16.2425 17.5427C17.2326 16.5804 17.255 14.9976 16.2927 14.0075C15.6442 13.1982 15.0315 12.3422 14.2379 11.6663C13.6086 11.1303 12.8426 10.75 12 10.75C11.1574 10.75 10.3914 11.1303 9.76209 11.6663C8.96846 12.3422 8.35575 13.1982 7.7073 14.0075C6.74496 14.9976 6.76745 16.5804 7.75753 17.5427C8.14807 17.9223 8.34334 18.1121 8.33832 18.1604C8.33587 18.1839 8.33206 18.1933 8.31739 18.2119C8.28737 18.25 8.05801 18.25 7.59942 18.25H7C3.82436 18.25 1.25 15.6757 1.25 12.5Z",fill:"currentColor"})]}))}var xe=forwardRef((n,r)=>{var s$1=n,{className:e,iconClassName:t,label:a$1="Close"}=s$1,o=c(s$1,["className","iconClassName","label"]);return jsxs(y,b(a({ref:r,variant:"outline",size:"icon",radius:"full",type:"button",className:f("border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-gray-500 dark:text-zinc-400","hover:text-red-600 hover:border-red-300 hover:bg-red-50","dark:hover:text-red-400 dark:hover:border-red-700 dark:hover:bg-red-900/40","active:scale-95 transition-all duration-200",e)},o),{children:[jsx(s,{className:f("size-5 transition-colors text-inherit",t)}),jsx("span",{className:"sr-only",children:a$1})]}))});xe.displayName="CloseButton";function Sa({file:e}){var r;let[t,a]=useState(false),o=e.previewUrl||e.url;return o&&!t?jsx("img",{src:o,alt:((r=e==null?void 0:e.name)==null?void 0:r.substring(0,10))||"image",className:"w-full h-full object-contain rounded-md drop-shadow-md",onError:()=>a(true)}):jsx(i,{})}function za({file:e}){return e.caption?jsxs("p",{className:"text-xs text-primary line-clamp-2 mb-2",children:[e.height," x ",e.width]}):null}function Ra({file:e,className:t}){let[a,o]=useState(false);return e.previewUrl&&!a?jsxs("div",{className:"relative w-full h-full",children:[jsx("img",{src:e.previewUrl,className:"w-full h-full object-contain rounded-md",alt:e.name,onError:()=>o(true)}),jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx("div",{className:"bg-black/60 rounded-full p-2 backdrop-blur-xs",children:jsx(D,{className:"size-5 text-white fill-white"})})})]}):e.url&&!a?jsxs("div",{className:"relative w-full h-full",children:[jsx("video",{src:`${e.url}#t=0.001`,className:"w-full h-full object-contain rounded-md",preload:"metadata",muted:true,playsInline:true,onError:()=>o(true)}),jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx("div",{className:"bg-black/60 rounded-full p-2 backdrop-blur-xs",children:jsx(D,{className:"size-5 text-white fill-white"})})})]}):jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent",children:jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:"video",className:t})})})})}function Ta({file:e}){var t;return (t=e.metaData)!=null&&t.duration?jsxs("p",{className:"text-xs text-primary mb-2",children:["Duration: ",Math.floor(e.metaData.duration/60),":",(e.metaData.duration%60).toString().padStart(2,"0")]}):null}function Ea({file:e,className:t}){return jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent",children:jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:"audio",className:t})})})})}function La({file:e}){var t;return (t=e.metaData)!=null&&t.duration?jsxs("p",{className:"text-xs text-primary mb-2",children:["Duration: ",Math.floor(e.metaData.duration/60),":",(e.metaData.duration%60).toString().padStart(2,"0")]}):null}function _a({file:e,className:t}){let a=I(e.mime,e.ext);return jsx("div",{className:"w-full h-full flex items-center justify-center bg-transparent relative",children:e.previewUrl?jsx("img",{src:e.previewUrl,alt:e.name,className:"w-full h-full object-contain rounded-md drop-shadow-md"}):jsx("div",{className:"text-center",children:jsx("div",{className:"text-4xl",children:jsx(J,{type:a,className:t})})})})}function Aa({file:e}){var t;return (t=e.metaData)!=null&&t.pageCount?jsxs("p",{className:"text-xs text-primary mb-2",children:["Pages: ",e.metaData.pageCount]}):null}function Oa({file:e}){let t=I(e.mime,e.ext);return jsx(J,{type:t})}var Ba={images:{component:Sa,metadataComponent:za},videos:{component:Ra,metadataComponent:Ta},files:{component:_a,metadataComponent:Aa},audios:{component:Ea,metadataComponent:La},default:{component:Oa}};function Xe(e){let t=H(e.mime,e.ext);return Ba[t]||Ba.default}function Mt(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("kbd",a({"data-slot":"kbd",className:f("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",e)},t))}function kt(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("kbd",a({"data-slot":"kbd-group",className:f("inline-flex items-center gap-1",e)},t))}function Ga(){let{isUploadModalOpen:e,setIsUploadModalOpen:t,uploadFiles:a$1,allowedFileTypes:o,maxUploadFiles:r,maxUploadSize:n}=E(),s=K(o),m=L(o),[l,v]=useState([]),[{isDragging:u,errors:x},{removeFile:c,clearFiles:w,handleDragEnter:F$1,handleDragLeave:M,handleDragOver:C,handleDrop:N,openFileDialog:D,getInputProps:k}]=ka({maxFiles:r,maxSize:n,accept:s,multiple:true,onFilesChange:g=>{let R=g.map(T=>{let A=l.find(de=>de.id===T.id);return A?a(a({},A),T):b(a({},T),{progress:100,status:"completed"})});v(R);}}),b$1=g=>{c(g);},S=g=>{v(R=>R.map(T=>T.id===g?b(a({},T),{progress:0,status:"uploading",error:void 0}):T));},j=()=>{let g=l.filter(R=>R.status==="completed");if(g.length>0){let R=g.map(T=>({name:T.file.name,size:T.file.size,type:H(T.file.type,T.file.name.split(".").pop()),lastModified:T.file instanceof File?T.file.lastModified:Date.now(),file:T.file,metadata:{}}));a$1(R),J();}},J=()=>{t(false),w(),v([]);},te=(g,R)=>{let T={id:"temp",name:g.name,size:g.size,mime:g.type,ext:g.name.split(".").pop()||"",url:R||"",createdAt:new Date(g.lastModified),updatedAt:new Date(g.lastModified),folderId:null,metaData:{}},{component:A}=Xe(T);return jsx(A,{file:T,metaData:T.metaData})},ve=l.filter(g=>g.status==="completed").length,d=l.filter(g=>g.status==="uploading").length,I=ve>0&&d===0;return jsx(Fe,{open:e,onOpenChange:t,children:jsxs(we,{className:"p-0 max-w-4xl max-h-[80vh] flex flex-col",variant:"default",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{children:["Upload Files",jsx(kt,{className:"ml-2",children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + U"]})})]}),jsx(xe,{onClick:()=>t(false)})]})}),jsx(Je,{})]}),jsxs("div",{className:"p-6 overflow-y-auto flex-1",children:[jsxs("div",{className:f("relative rounded-lg border-dashed border-[2.5px] bg-muted border-border px-6 py-16 text-center transition-colors mb-4",u?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-muted-foreground/50"),onDragEnter:F$1,onDragLeave:M,onDragOver:C,onDrop:N,children:[jsx("input",b(a({},k()),{className:"sr-only"})),jsxs("div",{className:"flex flex-col items-center",children:[jsx("div",{className:f("flex h-12 w-12 items-center justify-center rounded-full transition-colors",u?"border-primary bg-primary/10":"border-muted-foreground/25"),children:jsx(Io,{className:"mb-3 text-muted-foreground"})}),jsxs("div",{className:"space-y-2",children:[jsxs("p",{className:"text-sm font-medium",children:["Drop files here or"," ",jsx("button",{type:"button",onClick:D,className:"cursor-pointer text-primary underline-offset-4 underline",children:"browse files"})]}),jsxs("p",{className:"text-xs text-muted-foreground",children:[m," \u2022 Max size: ",ee(n)," \u2022 Max files: ",r]})]})]})]}),l.length>0&&jsx("div",{className:"space-y-4",children:jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3 lg:grid-cols-4",children:l.map(g=>jsxs("div",{className:"relative group",children:[jsx(xe,{onClick:()=>b$1(g.id),className:"absolute -inset-e-2 -top-2 z-10 size-6 rounded-full opacity-0 transition-opacity group-hover:opacity-100",iconClassName:"size-3"}),jsxs("div",{className:"relative overflow-hidden rounded-lg border bg-card transition-colors",children:[jsx("div",{className:"relative aspect-square bg-muted border-b border-border",children:jsx("div",{className:"flex h-full items-center justify-center p-4",children:jsx("div",{className:"w-[75%] h-[75%] flex items-center justify-center",children:g.status==="uploading"?jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[jsxs("svg",{className:"size-12 -rotate-90 absolute",viewBox:"0 0 48 48",children:[jsx("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"3",className:"text-muted-foreground/20"}),jsx("circle",{cx:"24",cy:"24",r:"20",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeDasharray:`${2*Math.PI*20}`,strokeDashoffset:`${2*Math.PI*20*(1-g.progress/100)}`,className:"text-primary transition-all duration-300",strokeLinecap:"round"})]}),g.file instanceof File&&te(g.file,g.preview)]}):g.file instanceof File&&te(g.file,g.preview)})})}),jsx("div",{className:"p-3",children:jsxs("div",{className:"space-y-1",children:[jsx("p",{className:"truncate text-xs font-medium",children:g.file.name}),jsxs("div",{className:"relative flex items-center justify-between gap-2",children:[jsx("span",{className:"text-[11px] text-primary font-semibold tracking-tight",children:ee(g.file.size)}),g.status==="error"&&g.error&&jsxs(wa,{children:[jsx(Na,{asChild:true,children:jsx(y,{onClick:()=>S(g.id),variant:"ghost",size:"icon",className:"absolute end-0 -top-1.25 size-6 text-destructive hover:bg-destructive/10 hover:text-destructive",children:jsx(F,{className:"size-3 opacity-100"})})}),jsx(Ma,{children:"Upload failed. Retry"})]})]})]})})]})]},g.id))})}),x.length>0&&jsxs(ba,{variant:"destructive",appearance:"light",className:"mt-5",children:[jsx(ya,{children:jsx(G,{})}),jsxs(Fa,{children:[jsx(ha,{children:"File upload error(s)"}),jsx(Ca,{children:x.map((g,R)=>jsx("p",{className:"last:mb-0",children:g},R))})]})]})]}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",radius:"full",variant:"outline",onClick:J,className:"w-full md:w-auto",children:"Cancel"})}),jsxs(y,{type:"button",radius:"full",onClick:j,disabled:!I,className:"w-full md:w-auto",children:["Upload ",ve>0&&`(${ve})`]})]})]})})}var On=cva(`
|
|
9
9
|
flex w-full bg-background border border-input shadow-xs shadow-black/5 transition-[color,box-shadow] text-foreground placeholder:text-muted-foreground/80
|
|
10
10
|
focus-visible:ring-ring/30 focus-visible:border-ring focus-visible:outline-none focus-visible:ring-[3px]
|
|
11
11
|
disabled:cursor-not-allowed disabled:opacity-60
|
|
@@ -65,36 +65,35 @@ import {c,b,a,s,d,f as f$1,l,E as E$1,F,p,k,z,q as q$1,n,o,m,r,j,y as y$1,x,K,L,
|
|
|
65
65
|
has-[[aria-invalid=true]]:ring-destructive/10
|
|
66
66
|
dark:has-[[aria-invalid=true]]:border-destructive
|
|
67
67
|
dark:has-[[aria-invalid=true]]:ring-destructive/20
|
|
68
|
-
`,{variants:{variant:{sm:"gap-1.25 [&_svg:not([class*=size-])]:size-3.5",md:"gap-1.5 [&_svg:not([class*=size-])]:size-4",lg:"gap-1.5 [&_svg:not([class*=size-])]:size-4"}},defaultVariants:{variant:"md"}});function Dt(r){var n=r,{className:e,type:t,variant:a$1}=n,o=c(n,["className","type","variant"]);return jsx("input",a({"data-slot":"input",type:t,className:f(On({variant:a$1}),e)},o))}function Ua(){let{isCreateFolderModalOpen:e,setIsCreateFolderModalOpen:t,isRenameFolderModalOpen:a,setIsRenameFolderModalOpen:o,createFolder:r,renameFolder:n,folderToRename:s,setFolderToRename:u}=E(),[l,v]=useState(""),m=a,x=e||a;useEffect(()=>{a&&s?v(s.name):e||v("");},[a,e,s]);let c=async()=>{if(l.trim()!==""){if(m&&s){let w=s.id;w!==null&&await n(w,l.trim()),o(false),u(null);}else r(l.trim()),t(false);v("");}},F=()=>{m?(o(false),u(null)):t(false),v("");};return x?jsx(we,{open:x,onOpenChange:F,children:jsxs(Fe,{className:"p-0 max-w-xl m-auto max-h-[32vh] flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsx(Le,{className:"pt-5 pb-3 m-0 border-b border-border flex w-full justify-between",children:jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{children:[m?"Rename Folder":"Create New Folder",!m&&jsx("span",{className:"ml-4",children:jsx(kt,{children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + F"]})})})]}),jsx(xe,{onClick:F})]})})}),jsxs("div",{className:"p-6",children:[jsx("label",{htmlFor:"folder-name",className:"hidden mb-2",children:"Folder Name:"}),jsx(Dt,{id:"folder-name",name:"folder-name",value:l,onChange:w=>v(w.target.value),placeholder:"Enter folder name",autoFocus:true,onKeyDown:w=>{w.key==="Enter"&&l.trim()!==""&&c();}})]}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",onClick:F,radius:"full",className:"w-full md:w-auto",children:"Cancel"})}),jsx(y,{type:"button",disabled:l.trim()==="",onClick:c,radius:"full",className:"w-full md:w-auto",children:m?"Rename":"Create"})]})]})}):null}function Ae(e,t=30){if(e.length<=t)return e;let a=e.slice(0,Math.ceil(t/2)),o=e.slice(-Math.floor(t/2));return `${a}...${o}`}function zo({threshold:e=0,root:t=null,rootMargin:a="0%"}={}){let[o,r]=useState(),[n,s]=useState(null),u=useRef(null);return useEffect(()=>(u.current&&u.current.disconnect(),n&&typeof window!="undefined"&&"IntersectionObserver"in window&&(u.current=new IntersectionObserver(([l])=>{r(l);},{threshold:e,root:t,rootMargin:a}),u.current.observe(n)),()=>{u.current&&u.current.disconnect();}),[n,e,t,a]),{ref:s,entry:o}}function $a({folder:e,selectedFolderId:t,onSelect:a,onLoadChildren:o$1,disabledFolderIds:r=[],treeState:n}){var b;let[s,u]=useState(false),l=((b=e.folderCount)!=null?b:0)>0,v=t===e.id,m=r.includes(e.id),x=n.loading.has(e.id),c=n.loaded.has(e.id),F=n.folders.get(e.id)||[],w=n.pagination.get(e.id),{ref:M,entry:C$1}=zo({threshold:.1,rootMargin:"100px"}),N=w&&w.currentPage<w.totalPages;return useEffect(()=>{if(s&&(C$1!=null&&C$1.isIntersecting)&&N&&!x){let S=((w==null?void 0:w.currentPage)||1)+1;o$1(e.id,S);}},[C$1==null?void 0:C$1.isIntersecting,N,x,s,w,e.id,o$1]),jsxs("li",{children:[jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[l?jsx("button",{onClick:async()=>{if(!l)return;let S=!s;u(S),S&&!c&&!x&&await o$1(e.id,1);},className:"p-1 -m-1 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors","aria-label":s?"Collapse folder":"Expand folder",children:jsx(o,{className:`size-4 text-gray-500 dark:text-zinc-400 transition-transform ${!m&&s?"rotate-90":""}`})}):jsx("div",{className:"w-4"}),jsxs("button",{onClick:()=>{m||a(e.id);},disabled:m,title:e.name,className:`flex items-center gap-1.5 px-2 py-1 rounded-xl flex-1 text-left transition-colors min-w-0 ${v?"bg-blue-100 text-blue-600 dark:text-blue-400 font-semibold":m?"opacity-50 cursor-not-allowed":"hover:bg-gray-100 dark:hover:bg-zinc-700"}`,children:[jsx(j,{className:"size-8 text-white shrink-0",strokeWidth:1.5}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"truncate min-w-0",children:Ae(e.name,15)}),m?jsx("span",{className:"text-[0.6rem] text-left font-medium text-gray-900 dark:text-zinc-300",children:"(Already selected)"}):""]})]})]}),!m&&s&&jsxs("ul",{className:"pl-6",children:[F.map(S=>jsx($a,{folder:S,selectedFolderId:t,onSelect:a,onLoadChildren:o$1,disabledFolderIds:r,treeState:n},S.id)),(x||N)&&jsx("li",{ref:M,className:"py-2 pl-6 flex justify-start",children:jsx(C,{className:"h-4 w-4 animate-spin text-blue-500"})}),x&&F.length===0&&jsx("li",{className:"py-1",children:jsx("div",{className:"flex items-center gap-1.5 px-2",children:jsx("span",{className:"text-sm text-gray-500 dark:text-zinc-400",children:"Loading..."})})})]})]})}function Ka(){let{isMoveFileModalOpen:e,setIsMoveFileModalOpen:t,selectedFiles:a$1,selectedFolders:o,bulkMove:r,provider:n}=E(),[s,u]=useState(void 0),[l,v]=useState({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}),{ref:m,entry:x}=zo({threshold:.1,rootMargin:"100px"}),c=l.pagination.get(null),F=c&&c.currentPage<c.totalPages,w=l.loading.has(null),M=o.map(b=>b.id),C$1=l.folders.get(null)||[];useEffect(()=>{e&&!l.loaded.has(null)&&!l.loading.has(null)&&N(null,1);},[e]),useEffect(()=>{if(e&&(x!=null&&x.isIntersecting)&&F&&!w){let b=((c==null?void 0:c.currentPage)||1)+1;N(null,b);}},[x==null?void 0:x.isIntersecting,F,w,c,e]);let N=async(b$1,S=1)=>{if(!l.loading.has(b$1)){v(j=>b(a({},j),{loading:new Set(j.loading).add(b$1)}));try{let j=await n.getFolders(b$1,S,20);v(J=>{let te=new Set(J.loading);te.delete(b$1);let ve=new Set(J.loaded);ve.add(b$1);let d=new Map(J.folders),I=d.get(b$1)||[];S>1?d.set(b$1,[...I,...j.folders]):d.set(b$1,j.folders);let g=new Map(J.pagination);return g.set(b$1,j.pagination),{folders:d,loading:te,loaded:ve,pagination:g}});}catch(j){console.error(`Failed to load folders for ${b$1}:`,j),v(J=>{let te=new Set(J.loading);return te.delete(b$1),b(a({},J),{loading:te})});}}},D=()=>{s!==void 0&&(r(s),t(false),u(void 0),v({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}));},k=b=>{t(b),b?N(null,1):(u(void 0),v({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}));};return e?jsx(we,{open:e,onOpenChange:k,children:jsxs(Fe,{className:"p-0 max-w-3xl max-h-full m-auto md:max-h-[80vh] flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{className:"w-full text-left",children:["Move Items",jsxs("p",{className:"text-gray-400 text-xs",children:["Moving ",a$1.length," file",a$1.length===1?"":"s"," and"," ",o.length," folder",o.length===1?"":"s","."]})]}),jsx(xe,{onClick:()=>k(false)})]})}),jsx(Je,{})]}),jsx("div",{className:"text-sm my-3 px-6 flex-1 flex flex-col min-h-0",children:jsx("div",{className:"space-y-4 flex flex-col flex-1 min-h-0",children:jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[jsx("label",{className:"block mb-2 font-medium text-gray-900 dark:text-zinc-100",children:"Select destination folder:"}),jsxs("ul",{className:"border rounded-xl p-2 shadow-inner overflow-y-auto flex-1 min-h-0",children:[jsx("li",{children:jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[jsx("div",{className:"w-4"}),jsxs("button",{onClick:()=>u(null),className:`flex items-center gap-1.5 px-2 py-1 rounded-xl flex-1 text-left transition-colors min-w-0 ${s===null?"bg-blue-100 text-blue-600 dark:text-blue-400 font-semibold":"hover:bg-gray-100 dark:hover:bg-zinc-700"}`,children:[jsx(j,{className:"size-8 text-white shrink-0",strokeWidth:1.5}),jsx("div",{className:"flex flex-col gap-1",children:jsx("span",{className:"truncate min-w-0",children:"Root Directory"})})]})]})}),C$1.map(b=>jsx($a,{folder:b,selectedFolderId:s,onSelect:S=>u(S),onLoadChildren:N,disabledFolderIds:M,treeState:l},b.id)),(w||F)&&jsx("li",{ref:m,className:"py-2 pl-6 flex justify-start",children:jsx(C,{className:"h-5 w-5 animate-spin text-blue-500"})}),C$1.length===0&&!w&&!F&&jsx("li",{className:"text-gray-500 dark:text-zinc-400 text-sm text-center py-4",children:"No nested folders available"})]})]})})}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",radius:"full",className:"w-full md:w-auto",children:"Cancel"})}),jsx(y,{type:"button",onClick:D,disabled:s===void 0,radius:"full",className:"w-full md:w-auto",children:"Move"})]})]})}):null}function Wa(n){var s=n,{className:e,viewportClassName:t,children:a$1,viewportRef:o}=s,r=c(s,["className","viewportClassName","children","viewportRef"]);return jsxs(ScrollArea.Root,b(a({"data-slot":"scroll-area",className:f("relative overflow-hidden",e)},r),{children:[jsx(ScrollArea.Viewport,{ref:o,className:f("h-full w-full rounded-[inherit]",t),children:a$1}),jsx($n,{}),jsx(ScrollArea.Corner,{})]}))}function $n(o){var r=o,{className:e,orientation:t="vertical"}=r,a$1=c(r,["className","orientation"]);return jsx(ScrollArea.ScrollAreaScrollbar,b(a({"data-slot":"scroll-area-scrollbar",orientation:t,className:f("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2 flex-col border-t border-t-transparent p-[1px]",e)},a$1),{children:jsx(ScrollArea.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}))}function et({title:e,open:t,onClose:a,previewSection:o,metadataSection:r,footer:n}){return jsx(we,{open:t,onOpenChange:s=>!s&&a(),children:jsxs(Fe,{className:"p-0 max-w-6xl w-full mx-auto flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full justify-between gap-2",children:[jsx("span",{children:e}),jsx(xe,{onClick:()=>a()})]})}),jsx(Je,{})]}),jsx(Wa,{className:"flex-1 h-0",children:jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 min-h-full",children:[jsx("div",{className:"p-6 border-b lg:border-b-0 lg:border-r border-slate-200 dark:border-zinc-700",children:o}),jsx("div",{className:"p-6 overflow-y-auto ",children:r})]})}),jsx(_e,{className:"px-6 py-4 border-t border-border",children:n})]})})}function tt({file:e}){let{provider:t,setFileDetailsModalFile:a,refreshData:o}=E(),[r$1,n]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",title:"Delete",className:"border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:text-red-600 dark:hover:text-red-400 hover:border-red-300 dark:hover:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/40 active:scale-95 transition-all duration-200",onClick:async()=>{n(true);try{await t.deleteFiles([e.id]),await o(),a(null),toast.success("File Deleted",{description:`${Ae(e.name,20)} has been deleted`});}catch(u){toast.error("Delete failed"),n(false);}},disabled:r$1,children:r$1?jsx(C,{className:"size-5 animate-spin"}):jsx(r,{className:"size-5"})})}function ot({file:e}){let[t$1,a]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:async()=>{a(true);try{let r=document.createElement("a");r.href=e.url,r.download=e.name,r.click(),toast.success("Download Started",{description:`Downloading ${Ae(e.name,20)}`});}catch(r){toast.error("Download failed");}finally{a(false);}},className:"border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:text-blue-600 dark:hover:text-blue-400 hover:border-blue-300 dark:hover:border-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/40 active:scale-95 transition-all duration-200",title:"Download",disabled:t$1,children:t$1?jsx(C,{className:"size-5 animate-spin"}):jsx(t,{className:"size-5",strokeWidth:2.5})})}function at({file:e}){let[t,a]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:async()=>{try{await navigator.clipboard.writeText(e.url),a(!0),toast.success("Link Copied",{description:"File URL copied to clipboard"}),setTimeout(()=>a(!1),2e3);}catch(r){toast.error("Failed to copy link");}},className:`border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 active:scale-95 transition-all duration-200
|
|
68
|
+
`,{variants:{variant:{sm:"gap-1.25 [&_svg:not([class*=size-])]:size-3.5",md:"gap-1.5 [&_svg:not([class*=size-])]:size-4",lg:"gap-1.5 [&_svg:not([class*=size-])]:size-4"}},defaultVariants:{variant:"md"}});function Dt(r){var n=r,{className:e,type:t,variant:a$1}=n,o=c(n,["className","type","variant"]);return jsx("input",a({"data-slot":"input",type:t,className:f(On({variant:a$1}),e)},o))}function Ua(){let{isCreateFolderModalOpen:e,setIsCreateFolderModalOpen:t,isRenameFolderModalOpen:a,setIsRenameFolderModalOpen:o,createFolder:r,renameFolder:n,folderToRename:s,setFolderToRename:m}=E(),[l,v]=useState(""),u=a,x=e||a;useEffect(()=>{a&&s?v(s.name):e||v("");},[a,e,s]);let c=async()=>{if(l.trim()!==""){if(u&&s){let F=s.id;F!==null&&await n(F,l.trim()),o(false),m(null);}else r(l.trim()),t(false);v("");}},w=()=>{u?(o(false),m(null)):t(false),v("");};return x?jsx(Fe,{open:x,onOpenChange:w,children:jsxs(we,{className:"p-0 max-w-xl m-auto max-h-[32vh] flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsx(Le,{className:"pt-5 pb-3 m-0 border-b border-border flex w-full justify-between",children:jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{children:[u?"Rename Folder":"Create New Folder",!u&&jsx("span",{className:"ml-4",children:jsx(kt,{children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + F"]})})})]}),jsx(xe,{onClick:w})]})})}),jsxs("div",{className:"p-6",children:[jsx("label",{htmlFor:"folder-name",className:"hidden mb-2",children:"Folder Name:"}),jsx(Dt,{id:"folder-name",name:"folder-name",value:l,onChange:F=>v(F.target.value),placeholder:"Enter folder name",autoFocus:true,onKeyDown:F=>{F.key==="Enter"&&l.trim()!==""&&c();}})]}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",onClick:w,radius:"full",className:"w-full md:w-auto",children:"Cancel"})}),jsx(y,{type:"button",disabled:l.trim()==="",onClick:c,radius:"full",className:"w-full md:w-auto",children:u?"Rename":"Create"})]})]})}):null}function Ae(e,t=30){if(e.length<=t)return e;let a=e.slice(0,Math.ceil(t/2)),o=e.slice(-Math.floor(t/2));return `${a}...${o}`}function zo({threshold:e=0,root:t=null,rootMargin:a="0%"}={}){let[o,r]=useState(),[n,s]=useState(null),m=useRef(null);return useEffect(()=>(m.current&&m.current.disconnect(),n&&typeof window!="undefined"&&"IntersectionObserver"in window&&(m.current=new IntersectionObserver(([l])=>{r(l);},{threshold:e,root:t,rootMargin:a}),m.current.observe(n)),()=>{m.current&&m.current.disconnect();}),[n,e,t,a]),{ref:s,entry:o}}function $a({folder:e,selectedFolderId:t,onSelect:a,onLoadChildren:o$1,disabledFolderIds:r=[],treeState:n}){var b;let[s,m]=useState(false),l=((b=e.folderCount)!=null?b:0)>0,v=t===e.id,u=r.includes(e.id),x=n.loading.has(e.id),c=n.loaded.has(e.id),w=n.folders.get(e.id)||[],F=n.pagination.get(e.id),{ref:M,entry:C$1}=zo({threshold:.1,rootMargin:"100px"}),N=F&&F.currentPage<F.totalPages;return useEffect(()=>{if(s&&(C$1!=null&&C$1.isIntersecting)&&N&&!x){let S=((F==null?void 0:F.currentPage)||1)+1;o$1(e.id,S);}},[C$1==null?void 0:C$1.isIntersecting,N,x,s,F,e.id,o$1]),jsxs("li",{children:[jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[l?jsx("button",{onClick:async()=>{if(!l)return;let S=!s;m(S),S&&!c&&!x&&await o$1(e.id,1);},className:"p-1 -m-1 hover:bg-gray-100 dark:hover:bg-zinc-700 rounded transition-colors","aria-label":s?"Collapse folder":"Expand folder",children:jsx(o,{className:`size-4 text-gray-500 dark:text-zinc-400 transition-transform ${!u&&s?"rotate-90":""}`})}):jsx("div",{className:"w-4"}),jsxs("button",{onClick:()=>{u||a(e.id);},disabled:u,title:e.name,className:`flex items-center gap-1.5 px-2 py-1 rounded-xl flex-1 text-left transition-colors min-w-0 ${v?"bg-blue-100 text-blue-600 dark:text-blue-400 font-semibold":u?"opacity-50 cursor-not-allowed":"hover:bg-gray-100 dark:hover:bg-zinc-700"}`,children:[jsx(j,{className:"size-8 text-white shrink-0",strokeWidth:1.5}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"truncate min-w-0",children:Ae(e.name,15)}),u?jsx("span",{className:"text-[0.6rem] text-left font-medium text-gray-900 dark:text-zinc-300",children:"(Already selected)"}):""]})]})]}),!u&&s&&jsxs("ul",{className:"pl-6",children:[w.map(S=>jsx($a,{folder:S,selectedFolderId:t,onSelect:a,onLoadChildren:o$1,disabledFolderIds:r,treeState:n},S.id)),(x||N)&&jsx("li",{ref:M,className:"py-2 pl-6 flex justify-start",children:jsx(C,{className:"h-4 w-4 animate-spin text-blue-500"})}),x&&w.length===0&&jsx("li",{className:"py-1",children:jsx("div",{className:"flex items-center gap-1.5 px-2",children:jsx("span",{className:"text-sm text-gray-500 dark:text-zinc-400",children:"Loading..."})})})]})]})}function Ka(){let{isMoveFileModalOpen:e,setIsMoveFileModalOpen:t,selectedFiles:a$1,selectedFolders:o,bulkMove:r,provider:n}=E(),[s,m]=useState(void 0),[l,v]=useState({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}),{ref:u,entry:x}=zo({threshold:.1,rootMargin:"100px"}),c=l.pagination.get(null),w=c&&c.currentPage<c.totalPages,F=l.loading.has(null),M=o.map(b=>b.id),C$1=l.folders.get(null)||[];useEffect(()=>{e&&!l.loaded.has(null)&&!l.loading.has(null)&&N(null,1);},[e]),useEffect(()=>{if(e&&(x!=null&&x.isIntersecting)&&w&&!F){let b=((c==null?void 0:c.currentPage)||1)+1;N(null,b);}},[x==null?void 0:x.isIntersecting,w,F,c,e]);let N=async(b$1,S=1)=>{if(!l.loading.has(b$1)){v(j=>b(a({},j),{loading:new Set(j.loading).add(b$1)}));try{let j=await n.getFolders(b$1,S,20);v(J=>{let te=new Set(J.loading);te.delete(b$1);let ve=new Set(J.loaded);ve.add(b$1);let d=new Map(J.folders),I=d.get(b$1)||[];S>1?d.set(b$1,[...I,...j.folders]):d.set(b$1,j.folders);let g=new Map(J.pagination);return g.set(b$1,j.pagination),{folders:d,loading:te,loaded:ve,pagination:g}});}catch(j){console.error(`Failed to load folders for ${b$1}:`,j),v(J=>{let te=new Set(J.loading);return te.delete(b$1),b(a({},J),{loading:te})});}}},D=()=>{s!==void 0&&(r(s),t(false),m(void 0),v({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}));},k=b=>{t(b),b?N(null,1):(m(void 0),v({folders:new Map,loading:new Set,loaded:new Set,pagination:new Map}));};return e?jsx(Fe,{open:e,onOpenChange:k,children:jsxs(we,{className:"p-0 max-w-3xl max-h-full m-auto md:max-h-[80vh] flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[jsxs("span",{className:"w-full text-left",children:["Move Items",jsxs("p",{className:"text-gray-400 text-xs",children:["Moving ",a$1.length," file",a$1.length===1?"":"s"," and"," ",o.length," folder",o.length===1?"":"s","."]})]}),jsx(xe,{onClick:()=>k(false)})]})}),jsx(Je,{})]}),jsx("div",{className:"text-sm my-3 px-6 flex-1 flex flex-col min-h-0",children:jsx("div",{className:"space-y-4 flex flex-col flex-1 min-h-0",children:jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[jsx("label",{className:"block mb-2 font-medium text-gray-900 dark:text-zinc-100",children:"Select destination folder:"}),jsxs("ul",{className:"border rounded-xl p-2 shadow-inner overflow-y-auto flex-1 min-h-0",children:[jsx("li",{children:jsxs("div",{className:"flex items-center gap-1.5 py-1",children:[jsx("div",{className:"w-4"}),jsxs("button",{onClick:()=>m(null),className:`flex items-center gap-1.5 px-2 py-1 rounded-xl flex-1 text-left transition-colors min-w-0 ${s===null?"bg-blue-100 text-blue-600 dark:text-blue-400 font-semibold":"hover:bg-gray-100 dark:hover:bg-zinc-700"}`,children:[jsx(j,{className:"size-8 text-white shrink-0",strokeWidth:1.5}),jsx("div",{className:"flex flex-col gap-1",children:jsx("span",{className:"truncate min-w-0",children:"Root Directory"})})]})]})}),C$1.map(b=>jsx($a,{folder:b,selectedFolderId:s,onSelect:S=>m(S),onLoadChildren:N,disabledFolderIds:M,treeState:l},b.id)),(F||w)&&jsx("li",{ref:u,className:"py-2 pl-6 flex justify-start",children:jsx(C,{className:"h-5 w-5 animate-spin text-blue-500"})}),C$1.length===0&&!F&&!w&&jsx("li",{className:"text-gray-500 dark:text-zinc-400 text-sm text-center py-4",children:"No nested folders available"})]})]})})}),jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",radius:"full",className:"w-full md:w-auto",children:"Cancel"})}),jsx(y,{type:"button",onClick:D,disabled:s===void 0,radius:"full",className:"w-full md:w-auto",children:"Move"})]})]})}):null}function Wa(n){var s=n,{className:e,viewportClassName:t,children:a$1,viewportRef:o}=s,r=c(s,["className","viewportClassName","children","viewportRef"]);return jsxs(ScrollArea.Root,b(a({"data-slot":"scroll-area",className:f("relative overflow-hidden",e)},r),{children:[jsx(ScrollArea.Viewport,{ref:o,className:f("h-full w-full rounded-[inherit]",t),children:a$1}),jsx($n,{}),jsx(ScrollArea.Corner,{})]}))}function $n(o){var r=o,{className:e,orientation:t="vertical"}=r,a$1=c(r,["className","orientation"]);return jsx(ScrollArea.ScrollAreaScrollbar,b(a({"data-slot":"scroll-area-scrollbar",orientation:t,className:f("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2 flex-col border-t border-t-transparent p-[1px]",e)},a$1),{children:jsx(ScrollArea.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-border"})}))}function et({title:e,open:t,onClose:a,previewSection:o,metadataSection:r,footer:n}){return jsx(Fe,{open:t,onOpenChange:s=>!s&&a(),children:jsxs(we,{className:"p-0 max-w-6xl w-full mx-auto flex flex-col",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsxs("div",{className:"flex w-full justify-between gap-2",children:[jsx("span",{children:e}),jsx(xe,{onClick:()=>a()})]})}),jsx(Je,{})]}),jsx(Wa,{className:"flex-1 h-0",children:jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 min-h-full",children:[jsx("div",{className:"p-6 border-b lg:border-b-0 lg:border-r border-slate-200 dark:border-zinc-700",children:o}),jsx("div",{className:"p-6 overflow-y-auto ",children:r})]})}),jsx(_e,{className:"px-6 py-4 border-t border-border",children:n})]})})}function tt({file:e}){let{provider:t,setFileDetailsModalFile:a,refreshData:o}=E(),[r$1,n]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",title:"Delete",className:"border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:text-red-600 dark:hover:text-red-400 hover:border-red-300 dark:hover:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/40 active:scale-95 transition-all duration-200",onClick:async()=>{n(true);try{await t.deleteFiles([e.id]),await o(),a(null),toast.success("File Deleted",{description:`${Ae(e.name,20)} has been deleted`});}catch(m){toast.error("Delete failed"),n(false);}},disabled:r$1,children:r$1?jsx(C,{className:"size-5 animate-spin"}):jsx(r,{className:"size-5"})})}function ot({file:e}){let[t$1,a]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:async()=>{a(true);try{let r=document.createElement("a");r.href=e.url,r.download=e.name,r.click(),toast.success("Download Started",{description:`Downloading ${Ae(e.name,20)}`});}catch(r){toast.error("Download failed");}finally{a(false);}},className:"border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:text-blue-600 dark:hover:text-blue-400 hover:border-blue-300 dark:hover:border-blue-700 hover:bg-blue-50 dark:hover:bg-blue-900/40 active:scale-95 transition-all duration-200",title:"Download",disabled:t$1,children:t$1?jsx(C,{className:"size-5 animate-spin"}):jsx(t,{className:"size-5",strokeWidth:2.5})})}function at({file:e}){let[t,a]=useState(false);return jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:async()=>{try{await navigator.clipboard.writeText(e.url),a(!0),toast.success("Link Copied",{description:"File URL copied to clipboard"}),setTimeout(()=>a(!1),2e3);}catch(r){toast.error("Failed to copy link");}},className:`border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 active:scale-95 transition-all duration-200
|
|
69
69
|
${t?"text-green-700 dark:text-green-400 border-green-400 dark:border-green-700 bg-green-100 dark:bg-green-900/40 font-bold":"hover:text-orange-600 dark:hover:text-orange-400 hover:border-orange-300 dark:hover:border-orange-700 hover:bg-orange-50 dark:hover:bg-orange-900/40"}`,title:"Copy Link",disabled:t,children:t?jsx(w,{className:"size-5 animate-in zoom-in duration-200",strokeWidth:3}):jsx(u,{className:"size-5",strokeWidth:2.5})})}function ja({file:e,onFullscreen:t}){return jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:t,className:"border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:text-purple-600 dark:hover:text-purple-400 hover:border-purple-300 dark:hover:border-purple-700 hover:bg-purple-50 dark:hover:bg-purple-900/40 active:scale-95 transition-all duration-200",title:"Fullscreen",children:jsx(v,{className:"size-5",strokeWidth:1})})}var jn=cva(`
|
|
70
70
|
w-full bg-background border border-input bg-background text-foreground shadow-xs shadow-black/5 transition-[color,box-shadow]
|
|
71
71
|
text-foreground placeholder:text-muted-foreground/80 focus-visible:border-ring focus-visible:outline-none focus-visible:ring-[3px]
|
|
72
72
|
focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 [&[readonly]]:opacity-70
|
|
73
73
|
aria-invalid:border-destructive aria-invalid:border-destructive/60 aria-invalid:ring-destructive/10 dark:aria-invalid:border-destructive dark:aria-invalid:ring-destructive/20
|
|
74
|
-
`,{variants:{variant:{sm:"px-2.5 py-2.5 text-xs rounded-md",md:"px-3 py-3 text-sm rounded-md",lg:"px-4 py-4 text-sm rounded-md"}},defaultVariants:{variant:"md"}});function Oe(o){var r=o,{className:e,variant:t}=r,a$1=c(r,["className","variant"]);return jsx("textarea",a({"data-slot":"textarea",className:f(jn({variant:t}),e)},a$1))}var Zn=cva("text-sm leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-50",{variants:{variant:{primary:"font-medium",secondary:"font-normal"}},defaultVariants:{variant:"primary"}});function Re(o){var r=o,{className:e,variant:t}=r,a$1=c(r,["className","variant"]);return jsx(Label.Root,a({"data-slot":"label",className:f(Zn({variant:t}),e)},a$1))}function rt(e){let t=typeof e=="string"?new Date(e):e,a=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),r=t.getFullYear();return `${a}/${o}/${r}`}function co(e){let t=Math.floor(e/60),a=e%60;return `${t}:${a.toString().padStart(2,"0")}`}var ei=cva("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}});function nt(o){var r=o,{className:e,orientation:t="vertical"}=r,a$1=c(r,["className","orientation"]);return jsx("div",a({role:"group","data-slot":"field","data-orientation":t,className:f(ei({orientation:t}),e)},a$1))}function it(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Re,a({"data-slot":"field-label",className:f("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",e)},t))}function st(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"input-group",role:"group",className:f("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e)},t))}var ti=cva("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function lt(o){var r=o,{className:e,align:t="inline-start"}=r,a$1=c(r,["className","align"]);return jsx("div",a({role:"group","data-slot":"input-group-addon","data-align":t,className:f(ti({align:t}),e),onClick:n=>{var s,
|
|
74
|
+
`,{variants:{variant:{sm:"px-2.5 py-2.5 text-xs rounded-md",md:"px-3 py-3 text-sm rounded-md",lg:"px-4 py-4 text-sm rounded-md"}},defaultVariants:{variant:"md"}});function Oe(o){var r=o,{className:e,variant:t}=r,a$1=c(r,["className","variant"]);return jsx("textarea",a({"data-slot":"textarea",className:f(jn({variant:t}),e)},a$1))}var Zn=cva("text-sm leading-none text-foreground peer-disabled:cursor-not-allowed peer-disabled:opacity-50",{variants:{variant:{primary:"font-medium",secondary:"font-normal"}},defaultVariants:{variant:"primary"}});function Re(o){var r=o,{className:e,variant:t}=r,a$1=c(r,["className","variant"]);return jsx(Label.Root,a({"data-slot":"label",className:f(Zn({variant:t}),e)},a$1))}function rt(e){let t=typeof e=="string"?new Date(e):e,a=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),r=t.getFullYear();return `${a}/${o}/${r}`}function co(e){let t=Math.floor(e/60),a=e%60;return `${t}:${a.toString().padStart(2,"0")}`}var ei=cva("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}});function nt(o){var r=o,{className:e,orientation:t="vertical"}=r,a$1=c(r,["className","orientation"]);return jsx("div",a({role:"group","data-slot":"field","data-orientation":t,className:f(ei({orientation:t}),e)},a$1))}function it(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Re,a({"data-slot":"field-label",className:f("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",e)},t))}function st(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"input-group",role:"group",className:f("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",e)},t))}var ti=cva("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}});function lt(o){var r=o,{className:e,align:t="inline-start"}=r,a$1=c(r,["className","align"]);return jsx("div",a({role:"group","data-slot":"input-group-addon","data-align":t,className:f(ti({align:t}),e),onClick:n=>{var s,m;n.target.closest("button")||(m=(s=n.currentTarget.parentElement)==null?void 0:s.querySelector("input"))==null||m.focus();}},a$1))}cva("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function dt(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("span",a({className:f("text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",e)},t))}function ct(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Dt,a({"data-slot":"input-group-control",className:f("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",e)},t))}function qa({file:e,onClose:t,onSave:a,onDelete:o}){var C$1;let[r,n]=useState(false),[s,m]=useState(e.name),[l,v]=useState(e.alternativeText||""),[u,x]=useState(e.caption||""),c=async()=>{n(true);try{await(a==null?void 0:a({name:s,alternativeText:l,caption:u})),t();}finally{n(false);}},w=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e}),jsx(ja,{file:e,onFullscreen:()=>window.open(e.url,"_blank")})]}),jsx("div",{className:"flex-1 flex items-center justify-center bg-gray-50 rounded-lg overflow-hidden",style:{backgroundImage:`
|
|
75
75
|
linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
|
|
76
76
|
linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
|
|
77
77
|
linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
|
|
78
78
|
linear-gradient(-45deg, transparent 75%, #e5e7eb 75%)
|
|
79
|
-
`,backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"},children:jsx("img",{src:e.previewUrl||e.url,alt:e.alternativeText||e.name,className:"max-w-full max-h-full object-contain"})})]}),w=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Dimensions"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.width&&e.height?`${e.width}\xD7${e.height}`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"N/A"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-200 dark:border-zinc-700",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>u(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-gray-200 dark:bg-zinc-700 rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"altText",children:"Alternative text"}),jsx(Oe,{id:"altText",value:l,onChange:N=>v(N.target.value),placeholder:"Describe the image for accessibility",rows:3}),jsx("p",{className:"text-xs text-muted-foreground",children:"This text will be displayed if the asset can't be shown."})]}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:m,onChange:N=>x(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:F,metadataSection:w,footer:jsxs("div",{className:"flex w-full justify-between items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{className:"w-full md:w-auto",variant:"outline",onClick:t,radius:"full",disabled:r,children:"Cancel"}),jsxs(y,{className:"w-full md:w-auto",onClick:c,radius:"full",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Za({file:e,onClose:t,onSave:a,onDelete:o}){var w,M,C$1;let[r,n]=useState(false),[s,u]=useState(e.name),[l,v]=useState(e.caption||""),m=async()=>{n(true);try{await(a==null?void 0:a({name:s,caption:l})),t();}finally{n(false);}},x=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsx("div",{className:"flex-1 flex items-center justify-center bg-black rounded-lg overflow-hidden",children:jsx("video",{src:e.url,controls:true,className:"max-w-full max-h-full",style:{maxHeight:"500px"},children:"Your browser does not support the video tag."})})]}),c=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Dimensions"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.width&&e.height?`${e.width}\xD7${e.height}`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Duration"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:(w=e.metaData)!=null&&w.duration?co(e.metaData.duration):"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:((M=e.ext)==null?void 0:M.replace(".",""))||"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Video Source"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400 capitalize",children:((C$1=e.metaData)==null?void 0:C$1.videoSource)||"local"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-200",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>u(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-gray-200 dark:bg-zinc-700 rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:l,onChange:N=>v(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:x,metadataSection:c,footer:jsxs("div",{className:"flex w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{variant:"outline",onClick:t,radius:"full",className:"w-full md:w-auto",disabled:r,children:"Cancel"}),jsxs(y,{onClick:m,radius:"full",className:"w-full md:w-auto",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Ja({file:e,onClose:t,onSave:a,onDelete:o}){var w,M,C$1;let[r,n]=useState(false),[s,u]=useState(e.name),[l,v]=useState(e.caption||""),m=async()=>{n(true);try{await(a==null?void 0:a({name:s,caption:l})),t();}finally{n(false);}},x=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-linear-to-br from-purple-50 to-blue-50 dark:from-purple-950 dark:to-blue-950 rounded-lg p-8",children:[jsx("div",{className:"mb-8",children:jsx("div",{className:"w-32 h-32 rounded-full bg-white dark:bg-gray-800 shadow-lg flex items-center justify-center",children:jsx(h,{className:"w-16 h-16 text-purple-600 dark:text-purple-400"})})}),jsx("div",{className:"w-full max-w-md",children:jsx("audio",{src:e.url,controls:true,className:"w-full",children:"Your browser does not support the audio tag."})})]})]}),c=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Duration"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:(w=e.metaData)!=null&&w.duration?co(e.metaData.duration):"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Bitrate"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:(M=e.metaData)!=null&&M.bitrate?`${e.metaData.bitrate} kbps`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"N/A"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-200 dark:border-zinc-700",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>u(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-gray-200 dark:bg-zinc-700 rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:l,onChange:N=>v(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:x,metadataSection:c,footer:jsxs("div",{className:"flex gap-2 w-full sm:justify-between justify-center items-center flex-col sm:flex-row ",children:[jsx(y,{variant:"outline",onClick:t,radius:"full",className:"w-full md:w-auto",disabled:r,children:"Cancel"}),jsxs(y,{onClick:m,radius:"full",className:"w-full md:w-auto",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Xa({file:e,onClose:t,onSave:a$1}){var M,C$1,N,D;let[o,r]=useState(false),[n,s]=useState(e.name),[u,l]=useState(((M=e.metaData)==null?void 0:M.description)||""),v=async()=>{r(true);try{await(a$1==null?void 0:a$1({name:n,metaData:b(a({},e.metaData),{description:u})})),t();}finally{r(false);}},m=((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"file",{component:x}=Xe(e),c=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-linear-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 rounded-lg p-8",children:[jsx("div",{className:"mb-4 w-32 h-32 flex items-center justify-center",children:jsx(x,{file:e,metaData:e.metaData})}),jsxs("p",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:[m," File"]})]})]}),F=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:m})]}),((N=e.metaData)==null?void 0:N.pageCount)&&jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Page Count"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.metaData.pageCount})]}),((D=e.metaData)==null?void 0:D.author)&&jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Author"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.metaData.author})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-200",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:n.replace(e.ext||"",""),onChange:k=>s(k.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-gray-200 dark:bg-zinc-700 rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"description",children:"Description"}),jsx(Oe,{id:"description",value:u,onChange:k=>l(k.target.value),placeholder:"Add a description",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:c,metadataSection:F,footer:jsxs("div",{className:"flex w-full justify-between items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{className:"w-full md:w-auto",variant:"outline",onClick:t,radius:"full",disabled:o,children:"Cancel"}),jsxs(y,{className:"w-full md:w-auto",onClick:v,radius:"full",disabled:o,children:[o&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})}function er({className:e$1}){let{fileDetailsModalFile:t,setFileDetailsModalFile:a,updateFileMetadata:o}=E(),r=()=>{a(null);},n=async u=>{t&&await o(t.id,u);},s=()=>{if(!t)return null;switch(H(t.mime,t.ext)){case e.IMAGE:return jsx(qa,{file:t,onClose:r,onSave:n});case e.VIDEO:return jsx(Za,{file:t,onClose:r,onSave:n});case e.AUDIO:return jsx(Ja,{file:t,onClose:r,onSave:n});case e.FILE:default:return jsx(Xa,{file:t,onClose:r,onSave:n})}};return jsxs("div",{className:f("",e$1),children:[jsx(Ga,{}),jsx(Ua,{}),jsx(Ka,{}),s()]})}function ai(a$1){var o=a$1,{children:e}=o,t=c(o,["children"]);return jsx(no,b(a({mode:d.PAGE,selectionMode:f$1.MULTIPLE},t),{children:e}))}function ri(u){var l=u,{children:e,fileSelectionMode:t=f$1.SINGLE,acceptedFileTypes:a$1,viewMode:o="grid",onFilesSelected:r,onClose:n}=l,s=c(l,["children","fileSelectionMode","acceptedFileTypes","viewMode","onFilesSelected","onClose"]);return jsx(no,b(a({mode:d.MODAL,selectionMode:t,acceptedFileTypesForModal:a$1||s.allowedFileTypes,viewMode:o,onFilesSelected:r,onClose:n},s),{children:e}))}var He={Page:ai,Modal:ri,Header:xa,Footer:va,Overlays:er};function or(){let{setIsMoveFileModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"lg",radius:"full",onClick:()=>e(true),className:"text-md font-medium border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:text-blue-600 dark:hover:text-blue-400 hover:border-blue-300 dark:hover:border-blue-700 shadow-sm transition-all duration-200",children:[jsx(m,{className:"size-5"}),jsx("span",{className:"hidden sm:inline",children:"Move"})]})}function ar(){let{bulkDelete:e}=E();return jsxs(y,{variant:"outline",size:"lg",radius:"full",onClick:e,className:"text-md font-medium border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:bg-red-50 dark:hover:bg-red-900/40 hover:text-red-600 dark:hover:text-red-400 hover:border-red-300 dark:hover:border-red-700 shadow-sm transition-all duration-200",children:[jsx(r,{className:"size-5"}),jsx("span",{className:"hidden",children:"Delete"})]})}function rr(){let{handleClearSelection:e}=E();return jsxs(y,{variant:"outline",size:"lg",onClick:e,className:"rounded-full text-md font-medium border border-transparent text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:border-blue-300 dark:hover:border-blue-700 hover:font-semibold transition-all duration-200",children:[jsx(s,{className:"size-5 transition-colors"}),"Clear"]})}function nr(){let{selectedFiles:e,selectedFolders:t}=E();return e.length+t.length===0?null:jsx("div",{className:"w-full",children:jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[jsxs("div",{className:"flex items-center gap-2 flex-1 sm:flex-initial",children:[jsx(or,{}),jsx(ar,{})]}),jsx(rr,{})]})})}function ir({className:e}){let{selectedFiles:t,selectedFolders:a}=E();return t.length+a.length===0?null:jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm border-t border-gray-200 dark:border-zinc-700 shadow-lg ${e||""}`,children:jsx("div",{className:"px-4 sm:px-6 py-3 mx-auto",children:jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[jsxs("div",{className:"flex items-center gap-2 flex-1 sm:flex-initial",children:[jsx(or,{}),jsx(ar,{})]}),jsx(rr,{})]})})})}function Oo(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"skeleton",className:f("animate-pulse rounded-md bg-accent",e)},t))}function po(){let{currentFolder:e,handleFolderClick:t,isLoading:a}=E(),o=useRouter(),r=()=>{o.back();};return a?jsxs("div",{className:"flex item-center w-full",children:[jsx(Oo,{className:"rounded-full size-10 mr-2 shrink-0"}),jsx(Oo,{className:"min-w-32 rounded-md h-full"})]}):jsx(Fragment,{children:e?jsxs("div",{className:"flex items-center flex-1 min-w-0 max-w-[calc(100%-40px)]",children:[jsx(y,{variant:"outline",size:"icon",radius:"full",disabled:a,className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 mr-2",onClick:r,children:jsx(p,{className:"size-5 text-gray-900 dark:text-zinc-100",strokeWidth:"1.5"})}),jsx("h1",{className:"text-lg flex-1 min-w-0 align-middle font-semibold",children:Ae(e.name,20)})]}):jsxs("div",{className:"flex items-center flex-1 min-w-0 max-w-[calc(100%-40px)]",children:[jsx(y,{className:"mr-2 shrink-0",radius:"full",variant:"ghost",mode:"icon",size:"icon",onClick:()=>t(null),children:jsx(k,{className:"size-6 text-gray-900 dark:text-zinc-100"})}),jsx("h1",{className:"text-lg flex-1 min-w-0 align-middle font-semibold",children:"Home"})]})})}function Wt(t){var e=c(t,[]);return jsx(DropdownMenu.Root,a({"data-slot":"dropdown-menu"},e))}function jt(t){var e=c(t,[]);return jsx(DropdownMenu.Trigger,a({className:"select-none","data-slot":"dropdown-menu-trigger"},e))}function Qt(o){var r=o,{className:e,sideOffset:t=4}=r,a$1=c(r,["className","sideOffset"]);return jsx(DropdownMenu.Portal,{children:jsx(DropdownMenu.Content,a({"data-slot":"dropdown-menu-content",sideOffset:t,className:f("space-y-0.5 z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-md shadow-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e)},a$1))})}function Ke(r){var n=r,{className:e,inset:t,variant:a$1}=n,o=c(n,["className","inset","variant"]);return jsx(DropdownMenu.Item,a({"data-slot":"dropdown-menu-item",className:f("text-foreground relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden transition-colors data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([role=img]):not([class*=text-])]:opacity-60 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0","focus:bg-accent focus:text-foreground","data-[active=true]:bg-accent data-[active=true]:text-accent-foreground",t&&"ps-8",a$1==="destructive"&&"text-destructive hover:text-destructive focus:text-destructive hover:bg-destructive/5 focus:bg-destructive/5 data-[active=true]:bg-destructive/5",e)},o))}function sr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(DropdownMenu.Separator,a({"data-slot":"dropdown-menu-separator",className:f("-mx-2 my-1.5 h-px bg-muted",e)},t))}function di(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command,a({className:f("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e)},t))}var lr=r=>{var n=r,{children:e,className:t,shouldFilter:a$1}=n,o=c(n,["children","className","shouldFilter"]);return jsx(we,b(a({},o),{children:jsxs(Fe,{className:f("overflow-hidden p-0 shadow-lg",t),children:[jsx(Ne,{className:"hidden"}),jsx(di,{shouldFilter:a$1,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})}))};function dr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsxs("div",{className:"flex items-center border-border border-b px-3","cmdk-input-wrapper":"","data-slot":"command-input",children:[jsx(l,{className:"me-2 h-4 w-4 shrink-0 opacity-50"}),jsx(Command.Input,a({className:f("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-hidden text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e)},t))]})}function cr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.List,a({"data-slot":"command-list",className:f("max-h-[300px] overflow-y-auto overflow-x-hidden",e)},t))}function fo(t){var e=c(t,[]);return jsx(Command.Empty,a({"data-slot":"command-empty",className:"py-6 text-center text-sm"},e))}function Vo(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.Group,a({"data-slot":"command-group",className:f("overflow-hidden p-1.5 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e)},t))}function Go(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.Item,a({"data-slot":"command-item",className:f("relative flex text-foreground cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0","[&_svg:not([role=img]):not([class*=text-])]:opacity-60",e)},t))}function go(e,t=500){let[a,o]=useState(e);return useEffect(()=>{let r=setTimeout(()=>{o(e);},t);return ()=>{clearTimeout(r);}},[e,t]),a}function Uo(){let[e,t]=useState(""),[a,o]=useState([]),[r,n]=useState([]),[s,u]=useState(false),{provider:l$1,handleFolderClick:v,handleClearSelection:m,isSearchModalOpen:x,setIsSearchModalOpen:c,setFileDetailsModalFile:F}=E(),w=go(e,300),M=useCallback(async D=>{u(true);try{let[k,b]=await Promise.all([l$1.findFiles(D),l$1.findFolders(D)]);o(k),n(b);}catch(k){let b=k instanceof Error?k.message:"Search failed";toast.error("Search Failed",{description:b}),o([]),n([]);}finally{u(false);}},[l$1]);return useEffect(()=>{x&&w.length>0?M(w):(o([]),n([]));},[w,x,M]),jsxs(Fragment,{children:[jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:()=>c(true),children:[jsx(l,{className:"size-4 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"hidden",children:"Search"})]}),jsxs(lr,{className:"max-w-4xl w-full",open:x,onOpenChange:D=>{c(D),D||(t(""),o([]),n([]));},shouldFilter:false,children:[jsx(dr,{placeholder:"Type to search files or folders...",value:e,onValueChange:D=>{t(D);}}),jsxs(cr,{children:[s&&jsx(fo,{children:"Searching..."}),!s&&a.length===0&&r.length===0&&!e&&jsx(fo,{children:jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[jsx(l,{className:"size-12 text-gray-300 dark:text-zinc-600 mb-3"}),jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-zinc-100 mb-1",children:"Search your files and folders"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400",children:"Start typing to find what you're looking for"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400 mt-2",children:jsx(kt,{children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + K"]})})})]})}),!s&&a.length===0&&r.length===0&&e&&jsx(fo,{children:jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[jsx(l,{className:"size-12 text-gray-300 dark:text-zinc-600 mb-3"}),jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-zinc-100 mb-1",children:"No results found"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400",children:"Try searching with different keywords"})]})}),r.length>0&&jsx(Vo,{heading:"Folders",children:r.map(D=>jsxs(Go,{onSelect:()=>{m(),c(false),v(D);},children:[jsx(j,{className:"size-4 mr-2 shrink-0",strokeWidth:1.5}),jsx("span",{children:Ae(D.name,60)})]},D.id))}),a.length>0&&jsx(Vo,{heading:"Files",children:a.map(D=>{let{component:k}=Xe(D);return jsxs(Go,{onSelect:()=>{m(),F(D);},children:[jsx("div",{className:"size-6 mr-2 shrink-0 flex items-center justify-center",children:jsx(k,{file:D,metaData:D.metaData})}),jsx("span",{children:Ae(D.name,60)})]},D.id)})})]})]})]})}var xi=cva(`
|
|
79
|
+
`,backgroundSize:"20px 20px",backgroundPosition:"0 0, 0 10px, 10px -10px, -10px 0px"},children:jsx("img",{src:e.previewUrl||e.url,alt:e.alternativeText||e.name,className:"max-w-full max-h-full object-contain"})})]}),F=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-primary",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Dimensions"}),jsx("p",{className:"text-xs font-bold text-primary",children:e.width&&e.height?`${e.width}\xD7${e.height}`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-primary",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-primary",children:((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"N/A"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-border",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>m(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-accent rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"altText",children:"Alternative text"}),jsx(Oe,{id:"altText",value:l,onChange:N=>v(N.target.value),placeholder:"Describe the image for accessibility",rows:3}),jsx("p",{className:"text-xs text-muted-foreground",children:"This text will be displayed if the asset can't be shown."})]}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:u,onChange:N=>x(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:w,metadataSection:F,footer:jsxs("div",{className:"flex w-full justify-between items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{className:"w-full md:w-auto",variant:"outline",onClick:t,radius:"full",disabled:r,children:"Cancel"}),jsxs(y,{className:"w-full md:w-auto",onClick:c,radius:"full",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Za({file:e,onClose:t,onSave:a,onDelete:o}){var F,M,C$1;let[r,n]=useState(false),[s,m]=useState(e.name),[l,v]=useState(e.caption||""),u=async()=>{n(true);try{await(a==null?void 0:a({name:s,caption:l})),t();}finally{n(false);}},x=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsx("div",{className:"flex-1 flex items-center justify-center bg-black rounded-lg overflow-hidden",children:jsx("video",{src:e.url,controls:true,className:"max-w-full max-h-full",style:{maxHeight:"500px"},children:"Your browser does not support the video tag."})})]}),c=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-primary",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Dimensions"}),jsx("p",{className:"text-xs font-bold text-primary",children:e.width&&e.height?`${e.width}\xD7${e.height}`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Duration"}),jsx("p",{className:"text-xs font-bold text-primary",children:(F=e.metaData)!=null&&F.duration?co(e.metaData.duration):"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-primary",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-primary",children:((M=e.ext)==null?void 0:M.replace(".",""))||"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Video Source"}),jsx("p",{className:"text-xs font-bold text-primary capitalize",children:((C$1=e.metaData)==null?void 0:C$1.videoSource)||"local"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-border",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>m(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-accent rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:l,onChange:N=>v(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:x,metadataSection:c,footer:jsxs("div",{className:"flex w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{variant:"outline",onClick:t,radius:"full",className:"w-full md:w-auto",disabled:r,children:"Cancel"}),jsxs(y,{onClick:u,radius:"full",className:"w-full md:w-auto",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Ja({file:e,onClose:t,onSave:a,onDelete:o}){var F,M,C$1;let[r,n]=useState(false),[s,m]=useState(e.name),[l,v]=useState(e.caption||""),u=async()=>{n(true);try{await(a==null?void 0:a({name:s,caption:l})),t();}finally{n(false);}},x=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-linear-to-br from-purple-50 to-blue-50 dark:from-purple-950 dark:to-blue-950 rounded-lg p-8",children:[jsx("div",{className:"mb-8",children:jsx("div",{className:"w-32 h-32 rounded-full bg-white dark:bg-gray-800 shadow-lg flex items-center justify-center",children:jsx(h,{className:"w-16 h-16 text-purple-600 dark:text-purple-400"})})}),jsx("div",{className:"w-full max-w-md",children:jsx("audio",{src:e.url,controls:true,className:"w-full",children:"Your browser does not support the audio tag."})})]})]}),c=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-primary",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Duration"}),jsx("p",{className:"text-xs font-bold text-primary",children:(F=e.metaData)!=null&&F.duration?co(e.metaData.duration):"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Bitrate"}),jsx("p",{className:"text-xs font-bold text-primary",children:(M=e.metaData)!=null&&M.bitrate?`${e.metaData.bitrate} kbps`:"N/A"})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-primary",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-primary",children:((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"N/A"})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-border",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:s.replace(e.ext||"",""),onChange:N=>m(N.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-accent rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"caption",children:"Caption"}),jsx(Oe,{id:"caption",value:l,onChange:N=>v(N.target.value),placeholder:"Add a caption",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:x,metadataSection:c,footer:jsxs("div",{className:"flex gap-2 w-full sm:justify-between justify-center items-center flex-col sm:flex-row ",children:[jsx(y,{variant:"outline",onClick:t,radius:"full",className:"w-full md:w-auto",disabled:r,children:"Cancel"}),jsxs(y,{onClick:u,radius:"full",className:"w-full md:w-auto",disabled:r,children:[r&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Finish"]})]})})}function Xa({file:e,onClose:t,onSave:a$1}){var M,C$1,N,D;let[o,r]=useState(false),[n,s]=useState(e.name),[m,l]=useState(((M=e.metaData)==null?void 0:M.description)||""),v=async()=>{r(true);try{await(a$1==null?void 0:a$1({name:n,metaData:b(a({},e.metaData),{description:m})})),t();}finally{r(false);}},u=((C$1=e.ext)==null?void 0:C$1.replace(".",""))||"file",{component:x}=Xe(e),c=jsxs("div",{className:"flex flex-col h-full",children:[jsxs("div",{className:"flex gap-2 mb-4",children:[jsx(tt,{file:e}),jsx(ot,{file:e}),jsx(at,{file:e})]}),jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-linear-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 rounded-lg p-8",children:[jsx("div",{className:"mb-4 w-32 h-32 flex items-center justify-center",children:jsx(x,{file:e,metaData:e.metaData})}),jsxs("p",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:[u," File"]})]})]}),w=jsxs("div",{className:"space-y-6",children:[jsxs("div",{className:"grid grid-cols-2 gap-4",children:[jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Size"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:ee(e.size)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Date"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:rt(e.createdAt)})]}),jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground tracking-wide mb-1",children:"Extension"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:u})]}),((N=e.metaData)==null?void 0:N.pageCount)&&jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Page Count"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.metaData.pageCount})]}),((D=e.metaData)==null?void 0:D.author)&&jsxs("div",{children:[jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"Author"}),jsx("p",{className:"text-xs font-bold text-blue-600 dark:text-blue-400",children:e.metaData.author})]})]}),jsxs("div",{className:"space-y-4 pt-4 border-t border-slate-200",children:[jsx("div",{className:"space-y-2",children:jsxs(nt,{className:"gap-0",children:[jsx(it,{htmlFor:"fileName",children:"File name"}),jsxs(st,{children:[jsx(ct,{id:"fileName",placeholder:"Enter file name",value:n.replace(e.ext||"",""),onChange:k=>s(k.target.value)}),jsx(lt,{align:"inline-end",className:"pr-1",children:jsx(dt,{className:"font-bold bg-gray-200 dark:bg-zinc-700 rounded-lg py-1 px-3",children:e.ext})})]})]})}),jsxs("div",{className:"space-y-2",children:[jsx(Re,{htmlFor:"description",children:"Description"}),jsx(Oe,{id:"description",value:m,onChange:k=>l(k.target.value),placeholder:"Add a description",rows:3})]})]})]});return jsx(et,{title:"Details",open:true,onClose:t,previewSection:c,metadataSection:w,footer:jsxs("div",{className:"flex w-full justify-between items-center flex-col sm:flex-row gap-2 ",children:[jsx(y,{className:"w-full md:w-auto",variant:"outline",onClick:t,radius:"full",disabled:o,children:"Cancel"}),jsxs(y,{className:"w-full md:w-auto",onClick:v,radius:"full",disabled:o,children:[o&&jsx(C,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]})})}function er({className:e$1}){let{fileDetailsModalFile:t,setFileDetailsModalFile:a,updateFileMetadata:o}=E(),r=()=>{a(null);},n=async m=>{t&&await o(t.id,m);},s=()=>{if(!t)return null;switch(H(t.mime,t.ext)){case e.IMAGE:return jsx(qa,{file:t,onClose:r,onSave:n});case e.VIDEO:return jsx(Za,{file:t,onClose:r,onSave:n});case e.AUDIO:return jsx(Ja,{file:t,onClose:r,onSave:n});case e.FILE:default:return jsx(Xa,{file:t,onClose:r,onSave:n})}};return jsxs("div",{className:f("",e$1),children:[jsx(Ga,{}),jsx(Ua,{}),jsx(Ka,{}),s()]})}function ai(a$1){var o=a$1,{children:e}=o,t=c(o,["children"]);return jsx(no,b(a({mode:d.PAGE,selectionMode:f$1.MULTIPLE},t),{children:e}))}function ri(m){var l=m,{children:e,fileSelectionMode:t=f$1.SINGLE,acceptedFileTypes:a$1,viewMode:o="grid",onFilesSelected:r,onClose:n}=l,s=c(l,["children","fileSelectionMode","acceptedFileTypes","viewMode","onFilesSelected","onClose"]);return jsx(no,b(a({mode:d.MODAL,selectionMode:t,acceptedFileTypesForModal:a$1||s.allowedFileTypes,viewMode:o,onFilesSelected:r,onClose:n},s),{children:e}))}var He={Page:ai,Modal:ri,Header:xa,Footer:va,Overlays:er};function or(){let{setIsMoveFileModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"lg",radius:"full",onClick:()=>e(true),className:"text-md font-medium border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:text-blue-600 dark:hover:text-blue-400 hover:border-blue-300 dark:hover:border-blue-700 shadow-sm transition-all duration-200",children:[jsx(m,{className:"size-5"}),jsx("span",{className:"hidden sm:inline",children:"Move"})]})}function ar(){let{bulkDelete:e}=E();return jsxs(y,{variant:"outline",size:"lg",radius:"full",onClick:e,className:"text-md font-medium border border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 hover:bg-red-50 dark:hover:bg-red-900/40 hover:text-red-600 dark:hover:text-red-400 hover:border-red-300 dark:hover:border-red-700 shadow-sm transition-all duration-200",children:[jsx(r,{className:"size-5"}),jsx("span",{className:"hidden",children:"Delete"})]})}function rr(){let{handleClearSelection:e}=E();return jsxs(y,{variant:"outline",size:"lg",onClick:e,className:"rounded-full text-md font-medium border border-transparent text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/40 hover:border-blue-300 dark:hover:border-blue-700 hover:font-semibold transition-all duration-200",children:[jsx(s,{className:"size-5 transition-colors"}),"Clear"]})}function nr(){let{selectedFiles:e,selectedFolders:t}=E();return e.length+t.length===0?null:jsx("div",{className:"w-full",children:jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[jsxs("div",{className:"flex items-center gap-2 flex-1 sm:flex-initial",children:[jsx(or,{}),jsx(ar,{})]}),jsx(rr,{})]})})}function ir({className:e}){let{selectedFiles:t,selectedFolders:a}=E();return t.length+a.length===0?null:jsx("div",{className:`fixed bottom-0 left-0 right-0 z-50 bg-white/80 dark:bg-zinc-900/80 backdrop-blur-sm border-t border-gray-200 dark:border-zinc-700 shadow-lg ${e||""}`,children:jsx("div",{className:"px-4 sm:px-6 py-3 mx-auto",children:jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[jsxs("div",{className:"flex items-center gap-2 flex-1 sm:flex-initial",children:[jsx(or,{}),jsx(ar,{})]}),jsx(rr,{})]})})})}function Oo(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx("div",a({"data-slot":"skeleton",className:f("animate-pulse rounded-md bg-accent",e)},t))}function po(){let{currentFolder:e,handleFolderClick:t,isLoading:a}=E(),o=useRouter(),r=()=>{o.back();};return a?jsxs("div",{className:"flex item-center w-full",children:[jsx(Oo,{className:"rounded-full size-10 mr-2 shrink-0"}),jsx(Oo,{className:"min-w-32 rounded-md h-full"})]}):jsx(Fragment,{children:e?jsxs("div",{className:"flex items-center flex-1 min-w-0 max-w-[calc(100%-40px)]",children:[jsx(y,{variant:"outline",size:"icon",radius:"full",disabled:a,className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 mr-2",onClick:r,children:jsx(p,{className:"size-5 text-gray-900 dark:text-zinc-100",strokeWidth:"1.5"})}),jsx("h1",{className:"text-lg flex-1 min-w-0 align-middle font-semibold",children:Ae(e.name,20)})]}):jsxs("div",{className:"flex items-center flex-1 min-w-0 max-w-[calc(100%-40px)]",children:[jsx(y,{className:"mr-2 shrink-0",radius:"full",variant:"ghost",mode:"icon",size:"icon",onClick:()=>t(null),children:jsx(k,{className:"size-6 text-gray-900 dark:text-zinc-100"})}),jsx("h1",{className:"text-lg flex-1 min-w-0 align-middle font-semibold",children:"Home"})]})})}function Wt(t){var e=c(t,[]);return jsx(DropdownMenu.Root,a({"data-slot":"dropdown-menu"},e))}function jt(t){var e=c(t,[]);return jsx(DropdownMenu.Trigger,a({className:"select-none","data-slot":"dropdown-menu-trigger"},e))}function Qt(o){var r=o,{className:e,sideOffset:t=4}=r,a$1=c(r,["className","sideOffset"]);return jsx(DropdownMenu.Portal,{children:jsx(DropdownMenu.Content,a({"data-slot":"dropdown-menu-content",sideOffset:t,className:f("space-y-0.5 z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover p-2 text-popover-foreground shadow-md shadow-black/5 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e)},a$1))})}function Ke(r){var n=r,{className:e,inset:t,variant:a$1}=n,o=c(n,["className","inset","variant"]);return jsx(DropdownMenu.Item,a({"data-slot":"dropdown-menu-item",className:f("text-foreground relative flex cursor-default select-none items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-hidden transition-colors data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([role=img]):not([class*=text-])]:opacity-60 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0","focus:bg-accent focus:text-foreground","data-[active=true]:bg-accent data-[active=true]:text-accent-foreground",t&&"ps-8",a$1==="destructive"&&"text-destructive hover:text-destructive focus:text-destructive hover:bg-destructive/5 focus:bg-destructive/5 data-[active=true]:bg-destructive/5",e)},o))}function sr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(DropdownMenu.Separator,a({"data-slot":"dropdown-menu-separator",className:f("-mx-2 my-1.5 h-px bg-muted",e)},t))}function di(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command,a({className:f("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e)},t))}var lr=r=>{var n=r,{children:e,className:t,shouldFilter:a$1}=n,o=c(n,["children","className","shouldFilter"]);return jsx(Fe,b(a({},o),{children:jsxs(we,{className:f("overflow-hidden p-0 shadow-lg",t),children:[jsx(Ne,{className:"hidden"}),jsx(di,{shouldFilter:a$1,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})}))};function dr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsxs("div",{className:"flex items-center border-border border-b px-3","cmdk-input-wrapper":"","data-slot":"command-input",children:[jsx(l,{className:"me-2 h-4 w-4 shrink-0 opacity-50"}),jsx(Command.Input,a({className:f("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-hidden text-foreground placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e)},t))]})}function cr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.List,a({"data-slot":"command-list",className:f("max-h-[300px] overflow-y-auto overflow-x-hidden",e)},t))}function fo(t){var e=c(t,[]);return jsx(Command.Empty,a({"data-slot":"command-empty",className:"py-6 text-center text-sm"},e))}function Vo(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.Group,a({"data-slot":"command-group",className:f("overflow-hidden p-1.5 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e)},t))}function Go(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(Command.Item,a({"data-slot":"command-item",className:f("relative flex text-foreground cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-hidden data-[disabled=true]:pointer-events-none data-[selected=true]:bg-accent data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0","[&_svg:not([role=img]):not([class*=text-])]:opacity-60",e)},t))}function go(e,t=500){let[a,o]=useState(e);return useEffect(()=>{let r=setTimeout(()=>{o(e);},t);return ()=>{clearTimeout(r);}},[e,t]),a}function Uo(){let[e,t]=useState(""),[a,o]=useState([]),[r,n]=useState([]),[s,m]=useState(false),{provider:l$1,handleFolderClick:v,handleClearSelection:u,isSearchModalOpen:x,setIsSearchModalOpen:c,setFileDetailsModalFile:w}=E(),F=go(e,300),M=useCallback(async D=>{m(true);try{let[k,b]=await Promise.all([l$1.findFiles(D),l$1.findFolders(D)]);o(k),n(b);}catch(k){let b=k instanceof Error?k.message:"Search failed";toast.error("Search Failed",{description:b}),o([]),n([]);}finally{m(false);}},[l$1]);return useEffect(()=>{x&&F.length>0?M(F):(o([]),n([]));},[F,x,M]),jsxs(Fragment,{children:[jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:()=>c(true),children:[jsx(l,{className:"size-4 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"hidden",children:"Search"})]}),jsxs(lr,{className:"max-w-4xl w-full",open:x,onOpenChange:D=>{c(D),D||(t(""),o([]),n([]));},shouldFilter:false,children:[jsx(dr,{placeholder:"Type to search files or folders...",value:e,onValueChange:D=>{t(D);}}),jsxs(cr,{children:[s&&jsx(fo,{children:"Searching..."}),!s&&a.length===0&&r.length===0&&!e&&jsx(fo,{children:jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[jsx(l,{className:"size-12 text-gray-300 dark:text-zinc-600 mb-3"}),jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-zinc-100 mb-1",children:"Search your files and folders"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400",children:"Start typing to find what you're looking for"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400 mt-2",children:jsx(kt,{children:jsxs(Mt,{children:[jsx("span",{className:"text-lg",children:"\u2318"})," + K"]})})})]})}),!s&&a.length===0&&r.length===0&&e&&jsx(fo,{children:jsxs("div",{className:"flex flex-col items-center justify-center py-8 px-4 text-center",children:[jsx(l,{className:"size-12 text-gray-300 dark:text-zinc-600 mb-3"}),jsx("p",{className:"text-sm font-medium text-gray-900 dark:text-zinc-100 mb-1",children:"No results found"}),jsx("p",{className:"text-xs text-gray-500 dark:text-zinc-400",children:"Try searching with different keywords"})]})}),r.length>0&&jsx(Vo,{heading:"Folders",children:r.map(D=>jsxs(Go,{onSelect:()=>{u(),c(false),v(D);},children:[jsx(j,{className:"size-4 mr-2 shrink-0",strokeWidth:1.5}),jsx("span",{children:Ae(D.name,60)})]},D.id))}),a.length>0&&jsx(Vo,{heading:"Files",children:a.map(D=>{let{component:k}=Xe(D);return jsxs(Go,{onSelect:()=>{u(),w(D);},children:[jsx("div",{className:"size-6 mr-2 shrink-0 flex items-center justify-center",children:jsx(k,{file:D,metaData:D.metaData})}),jsx("span",{children:Ae(D.name,60)})]},D.id)})})]})]})]})}var xi=cva(`
|
|
80
80
|
group peer bg-background shrink-0 rounded-md border border-input ring-offset-background focus-visible:outline-none
|
|
81
81
|
focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50
|
|
82
82
|
aria-invalid:border-destructive/60 aria-invalid:ring-destructive/10 dark:aria-invalid:border-destructive dark:aria-invalid:ring-destructive/20
|
|
83
83
|
[[data-invalid=true]_&]:border-destructive/60 [[data-invalid=true]_&]:ring-destructive/10 dark:[[data-invalid=true]_&]:border-destructive dark:[[data-invalid=true]_&]:ring-destructive/20,
|
|
84
84
|
data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=checked]:text-primary-foreground data-[state=indeterminate]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:text-primary-foreground
|
|
85
|
-
`,{variants:{size:{sm:"size-4.5 [&_svg]:size-3",md:"size-5 [&_svg]:size-3.5",lg:"size-5.5 [&_svg]:size-4"}},defaultVariants:{size:"md"}});function Yt(o){var r=o,{className:e,size:t}=r,a$1=c(r,["className","size"]);return jsx(Checkbox.Root,b(a({"data-slot":"checkbox",className:f(xi({size:t}),e)},a$1),{children:jsxs(Checkbox.Indicator,{className:f("flex items-center justify-center text-current"),children:[jsx(w,{className:"group-data-[state=indeterminate]:hidden"}),jsx(B,{className:"hidden group-data-[state=indeterminate]:block"})]})}))}function pr(){return jsx(Uo,{})}function $o(){let{setIsUploadModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"md",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-md font-medium",onClick:()=>e(true),children:[jsx(q$1,{strokeWidth:2,className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden sm:inline",children:"Upload File"})]})}function Ko(){let{setIsCreateFolderModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:()=>e(true),children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden",children:"Create Folder"})]})}function gr(e){return jsxs("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e),{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}))}function vr(e){return jsx("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e),{children:jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}))}function xr(){let[e,t]=useState(false);return useEffect(()=>{let r=localStorage.getItem("theme")==="dark";t(r),document.documentElement.classList.toggle("dark",r);},[]),jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:()=>{let o=!e;t(o),document.documentElement.classList.toggle("dark",o),localStorage.setItem("theme",o?"dark":"light");},className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900","aria-label":e?"Switch to light mode":"Switch to dark mode",children:e?jsx(gr,{className:"size-4 text-yellow-500"}):jsx(vr,{className:"size-4 text-gray-700 dark:text-zinc-300"})})}function br(){let{setIsUploadModalOpen:e,setIsCreateFolderModalOpen:t,setIsSearchModalOpen:a}=E();return jsxs(Fragment,{children:[jsxs("div",{className:"hidden md:flex gap-2",children:[jsx($o,{}),jsx(Ko,{}),jsx(pr,{}),jsx(xr,{})]}),jsx("div",{className:"flex md:hidden",children:jsxs(Wt,{children:[jsx(jt,{asChild:true,children:jsx(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",children:jsx(z,{className:"size-5"})})}),jsxs(Qt,{align:"end",className:"w-56 rounded-2xl shadow-xl bg-white/50 dark:bg-zinc-900/80 backdrop-blur-2xl border-gray-200 dark:border-zinc-700",children:[jsxs(Ke,{onClick:()=>e(true),className:"cursor-pointer",children:[jsx(q$1,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Upload File"})]}),jsxs(Ke,{onClick:()=>t(true),className:"cursor-pointer",children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Create Folder"})]}),jsxs(Ke,{onClick:()=>a(true),className:"cursor-pointer",children:[jsx(l,{className:"size-5 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"inline",children:"Search"})]})]})]})})]})}function hr({onSearchClick:e}){let{setIsUploadModalOpen:t,setIsCreateFolderModalOpen:a}=E();return jsxs(Fragment,{children:[jsxs("div",{className:"hidden md:flex gap-2",children:[jsx($o,{}),jsx(Ko,{}),e?jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:e,children:[jsx(l,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden",children:"Search"})]}):null]}),jsx("div",{className:"flex md:hidden",children:jsxs(Wt,{children:[jsx(jt,{asChild:true,children:jsx(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",children:jsx(z,{className:"size-5"})})}),jsxs(Qt,{align:"end",className:"w-48",children:[jsxs(Ke,{onClick:()=>t(true),className:"cursor-pointer",children:[jsx(q$1,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Upload File"})]}),jsxs(Ke,{onClick:()=>a(true),className:"cursor-pointer",children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Create Folder"})]}),e?jsxs(Ke,{onClick:e,className:"cursor-pointer",children:[jsx(l,{className:"size-5 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"inline",children:"Search"})]}):null]})]})})]})}function Cr(t){var e=c(t,[]);return jsx(q.Root,a({"data-slot":"context-menu"},e))}function
|
|
86
|
-
relative w-full aspect-square flex items-center justify-center mb-1 overflow-hidden rounded-2xl hover:bg-
|
|
87
|
-
${t?"bg-
|
|
88
|
-
`,children:[jsx("div",{className:"w-[75%] h-[75%] flex items-center justify-center",children:jsx(N,{file:e,metaData:e.metaData})}),(s===f$1.MULTIPLE||
|
|
85
|
+
`,{variants:{size:{sm:"size-4.5 [&_svg]:size-3",md:"size-5 [&_svg]:size-3.5",lg:"size-5.5 [&_svg]:size-4"}},defaultVariants:{size:"md"}});function Yt(o){var r=o,{className:e,size:t}=r,a$1=c(r,["className","size"]);return jsx(Checkbox.Root,b(a({"data-slot":"checkbox",className:f(xi({size:t}),e)},a$1),{children:jsxs(Checkbox.Indicator,{className:f("flex items-center justify-center text-current"),children:[jsx(w,{className:"group-data-[state=indeterminate]:hidden"}),jsx(B,{className:"hidden group-data-[state=indeterminate]:block"})]})}))}function pr(){return jsx(Uo,{})}function $o(){let{setIsUploadModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"md",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900 text-md font-medium",onClick:()=>e(true),children:[jsx(q$1,{strokeWidth:2,className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden sm:inline",children:"Upload File"})]})}function Ko(){let{setIsCreateFolderModalOpen:e}=E();return jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:()=>e(true),children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden",children:"Create Folder"})]})}function gr(e){return jsxs("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e),{children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}))}function vr(e){return jsx("svg",b(a({xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},e),{children:jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}))}function xr(){let[e,t]=useState(false);return useEffect(()=>{let r=localStorage.getItem("theme")==="dark";t(r),document.documentElement.classList.toggle("dark",r);},[]),jsx(y,{variant:"outline",size:"icon",radius:"full",onClick:()=>{let o=!e;t(o),document.documentElement.classList.toggle("dark",o),localStorage.setItem("theme",o?"dark":"light");},className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900","aria-label":e?"Switch to light mode":"Switch to dark mode",children:e?jsx(gr,{className:"size-4 text-yellow-500"}):jsx(vr,{className:"size-4 text-gray-700 dark:text-zinc-300"})})}function br(){let{setIsUploadModalOpen:e,setIsCreateFolderModalOpen:t,setIsSearchModalOpen:a}=E();return jsxs(Fragment,{children:[jsxs("div",{className:"hidden md:flex gap-2",children:[jsx($o,{}),jsx(Ko,{}),jsx(pr,{}),jsx(xr,{})]}),jsx("div",{className:"flex md:hidden",children:jsxs(Wt,{children:[jsx(jt,{asChild:true,children:jsx(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",children:jsx(z,{className:"size-5"})})}),jsxs(Qt,{align:"end",className:"w-56 rounded-2xl shadow-xl bg-white/50 dark:bg-zinc-900/80 backdrop-blur-2xl border-gray-200 dark:border-zinc-700",children:[jsxs(Ke,{onClick:()=>e(true),className:"cursor-pointer",children:[jsx(q$1,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Upload File"})]}),jsxs(Ke,{onClick:()=>t(true),className:"cursor-pointer",children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Create Folder"})]}),jsxs(Ke,{onClick:()=>a(true),className:"cursor-pointer",children:[jsx(l,{className:"size-5 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"inline",children:"Search"})]})]})]})})]})}function hr({onSearchClick:e}){let{setIsUploadModalOpen:t,setIsCreateFolderModalOpen:a}=E();return jsxs(Fragment,{children:[jsxs("div",{className:"hidden md:flex gap-2",children:[jsx($o,{}),jsx(Ko,{}),e?jsxs(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",onClick:e,children:[jsx(l,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"hidden",children:"Search"})]}):null]}),jsx("div",{className:"flex md:hidden",children:jsxs(Wt,{children:[jsx(jt,{asChild:true,children:jsx(y,{variant:"outline",size:"icon",radius:"full",className:"border-gray-200 dark:border-zinc-700 bg-white dark:bg-zinc-900",children:jsx(z,{className:"size-5"})})}),jsxs(Qt,{align:"end",className:"w-48",children:[jsxs(Ke,{onClick:()=>t(true),className:"cursor-pointer",children:[jsx(q$1,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Upload File"})]}),jsxs(Ke,{onClick:()=>a(true),className:"cursor-pointer",children:[jsx(n,{className:"size-5 text-gray-900 dark:text-zinc-100"}),jsx("span",{className:"inline",children:"Create Folder"})]}),e?jsxs(Ke,{onClick:e,className:"cursor-pointer",children:[jsx(l,{className:"size-5 text-gray-700 dark:text-zinc-300"}),jsx("span",{className:"inline",children:"Search"})]}):null]})]})})]})}function Cr(t){var e=c(t,[]);return jsx(q.Root,a({"data-slot":"context-menu"},e))}function Fr(t){var e=c(t,[]);return jsx(q.Trigger,a({"data-slot":"context-menu-trigger"},e))}function wr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(q.Portal,{children:jsx(q.Content,a({"data-slot":"context-menu-content",className:f("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e)},t))})}function Nr(r){var n=r,{className:e,inset:t,variant:a$1="default"}=n,o=c(n,["className","inset","variant"]);return jsx(q.Item,a({"data-slot":"context-menu-item","data-inset":t,"data-variant":a$1,className:f("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e)},o))}function Mr(a$1){var o=a$1,{className:e}=o,t=c(o,["className"]);return jsx(q.Separator,a({"data-slot":"context-menu-separator",className:f("bg-border -mx-1 my-1 h-px",e)},t))}function bo({children:e,menuItems:t,isInSelectionMode:a=false,mode:o}){let r=!a&&o!=="modal",n=(s=false)=>t.map((m,l)=>{let v=l===t.length-1,u=m.variant==="destructive",x=s?Ke:Nr,c=s?sr:Mr,w=l<t.length-1&&t[l+1].variant==="destructive";return jsxs(Fi.Fragment,{children:[jsxs(x,{onClick:m.onClick,className:m.className||`text-sm font-medium ${u?"text-red-600 focus:text-red-700 focus:bg-red-50":""} ${l===0?"rounded-t-xl":""} ${v?"rounded-b-xl":""}`,children:[m.icon,m.label]}),w&&!v&&jsx(c,{className:"bg-gray-200 dark:bg-zinc-700"})]},l)});return jsxs(Cr,{children:[jsx(Fr,{children:jsxs("div",{className:"relative w-full h-full",children:[e,r&&jsx("div",{className:"absolute top-0 right-0 z-10 md:hidden",onClick:s=>s.stopPropagation(),children:jsxs(Wt,{children:[jsx(jt,{asChild:true,children:jsx(y,{variant:"ghost",size:"icon",radius:"full",className:"focus-visible:ring-0 focus-visible:ring-offset-0",children:jsx(A,{className:"size-4 text-gray-700 dark:text-zinc-300"})})}),jsx(Qt,{className:"w-56 rounded-2xl shadow-xl bg-white/50 dark:bg-zinc-900/80 backdrop-blur-2xl border-gray-200 dark:border-zinc-700",children:n(true)})]})})]})}),r&&jsx(wr,{className:"w-56 rounded-2xl shadow-xl bg-white/50 dark:bg-zinc-900/80 backdrop-blur-2xl border-gray-200 dark:border-zinc-700",children:n(false)})]})}function kr({file:e,isSelected:t,onSelect:a,onDelete:o,onEdit:r$1,onMove:n,selectionMode:s,showCheckbox:m$1=false,mode:l=d.PAGE,isInSelectionMode:v=false}){let u=b=>{b.stopPropagation(),confirm(`Are you sure you want to delete "${e.name}"?`)&&o(e.id);},x$1=b=>{b.stopPropagation(),r$1(e);},c=b=>{b.stopPropagation(),a(e,void 0,true);},w=b=>{b.stopPropagation(),n(e);},F=b=>{a(e,b,false);},M=b=>{a(e,void 0,true);},C=b=>{b.stopPropagation();},{component:N,metadataComponent:D}=Xe(e);return jsx(bo,{menuItems:[{label:"Edit",icon:jsx(y$1,{className:"size-6"}),onClick:x$1},{label:"Select File",icon:jsx(x,{className:"size-6"}),onClick:c},{label:"Move to...",icon:jsx(m,{className:"size-6"}),onClick:w},{label:"Delete",icon:jsx(r,{className:"size-6 text-red-600"}),onClick:u,variant:"destructive"}],isInSelectionMode:v,mode:l,children:jsxs("div",{className:"group relative flex flex-col items-center justify-start transition-all duration-200 cursor-pointer w-full select-none",onDoubleClick:F,onClick:F,children:[jsxs("div",{className:`
|
|
86
|
+
relative w-full aspect-square flex items-center justify-center mb-1 overflow-hidden rounded-2xl hover:bg-accent/60
|
|
87
|
+
${t?"bg-accent/60":""}
|
|
88
|
+
`,children:[jsx("div",{className:"w-[75%] h-[75%] flex items-center justify-center",children:jsx(N,{file:e,metaData:e.metaData})}),(s===f$1.MULTIPLE||m$1)&&jsx("div",{className:`absolute top-2 left-2 z-10 ${t?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity duration-200`,onClick:C,children:jsx(Yt,{checked:t,onCheckedChange:M,className:"bg-background/90 border-border shadow-sm data-[state=checked]:bg-primary data-[state=checked]:border-primary rounded-full h-5 w-5"})})]}),jsxs("div",{className:"w-full text-center px-0.5 flex flex-col items-center",children:[jsx("span",{className:`
|
|
89
89
|
text-[13px] font-semibold leading-[1.3] tracking-tight line-clamp-2 px-2.5 py-[2px] rounded-[6px] transition-colors duration-100 wrap-break-word max-w-full
|
|
90
|
-
${t?"bg-
|
|
91
|
-
`,children:e.name}),jsxs("div",{className:`flex flex-col items-center justify-center gap-0.5 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:[jsx("span",{className:"text-[11px] text-
|
|
90
|
+
${t?"bg-primary text-primary-foreground antialiased shadow-sm":"text-foreground group-hover:text-foreground/80"}
|
|
91
|
+
`,children:e.name}),jsxs("div",{className:`flex flex-col items-center justify-center gap-0.5 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:[jsx("span",{className:"text-[11px] text-primary font-medium tracking-tight",children:ee(e.size)}),D?jsx("div",{className:"text-[11px] text-muted-foreground flex items-center scale-95",children:jsx(D,{file:e})}):null]})]})]})})}function Dr({folder:e,isSelected:t,onSelect:a,onRightClick:o,onDelete:r$1,onRename:n,onMove:s,selectionMode:m$1,showCheckbox:l,mode:v,isInSelectionMode:u}){let x$1=k=>{k.stopPropagation(),confirm(`Are you sure you want to delete "${e.name}"?
|
|
92
92
|
|
|
93
|
-
\u26A0\uFE0F Warning: This will also delete all ${e.fileCount} file(s) inside this folder.`)&&r$1(e.id);},c=k=>{k.stopPropagation(),n(e);},
|
|
94
|
-
relative w-full aspect-square flex items-center justify-center mb-1 overflow-hidden rounded-2xl hover:bg-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
`,children:e.name}),jsx("div",{className:`flex items-center justify-center gap-1 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:jsxs("span",{className:"text-[11px] text-blue-600 dark:text-blue-400 font-medium tracking-tight px-1.5 rounded-full",children:[e.fileCount," items"]})})]})]})})}function Co(){let{files:e,folders:t,isLoading:a,handleFileClick:o,handleFolderClick:r,bulkDelete:n,mode:s,selectionMode:u,isInSelectionMode:l,selectedFiles:v,selectedFolders:m,currentFolder:x,setSelectedFiles:c,setSelectedFolders:F,setIsRenameFolderModalOpen:w,setIsMoveFileModalOpen:M,setFileDetailsModalFile:C,setFolderToRename:N}=E(),k=(()=>{if(!x)return 18;let b=x.folderCount||0,S=x.fileCount||0,j=b+S;return j>0?j:18})();return a?jsx("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:Array.from({length:k}).map((b,S)=>jsxs("div",{className:"flex flex-col items-center justify-start w-full gap-2",children:[jsx("div",{className:"w-full aspect-square bg-gray-100 dark:bg-zinc-800 rounded-2xl animate-pulse"}),jsxs("div",{className:"flex flex-col items-center gap-1 w-full",children:[jsx("div",{className:"h-4 w-20 bg-gray-100 dark:bg-zinc-800 rounded animate-pulse"}),jsx("div",{className:"h-3 w-12 bg-gray-100 dark:bg-zinc-800 rounded animate-pulse"})]})]},S))}):jsxs("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:[t.map(b=>jsx(Dr,{folder:b,isSelected:m.some(S=>S.id===b.id),onSelect:r,onDelete:()=>n(),onRename:S=>{N(S),w(true);},onMove:S=>{F([S]),c([]),M(true);},selectionMode:u,mode:s,isInSelectionMode:l()},b.id)),e.map(b=>jsx(kr,{file:b,isSelected:v.some(S=>S.id===b.id),onSelect:o,onDelete:()=>n(),onEdit:S=>{C(S);},onMove:S=>{c([S]),F([]),M(true);},selectionMode:u,mode:s,isInSelectionMode:l()},b.id))]})}var wo=class extends Component{constructor(a){super(a);this.handleReset=()=>{window.location.reload();};this.state={hasError:false,error:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,o){console.error("FileManager Error Boundary caught an error:",a,o);}render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsx("div",{className:"flex items-center justify-center min-h-[400px] p-8 w-full h-full bg-slate-50/50 rounded-lg border border-dashed border-slate-200",children:jsxs("div",{className:"text-center max-w-md flex flex-col items-center",children:[jsx("div",{className:"bg-red-100 p-3 rounded-full mb-4",children:jsx(E$1,{className:"size-8 text-red-600"})}),jsx("h2",{className:"text-xl font-semibold text-slate-900 mb-2",children:"Something went wrong"}),jsx("p",{className:"text-sm text-slate-500 mb-6",children:"The file manager encountered an unexpected error. Refreshing the page usually resolves this issue."}),this.state.error&&jsxs("details",{className:"mb-6 text-left w-full border border-slate-200 rounded-lg overflow-hidden flex-col group",children:[jsx("summary",{className:"cursor-pointer text-xs font-mono bg-slate-100 p-2 text-slate-600 hover:bg-slate-200 transition-colors",children:"View Technical Details"}),jsx("div",{className:"p-3 bg-white dark:bg-zinc-900",children:jsx("pre",{className:"text-[10px] text-slate-600 font-mono whitespace-pre-wrap word-break-all max-h-40 overflow-auto",children:this.state.error.toString()})})]}),jsxs(y,{onClick:this.handleReset,radius:"full",className:"gap-2",children:[jsx(F,{className:"size-4"}),"Reload Application"]})]})}):this.props.children}};function Pr(){let{handleSelectAllGlobal:e,handleClearSelection:t,getSelectionState:a,isCreateFolderModalOpen:o,setIsCreateFolderModalOpen:r,isUploadModalOpen:n,setIsUploadModalOpen:s,isSearchModalOpen:u,setIsSearchModalOpen:l}=E();return useEffect(()=>{let v=m=>{m.key==="k"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),l(!u)),m.key==="a"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),a()===true?t():e(true)),m.key==="f"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),r(!o)),m.key==="u"&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),s(!n));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,t,a,o,r,n,s,u,l]),null}function Mi(e){return jsx(wo,{children:jsxs(He.Page,b(a({},e),{children:[jsx(Pr,{}),jsxs("div",{className:"flex h-full relative pb-12 overflow-hidden",children:[jsxs("div",{className:"flex-1 flex w-full flex-col",children:[jsx(He.Header,{children:jsxs("div",{className:"flex w-full justify-between gap-2",children:[jsx(po,{}),jsx(br,{})]})}),jsx(ir,{className:"-mb-1"}),jsx(Co,{}),jsx(He.Footer,{className:"pt-6 pb-10"})]}),jsx(He.Overlays,{})]})]}))})}function Di(o){var r=o,{open:e,onClose:t}=r,a$1=c(r,["open","onClose"]);return jsx(He.Modal,b(a({},a$1),{onClose:t,children:jsx(we,{open:e,onOpenChange:t,children:jsx(Pi,{onClose:t})})}))}function Pi({onClose:e}){let{updateSearchQuery:t}=E(),[a,o]=useState(false),[r,n]=useState(""),s=useRef(null),u=go(r,300);return useEffect(()=>{t(u);},[u,t]),useEffect(()=>{a&&s.current&&s.current.focus();},[a]),jsxs(Fe,{className:"p-0",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsx("div",{className:"flex w-full justify-between gap-2",children:a?jsxs("div",{className:"flex items-center gap-4 flex-1",children:[jsx(l,{className:"size-5 text-gray-500 shrink-0"}),jsx(Dt,{ref:s,type:"text",placeholder:"Search files and folders...",className:"border-none shadow-none focus-visible:ring-0 h-auto p-0 text-base font-semibold",value:r,onChange:l=>n(l.target.value),onKeyDown:l=>{l.key==="Escape"&&(n(""),t(""),o(false));}}),jsx(xe,{onClick:()=>{n(""),t(""),o(false);},className:"shrink-0",label:"Cancel Search"})]}):jsxs(Fragment,{children:[jsx(po,{}),jsx(hr,{onSearchClick:()=>o(true)}),jsx(xe,{onClick:e})]})})}),jsx(Je,{className:"sr-only",children:"Browse and select files from your media library"})]}),jsxs("div",{className:"overflow-y-auto flex-1 pb-4",children:[jsx(Co,{}),jsx(He.Footer,{className:"my-4"}),jsx(He.Overlays,{})]}),jsx(Ii,{onClose:e})]})}function Ii({onClose:e}){let{selectedFiles:t,onFilesSelected:a,setSelectedFiles:o,setSelectedFolders:r,updateSearchQuery:n,handlePageChange:s}=E();return jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2",children:[jsx(nr,{}),jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",onClick:e,radius:"full",className:"w-full md:w-auto mr-0",children:"Cancel"})}),jsxs(y,{type:"button",onClick:()=>{a&&t.length>0&&(a(t),o([]),r([]),n(""),s(1),e());},disabled:t.length===0,radius:"full",className:"w-full md:w-auto",children:["Select ",t.length>0?`(${t.length})`:""]})]})}export{Mi as FileManager,Di as FileManagerModal,no as FileManagerProvider,E as useFileManager};
|
|
93
|
+
\u26A0\uFE0F Warning: This will also delete all ${e.fileCount} file(s) inside this folder.`)&&r$1(e.id);},c=k=>{k.stopPropagation(),n(e);},w=k=>{k.stopPropagation(),s(e);},F=k=>{k.stopPropagation(),a(e,void 0,true);},M=k=>{a(e,k,false);},C=k=>{a(e,void 0,true);},N=k=>{k.stopPropagation();};return jsx(bo,{menuItems:[{label:"Rename",icon:jsx(y$1,{className:"size-6"}),onClick:c},{label:"Select Folder",icon:jsx(x,{className:"size-6"}),onClick:F},{label:"Move to...",icon:jsx(m,{className:"size-5 mr-1"}),onClick:w},{label:"Delete",icon:jsx(r,{className:"size-5 mr-1 text-red-600"}),onClick:x$1,variant:"destructive"}],isInSelectionMode:u,mode:v,children:jsxs("div",{className:"group relative flex flex-col items-center justify-start transition-all duration-200 cursor-pointer w-full select-none",onDoubleClick:M,onClick:M,children:[jsxs("div",{className:`
|
|
94
|
+
relative w-full aspect-square flex items-center justify-center mb-1 overflow-hidden rounded-2xl hover:bg-accent/60
|
|
95
|
+
${t?"bg-accent/60":""}
|
|
96
|
+
`,children:[jsx("div",{className:"w-[75%] h-[75%] flex items-center justify-center transform dark:brightness-[2]",children:jsx(j,{className:"w-full h-full text-blue-400 fill-blue-400/20 drop-shadow-sm",strokeWidth:1.5})}),(m$1===f$1.MULTIPLE||l)&&jsx("div",{className:`absolute top-2 left-2 z-10 ${t?"opacity-100":"opacity-0 group-hover:opacity-100"} transition-opacity duration-200`,onClick:N,children:jsx(Yt,{checked:t,onCheckedChange:C,className:"bg-background/90 border-border shadow-sm data-[state=checked]:bg-primary data-[state=checked]:border-primary rounded-full h-5 w-5"})})]}),jsxs("div",{className:"w-full text-center px-0.5 flex flex-col items-center",children:[jsx("span",{className:`
|
|
97
|
+
text-[13px] font-semibold leading-[1.3] tracking-tight line-clamp-2 px-2.5 pb-[2px] rounded-[6px] transition-colors duration-100 wrap-break-word max-w-full
|
|
98
|
+
${t?"bg-primary text-primary-foreground antialiased shadow-sm":"text-foreground group-hover:text-foreground/80"}
|
|
99
|
+
`,children:e.name}),jsx("div",{className:`flex items-center justify-center gap-1 mt-1 transition-opacity duration-200 ${t?"opacity-60":"opacity-100"}`,children:jsxs("span",{className:"text-[11px] text-primary font-medium tracking-tight px-1.5 rounded-full",children:[e.fileCount," items"]})})]})]})})}function Co(){let{files:e,folders:t,isLoading:a,handleFileClick:o,handleFolderClick:r,bulkDelete:n,mode:s,selectionMode:m,isInSelectionMode:l,selectedFiles:v,selectedFolders:u,currentFolder:x,setSelectedFiles:c,setSelectedFolders:w,setIsRenameFolderModalOpen:F,setIsMoveFileModalOpen:M,setFileDetailsModalFile:C,setFolderToRename:N}=E(),k=(()=>{if(!x)return 18;let b=x.folderCount||0,S=x.fileCount||0,j=b+S;return j>0?j:18})();return a?jsx("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:Array.from({length:k}).map((b,S)=>jsxs("div",{className:"flex flex-col items-center justify-start w-full gap-2",children:[jsx("div",{className:"w-full aspect-square bg-muted rounded-2xl animate-pulse"}),jsxs("div",{className:"flex flex-col items-center gap-1 w-full",children:[jsx("div",{className:"h-4 w-20 bg-muted rounded animate-pulse"}),jsx("div",{className:"h-3 w-12 bg-muted rounded animate-pulse"})]})]},S))}):jsxs("div",{className:"p-4 grid grid-cols-2 gap-x-4 gap-y-8 sm:grid-cols-3 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-7 2xl:grid-cols-8 content-start",children:[t.map(b=>jsx(Dr,{folder:b,isSelected:u.some(S=>S.id===b.id),onSelect:r,onDelete:()=>n(),onRename:S=>{N(S),F(true);},onMove:S=>{w([S]),c([]),M(true);},selectionMode:m,mode:s,isInSelectionMode:l()},b.id)),e.map(b=>jsx(kr,{file:b,isSelected:v.some(S=>S.id===b.id),onSelect:o,onDelete:()=>n(),onEdit:S=>{C(S);},onMove:S=>{c([S]),w([]),M(true);},selectionMode:m,mode:s,isInSelectionMode:l()},b.id))]})}var Fo=class extends Component{constructor(a){super(a);this.handleReset=()=>{window.location.reload();};this.state={hasError:false,error:null};}static getDerivedStateFromError(a){return {hasError:true,error:a}}componentDidCatch(a,o){console.error("FileManager Error Boundary caught an error:",a,o);}render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsx("div",{className:"flex items-center justify-center min-h-[400px] p-8 w-full h-full bg-slate-50/50 rounded-lg border border-dashed border-slate-200",children:jsxs("div",{className:"text-center max-w-md flex flex-col items-center",children:[jsx("div",{className:"bg-red-100 p-3 rounded-full mb-4",children:jsx(E$1,{className:"size-8 text-red-600"})}),jsx("h2",{className:"text-xl font-semibold text-slate-900 mb-2",children:"Something went wrong"}),jsx("p",{className:"text-sm text-slate-500 mb-6",children:"The file manager encountered an unexpected error. Refreshing the page usually resolves this issue."}),this.state.error&&jsxs("details",{className:"mb-6 text-left w-full border border-slate-200 rounded-lg overflow-hidden flex-col group",children:[jsx("summary",{className:"cursor-pointer text-xs font-mono bg-slate-100 p-2 text-slate-600 hover:bg-slate-200 transition-colors",children:"View Technical Details"}),jsx("div",{className:"p-3 bg-white dark:bg-zinc-900",children:jsx("pre",{className:"text-[10px] text-slate-600 font-mono whitespace-pre-wrap word-break-all max-h-40 overflow-auto",children:this.state.error.toString()})})]}),jsxs(y,{onClick:this.handleReset,radius:"full",className:"gap-2",children:[jsx(F,{className:"size-4"}),"Reload Application"]})]})}):this.props.children}};function Pr(){let{handleSelectAllGlobal:e,handleClearSelection:t,getSelectionState:a,isCreateFolderModalOpen:o,setIsCreateFolderModalOpen:r,isUploadModalOpen:n,setIsUploadModalOpen:s,isSearchModalOpen:m,setIsSearchModalOpen:l}=E();return useEffect(()=>{let v=u=>{u.key==="k"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),l(!m)),u.key==="a"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),a()===true?t():e(true)),u.key==="f"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),r(!o)),u.key==="u"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),s(!n));};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[e,t,a,o,r,n,s,m,l]),null}function Mi(e){return jsx(Fo,{children:jsxs(He.Page,b(a({},e),{children:[jsx(Pr,{}),jsxs("div",{className:"flex h-full relative pb-12 overflow-hidden",children:[jsxs("div",{className:"flex-1 flex w-full flex-col",children:[jsx(He.Header,{children:jsxs("div",{className:"flex w-full justify-between gap-2",children:[jsx(po,{}),jsx(br,{})]})}),jsx(ir,{className:"-mb-1"}),jsx(Co,{}),jsx(He.Footer,{className:"pt-6 pb-10"})]}),jsx(He.Overlays,{})]})]}))})}function Di(o){var r=o,{open:e,onClose:t}=r,a$1=c(r,["open","onClose"]);return jsx(He.Modal,b(a({},a$1),{onClose:t,children:jsx(Fe,{open:e,onOpenChange:t,children:jsx(Pi,{onClose:t})})}))}function Pi({onClose:e}){let{updateSearchQuery:t}=E(),[a,o]=useState(false),[r,n]=useState(""),s=useRef(null),m=go(r,300);return useEffect(()=>{t(m);},[m,t]),useEffect(()=>{a&&s.current&&s.current.focus();},[a]),jsxs(we,{className:"p-0",variant:"fullscreen",showCloseButton:false,children:[jsxs(Le,{className:"pt-5 pb-3 m-0 border-b border-border",children:[jsx(Ne,{className:"px-6 text-base",children:jsx("div",{className:"flex w-full justify-between gap-2",children:a?jsxs("div",{className:"flex items-center gap-4 flex-1",children:[jsx(l,{className:"size-5 text-gray-500 shrink-0"}),jsx(Dt,{ref:s,type:"text",placeholder:"Search files and folders...",className:"border-none shadow-none focus-visible:ring-0 h-auto p-0 text-base font-semibold",value:r,onChange:l=>n(l.target.value),onKeyDown:l=>{l.key==="Escape"&&(n(""),t(""),o(false));}}),jsx(xe,{onClick:()=>{n(""),t(""),o(false);},className:"shrink-0",label:"Cancel Search"})]}):jsxs(Fragment,{children:[jsx(po,{}),jsx(hr,{onSearchClick:()=>o(true)}),jsx(xe,{onClick:e})]})})}),jsx(Je,{className:"sr-only",children:"Browse and select files from your media library"})]}),jsxs("div",{className:"overflow-y-auto flex-1 pb-4",children:[jsx(Co,{}),jsx(He.Footer,{className:"my-4"}),jsx(He.Overlays,{})]}),jsx(Ii,{onClose:e})]})}function Ii({onClose:e}){let{selectedFiles:t,onFilesSelected:a,setSelectedFiles:o,setSelectedFolders:r,updateSearchQuery:n,handlePageChange:s}=E();return jsxs(_e,{className:"px-6 py-4 border-t border-border w-full sm:justify-between justify-center items-center flex-col sm:flex-row gap-2",children:[jsx(nr,{}),jsx(Ge,{asChild:true,children:jsx(y,{type:"button",variant:"outline",onClick:e,radius:"full",className:"w-full md:w-auto mr-0",children:"Cancel"})}),jsxs(y,{type:"button",onClick:()=>{a&&t.length>0&&(a(t),o([]),r([]),n(""),s(1),e());},disabled:t.length===0,radius:"full",className:"w-full md:w-auto",children:["Select ",t.length>0?`(${t.length})`:""]})]})}export{Mi as FileManager,Di as FileManagerModal,no as FileManagerProvider,E as useFileManager};
|