1import{h as f,j as e,F as _,I as R,O as K,X as Q,t as me,b as he,r as l,K as x,B as I,Q as ue,V as pe,w as ge,m as fe,G as je}from"./index-BSEGU3Pg.js";import{T as q}from"./trash-2-xDUukxB8.js";import{L as G}from"./lock-BICjSpnZ.js";import{C}from"./cloud-DMaWoDg1.js";import{L as be}from"./list-CV9u4s-e.js";import{R as Ne}from"./refresh-cw-KfklUMn_.js";/** 2 * @license lucide-react v0.562.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ye=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Z=f("file",ye);/** 7 * @license lucide-react v0.562.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ve=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],we=f("folder-plus",ve);/** 12 * @license lucide-react v0.562.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ke=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],H=f("folder",ke);/** 17 * @license lucide-react v0.562.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const ze=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],F=f("upload",ze);function Ce({files:c,onDownload:d,onDelete:i,formatBytes:o}){const r=t=>{switch(t){case"video":return e.jsx(K,{size:24,className:"text-purple-400"});case"image":return e.jsx(R,{size:24,className:"text-blue-400"});default:return e.jsx(Z,{size:24,className:"text-gray-400"})}};return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",children:c.map(t=>e.jsxs("div",{className:"bg-dark-900 rounded-xl overflow-hidden border border-dark-700 hover:border-dark-600 transition-colors group",children:[e.jsxs("div",{className:"aspect-video bg-dark-800 flex items-center justify-center relative",children:[t.signed_url&&t.media_type==="image"?e.jsx("img",{src:t.signed_url,alt:t.original_name,className:"w-full h-full object-cover"}):r(t.media_type),e.jsxs("div",{className:"absolute inset-0 bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2",children:[e.jsx("button",{onClick:()=>d(t),className:"p-2 bg-white/20 rounded-lg hover:bg-white/30",children:e.jsx(_,{size:18,className:"text-white"})}),e.jsx("button",{onClick:()=>i(t.id),className:"p-2 bg-red-500/20 rounded-lg hover:bg-red-500/30",children:e.jsx(q,{size:18,className:"text-red-400"})})]})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("p",{className:"text-sm text-white truncate",title:t.original_name,children:t.original_name}),e.jsx("p",{className:"text-xs text-gray-500",children:o(t.file_size)})]})]},t.id))})}function Fe({files:c,onDownload:d,onDelete:i,formatBytes:o}){const r=t=>{switch(t){case"video":return e.jsx(K,{size:24,className:"text-purple-400"});case"image":return e.jsx(R,{size:24,className:"text-blue-400"});default:return e.jsx(Z,{size:24,className:"text-gray-400"})}};return e.jsx("div",{className:"bg-dark-900 rounded-xl border border-dark-700 overflow-hidden",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-dark-800",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-left p-3 text-xs text-gray-500 uppercase",children:"Name"}),e.jsx("th",{className:"text-left p-3 text-xs text-gray-500 uppercase",children:"Type"}),e.jsx("th",{className:"text-left p-3 text-xs text-gray-500 uppercase",children:"Size"}),e.jsx("th",{className:"text-left p-3 text-xs text-gray-500 uppercase",children:"Date"}),e.jsx("th",{className:"text-right p-3 text-xs text-gray-500 uppercase",children:"Actions"})]})}),e.jsx("tbody",{children:c.map(t=>e.jsxs("tr",{className:"border-t border-dark-700 hover:bg-dark-800",children:[e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[r(t.media_type),e.jsx("span",{className:"text-white truncate max-w-xs",children:t.original_name})]})}),e.jsx("td",{className:"p-3 text-gray-400 capitalize",children:t.media_type}),e.jsx("td",{className:"p-3 text-gray-400",children:o(t.file_size)}),e.jsx("td",{className:"p-3 text-gray-500 text-sm",children:new Date(t.created_at).toLocaleDateString()}),e.jsxs("td",{className:"p-3 text-right",children:[e.jsx("button",{onClick:()=>d(t),className:"p-2 text-gray-500 hover:text-white",children:e.jsx(_,{size:16})}),e.jsx("button",{onClick:()=>i(t.id),className:"p-2 text-gray-500 hover:text-red-400",children:e.jsx(q,{size:16})})]})]},t.id))})]})})}function _e({show:c,uploading:d,uploadProgress:i,onClose:o,onFileSelect:r}){return c?e.jsx("div",{className:"fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-dark-900 rounded-2xl max-w-lg w-full p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Upload Files"}),e.jsx("button",{onClick:o,className:"text-gray-500 hover:text-white",children:e.jsx(Q,{size:24})})]}),e.jsxs("div",{className:"border-2 border-dashed border-dark-600 rounded-xl p-8 text-center hover:border-primary-500 transition-colors cursor-pointer",onClick:()=>document.getElementById("file-input").click(),children:[e.jsx(F,{size:48,className:"mx-auto text-gray-500 mb-4"}),e.jsx("p",{className:"text-white mb-2",children:"Click to select files or drag & drop"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Max file size: 500MB"}),e.jsx("input",{id:"file-input",type:"file",multiple:!0,className:"hidden",onChange:t=>r(t.target.files)})]}),d&&e.jsxs("div",{className:"mt-4",children:[e.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[e.jsx("span",{className:"text-gray-400",children:"Uploading..."}),e.jsxs("span",{className:"text-primary-400",children:[i,"%"]})]}),e.jsx("div",{className:"h-2 bg-dark-700 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-primary-500 transition-all",style:{width:`${i}%`}})})]})]})}):null}function Se({show:c,folderName:d,onClose:i,onChange:o,onCreate:r}){return c?e.jsx("div",{className:"fixed inset-0 bg-black/80 z-50 flex items-center justify-center p-4",children:e.jsxs("div",{className:"bg-dark-900 rounded-2xl max-w-sm w-full p-6",children:[e.jsx("h2",{className:"text-xl font-bold text-white mb-4",children:"New Folder"}),e.jsx("input",{type:"text",value:d,onChange:t=>o(t.target.value),placeholder:"Folder name",className:"w-full bg-dark-800 border border-dark-700 rounded-lg py-2 px-4 text-white mb-4 focus:outline-none focus:border-primary-500",autoFocus:!0,onKeyPress:t=>{t.key==="Enter"&&r()}}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:i,className:"btn-secondary flex-1",children:"Cancel"}),e.jsx("button",{onClick:r,className:"btn-primary flex-1",children:"Create"})]})]})}):null}function Ve(){const c=me(),d=he(),[i,o]=l.useState(null),[r,t]=l.useState(null),[J,X]=l.useState([]),[W,Y]=l.useState([]),[ee,se]=l.useState(!0),[te,S]=l.useState(!1),[ae,M]=l.useState(0),[h,D]=l.useState("default"),[j,$]=l.useState("grid"),[b,re]=l.useState(""),[Me,De]=l.useState([]),[le,p]=l.useState(!1),[ie,N]=l.useState(!1),[y,U]=l.useState(""),[B,v]=l.useState(!1),[E,m]=l.useState(null);l.useEffect(()=>{ne()},[]),l.useEffect(()=>{i!=null&&i.is_premium&&(g(),L(),w())},[i,h]);const ne=async()=>{try{const s=await fetch(`${x}/vault/subscription`,{credentials:"include"}),a=await s.json();a.success?o(a.subscription):s.status===401&&c(d("/login?redirect=/vault"))}catch(s){console.error("Failed to fetch subscription:",s)}finally{se(!1)}},w=async()=>{try{const a=await(await fetch(`${x}/vault/usage`,{credentials:"include"})).json();a.success&&t(a.usage)}catch(s){console.error("Failed to fetch usage:",s)}},g=async()=>{try{const a=await(await fetch(`${x}/vault/files?folder=${h}`,{credentials:"include"})).json();a.success&&X(a.files)}catch(s){console.error("Failed to fetch files:",s)}},L=async()=>{try{const a=await(await fetch(`${x}/vault/folders`,{credentials:"include"})).json();a.success&&Y(a.folders)}catch(s){console.error("Failed to fetch folders:",s)}},P=async s=>{if(s!=null&&s.length){S(!0),M(0),m(null);for(let a=0;a<s.length;a++){const n=s[a],u=new FormData;u.append("file",n),u.append("folder",h);try{const T=await(await fetch(`${x}/vault/upload`,{method:"POST",credentials:"include",body:u})).json();T.success||m(T.error||"Upload failed"),M(Math.round((a+1)/s.length*100))}catch(O){m("Upload failed: "+O.message)}}S(!1),p(!1),g(),w()}},V=async s=>{if(confirm("Delete this file permanently?"))try{(await fetch(`${x}/vault/files/${s}`,{method:"DELETE",credentials:"include"})).ok&&(g(),w())}catch{m("Delete failed")}},A=async s=>{try{const n=await(await fetch(`${x}/vault/files/${s.id}/download`,{credentials:"include"})).json();n.success&&window.open(n.download_url,"_blank")}catch{m("Download failed")}}
21,ce=async()=>{if(y.trim())try{await fetch(`${x}/vault/folders`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y})}),U(""),N(!1),L()}catch{m("Failed to create folder")}},de=l.useCallback(s=>{var n;s.preventDefault(),v(!1);const a=(n=s.dataTransfer)==null?void 0:n.files;a!=null&&a.length&&P(a)},[h]),oe=s=>{s.preventDefault(),v(!0)},xe=()=>{v(!1)},k=J.filter(s=>{var a,n;return((a=s.original_name)==null?void 0:a.toLowerCase().includes(b.toLowerCase()))||((n=s.filename)==null?void 0:n.toLowerCase().includes(b.toLowerCase()))}),z=s=>{if(!s)return"0 B";const a=1024,n=["B","KB","MB","GB"],u=Math.floor(Math.log(s)/Math.log(a));return parseFloat((s/Math.pow(a,u)).toFixed(1))+" "+n[u]};return ee?e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary-500"})}):i!=null&&i.is_premium?e.jsxs("div",{onDrop:de,onDragOver:oe,onDragLeave:xe,className:`min-h-[80vh] ${B?"ring-2 ring-primary-500 ring-inset":""}`,children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[e.jsx(C,{className:"text-primary-500"}),"My Vault"]}),e.jsxs("p",{className:"text-gray-500 text-sm",children:[i.tier_info.name," Plan - ",(r==null?void 0:r.total_mb)||0," MB / ",(r==null?void 0:r.limit_mb)||0," MB used"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>p(!0),className:"btn-primary flex items-center gap-2",children:[e.jsx(F,{size:18}),"Upload"]}),e.jsxs("button",{onClick:()=>N(!0),className:"btn-secondary flex items-center gap-2",children:[e.jsx(we,{size:18}),"New Folder"]})]})]}),r&&e.jsxs("div",{className:"bg-dark-900 rounded-xl p-4 mb-6 border border-dark-700",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(pe,{size:18,className:"text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-300",children:"Storage"})]}),e.jsxs("span",{className:"text-sm text-gray-400",children:[r.percent_used,"% used"]})]}),e.jsx("div",{className:"h-2 bg-dark-700 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full transition-all ${r.percent_used>90?"bg-red-500":r.percent_used>70?"bg-yellow-500":"bg-primary-500"}`,style:{width:`${r.percent_used}%`}})}),e.jsxs("div",{className:"flex justify-between mt-2 text-xs text-gray-500",children:[e.jsxs("span",{children:[z(r.total_bytes)," used"]}),e.jsxs("span",{children:[r.remaining_mb," MB remaining"]})]})]}),E&&e.jsxs("div",{className:"bg-red-900/30 border border-red-700 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(ge,{className:"text-red-400"}),e.jsx("span",{className:"text-red-300",children:E}),e.jsx("button",{onClick:()=>m(null),className:"ml-auto text-red-400 hover:text-red-300",children:e.jsx(Q,{size:18})})]}),e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto pb-2",children:[e.jsxs("button",{onClick:()=>D("default"),className:`px-4 py-2 rounded-lg flex items-center gap-2 whitespace-nowrap ${h==="default"?"bg-primary-600 text-white":"bg-dark-800 text-gray-400 hover:text-white"}`,children:[e.jsx(H,{size:16}),"All Files"]}),W.map(s=>e.jsxs("button",{onClick:()=>D(s.folder),className:`px-4 py-2 rounded-lg flex items-center gap-2 whitespace-nowrap ${h===s.folder?"bg-primary-600 text-white":"bg-dark-800 text-gray-400 hover:text-white"}`,children:[e.jsx(H,{size:16}),s.folder,e.jsxs("span",{className:"text-xs opacity-70",children:["(",s.file_count,")"]})]},s.folder))]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs("div",{className:"relative",children:[e.jsx(fe,{size:18,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-500"}),e.jsx("input",{type:"text",value:b,onChange:s=>
21re(s.target.value),placeholder:"Search files...",className:"bg-dark-800 border border-dark-700 rounded-lg py-2 pl-10 pr-4 text-sm text-white w-48 focus:outline-none focus:border-primary-500"})]}),e.jsxs("div",{className:"flex bg-dark-800 rounded-lg p-1",children:[e.jsx("button",{onClick:()=>$("grid"),className:`p-2 rounded ${j==="grid"?"bg-dark-700 text-white":"text-gray-500"}`,children:e.jsx(je,{size:18})}),e.jsx("button",{onClick:()=>$("list"),className:`p-2 rounded ${j==="list"?"bg-dark-700 text-white":"text-gray-500"}`,children:e.jsx(be,{size:18})})]}),e.jsx("button",{onClick:g,className:"p-2 text-gray-500 hover:text-white",children:e.jsx(Ne,{size:18})})]})]}),B&&e.jsx("div",{className:"fixed inset-0 bg-black/80 z-50 flex items-center justify-center pointer-events-none",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{size:64,className:"mx-auto text-primary-500 mb-4"}),e.jsx("p",{className:"text-xl text-white",children:"Drop files to upload"})]})}),k.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(C,{size:64,className:"mx-auto text-gray-600 mb-4"}),e.jsx("h3",{className:"text-xl text-gray-400 mb-2",children:"No files yet"}),e.jsx("p",{className:"text-gray-600 mb-4",children:"Upload files or drag & drop them here"}),e.jsx("button",{onClick:()=>p(!0),className:"btn-primary",children:"Upload Files"})]}):j==="grid"?e.jsx(Ce,{files:k,onDownload:A,onDelete:V,formatBytes:z}):e.jsx(Fe,{files:k,onDownload:A,onDelete:V,formatBytes:z}),e.jsx(_e,{show:le,uploading:te,uploadProgress:ae,onClose:()=>p(!1),onFileSelect:P}),e.jsx(Se,{show:ie,folderName:y,onClose:()=>N(!1),onChange:U,onCreate:ce})]}):e.jsxs("div",{className:"max-w-2xl mx-auto text-center py-16",children:[e.jsx(I,{position:"top"}),e.jsxs("div",{className:"bg-gradient-to-br from-primary-900/30 to-dark-800 rounded-2xl p-8 border border-dark-700",children:[e.jsx(G,{size:64,className:"mx-auto text-primary-500 mb-6"}),e.jsx("h1",{className:"text-3xl font-bold text-white mb-4",children:"Premium Vault"}),e.jsx("p",{className:"text-gray-400 mb-6",children:"Store your favorite content securely in the cloud. Access from anywhere, anytime."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[e.jsxs("div",{className:"bg-dark-900 rounded-xl p-4",children:[e.jsx(C,{size:32,className:"mx-auto text-blue-400 mb-2"}),e.jsx("h3",{className:"font-semibold text-white",children:"Cloud Storage"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Up to 100GB"})]}),e.jsxs("div",{className:"bg-dark-900 rounded-xl p-4",children:[e.jsx(_,{size:32,className:"mx-auto text-green-400 mb-2"}),e.jsx("h3",{className:"font-semibold text-white",children:"Rip & Save"}),e.jsx("p",{className:"text-sm text-gray-500",children:"From any site"})]}),e.jsxs("div",{className:"bg-dark-900 rounded-xl p-4",children:[e.jsx(G,{size:32,className:"mx-auto text-purple-400 mb-2"}),e.jsx("h3",{className:"font-semibold text-white",children:"Private"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Encrypted storage"})]})]}),e.jsxs("button",{onClick:()=>c(d("/subscription")),className:"btn-primary px-8 py-3 text-lg flex items-center gap-2 mx-auto",children:[e.jsx(ue,{size:20}),"Upgrade to Premium"]}),e.jsx("p",{className:"text-sm text-gray-500 mt-4",children:"Starting at $4.99/month"})]}),e.jsx(I,{position:"bottom"})]})}export{Ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.