Files
COSMOS/templates/oortconsole.html
T

5188 lines
637 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cosmos Storage — Console</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@1&family=JetBrains+Mono:wght@300;400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
<style>
/* ═══════════════════════════════════════════════════════════════════
UNITY STORAGE — PREMIUM DARK DESIGN SYSTEM (Enterprise Ultimate)
Reference: CRE Innovations Premium Design System (Dark Mode)
═══════════════════════════════════════════════════════════════════ */
:root {
/* ── Classy & Techy Dark Theme Scale ── */
--cream-0: #000000; /* Pitch black for OLED */
--cream-1: rgba(255, 255, 255, 0.02); /* Ultra subtle glass for cards */
--cream-2: rgba(255, 255, 255, 0.04); /* Hover state for cards */
--cream-3: rgba(255, 255, 255, 0.08); /* Borders / subtle lines */
--cream-4: rgba(255, 255, 255, 0.15); /* Distinct borders / hover states */
/* ── Deep Tech Light Text Scale ── */
--ink-0: #ffffff; /* Pure white headings */
--ink-1: #ffffff; /* Pure white body */
--ink-2: #fafafa; /* Extremely bright silver for secondary text */
--ink-3: #e4e4e7; /* Very visible muted text */
--ink-4: #a1a1aa; /* Disabled / bottom bar */
/* ── Accent Colors ── */
--accent-cyan: #06b6d4;
--accent-blue: #3b82f6;
--accent-violet: #8b5cf6;
--accent-emerald: #10b981;
--accent-indigo: #6366f1;
--violet-light: #8B5CF6;
--violet-mid: #a78bfa;
/* ── iOS Liquid Glass Dark Mode Surfaces ── */
--surface-0: rgba(25, 25, 30, 0.80);
--surface-1: rgba(18, 18, 22, 0.70);
--surface-sm: rgba(18, 18, 22, 0.60);
--border-strong: rgba(255, 255, 255, 0.15);
/* ── Card Token System (dark) ── */
--card-border: rgba(255, 255, 255, 0.10);
--card-border-top: rgba(255, 255, 255, 0.18);
--card-border-left: rgba(255, 255, 255, 0.12);
--card-shadow: 0 8px 32px rgba(0,0,0,0.40), 0 1px 0 rgba(255,255,255,0.08) inset;
--card-shadow-hover: 0 16px 48px rgba(0,0,0,0.55), 0 1px 0 rgba(255,255,255,0.12) inset;
/* ── Layout Mapping for Existing App ── */
--bg: var(--cream-0);
--bg2: var(--cream-1);
--surface: var(--surface-0);
--surface2: var(--surface-1);
--surface3: rgba(255, 255, 255, 0.08);
--border: var(--cream-3);
--border2: var(--cream-4);
--text: var(--ink-0);
--text2: var(--ink-2);
--text3: var(--ink-4);
--accent: var(--violet-light);
--blue: var(--accent-blue);
--blue2: #60a5fa;
--indigo: #818cf8;
--green: #10b981;
--red: #f87171;
--amber: #fbbf24;
--cyan: #22d3ee;
--sidebar: 260px;
--topbar: 70px;
--radius: 12px;
--radius2: 20px;
}
* { box-sizing:border-box; margin:0; padding:0; -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing: grayscale; }
html, body { height:100%; overflow:hidden; }
body {
background-color: var(--bg);
color: var(--text);
font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
font-size: 15px;
line-height: 1.65;
position: relative;
}
/* NOISE TEXTURE BACKGROUND (From CRE Innovations) */
body::after {
content: '';
position: absolute;
inset: -200%;
width: 400%;
height: 400%;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
pointer-events: none;
animation: grain 8s steps(10) infinite;
opacity: 0.45;
z-index: -1;
}
@keyframes grain {
0%,100% { transform: translate(0,0); }
10% { transform: translate(-5%,-10%); }
30% { transform: translate(3%,-15%); }
50% { transform: translate(12%,9%); }
70% { transform: translate(9%,4%); }
90% { transform: translate(-1%,7%); }
}
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--cream-4); border-radius:10px; }
::-webkit-scrollbar-thumb:hover { background:var(--ink-4); }
button,input,select,textarea { font-family:inherit; font-size:inherit; color:inherit; }
a { text-decoration:none; color:inherit; }
h1, h2, h3, .page-title { font-weight: 800; letter-spacing: -0.035em; color: var(--ink-0); }
/* ─── ANIMATIONS ─── */
@keyframes fade-in-up {
from { opacity: 0; transform: translateY(28px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-ring {
0% { box-shadow: 0 0 0 0 rgba(139,92,246,0.45); transform: scale(1); }
70% { box-shadow: 0 0 0 7px rgba(139,92,246,0); transform: scale(1.15); }
100% { box-shadow: 0 0 0 0 rgba(139,92,246,0); transform: scale(1); }
}
@keyframes gradient-border-flow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
.g-text {
background: linear-gradient(135deg, var(--accent-blue) 0%, var(--accent-violet) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* ═══════════════════════════════════════════════════════════════════
LAYOUT COMPONENTS
═══════════════════════════════════════════════════════════════════ */
.layout { display:flex; height:100vh; overflow:hidden; position: relative; z-index: 1; }
.sidebar {
width:var(--sidebar); min-width:var(--sidebar);
background: rgba(18, 18, 22, 0.4);
backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
border-right: 1px solid var(--card-border);
box-shadow: 1px 0 20px rgba(0,0,0,0.5);
display:flex; flex-direction:column;
height:100vh; overflow:hidden; flex-shrink:0;
z-index: 10;
}
.sidebar-logo {
height:var(--topbar); min-height:var(--topbar);
display:flex; align-items:center; gap:14px;
padding:0 24px; border-bottom:1px solid var(--border);
font-weight:800; font-size:18px; letter-spacing:-0.5px;
color: var(--ink-0);
}
.logo-icon {
width:36px; height:36px; border-radius:10px;
background: linear-gradient(135deg, var(--accent-blue), var(--accent-violet));
display:flex; align-items:center; justify-content:center; flex-shrink:0;
box-shadow: 0 8px 20px rgba(139, 92, 246, 0.25), inset 0 1px 1px rgba(255,255,255,0.2);
color:white;
}
.sidebar-body { flex:1; overflow-y:auto; padding:20px 16px; }
.sidebar-section { margin-bottom:24px; }
.sidebar-section-label {
font-size:11px; font-weight:800;
text-transform:uppercase; letter-spacing:0.15em;
color:var(--text3); padding:8px 12px;
}
.nav-item, .nav-bucket {
display:flex; align-items:center; gap:12px;
padding:10px 14px; border-radius:10px;
cursor:pointer; color:var(--text2);
font-size:14.5px; font-weight:600;
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
user-select:none; margin-bottom: 4px;
}
.nav-item:hover, .nav-bucket:hover {
background: var(--cream-2); color: var(--ink-0);
transform: translateX(4px);
}
.nav-item.active, .nav-bucket.active {
background: rgba(139, 92, 246, 0.15);
color: var(--accent); font-weight:700;
box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item svg { width:18px; height:18px; flex-shrink:0; opacity: 0.8; transition:0.2s;}
.nav-item.active svg { opacity:1; }
.nav-bucket-icon {
width:24px; height:24px; border-radius:8px;
background: rgba(255,255,255,0.06); color:var(--text2);
display:flex; align-items:center; justify-content:center; flex-shrink:0;
border: 1px solid var(--card-border);
}
.nav-bucket.active .nav-bucket-icon {
background: linear-gradient(135deg, var(--accent), var(--blue));
color:white; box-shadow: 0 4px 10px rgba(139,92,246,0.3);
border: none;
}
.nav-bucket-name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar-create-bucket {
display:flex; align-items:center; gap:12px;
padding:10px 14px; border-radius:10px;
cursor:pointer; color:var(--text3); font-size:13.5px; font-weight:600;
transition:all 0.2s; border: 1px dashed var(--cream-4);
margin-top: 12px; background: rgba(255,255,255,0.02);
}
.sidebar-create-bucket:hover {
color: var(--accent); background: rgba(139, 92, 246, 0.08);
border-color: rgba(139, 92, 246, 0.4);
}
.sidebar-user {
border-top:1px solid var(--border); padding:16px;
cursor:pointer; background: rgba(0,0,0,0.2);
}
.sidebar-user-card {
display:flex; align-items:center; gap:12px;
padding:12px; border-radius:12px;
transition:all 0.2s;
}
.sidebar-user-card:hover { background: var(--cream-2); }
.user-avatar {
width:40px; height:40px; border-radius:10px;
background: linear-gradient(135deg, var(--blue), var(--indigo));
display:flex; align-items:center; justify-content:center;
font-weight:700; font-size:16px; flex-shrink:0; color:white;
}
.user-name { font-weight:700; font-size:14.5px; color:var(--ink-0); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role { font-size:12.5px; color:var(--text3); margin-top:2px; font-weight:500; }
.main { flex:1; display:flex; flex-direction:column; height:100vh; overflow:hidden; min-width:0; position:relative; z-index:1; }
.topbar {
height:var(--topbar); min-height:var(--topbar);
background: rgba(18, 18, 22, 0.4);
backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
border-bottom:1px solid var(--card-border);
display:flex; align-items:center; padding:0 36px; gap:16px;
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
z-index: 50;
}
.breadcrumb { display:flex; align-items:center; gap:8px; flex:1; min-width:0; }
.bc-item { color:var(--text2); font-size:14.5px; font-weight:600; cursor:pointer; transition:0.2s; }
.bc-item:hover { color:var(--ink-0); }
.bc-item.active { color:var(--ink-0); font-weight:700; cursor:default; pointer-events:none; }
.bc-sep { color:var(--text3); font-size:13px; margin:0 4px; }
.topbar-actions { display:flex; align-items:center; gap:12px; flex-shrink:0; }
.content { flex:1; overflow-y:auto; padding:0; }
.view { display:none; }
.view.active { display:flex; flex-direction:column; height:100%; animation: fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
/* ═══════════════════════════════════════════════════════════════════
BUTTONS
═══════════════════════════════════════════════════════════════════ */
.btn {
display:inline-flex; align-items:center; justify-content:center; gap:8px;
padding:10px 20px; border-radius:999px; /* Pill */
font-size:14px; font-weight:700; cursor:pointer;
border:none; transition:transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s;
white-space:nowrap; letter-spacing:0.02em; position:relative; overflow:hidden;
}
.btn svg { width:18px; height:18px; flex-shrink:0; }
.btn-sm { padding:8px 16px; font-size:13px; }
.btn-primary {
background: linear-gradient(145deg, #7c3aed 0%, #4f46e5 100%);
color: #fff;
box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 4px 16px rgba(109,40,217,0.3);
}
.btn-primary::after {
content: ''; position: absolute; inset: 0;
background: linear-gradient(to bottom, rgba(255,255,255,0.1) 0%, transparent 60%);
border-radius: inherit; pointer-events: none;
}
.btn-primary:hover {
transform: translateY(-2px) scale(1.02);
box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 8px 24px rgba(109,40,217,0.5);
}
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
background: rgba(255, 255, 255, 0.05);
backdrop-filter: blur(20px);
color: var(--ink-0);
border: 1px solid rgba(255, 255, 255, 0.1);
}
.btn-ghost:hover {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.2);
transform: translateY(-1px);
}
.btn-danger {
background: rgba(239, 68, 68, 0.1); color: var(--red);
border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: var(--red); color: white; box-shadow: 0 4px 16px rgba(239,68,68,0.3); }
.btn:disabled { opacity:0.5; cursor:not-allowed; transform:none !important; box-shadow:none !important; }
/* ═══════════════════════════════════════════════════════════════════
DASHBOARD
═══════════════════════════════════════════════════════════════════ */
.page-header { padding:40px 40px 10px; }
.page-title { font-size:32px; font-weight:800; margin-bottom:6px; letter-spacing:-0.035em; }
.page-subtitle { color:var(--text2); font-size:15px; font-weight:500; }
.stats-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:24px; padding:24px 40px; }
.stat-card {
background: var(--surface-1);
backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
border: 1px solid var(--card-border);
border-top-color: var(--card-border-top);
border-left-color: var(--card-border-left);
border-radius: var(--radius2); padding:28px;
box-shadow: var(--card-shadow);
transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1);
position:relative; overflow:hidden;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow-hover); }
.stat-card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.stat-card-label { font-size:12px; color:var(--text2); font-weight:800; text-transform:uppercase; letter-spacing:0.12em; }
.stat-card-icon { width:44px; height:44px; border-radius:12px; display:flex; align-items:center; justify-content:center; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.stat-card-icon svg { width:20px; height:20px; }
.stat-card-value { font-size:36px; font-weight:800; letter-spacing:-0.035em; margin-bottom:4px; color:var(--ink-0); }
.stat-card-meta { font-size:14px; color:var(--text3); font-weight:500; }
.charts-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(320px, 1fr)); gap:24px; padding:0 40px 40px; }
.chart-card {
background: var(--surface-1);
backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--card-border);
border-top-color: var(--card-border-top); border-left-color: var(--card-border-left);
border-radius: var(--radius2); padding:32px; box-shadow: var(--card-shadow);
}
.chart-card-header { margin-bottom:24px; }
.chart-card-title { font-size:20px; font-weight:800; margin-bottom:4px; color:var(--ink-0); letter-spacing:-0.035em; }
.chart-card-sub { font-size:14px; color:var(--text2); }
.chart-wrap { position:relative; height:240px; }
.quota-bar-wrap { margin-top:20px; }
.quota-label { display:flex; justify-content:space-between; font-size:14px; font-weight:600; color:var(--text2); margin-bottom:10px; }
.quota-track { height:8px; background:rgba(255,255,255,0.05); border-radius:4px; overflow:hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.2); }
.quota-fill { height:100%; border-radius:4px; background:linear-gradient(90deg,var(--blue),var(--accent)); transition:width 0.6s cubic-bezier(0.16, 1, 0.3, 1); box-shadow: 0 0 12px rgba(139,92,246,0.4); }
.quota-fill.warning { background:linear-gradient(90deg,var(--amber),var(--red)); box-shadow: 0 0 12px rgba(239,68,68,0.4); }
/* ═══════════════════════════════════════════════════════════════════
FILE BROWSER
═══════════════════════════════════════════════════════════════════ */
.browser-header {
display:flex; align-items:center; justify-content:space-between;
padding:24px 40px; border-bottom:1px solid var(--border); flex-shrink:0;
}
#browser-title { font-size:22px; font-weight:800; letter-spacing:-0.035em; color:var(--ink-0); }
.empty-state {
display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%;
padding:80px 24px; text-align:center; color:var(--text2);
}
.empty-state-icon {
width:96px; height:96px; border-radius:28px;
background: var(--surface-1); border: 1px solid var(--card-border);
box-shadow: var(--card-shadow);
display:flex; align-items:center; justify-content:center; margin-bottom:24px;
}
.empty-state-icon svg { width:40px; height:40px; color:var(--text3); }
.empty-state h3 { font-size:24px; font-weight:800; color:var(--ink-0); margin-bottom:12px; letter-spacing:-0.035em; }
.file-table-wrap { flex:1; overflow-y:auto; padding:0 24px; margin-top: 16px; }
.file-table { width:100%; border-collapse:separate; border-spacing: 0 8px; }
.file-table th {
padding:12px 24px; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:0.12em;
color:var(--text3); text-align:left; position:sticky; top:0; z-index:1;
background: rgba(18,18,22,0.95); backdrop-filter: blur(10px);
}
.file-table td {
padding:16px 24px; vertical-align:middle; font-size:14.5px; font-weight:500;
background: var(--surface-1); border-top: 1px solid var(--card-border-top); border-bottom: 1px solid var(--card-border);
}
.file-table tbody tr td:first-child { border-left: 1px solid var(--card-border-left); border-top-left-radius: 16px; border-bottom-left-radius: 16px; }
.file-table tbody tr td:last-child { border-right: 1px solid var(--card-border); border-top-right-radius: 16px; border-bottom-right-radius: 16px; }
.file-table tbody tr {
transition:all 0.3s cubic-bezier(0.16, 1, 0.3, 1); cursor:pointer;
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.file-table tbody tr:hover { transform: translateY(-2px) scale(1.005); box-shadow: 0 12px 24px rgba(0,0,0,0.3); background: rgba(30,30,36,0.8); }
.file-row-name { display:flex; align-items:center; gap:16px; }
.file-icon { width:40px; height:40px; border-radius:10px; display:flex; align-items:center; justify-content:center; flex-shrink:0; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1); }
.file-icon.folder { color:var(--amber); }
.file-icon.doc { color:var(--blue); }
.file-icon.img { color:var(--green); }
.file-icon.vid { color:var(--red); }
.file-icon.arc { color:var(--accent); }
.file-icon svg { width:20px; height:20px; }
.file-name-text { font-weight:700; font-size:14.5px; color:var(--ink-0); }
.file-meta { font-size:13px; color:var(--text3); margin-top:2px; }
.row-actions { display:flex; align-items:center; gap:6px; justify-content:flex-end; opacity:0; transition:0.2s; }
.file-table tbody tr:hover .row-actions { opacity:1; }
.icon-btn {
width:36px; height:36px; border-radius:10px; background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1);
cursor:pointer; display:flex; align-items:center; justify-content:center; color:var(--text2); transition:all 0.2s;
}
.icon-btn:hover { background:var(--cream-4); color:var(--ink-0); transform:scale(1.05); box-shadow:0 4px 12px rgba(0,0,0,0.2); }
.icon-btn.danger:hover { background:var(--red); color:white; border-color:var(--red); }
/* ═══════════════════════════════════════════════════════════════════
PROFILE / CREDENTIALS VIEW
═══════════════════════════════════════════════════════════════════ */
.form-page { padding:36px 40px; max-width:800px; }
.profile-hero {
position: relative;
background: var(--surface-1); backdrop-filter: blur(20px);
border-radius: var(--radius2); padding:40px; display:flex; align-items:center; gap:32px; margin-bottom:32px;
box-shadow: 0 12px 48px rgba(109, 40, 217, 0.15);
}
.profile-hero::before {
content: ""; position: absolute; inset: -1.5px; border-radius: inherit; padding: 1.5px;
background: linear-gradient(135deg, #6d28d9 0%, #a21caf 33%, #b45309 66%, #0e7490 100%);
background-size: 300% 300%; animation: gradient-border-flow 8s ease infinite;
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; pointer-events: none;
}
.profile-hero-avatar {
width:100px; height:100px; border-radius:30px;
background: linear-gradient(135deg, var(--accent), var(--blue));
display:flex; align-items:center; justify-content:center; font-weight:800; font-size:36px; flex-shrink:0; color:white;
box-shadow: 0 16px 32px rgba(139,92,246,0.3); border:2px solid rgba(255,255,255,0.2);
}
.profile-hero-name { font-size:32px; font-weight:800; margin-bottom:6px; letter-spacing:-0.035em; color:var(--ink-0); }
.form-section {
background: var(--surface-1); backdrop-filter: blur(20px); border: 1px solid var(--card-border);
border-radius: var(--radius2); margin-bottom:24px; box-shadow: var(--card-shadow);
}
.form-section-header { padding:24px 32px; border-bottom:1px solid rgba(255,255,255,0.05); display:flex; align-items:center; justify-content:space-between; }
.form-section-title { font-size:18px; font-weight:800; color:var(--ink-0); letter-spacing:-0.035em; }
.form-section-subtitle { font-size:14px; color:var(--text2); margin-top:4px; }
.form-section-body { padding:32px; }
.form-row { margin-bottom:20px; }
.form-row:last-child { margin-bottom:0; }
.form-label { display:block; font-size:13px; font-weight:700; color:var(--ink-2); margin-bottom:8px; }
.form-control {
width:100%; background: rgba(0,0,0,0.2);
border: 1.5px solid rgba(255,255,255,0.1); color: var(--ink-0);
padding:14px 16px; border-radius:12px; font-size:14.5px; font-weight:500;
outline:none; transition:all 0.2s; box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}
.form-control:focus { border-color: var(--accent); background: rgba(0,0,0,0.4); box-shadow: 0 0 0 4px rgba(139,92,246,0.2); }
.form-control[readonly] { background:rgba(255,255,255,0.02); color:var(--text2); cursor:default; font-family:'SF Mono',Monaco,monospace; }
.cred-box {
background: rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.08);
border-radius: 12px; padding:16px 20px; font-family:'SF Mono',Monaco,monospace;
font-size:13.5px; color:var(--text2); display:flex; align-items:center; justify-content:space-between; gap:16px;
}
.cred-copy { background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1); color:var(--text); cursor:pointer; padding:8px; border-radius:8px; transition:0.2s; }
.cred-copy:hover { background:rgba(255,255,255,0.1); transform:translateY(-1px); }
.code-block {
background: #000; border-radius:12px; padding:24px; font-family:'SF Mono',Monaco,monospace;
font-size:13.5px; color:var(--cyan); line-height:1.7; overflow-x:auto; white-space:pre;
border: 1px solid rgba(255,255,255,0.1);
}
.badge { display:inline-flex; align-items:center; padding:6px 14px; border-radius:999px; font-size:12px; font-weight:700; letter-spacing:0.1em; text-transform:uppercase; }
.badge-blue { background:rgba(59,130,246,0.15); color:#60a5fa; border:1px solid rgba(59,130,246,0.3); }
.badge-green { background:rgba(16,185,129,0.15); color:#34d399; border:1px solid rgba(16,185,129,0.3); }
/* ═══════════════════════════════════════════════════════════════════
DRAWER & MODALS
═══════════════════════════════════════════════════════════════════ */
.modal-bg {
position:fixed; inset:0; background:rgba(0,0,0,0.8);
backdrop-filter:blur(12px); -webkit-backdrop-filter:blur(12px);
z-index:400; display:flex; align-items:center; justify-content:center;
opacity:0; pointer-events:none; transition:opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-bg.open { opacity:1; pointer-events:auto; }
.modal {
background: var(--surface-0); border: 1px solid var(--card-border);
backdrop-filter: blur(30px) saturate(200%); border-radius: 28px; padding:0; width:100%; max-width:480px;
transform:scale(0.95) translateY(20px); transition:all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
box-shadow: 0 40px 100px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.2); overflow:hidden;
}
.modal-bg.open .modal { transform:scale(1) translateY(0); }
.modal-header { padding:24px 32px; border-bottom:1px solid rgba(255,255,255,0.05); display:flex; align-items:center; justify-content:space-between; }
.modal-title { font-size:20px; font-weight:800; color:var(--ink-0); }
.modal-close { background:rgba(255,255,255,0.05); border:1px solid rgba(255,255,255,0.1); cursor:pointer; width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; color:white; transition:0.2s; }
.modal-close:hover { background:rgba(255,255,255,0.1); transform:scale(1.05); }
.modal-body { padding:32px; }
.modal-body p { font-size:15px; color:var(--text2); margin-bottom:24px; line-height:1.6; }
.modal-footer { padding:24px 32px; background:rgba(0,0,0,0.2); border-top:1px solid rgba(255,255,255,0.05); display:flex; justify-content:flex-end; gap:16px; }
/* ═══════════════════════════════════════════════════════════════════
TOASTS & TOGGLE
═══════════════════════════════════════════════════════════════════ */
.toast-stack { position:fixed; bottom:40px; left:50%; transform:translateX(-50%); z-index:1000; display:flex; flex-direction:column-reverse; gap:16px; align-items:center; pointer-events:none; }
.toast {
background: rgba(20,20,25,0.95); border: 1px solid rgba(255,255,255,0.15);
backdrop-filter: blur(20px);
color: white; padding:16px 24px; border-radius:20px;
font-size:14.5px; font-weight:700; display:flex; align-items:center; gap:14px;
box-shadow: 0 20px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
animation:toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes toastIn { from { opacity:0; transform:translateY(30px) scale(0.95); } to { opacity:1; transform:none; } }
#mode-toggle:checked + .slider { background: linear-gradient(135deg, var(--accent), var(--blue)) !important; }
#mode-toggle:checked + .slider .slider-dot { transform: translateX(20px); }
.slider { border-radius:34px; background: rgba(255,255,255,0.1); box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); }
.slider-dot { box-shadow: 0 2px 4px rgba(0,0,0,0.4); background: white; }
.drive-item { display:flex; align-items:center; padding:16px 24px; border-radius:20px; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); cursor:pointer; margin-bottom:12px; border: 1px solid var(--card-border); background:var(--surface-1); box-shadow: var(--card-shadow); }
.drive-item:hover { background:rgba(30,30,36,0.8); transform:translateY(-2px); box-shadow: var(--card-shadow-hover); }
.drive-item-icon { display:flex; align-items:center; justify-content:center; background:rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); padding:14px; border-radius:14px; color:var(--amber); margin-right:20px; }
@media (max-width:800px) {
.layout { flex-direction: column; }
.sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; }
.sidebar-logo { border-bottom: none; }
.sidebar-body { display: flex; flex-direction: row; overflow-x: auto; white-space: nowrap; padding: 0 16px; gap: 12px; align-items: center; }
.sidebar-section { margin-bottom: 0; display: flex; flex-direction: row; gap: 8px; align-items: center; }
.sidebar-section-label { display: none; }
.topbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 60px; justify-content: center; gap: 12px; border-top: 1px solid var(--border); }
.content-header { flex-direction: column; align-items: flex-start; gap: 12px; }
.data-grid { grid-template-columns: 1fr; }
.object-row { flex-wrap: wrap; gap: 8px; }
.object-name-col { flex: 1 1 100%; }
}
@media (max-width:800px) {
.file-table thead { display: none; }
.file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
.file-table tr { margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.file-table td { text-align: left; padding: 4px 12px; position: relative; }
.file-table td:nth-child(2)::before { content: "Size: "; font-weight: bold; }
.file-table td:nth-child(4)::before { content: "Modified: "; font-weight: bold; }
.grid { display: flex !important; flex-direction: column !important; }
}
@media (max-width:800px) {
.drive-item { flex-wrap: wrap; }
.drive-item > div:nth-child(2), .drive-item > div:nth-child(3) { display: none; }
.drive-item > div:first-child { flex: 1 1 100%; }
div[style*="text-transform:uppercase"] { display: none !important; }
}
/* ─── ANALYTICS RESPONSIVE ─── */
@media (max-width: 768px) {
.mobile-pad { padding: 0 16px 24px !important; }
.stats-grid { grid-template-columns: 1fr !important; }
#analytics-kpi { grid-template-columns: 1fr 1fr !important; padding: 0 16px 24px !important; }
.chart-card.globe-card { flex-direction: column !important; min-height: auto !important; }
.chart-card.globe-card > div:first-child { width: 100% !important; border-right: none !important; border-bottom: 1px solid rgba(255,255,255,0.05); }
canvas#globeCanvas { width: 100% !important; height: auto !important; }
.globe-card { flex-direction: column !important; }
.globe-card > div:first-child { width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border); height: 160px; }
#analytics-kpi { grid-template-columns: repeat(2, 1fr) !important; padding: 16px !important; }
#analytics-globe-row { grid-template-columns: 1fr !important; padding: 0 16px 24px !important; }
#globeCanvas { width: 100% !important; height: auto !important; max-width: 280px; }
.stats-grid { grid-template-columns: repeat(2, 1fr) !important; padding: 16px !important; }
#analytics-kpi { grid-template-columns: repeat(2, 1fr) !important; padding: 16px !important; }
#analytics-globe-row { grid-template-columns: 1fr !important; padding: 0 16px 24px !important; }
#globeCanvas { width: 220px !important; height: 220px !important; }
.stats-grid { grid-template-columns: repeat(2, 1fr) !important; padding: 16px !important; }
.charts-grid { grid-template-columns: 1fr !important; padding: 0 16px 24px !important; }
.page-header { padding: 20px 16px 10px !important; }
.browser-header { padding: 16px !important; }
.file-table-wrap { padding: 0 12px !important; }
.form-page { padding: 16px !important; }
.form-section-body { padding: 16px !important; }
.form-section-header { padding: 16px !important; }
.topbar { padding: 0 12px !important; gap: 8px !important; }
.topbar-actions { gap: 6px !important; }
.topbar-actions > div > button { padding: 6px 10px !important; font-size: 11px !important; }
.profile-hero { flex-direction: column !important; align-items: center !important; padding: 24px 16px !important; }
}
@media (max-width: 480px) {
#analytics-kpi { grid-template-columns: 1fr !important; }
.stats-grid { grid-template-columns: 1fr !important; }
.stat-card-value { font-size: 28px !important; }
}
input[type="datetime-local"], input[type="date"] {
color-scheme: dark;
}
.globe-card { flex-direction: row; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #6366f1; }
input:checked + .slider:before { transform: translateX(16px); }
</style>
<style>
.drive-item { display:flex; align-items:center; padding:12px 16px; border-radius:12px; transition: all 0.2s; cursor:pointer; margin-bottom:4px; border: 1px solid transparent; background:var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.drive-item:hover { background:var(--surface2); border-color:var(--border2); transform:translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.drive-item-icon { display:flex; align-items:center; justify-content:center; background:var(--surface2); padding:10px; border-radius:10px; color:var(--accent); margin-right:16px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.drive-item-icon.folder { background:rgba(245, 158, 11, 0.15); color:#d97706; }
.btn-icon { background:none; border:none; color:var(--text3); cursor:pointer; padding:8px; border-radius:8px; transition:0.2s; display:flex; align-items:center; justify-content:center; width:32px; height:32px; }
.btn-icon:hover { background:var(--surface3); color:var(--text); }
.btn-icon.danger:hover { background:rgba(239,68,68,0.1); color:var(--red); }
/* ─── REFINED BROWSER TOOLBAR & CATEGORY PILLS ─── */
.browser-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
padding: 12px 32px;
background: rgba(15, 23, 42, 0.45);
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
backdrop-filter: blur(12px);
margin-bottom: 8px;
}
.browser-search-box {
position: relative;
width: 300px;
max-width: 100%;
}
.browser-search-box input {
width: 100%;
height: 36px;
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 999px;
padding: 0 32px 0 36px;
font-size: 12.5px;
color: #fff;
outline: none;
transition: all 0.2s ease;
}
.browser-search-box input:focus {
background: rgba(255, 255, 255, 0.07);
border-color: rgba(56, 189, 248, 0.5);
box-shadow: 0 0 16px rgba(56, 189, 248, 0.2);
}
.browser-search-box .search-icon {
position: absolute;
left: 12px;
top: 11px;
color: var(--text3);
pointer-events: none;
}
.btn-clear-search {
position: absolute;
right: 10px;
top: 9px;
background: rgba(255, 255, 255, 0.1);
border: none;
color: var(--text2);
width: 18px;
height: 18px;
border-radius: 50%;
cursor: pointer;
font-size: 10px;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.btn-clear-search:hover {
background: rgba(239, 68, 68, 0.3);
color: #f87171;
}
.category-filter-segmented {
display: flex;
align-items: center;
gap: 4px;
background: rgba(0, 0, 0, 0.3);
border: 1px solid rgba(255, 255, 255, 0.07);
border-radius: 999px;
padding: 3px 4px;
flex-wrap: wrap;
}
.cat-pill {
display: flex;
align-items: center;
gap: 6px;
background: transparent;
border: 1px solid transparent;
color: var(--text3);
padding: 5px 12px;
border-radius: 999px;
font-size: 11.5px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
user-select: none;
}
.cat-pill:hover {
background: rgba(255, 255, 255, 0.06);
color: var(--text);
}
.cat-pill.active {
background: rgba(56, 189, 248, 0.16);
color: #38bdf8;
border-color: rgba(56, 189, 248, 0.35);
box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}
.cat-pill-dot {
width: 6px;
height: 6px;
border-radius: 50%;
display: inline-block;
}
.dot-all { background: #94a3b8; }
.dot-images { background: #38bdf8; box-shadow: 0 0 6px rgba(56,189,248,0.5); }
.dot-media { background: #a855f7; box-shadow: 0 0 6px rgba(168,85,247,0.5); }
.dot-docs { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.dot-code { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.dot-archives { background: #6366f1; box-shadow: 0 0 6px rgba(99,102,241,0.5); }
@media (max-width: 800px) {
.browser-toolbar {
padding: 10px 16px;
flex-direction: column;
align-items: stretch;
}
.browser-search-box {
width: 100%;
}
.category-filter-segmented {
overflow-x: auto;
white-space: nowrap;
padding: 3px;
scrollbar-width: none;
}
.category-filter-segmented::-webkit-scrollbar {
display: none;
}
}
@media (max-width:800px) {
.layout { flex-direction: column; }
.sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; }
.sidebar-logo { border-bottom: none; }
.sidebar-body { display: flex; flex-direction: row; overflow-x: auto; white-space: nowrap; padding: 0 16px; gap: 12px; align-items: center; }
.sidebar-section { margin-bottom: 0; display: flex; flex-direction: row; gap: 8px; align-items: center; }
.sidebar-section-label { display: none; }
.topbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 60px; justify-content: center; gap: 12px; border-top: 1px solid var(--border); }
.content-header { flex-direction: column; align-items: flex-start; gap: 12px; }
.data-grid { grid-template-columns: 1fr; }
.object-row { flex-wrap: wrap; gap: 8px; }
.object-name-col { flex: 1 1 100%; }
}
@media (max-width:800px) {
.file-table thead { display: none; }
.file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
.file-table tr { margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.file-table td { text-align: left; padding: 4px 12px; position: relative; }
.file-table td:nth-child(2)::before { content: "Size: "; font-weight: bold; }
.file-table td:nth-child(4)::before { content: "Modified: "; font-weight: bold; }
.grid { display: flex !important; flex-direction: column !important; }
}
@media (max-width:800px) {
.drive-item { flex-wrap: wrap; }
.drive-item > div:nth-child(2), .drive-item > div:nth-child(3) { display: none; }
.drive-item > div:first-child { flex: 1 1 100%; }
div[style*="text-transform:uppercase"] { display: none !important; }
}
input[type="datetime-local"], input[type="date"] {
color-scheme: dark;
}
.globe-card { flex-direction: row; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #6366f1; }
input:checked + .slider:before { transform: translateX(16px); }
</style>
<script>
// https://d3js.org v7.9.0 Copyright 2010-2023 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function n(t,n){return null==t||null==n?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function e(t,n){return null==t||null==n?NaN:n<t?-1:n>t?1:n>=t?0:NaN}function r(t){let r,o,a;function u(t,n,e=0,i=t.length){if(e<i){if(0!==r(n,n))return i;do{const r=e+i>>>1;o(t[r],n)<0?e=r+1:i=r}while(e<i)}return e}return 2!==t.length?(r=n,o=(e,r)=>n(t(e),r),a=(n,e)=>t(n)-e):(r=t===n||t===e?t:i,o=t,a=t),{left:u,center:function(t,n,e=0,r=t.length){const i=u(t,n,e,r-1);return i>e&&a(t[i-1],n)>-a(t[i],n)?i-1:i},right:function(t,n,e=0,i=t.length){if(e<i){if(0!==r(n,n))return i;do{const r=e+i>>>1;o(t[r],n)<=0?e=r+1:i=r}while(e<i)}return e}}}function i(){return 0}function o(t){return null===t?NaN:+t}const a=r(n),u=a.right,c=a.left,f=r(o).center;var s=u;const l=d(y),h=d((function(t){const n=y(t);return(t,e,r,i,o)=>{n(t,e,(r<<=2)+0,(i<<=2)+0,o<<=2),n(t,e,r+1,i+1,o),n(t,e,r+2,i+2,o),n(t,e,r+3,i+3,o)}}));function d(t){return function(n,e,r=e){if(!((e=+e)>=0))throw new RangeError("invalid rx");if(!((r=+r)>=0))throw new RangeError("invalid ry");let{data:i,width:o,height:a}=n;if(!((o=Math.floor(o))>=0))throw new RangeError("invalid width");if(!((a=Math.floor(void 0!==a?a:i.length/o))>=0))throw new RangeError("invalid height");if(!o||!a||!e&&!r)return n;const u=e&&t(e),c=r&&t(r),f=i.slice();return u&&c?(p(u,f,i,o,a),p(u,i,f,o,a),p(u,f,i,o,a),g(c,i,f,o,a),g(c,f,i,o,a),g(c,i,f,o,a)):u?(p(u,i,f,o,a),p(u,f,i,o,a),p(u,i,f,o,a)):c&&(g(c,i,f,o,a),g(c,f,i,o,a),g(c,i,f,o,a)),n}}function p(t,n,e,r,i){for(let o=0,a=r*i;o<a;)t(n,e,o,o+=r,1)}function g(t,n,e,r,i){for(let o=0,a=r*i;o<r;++o)t(n,e,o,o+a,r)}function y(t){const n=Math.floor(t);if(n===t)return function(t){const n=2*t+1;return(e,r,i,o,a)=>{if(!((o-=a)>=i))return;let u=t*r[i];const c=a*t;for(let t=i,n=i+c;t<n;t+=a)u+=r[Math.min(o,t)];for(let t=i,f=o;t<=f;t+=a)u+=r[Math.min(o,t+c)],e[t]=u/n,u-=r[Math.max(i,t-c)]}}(t);const e=t-n,r=2*t+1;return(t,i,o,a,u)=>{if(!((a-=u)>=o))return;let c=n*i[o];const f=u*n,s=f+u;for(let t=o,n=o+f;t<n;t+=u)c+=i[Math.min(a,t)];for(let n=o,l=a;n<=l;n+=u)c+=i[Math.min(a,n+f)],t[n]=(c+e*(i[Math.max(o,n-s)]+i[Math.min(a,n+s)]))/r,c-=i[Math.max(o,n-f)]}}function v(t,n){let e=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&++e;else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(i=+i)>=i&&++e}return e}function _(t){return 0|t.length}function b(t){return!(t>0)}function m(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function x(t,n){let e,r=0,i=0,o=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(e=n-i,i+=e/++r,o+=e*(n-i));else{let a=-1;for(let u of t)null!=(u=n(u,++a,t))&&(u=+u)>=u&&(e=u-i,i+=e/++r,o+=e*(u-i))}if(r>1)return o/(r-1)}function w(t,n){const e=x(t,n);return e?Math.sqrt(e):e}function M(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r<n&&(r=n)));else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(void 0===e?o>=o&&(e=r=o):(e>o&&(e=o),r<o&&(r=o)))}return[e,r]}class T{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let e=0;for(let r=0;r<this._n&&r<32;r++){const i=n[r],o=t+i,a=Math.abs(t)<Math.abs(i)?t-(o-i):i-(o-t);a&&(n[e++]=a),t=o}return n[e]=t,this._n=e+1,this}valueOf(){const t=this._partials;let n,e,r,i=this._n,o=0;if(i>0){for(o=t[--i];i>0&&(n=o,e=t[--i],o=n+e,r=e-(o-n),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(e=2*r,n=o+e,e==n-o&&(o=n))}return o}}class InternMap extends Map{constructor(t,n=N){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[n,e]of t)this.set(n,e)}get(t){return super.get(A(this,t))}has(t){return super.has(A(this,t))}set(t,n){return super.set(S(this,t),n)}delete(t){return super.delete(E(this,t))}}class InternSet extends Set{constructor(t,n=N){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const n of t)this.add(n)}has(t){return super.has(A(
</script>
<script>
// https://github.com/topojson/topojson-client v3.1.0 Copyright 2019 Mike Bostock
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).topojson=e.topojson||{})}(this,function(e){"use strict";function t(e){return e}function r(e){if(null==e)return t;var r,n,o=e.scale[0],a=e.scale[1],i=e.translate[0],c=e.translate[1];return function(e,t){t||(r=n=0);var u=2,f=e.length,s=new Array(f);for(s[0]=(r+=e[0])*o+i,s[1]=(n+=e[1])*a+c;u<f;)s[u]=e[u],++u;return s}}function n(e){var t,n=r(e.transform),o=1/0,a=o,i=-o,c=-o;function u(e){(e=n(e))[0]<o&&(o=e[0]),e[0]>i&&(i=e[0]),e[1]<a&&(a=e[1]),e[1]>c&&(c=e[1])}function f(e){switch(e.type){case"GeometryCollection":e.geometries.forEach(f);break;case"Point":u(e.coordinates);break;case"MultiPoint":e.coordinates.forEach(u)}}for(t in e.arcs.forEach(function(e){for(var t,r=-1,u=e.length;++r<u;)(t=n(e[r],r))[0]<o&&(o=t[0]),t[0]>i&&(i=t[0]),t[1]<a&&(a=t[1]),t[1]>c&&(c=t[1])}),e.objects)f(e.objects[t]);return[o,a,i,c]}function o(e,t){var r=t.id,n=t.bbox,o=null==t.properties?{}:t.properties,i=a(e,t);return null==r&&null==n?{type:"Feature",properties:o,geometry:i}:null==n?{type:"Feature",id:r,properties:o,geometry:i}:{type:"Feature",id:r,bbox:n,properties:o,geometry:i}}function a(e,t){var n=r(e.transform),o=e.arcs;function a(e,t){t.length&&t.pop();for(var r=o[e<0?~e:e],a=0,i=r.length;a<i;++a)t.push(n(r[a],a));e<0&&function(e,t){for(var r,n=e.length,o=n-t;o<--n;)r=e[o],e[o++]=e[n],e[n]=r}(t,i)}function i(e){return n(e)}function c(e){for(var t=[],r=0,n=e.length;r<n;++r)a(e[r],t);return t.length<2&&t.push(t[0]),t}function u(e){for(var t=c(e);t.length<4;)t.push(t[0]);return t}function f(e){return e.map(u)}return function e(t){var r,n=t.type;switch(n){case"GeometryCollection":return{type:n,geometries:t.geometries.map(e)};case"Point":r=i(t.coordinates);break;case"MultiPoint":r=t.coordinates.map(i);break;case"LineString":r=c(t.arcs);break;case"MultiLineString":r=t.arcs.map(c);break;case"Polygon":r=f(t.arcs);break;case"MultiPolygon":r=t.arcs.map(f);break;default:return null}return{type:n,coordinates:r}}(t)}function i(e,t){var r={},n={},o={},a=[],i=-1;function c(e,t){for(var n in e){var o=e[n];delete t[o.start],delete o.start,delete o.end,o.forEach(function(e){r[e<0?~e:e]=1}),a.push(o)}}return t.forEach(function(r,n){var o,a=e.arcs[r<0?~r:r];a.length<3&&!a[1][0]&&!a[1][1]&&(o=t[++i],t[i]=r,t[n]=o)}),t.forEach(function(t){var r,a,i=function(t){var r,n=e.arcs[t<0?~t:t],o=n[0];e.transform?(r=[0,0],n.forEach(function(e){r[0]+=e[0],r[1]+=e[1]})):r=n[n.length-1];return t<0?[r,o]:[o,r]}(t),c=i[0],u=i[1];if(r=o[c])if(delete o[r.end],r.push(t),r.end=u,a=n[u]){delete n[a.start];var f=a===r?r:r.concat(a);n[f.start=r.start]=o[f.end=a.end]=f}else n[r.start]=o[r.end]=r;else if(r=n[u])if(delete n[r.start],r.unshift(t),r.start=c,a=o[c]){delete o[a.end];var s=a===r?r:a.concat(r);n[s.start=a.start]=o[s.end=r.end]=s}else n[r.start]=o[r.end]=r;else n[(r=[t]).start=c]=o[r.end=u]=r}),c(o,n),c(n,o),t.forEach(function(e){r[e<0?~e:e]||a.push([e])}),a}function c(e,t,r){var n,o,a;if(arguments.length>1)n=function(e,t,r){var n,o=[],a=[];function i(e){var t=e<0?~e:e;(a[t]||(a[t]=[])).push({i:e,g:n})}function c(e){e.forEach(i)}function u(e){e.forEach(c)}return function e(t){switch(n=t,t.type){case"GeometryCollection":t.geometries.forEach(e);break;case"LineString":c(t.arcs);break;case"MultiLineString":case"Polygon":u(t.arcs);break;case"MultiPolygon":!function(e){e.forEach(u)}(t.arcs)}}(t),a.forEach(null==r?function(e){o.push(e[0].i)}:function(e){r(e[0].g,e[e.length-1].g)&&o.push(e[0].i)}),o}(0,t,r);else for(o=0,n=new Array(a=e.arcs.length);o<a;++o)n[o]=o;return{type:"MultiLineString",arcs:i(e,n)}}function u(e,t){var r={},n=[],o=[];function c(e){e.forEach(function(t){t.forEach(function(t){(r[t=t<0?~t:t]||(r[t]=[])).push(e)})}),n.push(e)}function u(t){return function(e){for(var t,r=-1,n=e.length,o=e[n-1],a=0;++r<n;)t=o,o=e[r],a+=t[0]*o[1]-t[1]*o[0];return Math.abs(a)}(a(e,{type:"Polygon",arcs:[t]}).coordinates[0])}return t.forEach(function e(t){switch(t.type){case"GeometryCollection":t.geometries.forEach(e);break;case"Polygo
</script>
</head>
<body>
<canvas id="space-bg" style="position:fixed;inset:0;z-index:0;pointer-events:none;"></canvas>
<!-- Mode Transition Overlay -->
<div id="mode-transition-layer" style="position:fixed; inset:0; background:var(--bg); z-index:99999; opacity:0; pointer-events:none; transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1); display:flex; align-items:center; justify-content:center; flex-direction:column;">
<div style="width:48px; height:48px; border:4px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation: spin 1s linear infinite;"></div>
<div id="transition-text" style="margin-top:24px; font-size:20px; font-weight:600; color:var(--text); letter-spacing:-0.5px;">Switching workspace...</div>
</div>
<div class="layout">
<!-- ════════════════════════════════ SIDEBAR ════════════════════════════════ -->
<div class="sidebar-overlay" id="sidebar-overlay" onclick="closeSidebar()"></div>
<aside class="sidebar">
<div class="sidebar-logo">
<div class="logo-icon">
<svg width="16" height="16" fill="none" stroke="#fff" stroke-width="2.5" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
Cosmos
</div>
<div class="sidebar-body">
<div class="sidebar-section">
<div class="sidebar-section-label">Overview</div>
<div class="nav-item active" id="nav-dashboard" onclick="switchView('dashboard')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
Dashboard
</div>
<div class="nav-item" id="nav-analytics" onclick="switchView('analytics')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
Analytics
</div>
</div>
<div class="sidebar-section">
<div class="sidebar-section-label">Buckets</div>
<div id="sidebar-buckets"></div>
<div class="sidebar-create-bucket" onclick="openModal('modal-create-bucket')">
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
<span>Create bucket</span>
</div>
</div>
<div class="sidebar-section">
<div class="sidebar-section-label">Account</div>
<div class="nav-item" id="nav-account" onclick="switchView('account')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
Profile & API Keys
</div>
<div class="nav-item" id="nav-security" onclick="switchView('security')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg>
Security
</div>
<a href="/oort/logout" class="nav-item" style="color:var(--red); text-decoration:none;">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/></svg>
Sign Out
</a>
</div>
</div>
<div class="sidebar-user" onclick="switchView('account')">
<div class="sidebar-user-card">
<div class="user-avatar" id="sidebarAvatar">U</div>
<div class="user-info">
<div class="user-name" id="sidebarName">Loading…</div>
<div class="user-role">S3 Object Storage</div>
</div>
</div>
</div>
</aside>
<!-- ═══════════════════════════════ MAIN ════════════════════════════════ -->
<div class="main">
<!-- TOPBAR -->
<div class="topbar">
<button class="mobile-menu-btn" style="display:none; align-items:center; justify-content:center; background:none; border:none; color:#fff; cursor:pointer; padding:6px;" onclick="toggleSidebar()">
<svg width="24" height="24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 12h18M3 6h18M3 18h18"/></svg>
</button>
<div class="topbar-search" style="flex:1; display:flex; align-items:center; background:rgba(255,255,255,0.05); border-radius:8px; padding:0 12px; margin:0 16px;">
<svg width="16" height="16" fill="none" stroke="#86868b" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<input type="text" id="inp-search" placeholder="Filter files..." style="background:transparent; border:none; color:#fff; padding:10px; flex:1; outline:none; font-size:14px;" onkeyup="filterFiles(this.value)">
</div>
<div class="breadcrumb" id="topbarBreadcrumb">
<span class="bc-item active">Dashboard</span>
</div>
<div class="topbar-actions" id="topbarActions">
<!-- Mode Switcher Pill -->
<div style="display:flex; align-items:center; gap:0; background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); border-radius:999px; padding:4px; margin-right:16px; border-right:none;">
<button id="pill-drive" onclick="setMode('drive')"
style="display:flex;align-items:center;gap:6px;padding:7px 16px;border-radius:999px;border:none;cursor:pointer;font-size:13px;font-weight:700;transition:all 0.3s cubic-bezier(0.16,1,0.3,1);background:linear-gradient(135deg,#7c3aed,#4f46e5);color:white;box-shadow:0 2px 8px rgba(124,58,237,0.4);">
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>
Cloud Drive
</button>
<button id="pill-s3" onclick="setMode('s3')"
style="display:flex;align-items:center;gap:6px;padding:7px 16px;border-radius:999px;border:none;cursor:pointer;font-size:13px;font-weight:700;transition:all 0.3s cubic-bezier(0.16,1,0.3,1);background:transparent;color:rgba(255,255,255,0.55);">
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
S3 Storage
</button>
<!-- hidden checkbox for backwards compat -->
<input type="checkbox" id="mode-toggle" style="display:none;" onchange="toggleUIMode()">
</div>
<button class="btn btn-ghost btn-sm" onclick="openUploader()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
Upload
</button>
<button class="btn btn-primary btn-sm" onclick="openModal('modal-create-bucket')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
New Bucket
</button>
</div>
</div>
<!-- ─── DASHBOARD VIEW ─── -->
<div class="view" id="view-dashboard">
<div class="content" style="overflow-y:auto; padding-bottom: 80px;">
<div class="page-header" style="padding-top:24px">
<div style="display:flex;align-items:center;justify-content:space-between">
<div>
<div class="page-title">Overview</div>
<div class="page-subtitle" id="dash-subtitle">Loading storage statistics…</div>
</div>
<div>
<button class="btn btn-ghost btn-sm" onclick="loadDashboard()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>
Refresh
</button>
</div>
</div>
</div>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Storage Used</div>
<div class="stat-card-icon" style="background:rgba(59,130,246,.12)">
<svg fill="none" stroke="#3b82f6" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
</div>
<div class="stat-card-value" id="dash-used">—</div>
<div class="stat-card-meta" id="dash-used-pct">of 50 GB limit</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Total Objects</div>
<div class="stat-card-icon" style="background:rgba(99,102,241,.12)">
<svg fill="none" stroke="#6366f1" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"/><polyline points="13 2 13 9 20 9"/></svg>
</div>
</div>
<div class="stat-card-value" id="dash-objects">—</div>
<div class="stat-card-meta">Files stored</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Buckets</div>
<div class="stat-card-icon" style="background:rgba(34,197,94,.12)">
<svg fill="none" stroke="#22c55e" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><rect x="2" y="7" width="20" height="14" rx="2" ry="2"/><path d="M16 21V5a2 2 0 00-2-2h-4a2 2 0 00-2 2v16"/></svg>
</div>
</div>
<div class="stat-card-value" id="dash-buckets">—</div>
<div class="stat-card-meta">Active containers</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Available</div>
<div class="stat-card-icon" style="background:rgba(6,182,212,.12)">
<svg fill="none" stroke="#06b6d4" stroke-width="2" viewBox="0 0 24 24" width="16" height="16"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
</div>
</div>
<div class="stat-card-value" id="dash-avail">—</div>
<div class="stat-card-meta">Remaining quota</div>
</div>
</div>
<div class="charts-grid">
<div class="chart-card">
<div class="chart-card-header">
<div class="chart-card-title">Storage Quota</div>
<div class="chart-card-sub" id="quota-hard-limit-label">Storage Quota</div>
</div>
<div class="chart-wrap">
<canvas id="usageChart"></canvas>
</div>
<div class="quota-bar-wrap">
<div class="quota-label">
<span id="quota-label-used">0 B used</span>
<span id="quota-label-pct">0%</span>
</div>
<div class="quota-track">
<div class="quota-fill" id="quota-fill" style="width:0%"></div>
</div>
</div>
</div>
<!-- Storage Breakdown Donut Chart -->
<div class="chart-card" id="dash-breakdown-card">
<div class="chart-card-header" style="display:flex; justify-content:space-between; align-items:flex-start;">
<div>
<div class="chart-card-title">Storage Breakdown</div>
<div class="chart-card-sub">Capacity by file type across all buckets</div>
</div>
<div id="dash-breakdown-total" style="font-family:var(--mono); font-size:13px; color:#38bdf8; font-weight:700; background:rgba(56,189,248,0.1); border:1px solid rgba(56,189,248,0.25); padding:3px 10px; border-radius:999px;">—</div>
</div>
<div class="chart-wrap" style="height:210px; position:relative;">
<canvas id="dashStorageBreakdownChart"></canvas>
</div>
<div id="dash-breakdown-pills" style="display:flex; flex-wrap:wrap; gap:6px; justify-content:center; margin-top:14px; font-size:11.5px;"></div>
</div>
<div class="chart-card">
<div class="chart-card-header">
<div class="chart-card-title">Buckets</div>
<div class="chart-card-sub">Your storage containers</div>
</div>
<div id="dash-bucket-list" style="margin-top:4px"></div>
<div style="margin-top:16px">
<button class="btn btn-ghost btn-sm" onclick="openModal('modal-create-bucket')">+ Create bucket</button>
</div>
</div>
</div>
</div>
</div>
<!-- ─── ANALYTICS VIEW ─── -->
<div class="view" id="view-analytics">
<div class="content" style="overflow-y:auto; padding-bottom: 80px;">
<div class="page-header" style="padding-top:24px; padding-bottom:16px;">
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin-bottom:16px;">
<div>
<div class="page-title">Analytics</div>
<div class="page-subtitle" id="analytics-subtitle">Real-time storage performance metrics</div>
</div>
<button class="btn btn-ghost btn-sm" onclick="loadAnalytics()" style="flex-shrink:0;">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>
Refresh
</button>
</div>
<!-- Filter bar — full width row below title -->
<div style="display:flex; gap:8px; flex-wrap:wrap; align-items:center; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.07); border-radius:12px; padding:12px 16px;">
<svg width="14" height="14" fill="none" stroke="var(--text3)" stroke-width="2" viewBox="0 0 24 24" style="flex-shrink:0;"><line x1="4" y1="6" x2="20" y2="6"/><line x1="8" y1="12" x2="16" y2="12"/><line x1="12" y1="18" x2="12" y2="18"/></svg>
<select id="an-filter-bucket" class="form-control" style="flex:1;min-width:120px;max-width:180px;" onchange="loadAnalytics()">
<option value="all">All Buckets</option>
</select>
<div style="display:flex; align-items:center; gap:6px; background:rgba(255,255,255,0.04); border:1px solid rgba(255,255,255,0.08); border-radius:8px; padding:4px 10px; flex:2; min-width:260px;">
<svg width="12" height="12" fill="none" stroke="var(--text3)" stroke-width="2" viewBox="0 0 24 24" style="flex-shrink:0;"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
<span style="font-size:11px;color:var(--text3);flex-shrink:0;">From</span>
<input type="datetime-local" id="an-filter-date-start" style="background:transparent;border:none;color:#fff;font-size:12px;outline:none;flex:1;min-width:0;" onchange="loadAnalytics()">
<span style="font-size:11px;color:var(--text3);flex-shrink:0;">To</span>
<input type="datetime-local" id="an-filter-date-end" style="background:transparent;border:none;color:#fff;font-size:12px;outline:none;flex:1;min-width:0;" onchange="loadAnalytics()">
</div>
<select id="an-filter-region" class="form-control" style="flex:1;min-width:120px;max-width:160px;" onchange="loadAnalytics()">
<option value="all">All Regions</option>
<option value="US">United States</option>
<option value="EU">Europe</option>
<option value="AS">Asia</option>
<option value="IN">India</option>
</select>
<select id="an-filter-op" class="form-control" style="flex:1;min-width:110px;max-width:150px;" onchange="loadAnalytics()">
<option value="all">All Operations</option>
<option value="read">Reads</option>
<option value="write">Writes</option>
</select>
<button class="btn btn-ghost btn-sm" onclick="clearAnalyticsFilters()" style="flex-shrink:0;">Clear</button>
</div>
</div>
<!-- KPI Row -->
<div class="stats-grid" id="analytics-kpi" style="padding: 0 16px 24px; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));">
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Total Requests</div>
<div class="stat-card-icon" style="background:rgba(99,102,241,.12)">
<svg fill="none" stroke="#6366f1" stroke-width="2" viewBox="0 0 24 24" width="18" height="18"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"/></svg>
</div>
</div>
<div class="stat-card-value" id="an-total-req">—</div>
<div class="stat-card-meta">All time</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Bandwidth</div>
<div class="stat-card-icon" style="background:rgba(59,130,246,.12)">
<svg fill="none" stroke="#3b82f6" stroke-width="2" viewBox="0 0 24 24" width="18" height="18"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
</div>
<div class="stat-card-value" id="an-bandwidth">—</div>
<div class="stat-card-meta">Total transferred</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Success Rate</div>
<div class="stat-card-icon" style="background:rgba(16,185,129,.12)">
<svg fill="none" stroke="#10b981" stroke-width="2" viewBox="0 0 24 24" width="18" height="18"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>
</div>
</div>
<div class="stat-card-value" id="an-success-rate">—</div>
<div class="stat-card-meta">2xx responses</div>
</div>
<div class="stat-card">
<div class="stat-card-header">
<div class="stat-card-label">Errors</div>
<div class="stat-card-icon" style="background:rgba(239,68,68,.12)">
<svg fill="none" stroke="#ef4444" stroke-width="2" viewBox="0 0 24 24" width="18" height="18"><circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/></svg>
</div>
</div>
<div class="stat-card-value" id="an-errors">—</div>
<div class="stat-card-meta">4xx + 5xx</div>
</div>
</div>
<!-- Globe Row -->
<div id="analytics-globe-row" style="padding:0 16px 24px;" class="mobile-pad">
<!-- Globe -->
<div class="chart-card globe-card" style="display:flex; padding:0; overflow:hidden; min-height: 480px;">
<!-- Country List Sidebar -->
<div style="width:200px; background:rgba(255,255,255,0.01); border-right:1px solid rgba(255,255,255,0.05); display:flex; flex-direction:column;">
<div style="padding:16px 20px; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:0.05em; color:var(--text2); border-bottom:1px solid rgba(255,255,255,0.05); display:flex; align-items:center; gap:8px;">
<svg width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0118 0z"></path><circle cx="12" cy="10" r="3"></circle></svg>
Active Regions
</div>
<div id="globe-country-list" style="overflow-y:auto; flex:1; padding:12px;" onmouseleave="clearHoverFilter()">
<!-- Populated by JS -->
</div>
</div>
<!-- Globe Canvas container -->
<div style="flex:1; display:flex;flex-direction:column;align-items:center;justify-content:center; position:relative; padding:24px;">
<div class="chart-card-header" style="width:100%; text-align:center; margin-bottom: 24px;">
<div class="chart-card-title" style="font-size:18px;">Global Traffic</div>
<div class="chart-card-sub" style="font-size:13px;">Drag to rotate &middot; Ctrl+Scroll to zoom</div>
</div>
<canvas id="globeCanvas" width="500" height="400" style="display:block;margin:0 auto; cursor:grab;"></canvas>
</div>
</div>
</div>
<!-- Charts Row: Request Volume and Storage Breakdown Side-by-Side -->
<div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(360px, 1fr)); gap:24px; padding:0 16px 24px;" id="analytics-charts-row">
<!-- Request Timeline -->
<div class="chart-card">
<div class="chart-card-header">
<div class="chart-card-title">Request Volume</div>
<div class="chart-card-sub">Last 24 hours</div>
</div>
<div class="chart-wrap" style="height:280px; position:relative;">
<canvas id="analyticsChart"></canvas>
</div>
</div>
<!-- Storage Breakdown Donut Chart -->
<div class="chart-card">
<div class="chart-card-header">
<div class="chart-card-title">Storage Breakdown</div>
<div class="chart-card-sub">Capacity distribution by file type</div>
</div>
<div class="chart-wrap" style="height:280px; position:relative;">
<canvas id="storageBreakdownChart"></canvas>
</div>
</div>
</div>
<!-- Per-bucket table -->
<div style="padding:0 40px 40px;">
<div class="chart-card">
<div class="chart-card-header">
<div class="chart-card-title">Per-Bucket Breakdown</div>
<div class="chart-card-sub">Performance metrics by bucket</div>
</div>
<div style="overflow-x:auto;margin-top:8px;">
<table style="width:100%;border-collapse:collapse;font-size:13.5px;">
<thead>
<tr style="border-bottom:1px solid var(--border);">
<th style="text-align:left;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Bucket</th>
<th style="text-align:right;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Requests</th>
<th style="text-align:right;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Status</th>
<th style="text-align:right;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Errors</th>
<th style="text-align:right;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Bandwidth</th>
<th style="text-align:left;padding:12px 16px;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:0.1em;color:var(--text3);">Last Hit</th>
</tr>
</thead>
<tbody id="analytics-bucket-tbody">
<tr><td colspan="6" style="text-align:center;padding:40px;color:var(--text3);">Loading…</td></tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- ─── BROWSER VIEW ─── -->
<div class="view" id="view-browser">
<!-- Top Action Header -->
<div class="browser-header">
<div style="display:flex; align-items:center; gap:12px;">
<div style="width:32px; height:32px; border-radius:8px; background:rgba(56,189,248,0.12); border:1px solid rgba(56,189,248,0.25); display:flex; align-items:center; justify-content:center; color:#38bdf8;">
<svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
<div>
<div style="font-weight:700; font-size:16px; color:var(--ink-0); letter-spacing:-0.02em;" id="browser-title">Bucket</div>
</div>
</div>
<div class="browser-actions">
<button class="btn btn-ghost btn-sm" onclick="loadObjects()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><polyline points="23 4 23 10 17 10"/><path d="M20.49 15a9 9 0 11-2.12-9.36L23 10"/></svg>
Refresh
</button>
<button class="btn btn-ghost btn-sm" onclick="openBucketSettings()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><circle cx="12" cy="12" r="3"></circle></svg>
Settings
</button>
<button class="btn btn-ghost btn-sm" onclick="openModal('modal-mkdir')">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/><line x1="12" y1="11" x2="12" y2="17"/><line x1="9" y1="14" x2="15" y2="14"/></svg>
New Folder
</button>
<!-- Folder upload button -->
<button class="btn btn-ghost btn-sm" onclick="document.getElementById('inp-folder-upload').click()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/><polyline points="12 11 12 17 12 11"/><polyline points="9 14 12 11 15 14"/></svg>
Upload Folder
</button>
<input type="file" id="inp-folder-upload" webkitdirectory directory multiple style="display:none" onchange="queueFiles(this.files)">
<button class="btn btn-primary btn-sm" onclick="openUploader()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
Upload Files
</button>
</div>
</div>
<!-- Feature 7: Dedicated Search & Filter Toolbar -->
<div class="browser-toolbar">
<div class="browser-search-box">
<svg class="search-icon" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>
<input type="text" id="browser-search-inp" placeholder="Search files & folders in bucket..." autocomplete="off" oninput="onSearchInput(this.value)">
<button id="browser-search-clear" class="btn-clear-search" style="display:none;" onclick="clearSearchInput()" title="Clear search">✕</button>
</div>
<div class="category-filter-segmented" id="cat-filter-chips">
<button class="cat-pill active" data-cat="all" onclick="filterByCategory('all')">
<span class="cat-pill-dot dot-all"></span>All
</button>
<button class="cat-pill" data-cat="images" onclick="filterByCategory('images')">
<span class="cat-pill-dot dot-images"></span>Images
</button>
<button class="cat-pill" data-cat="media" onclick="filterByCategory('media')">
<span class="cat-pill-dot dot-media"></span>Media
</button>
<button class="cat-pill" data-cat="docs" onclick="filterByCategory('docs')">
<span class="cat-pill-dot dot-docs"></span>Docs
</button>
<button class="cat-pill" data-cat="code" onclick="filterByCategory('code')">
<span class="cat-pill-dot dot-code"></span>Code
</button>
<button class="cat-pill" data-cat="archives" onclick="filterByCategory('archives')">
<span class="cat-pill-dot dot-archives"></span>Archives
</button>
</div>
</div>
<!-- Sticky Batch Action Bar (shown when 1+ checkboxes selected) -->
<div id="batch-action-bar" style="display:none; position:sticky; top:12px; z-index:100; margin:8px 16px; background:rgba(15,23,42,0.95); border:1px solid rgba(56,189,248,0.35); border-radius:12px; padding:10px 18px; box-shadow:0 12px 36px rgba(0,0,0,0.6); backdrop-filter:blur(16px); align-items:center; justify-content:space-between; gap:16px;">
<div style="display:flex; align-items:center; gap:12px;">
<span id="batch-count-badge" style="background:rgba(56,189,248,0.2); color:#38bdf8; padding:3px 10px; border-radius:999px; font-weight:700; font-size:12px;">0 items</span>
<span id="batch-size-badge" style="color:var(--text2); font-size:13px; font-family:var(--mono);">0 B</span>
</div>
<div style="display:flex; gap:10px; align-items:center;">
<button class="btn btn-sm btn-ghost" onclick="batchDownloadZip()">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
Download .ZIP
</button>
<button class="btn btn-sm btn-ghost" style="color:#f87171;" onclick="batchDeleteSelected()">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>
Delete Selected
</button>
<button class="btn btn-sm btn-ghost" onclick="clearBatchSelection()">Clear</button>
</div>
</div>
<div class="file-table-wrap" id="file-table-wrap">
<!-- populated by JS -->
</div>
</div>
<!-- ─── ACCOUNT VIEW ─── -->
<div class="view" id="view-account">
<div class="content" style="overflow-y:auto; padding-bottom: 80px;">
<div class="form-page" style="margin: 0 auto">
<!-- Hidden file input for profile image update -->
<input type="file" id="inp-update-avatar" accept="image/*" style="display:none" onchange="uploadProfileImage(this)">
<div class="profile-hero" style="justify-content:center; flex-direction:column; text-align:center; padding: 40px 20px">
<div class="profile-hero-avatar" id="profileAvatar"
style="width:96px;height:96px;font-size:36px;margin-bottom:12px;background-size:cover;background-position:center;border:4px solid var(--surface2);position:relative;cursor:pointer;overflow:hidden"
onclick="document.getElementById('inp-update-avatar').click()"
onmouseenter="document.getElementById('avatar-overlay').style.opacity='1'"
onmouseleave="document.getElementById('avatar-overlay').style.opacity='0'">
<span id="profileAvatarText">U</span>
<div id="avatar-overlay" style="position:absolute;inset:0;background:rgba(0,0,0,0.6);display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity 0.2s">
<svg width="24" height="24" fill="none" stroke="#fff" stroke-width="2" viewBox="0 0 24 24"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
</div>
</div>
<div>
<div class="profile-hero-name" id="profileName" style="font-size:24px">—</div>
<div class="profile-hero-meta" style="justify-content:center; margin-top:8px">
<span id="profileUsername" style="color:var(--text2)">@username</span>
<span id="profileAK" style="font-family:monospace;font-size:12px;color:var(--text3)">—</span>
</div>
<div style="margin-top:16px; display:flex; gap:8px; justify-content:center">
<span class="badge badge-blue">S3 Storage</span>
<span class="badge badge-green">Enterprise Active</span>
</div>
</div>
</div>
<!-- Tabs -->
<div style="display:flex; border-bottom:1px solid var(--border); margin-bottom:24px; gap:24px;">
<div onclick="switchPTab('general')" id="ptab-general" style="padding-bottom:12px; cursor:pointer; color:var(--text); border-bottom:2px solid var(--accent); font-weight:500;">General Info</div>
<div onclick="switchPTab('api')" id="ptab-api" style="padding-bottom:12px; cursor:pointer; color:var(--text2); border-bottom:2px solid transparent; font-weight:500; transition:.2s;">API & Credentials</div>
<div onclick="switchPTab('quota')" id="ptab-quota" style="padding-bottom:12px; cursor:pointer; color:var(--text2); border-bottom:2px solid transparent; font-weight:500; transition:.2s;">Quota</div>
</div>
<!-- General Tab -->
<div id="ptab-content-general">
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Edit Profile</div>
<div class="form-section-subtitle">Update your personal information.</div>
</div>
</div>
<div class="form-section-body">
<div class="form-row">
<label class="form-label">Full Name</label>
<input type="text" class="form-control" id="inp-update-name" placeholder="Full Name">
</div>
<div class="form-row">
<label class="form-label">Username</label>
<input type="text" class="form-control" id="inp-update-username" placeholder="Username">
</div>
<button class="btn btn-primary" onclick="updateProfile()">Save Changes</button>
</div>
</div>
</div>
<!-- API Tab -->
<div id="ptab-content-api" style="display:none;">
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Connection Details & Keys</div>
<div class="form-section-subtitle">Use these to connect S3-compatible tools and SDKs</div>
</div>
</div>
<div class="form-section-body">
<div class="form-row">
<div class="form-label">S3 Endpoint</div>
<div class="cred-box">
<span class="cred-box-val" id="cred-endpoint">—</span>
<button class="cred-copy" onclick="copyText('cred-endpoint')" title="Copy"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button>
</div>
</div>
<div class="form-row">
<div class="form-label">Region</div>
<div class="cred-box"><span class="cred-box-val">us-east-1</span></div>
</div>
<div class="form-row" style="margin-top:24px">
<div class="form-label">Access Key ID</div>
<div class="cred-box">
<span class="cred-box-val" id="cred-ak">—</span>
<button class="cred-copy" onclick="copyText('cred-ak')" title="Copy"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button>
</div>
</div>
<div class="form-row">
<div class="form-label">Secret Access Key</div>
<div class="cred-box" style="display:flex; padding:0;">
<input type="password" id="cred-sk-inp" readonly style="flex:1; background:transparent; border:none; color:var(--text); padding:12px; font-family:monospace; font-size:13px; outline:none;">
<button onclick="toggleSK()" title="Show/Hide" style="background:none; border:none; color:var(--text2); cursor:pointer; padding:0 12px;"><svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg></button>
<button onclick="copyText('cred-sk-inp', true)" title="Copy" style="background:none; border:none; color:var(--text2); cursor:pointer; padding:0 12px; border-left:1px solid var(--border)"><svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg></button>
</div>
</div>
</div>
</div>
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Python Boto3 Integration</div>
<div class="form-section-subtitle">Connect programmatically using the official AWS SDK for Python</div>
</div>
</div>
<div class="form-section-body">
<div class="code-block" id="cred-py-snippet">Loading…</div>
</div>
</div>
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">AWS CLI Integration</div>
</div>
</div>
<div class="form-section-body">
<div class="code-block" id="cred-cli-snippet">Loading…</div>
</div>
</div>
</div>
<!-- Quota Tab -->
<div id="ptab-content-quota" style="display:none;">
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Request Quota Increase</div>
<div class="form-section-subtitle">Request an expansion up to 100 GB for your workload.</div>
</div>
</div>
<div class="form-section-body">
<div class="form-row">
<label class="form-label" style="display:flex;justify-content:space-between">
<span>Requested Storage Limit</span>
<span id="quota-val-lbl" style="color:var(--accent)">50 GB</span>
</label>
<input type="range" id="quota-slider" min="11" max="500" step="1" value="50" style="width:100%; margin: 12px 0; accent-color: var(--accent)" oninput="document.getElementById('quota-val-lbl').textContent = this.value + ' GB'">
</div>
<button class="btn btn-primary" id="btn-req-quota" onclick="requestQuota()">Submit Expansion Request</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- ─── SECURITY VIEW ─── -->
<div class="view" id="view-security">
<div class="content" style="overflow-y:auto; padding-bottom: 80px;">
<div class="form-page" style="margin: 0 auto">
<div class="form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Change Password</div>
<div class="form-section-subtitle">Updates your portal login and MinIO Secret Key simultaneously</div>
</div>
</div>
<div class="form-section-body">
<div class="form-row">
<label class="form-label">New Password</label>
<input type="password" class="form-control" id="inp-new-password" placeholder="Minimum 8 characters">
</div>
<div class="form-row">
<label class="form-label">Confirm Password</label>
<input type="password" class="form-control" id="inp-confirm-password" placeholder="Re-enter new password">
</div>
<button class="btn btn-primary" id="btn-change-pwd" onclick="changePassword()">Update Password</button>
</div>
</div>
<div class="danger-section form-section">
<div class="form-section-header">
<div>
<div class="form-section-title">Danger Zone</div>
<div class="form-section-subtitle">Permanent bucket deletion — this cannot be undone</div>
</div>
</div>
<div class="form-section-body">
<div class="form-row">
<label class="form-label">Select bucket to delete</label>
<select class="form-control" id="sel-delete-bucket"></select>
</div>
<button class="btn btn-danger" onclick="deleteBucket()">Delete Bucket & All Data</button>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.main -->
</div><!-- /.layout -->
<!-- ════════════════════ UPLOAD MANAGER & DROPZONE ════════════════════ -->
<!-- GLOBAL DROPZONE -->
<div id="global-dropzone" style="display:none; position:fixed; inset:0; z-index:9999; background:rgba(9, 14, 23, 0.85); backdrop-filter:blur(8px); flex-direction:column; align-items:center; justify-content:center; color:white; transition: opacity 0.2s;">
<div style="border:3px dashed rgba(255,255,255,0.4); border-radius:24px; padding:64px 128px; display:flex; flex-direction:column; align-items:center; background:rgba(255,255,255,0.05); box-shadow:0 24px 64px rgba(0,0,0,0.5);">
<div style="background:var(--accent); padding:24px; border-radius:50%; margin-bottom:24px; box-shadow:0 8px 32px rgba(59,130,246,0.4);">
<svg width="48" height="48" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>
</div>
<h1 style="font-size:36px; font-weight:700; margin:0 0 16px 0; letter-spacing:-0.5px;">Drop files to upload</h1>
<p style="font-size:18px; opacity:0.9; margin:0; font-weight:400;">Uploading directly to <span id="global-drop-bucket" style="font-weight:700; color:var(--accent);">bucket</span></p>
</div>
</div>
<!-- UPLOAD MANAGER (Bottom Right) -->
<div id="upload-manager" style="display:none; position:fixed; bottom:24px; right:24px; width:400px; background:var(--surface); border:1px solid var(--border); border-radius:12px; box-shadow:0 16px 48px rgba(0,0,0,0.3); z-index:9000; flex-direction:column; overflow:hidden; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateY(0);">
<div id="upload-manager-header" style="background:var(--surface2); padding:16px 20px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; cursor:pointer;" onclick="toggleUploadManager()">
<div style="font-weight:600; font-size:15px; display:flex; align-items:center; gap:12px;">
<div id="um-spinner" style="width:16px; height:16px; border:2px solid var(--accent); border-top-color:transparent; border-radius:50%; animation: spin 1s linear infinite;"></div>
<span id="upload-manager-title">Uploading...</span>
</div>
<div style="display:flex; gap:8px;">
<button style="background:none; border:none; color:var(--text2); cursor:pointer; padding:4px;" title="Minimize"><svg id="um-chevron" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="transition:transform 0.2s;"><polyline points="6 9 12 15 18 9"/></svg></button>
<button style="background:none; border:none; color:var(--text2); cursor:pointer; padding:4px;" title="Close" onclick="event.stopPropagation(); document.getElementById('upload-manager').style.display='none'"><svg width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button>
</div>
</div>
<div id="upload-manager-list" style="max-height:350px; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px;">
<!-- Items -->
</div>
<input type="file" id="file-input" multiple style="display:none" onchange="queueFiles(this.files);this.value=''">
</div>
<style>
@keyframes spin { 100% { transform: rotate(360deg); } }
.um-item { display:flex; align-items:center; padding:12px; gap:14px; border-radius:8px; border:1px solid var(--border); background:var(--bg); transition: background 0.2s; }
.um-icon { background:var(--surface2); padding:10px; border-radius:8px; color:var(--accent); display:flex; align-items:center; justify-content:center; }
.um-content { flex:1; min-width:0; }
.um-name { font-size:13px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.um-meta { display:flex; justify-content:space-between; font-size:12px; color:var(--text3); margin-top:6px; font-weight:500;}
.um-track { height:5px; background:var(--surface2); border-radius:3px; margin-top:8px; overflow:hidden; }
.um-fill { height:100%; width:0%; background:var(--accent); transition: width 0.15s ease-out; border-radius:3px; }
.um-cancel { background:none; border:none; color:var(--text3); cursor:pointer; padding:6px; border-radius:6px; transition:0.2s; }
.um-cancel:hover { background:var(--surface2); color:var(--text); }
@media (max-width:800px) {
.layout { flex-direction: column; }
.sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; }
.sidebar-logo { border-bottom: none; }
.sidebar-body { display: flex; flex-direction: row; overflow-x: auto; white-space: nowrap; padding: 0 16px; gap: 12px; align-items: center; }
.sidebar-section { margin-bottom: 0; display: flex; flex-direction: row; gap: 8px; align-items: center; }
.sidebar-section-label { display: none; }
.topbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 60px; justify-content: center; gap: 12px; border-top: 1px solid var(--border); }
.content-header { flex-direction: column; align-items: flex-start; gap: 12px; }
.data-grid { grid-template-columns: 1fr; }
.object-row { flex-wrap: wrap; gap: 8px; }
.object-name-col { flex: 1 1 100%; }
}
@media (max-width:800px) {
.file-table thead { display: none; }
.file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
.file-table tr { margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.file-table td { text-align: left; padding: 4px 12px; position: relative; }
.file-table td:nth-child(2)::before { content: "Size: "; font-weight: bold; }
.file-table td:nth-child(4)::before { content: "Modified: "; font-weight: bold; }
.grid { display: flex !important; flex-direction: column !important; }
}
@media (max-width:800px) {
.drive-item { flex-wrap: wrap; }
.drive-item > div:nth-child(2), .drive-item > div:nth-child(3) { display: none; }
.drive-item > div:first-child { flex: 1 1 100%; }
div[style*="text-transform:uppercase"] { display: none !important; }
}
input[type="datetime-local"], input[type="date"] {
color-scheme: dark;
}
.globe-card { flex-direction: row; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #6366f1; }
input:checked + .slider:before { transform: translateX(16px); }
</style>
<!-- ════════════ MODALS ════════════ -->
<!-- Move / Rename -->
<div class="modal-bg" id="modal-move">
<div class="modal">
<div class="modal-header">
<div class="modal-title">Move or Rename</div>
<button class="modal-close" onclick="closeModal('modal-move')">✕</button>
</div>
<div class="modal-body">
<input type="hidden" id="inp-move-source">
<p style="font-size:13px; color:var(--text2); margin-bottom:16px;">Move this item to a new folder, or rename it. Do not include the bucket name.</p>
<div class="form-row">
<label class="form-label">Destination Path</label>
<input type="text" class="form-control" id="inp-move-dest" placeholder="e.g. documents/report.pdf" onkeydown="if(event.key==='Enter')executeMove()">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal('modal-move')">Cancel</button>
<button class="btn btn-primary" onclick="executeMove()">Confirm Move</button>
</div>
</div>
</div>
<!-- Create Bucket -->
<div class="modal-bg" id="modal-create-bucket">
<div class="modal">
<div class="modal-header">
<div class="modal-title">Create Bucket</div>
<button class="modal-close" onclick="closeModal('modal-create-bucket')">✕</button>
</div>
<div class="modal-body">
<p>Bucket names must be unique across your account. A hard 50 GB quota is enforced automatically.</p>
<div class="form-row">
<label class="form-label">Bucket Name</label>
<input type="text" class="form-control" id="inp-new-bucket" placeholder="e.g. my-project-files" onkeydown="if(event.key==='Enter')createBucket()">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal('modal-create-bucket')">Cancel</button>
<button class="btn btn-primary" id="btn-create-bucket" onclick="createBucket()">Create Bucket</button>
</div>
</div>
</div>
<!-- New Folder -->
<div class="modal-bg" id="modal-mkdir">
<div class="modal">
<div class="modal-header">
<div class="modal-title">Create Folder</div>
<button class="modal-close" onclick="closeModal('modal-mkdir')">✕</button>
</div>
<div class="modal-body">
<div class="form-row">
<label class="form-label">Folder Name</label>
<input type="text" class="form-control" id="inp-mkdir" placeholder="new-folder" onkeydown="if(event.key==='Enter')createFolder()">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal('modal-mkdir')">Cancel</button>
<button class="btn btn-primary" onclick="createFolder()">Create Folder</button>
</div>
</div>
</div>
<!-- ─── SHARE LINK MODAL ─── -->
<div class="modal-bg" id="modal-share-link">
<div class="modal" style="max-width:520px;">
<div class="modal-header">
<div class="modal-title">Create Secure Share Link</div>
<button class="btn-icon" onclick="closeModal('modal-share-link')"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12"/></svg></button>
</div>
<div class="modal-body" style="padding:24px;">
<div style="font-size:13px; color:var(--text3); margin-bottom:16px;">
Generate an expiring public download link for:
<div id="share-target-key" style="font-weight:600; color:var(--text); font-family:var(--mono); margin-top:4px; word-break:break-all;"></div>
</div>
<div class="form-row" style="margin-bottom:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Link Expiration</label>
<select class="form-control" id="share-expire-select">
<option value="3600">1 Hour</option>
<option value="21600">6 Hours</option>
<option value="86400" selected>24 Hours (1 Day)</option>
<option value="259200">3 Days</option>
<option value="604800">7 Days</option>
<option value="2592000">30 Days</option>
</select>
</div>
<div class="form-row" style="margin-bottom:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Optional Passphrase (Leave blank for open access)</label>
<input type="password" class="form-control" id="share-password" placeholder="Passphrase to protect this file">
</div>
<div class="form-row" style="margin-bottom:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Max Downloads (0 for unlimited)</label>
<input type="number" class="form-control" id="share-max-dl" value="0" min="0">
</div>
<div id="share-result-wrap" style="display:none; margin-top:16px; background:rgba(56,189,248,0.06); border:1px solid rgba(56,189,248,0.25); border-radius:10px; padding:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:#38bdf8; margin-bottom:6px;">Your Share Link is Ready!</label>
<div style="display:flex; gap:8px;">
<input type="text" id="share-result-url" class="form-control" readonly style="font-family:var(--mono); font-size:12px; flex:1;">
<button class="btn btn-primary btn-sm" onclick="copyShareResultURL()">Copy</button>
<button class="btn btn-ghost btn-sm" onclick="window.open(document.getElementById('share-result-url').value, '_blank')">Open</button>
</div>
</div>
</div>
<div class="modal-footer" id="share-footer-actions">
<button class="btn btn-ghost" onclick="closeModal('modal-share-link')">Close</button>
<button class="btn btn-primary" id="btn-create-share" onclick="generateShareLink()">Generate Link</button>
</div>
</div>
</div>
<!-- ─── PREVIEW & CODE EDITOR MODAL ─── -->
<div class="modal-bg" id="modal-preview-editor">
<div class="modal" style="max-width:960px; width:92vw; max-height:92vh; display:flex; flex-direction:column; padding:0; overflow:hidden;">
<div class="modal-header" style="padding:16px 20px; border-bottom:1px solid var(--border); display:flex; align-items:center; justify-content:space-between; flex-shrink:0;">
<div style="display:flex; align-items:center; gap:12px; min-width:0;">
<div class="modal-title" id="preview-title" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:40vw; font-size:15px;">Preview</div>
<span id="preview-badge" style="font-family:var(--mono); font-size:10px; padding:2px 8px; border-radius:999px; background:rgba(56,189,248,0.12); color:#38bdf8;">CODE</span>
</div>
<div style="display:flex; gap:8px; align-items:center; flex-shrink:0;">
<button id="btn-save-preview" class="btn btn-primary btn-sm" style="display:none;" onclick="savePreviewContent()">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M19 21H5a2 2 0 01-2-2V5a2 2 0 012-2h11l5 5v11a2 2 0 01-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>
Save &amp; Upload
</button>
<button class="btn btn-ghost btn-sm" onclick="openShareFromPreview()">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>
Share
</button>
<button class="btn btn-ghost btn-sm" onclick="downloadPreviewFile()">
<svg width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>
Download
</button>
<button class="btn-icon" onclick="closeModal('modal-preview-editor')"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12"/></svg></button>
</div>
</div>
<div class="modal-body" id="preview-body" style="padding:0; flex:1; overflow:auto; display:flex; align-items:center; justify-content:center; min-height:400px; background:rgba(0,0,0,0.4);">
<!-- Content injected by JS -->
</div>
</div>
</div>
<!-- ─── ADD WEBHOOK MODAL ─── -->
<div class="modal-bg" id="modal-add-webhook">
<div class="modal" style="max-width:520px;">
<div class="modal-header">
<div class="modal-title">Add Event Webhook</div>
<button class="btn-icon" onclick="closeModal('modal-add-webhook')"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12"/></svg></button>
</div>
<div class="modal-body" style="padding:24px;">
<div class="form-row" style="margin-bottom:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Payload URL</label>
<input type="url" class="form-control" id="webhook-target-url" placeholder="https://api.example.com/webhook" required>
</div>
<div class="form-row" style="margin-bottom:14px;">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Secret Token (Optional HMAC-SHA256 signature)</label>
<input type="text" class="form-control" id="webhook-secret" placeholder="Optional webhook secret">
</div>
<div class="form-row">
<label class="form-label" style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:6px;">Trigger Events</label>
<div style="display:flex; flex-direction:column; gap:8px; margin-top:6px;">
<label style="display:flex; align-items:center; gap:8px; font-size:13px; cursor:pointer;">
<input type="checkbox" id="wh-evt-upload" checked style="accent-color:var(--accent);">
<span><strong>object:created</strong> — Trigger when a file is uploaded or updated</span>
</label>
<label style="display:flex; align-items:center; gap:8px; font-size:13px; cursor:pointer;">
<input type="checkbox" id="wh-evt-delete" checked style="accent-color:var(--accent);">
<span><strong>object:deleted</strong> — Trigger when a file is deleted</span>
</label>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal('modal-add-webhook')">Cancel</button>
<button class="btn btn-primary" onclick="saveNewWebhook()">Create Webhook</button>
</div>
</div>
</div>
<div class="toast-stack" id="toast-stack"></div>
<!-- ════════════════════════════════ SCRIPT ════════════════════════════════ -->
<script>
const SID = '{{.SID}}';
const CHUNK = 10 * 1024 * 1024; // 10 MB
let QUOTA = 10 * 1024 * 1024 * 1024; // default, overridden by API
let state = {
bucket: '',
prefix: '',
buckets: [],
profile: null,
chartInst: null,
};
/* ─── API ─────────────────────────────────────────────────────────── */
async function api(path, opts = {}) {
try {
const url = new URL(path, location.origin);
const r = await fetch(url.toString(), {
headers: { 'X-Session-Id': SID, 'Content-Type': 'application/json', ...(opts.headers || {}) },
...opts,
});
if (!r.ok) {
const j = await r.json().catch(() => ({}));
throw new Error(j.error || `HTTP ${r.status}`);
}
return r.json();
} catch (e) {
toast(e.message, 'error');
return null;
}
}
/* ─── TOAST ───────────────────────────────────────────────────────── */
function toast(msg, type = 'success') {
const el = document.createElement('div');
el.className = `toast ${type}`;
el.textContent = msg;
const stack = document.getElementById('toast-stack');
stack.appendChild(el);
setTimeout(() => el.remove(), 3500);
}
/* ─── MODAL ───────────────────────────────────────────────────────── */
function openModal(id) {
document.getElementById(id).classList.add('open');
const inp = document.querySelector(`#${id} input`);
if (inp) setTimeout(() => inp.focus(), 100);
}
function closeModal(id) { document.getElementById(id).classList.remove('open'); }
/* ─── VIEW SWITCHING ──────────────────────────────────────────────── */
async function openBucketSettings() {
document.getElementById('bucket-setting-public').checked = false;
document.getElementById('bucket-domains-list').innerHTML = 'Loading domains...';
const username = state.profile && state.profile.username ? state.profile.username : document.getElementById('sidebarName').textContent.replace('@','');
const disp = getBucketDisplayName(state.bucket);
document.getElementById('bucket-public-url-input').value = `https://cosmos.linuxguy.space/oort/${username}/${disp}`;
openModal('modal-bucket-settings');
const r = await api(`/oort/api/bucket/settings?bucket=${state.bucket}`);
if (r) {
document.getElementById('bucket-setting-public').checked = !!r.is_public;
}
loadBucketDomains();
loadSiteConfig();
loadWebhooks();
}
async function copyBucketURL() {
const url = document.getElementById('bucket-public-url-input').value;
try { await navigator.clipboard.writeText(url); toast("URL Copied!"); }
catch(e) { prompt("Copy:", url); }
}
async function emptyCurrentBucket() {
const conf = prompt(`WARNING: This will permanently delete ALL files in this bucket.\nType the bucket name '${getBucketDisplayName(state.bucket)}' to confirm:`);
if (conf !== getBucketDisplayName(state.bucket)) {
if(conf !== null) toast('Bucket name did not match', true);
return;
}
const r = await api(`/oort/api/bucket/empty?bucket=${state.bucket}`, { method: 'POST' });
if (r) {
toast('Bucket emptied successfully');
loadObjects();
closeModal('modal-bucket-settings');
}
}
async function loadBucketDomains() {
const list = document.getElementById('bucket-domains-list');
list.innerHTML = '<div style="color:var(--text3); font-size:12px;">Loading...</div>';
try {
const r = await api(`/oort/api/bucket/domains?bucket=${encodeURIComponent(state.bucket)}`);
if (!r || !r.domains || r.domains.length === 0) {
list.innerHTML = `<div style="color:var(--text3); font-size:13px;">No custom domains attached.</div>
<div style="margin-top:10px; font-size:12px; color:var(--text3); line-height:1.6;">
To use a custom domain, point a CNAME record for your domain to <code style="background:rgba(255,255,255,0.08); padding:1px 5px; border-radius:4px;">cosmos.linuxguy.space</code>
</div>`;
return;
}
list.innerHTML = r.domains.map(d => `
<div style="display:flex; justify-content:space-between; align-items:center; padding:10px 12px; border-bottom:1px solid rgba(255,255,255,0.05); gap:8px;">
<span style="color:#fff; font-size:13px; font-weight:500;">${d}</span>
<button onclick="removeBucketDomain('${d}')" style="background:rgba(239,68,68,0.1); color:#ef4444; border:1px solid rgba(239,68,68,0.2); border-radius:6px; padding:4px 12px; cursor:pointer; font-size:12px; font-weight:600;">Remove</button>
</div>
`).join('');
} catch(e) {
list.innerHTML = `<div style="color:#ef4444; font-size:13px;">Failed to load domains: ${e.message}</div>`;
}
}
async function addBucketDomain() {
const inp = document.getElementById('bucket-new-domain');
const d = inp.value.trim();
if(!d) { toast('Enter a domain name', 'error'); return; }
// basic validation
if(!d.includes('.')) { toast('Please enter a valid domain like static.example.com', 'error'); return; }
try {
const res = await api('/oort/api/bucket/domain/add', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, domain: d })
});
if(res) {
inp.value = '';
loadBucketDomains();
toast('Domain added successfully');
}
} catch(e) {
toast('Failed: ' + e.message, 'error');
}
}
async function removeBucketDomain(d) {
if(!confirm(`Remove ${d} from this bucket?`)) return;
try {
const res = await api('/oort/api/bucket/domain/remove', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, domain: d })
});
if(res) {
loadBucketDomains();
toast('Domain removed');
}
} catch(e) {
toast('Failed: ' + e.message, 'error');
}
}
async function toggleBucketPrivacy(isPublic) {
const res = await api('/oort/api/bucket/settings', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, is_public: isPublic })
});
if(res) toast(isPublic ? 'Bucket is now Public' : 'Bucket is now Private');
else document.getElementById('bucket-setting-public').checked = !isPublic; // revert UI
}
function switchView(name, bucket, prefix) {
if (window.innerWidth <= 768) {
const sb = document.querySelector('.sidebar');
if(sb) sb.classList.remove('mobile-open');
}
document.querySelectorAll('.view').forEach(v => v.classList.remove('active'));
document.querySelectorAll('.nav-item').forEach(n => n.classList.remove('active'));
document.querySelectorAll('.nav-bucket').forEach(n => n.classList.remove('active'));
const view = document.getElementById('view-' + name);
if (view) view.classList.add('active');
const nav = document.getElementById('nav-' + name);
if (nav) nav.classList.add('active');
if (name === 'browser' && bucket) {
state.bucket = bucket;
state.prefix = prefix || '';
document.querySelectorAll('.nav-bucket').forEach(n =>
n.classList.toggle('active', n.dataset.bucket === bucket));
loadObjects();
}
if (name === 'dashboard') loadDashboard();
if (name === 'analytics') loadAnalytics();
if (name === 'account') populateAccount();
if (name === 'security') populateSecurity();
updateTopbar(name);
}
function getBucketDisplayName(internal) {
if (!state.buckets) return internal;
const b = state.buckets.find(x => x.Name === internal);
return b ? (b.DisplayName || b.Name) : internal;
}
function updateTopbar(view) {
const bc = document.getElementById('topbarBreadcrumb');
const labels = {
dashboard: 'Dashboard',
account: 'Profile & API Keys',
security: 'Security Settings',
browser: (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'Drive: ') + getBucketDisplayName(state.bucket),
};
const label = labels[view] || view;
bc.innerHTML = `<span class="bc-item active">${label}</span>`;
if (view === 'browser') {
const parts = state.prefix.split('/').filter(Boolean);
let built = '';
const disp = getBucketDisplayName(state.bucket);
const crumbs = [`<span class="bc-item" onclick="switchView('browser','${state.bucket}','')">${disp}</span>`];
parts.forEach((p, i) => {
built += p + '/';
const prefix = built;
crumbs.push(`<span class="bc-sep">/</span><span class="bc-item ${i===parts.length-1?'active':''}" onclick="switchView('browser','${state.bucket}','${prefix}')">${p}</span>`);
});
bc.innerHTML = crumbs.join('');
}
}
/* ─── INIT ────────────────────────────────────────────────────────── */
window.onload = async () => {
try {
const savedMode = localStorage.getItem('unity_ui_mode');
if (savedMode === 's3') {
setMode('s3', true);
}
const p = await api('/oort/api/profile');
if (!p) {
document.getElementById('sidebarName').textContent = 'Error';
return;
}
state.profile = p;
if (p.profile_image) {
document.getElementById('sidebarAvatar').textContent = '';
document.getElementById('sidebarAvatar').style.backgroundImage = `url('${p.profile_image}')`;
document.getElementById('sidebarAvatar').style.backgroundSize = 'cover';
} else {
const initial = (p.name || p.username || p.access_key || 'U').charAt(0).toUpperCase();
document.getElementById('sidebarAvatar').textContent = initial;
}
document.getElementById('sidebarName').textContent = p.name || p.username || p.access_key;
await loadBuckets();
switchView('dashboard');
} catch (err) {
console.error(err);
document.getElementById('sidebarName').textContent = 'Error loading';
}
};
// ... (other functions) ...
/* ─── ACCOUNT ─────────────────────────────────────────────────────── */
function populateAccount() {
try {
const p = state.profile;
if (!p) return;
if (p.profile_image) {
document.getElementById('profileAvatarText').textContent = '';
document.getElementById('profileAvatar').style.backgroundImage = `url(${p.profile_image})`;
} else {
document.getElementById('profileAvatarText').textContent = (p.name || p.access_key).charAt(0).toUpperCase();
document.getElementById('profileAvatar').style.backgroundImage = 'none';
}
document.getElementById('profileName').textContent = p.name || p.access_key;
document.getElementById('profileUsername').textContent = p.username ? '@' + p.username : '@user';
document.getElementById('profileAK').textContent = p.access_key;
document.getElementById('cred-endpoint').textContent = p.endpoint;
document.getElementById('cred-ak').textContent = p.access_key;
if (document.getElementById('cred-sk')) {
document.getElementById('cred-sk').textContent = p.secret_key;
}
if (document.getElementById('cred-sk-inp')) {
document.getElementById('cred-sk-inp').value = p.secret_key;
}
if (document.getElementById('inp-update-name')) {
document.getElementById('inp-update-name').value = p.name || '';
}
if (document.getElementById('inp-update-username')) {
document.getElementById('inp-update-username').value = p.username || '';
}
document.getElementById('cred-cli-snippet').textContent =
`# 1. Create an isolated profile for Cosmos
aws configure set aws_access_key_id ${p.access_key} --profile unity
aws configure set aws_secret_access_key ${p.secret_key} --profile unity
aws configure set region us-east-1 --profile unity
# 2. List all available buckets
aws s3 ls \
--profile unity \
--endpoint-url ${p.endpoint}
# 3. Create a new bucket
aws s3 mb s3://my-new-bucket \
--profile unity \
--endpoint-url ${p.endpoint}
# 4. Upload assets to your bucket
aws s3 cp ./data.csv s3://my-new-bucket/ \
--profile unity \
--endpoint-url ${p.endpoint}`;
document.getElementById('cred-py-snippet').textContent =
`import boto3
from botocore.client import Config
from botocore.exceptions import ClientError
def get_s3_client():
"""Initialize and return a secure S3 client."""
return boto3.client(
's3',
endpoint_url='${p.endpoint}',
aws_access_key_id='${p.access_key}',
aws_secret_access_key='${p.secret_key}',
config=Config(signature_version='s3v4'),
region_name='us-east-1'
)
def upload_asset(file_path, bucket_name, object_name=None):
"""Upload a file securely to an S3 bucket."""
s3_client = get_s3_client()
object_name = object_name or file_path
try:
print(f"Uploading {file_path} to {bucket_name}...")
s3_client.upload_file(file_path, bucket_name, object_name)
print("Upload successful.")
except ClientError as e:
print(f"Error: {e}")
return False
return True
if __name__ == "__main__":
# Example: List available buckets
client = get_s3_client()
response = client.list_buckets()
buckets = [b['Name'] for b in response.get('Buckets', [])]
print("Available Buckets:", buckets)
`;
} catch (e) {
toast("populateAccount error: " + e.message, 'error');
document.getElementById('cred-cli-snippet').textContent = e.stack;
document.getElementById('cred-py-snippet').textContent = e.stack;
document.getElementById('profileName').textContent = e.message;
}
}
function copyText(elemId, isInput = false) {
const el = document.getElementById(elemId);
const txt = isInput ? el.value : el.textContent;
navigator.clipboard.writeText(txt).then(() => toast('Copied to clipboard'));
}
async function uploadProfileImage(input) {
if (!input.files || !input.files[0]) return;
const file = input.files[0];
const formData = new FormData();
formData.append('profile_image', file);
toast('Uploading profile image...');
const res = await fetch('/oort/api/profile/image', {
method: 'POST',
headers: { 'X-Session-Id': SID },
body: formData
});
if (res.ok) {
toast('Profile image updated successfully');
const p = await api('/oort/api/profile');
if (p) {
state.profile = p;
populateAccount();
if (p.profile_image) {
document.getElementById('sidebarAvatar').textContent = '';
document.getElementById('sidebarAvatar').style.backgroundImage = `url(${p.profile_image})`;
}
}
} else {
toast('Failed to upload image', true);
}
}
function switchPTab(tab) {
document.getElementById('ptab-general').style.borderColor = tab==='general' ? 'var(--accent)' : 'transparent';
document.getElementById('ptab-api').style.borderColor = tab==='api' ? 'var(--accent)' : 'transparent';
document.getElementById('ptab-quota').style.borderColor = tab==='quota' ? 'var(--accent)' : 'transparent';
document.getElementById('ptab-general').style.color = tab==='general' ? 'var(--text)' : 'var(--text2)';
document.getElementById('ptab-api').style.color = tab==='api' ? 'var(--text)' : 'var(--text2)';
document.getElementById('ptab-quota').style.color = tab==='quota' ? 'var(--text)' : 'var(--text2)';
document.getElementById('ptab-content-general').style.display = tab==='general' ? 'block' : 'none';
document.getElementById('ptab-content-api').style.display = tab==='api' ? 'block' : 'none';
document.getElementById('ptab-content-quota').style.display = tab==='quota' ? 'block' : 'none';
}
async function updateProfile() {
const name = document.getElementById('inp-update-name').value;
const username = document.getElementById('inp-update-username').value;
if (!name || !username) {
return toast('Name and username are required', true);
}
const res = await api('/oort/api/profile/update', {
method: 'POST',
body: JSON.stringify({ name, username })
});
if (res && res.success) {
toast('Profile updated successfully');
const p = await api('/oort/api/profile');
if (p) {
state.profile = p;
populateAccount();
}
}
}
function toggleSK() {
const inp = document.getElementById('cred-sk-inp');
inp.type = inp.type === 'password' ? 'text' : 'password';
}
async function uploadProfileImage(input) {
if (!input.files || !input.files[0]) return;
const file = input.files[0];
const formData = new FormData();
formData.append('profile_image', file);
toast('Uploading profile image...');
const res = await fetch('/oort/api/profile/image', {
method: 'POST',
headers: { 'X-Session-Id': SID },
body: formData
});
if (res.ok) {
toast('Profile image updated successfully');
const p = await api('/oort/api/profile');
if (p) {
state.profile = p;
populateAccount();
// Also update sidebar avatar
if (p.profile_image) {
document.getElementById('sidebarAvatar').textContent = '';
document.getElementById('sidebarAvatar').style.backgroundImage = `url(${p.profile_image})`;
}
}
} else {
toast('Failed to upload image', true);
}
}
async function requestQuota() {
const v = document.getElementById('quota-slider').value;
const btn = document.getElementById('btn-req-quota');
btn.disabled = true; btn.textContent = 'Submitting...';
const r = await api('/oort/api/quota', { method: 'POST', body: JSON.stringify({ amount: parseInt(v) }) });
if (r?.success) toast(`Expansion request for ${v} GB submitted to admin`);
btn.disabled = false; btn.textContent = 'Submit Expansion Request';
}
/* ─── BUCKETS ─────────────────────────────────────────────────────── */
async function loadBuckets() {
const r = await api('/oort/api/buckets');
if (!r) return;
state.buckets = r.buckets || [];
renderSidebarBuckets();
return state.buckets;
}
function renderSidebarBuckets() {
const el = document.getElementById('sidebar-buckets');
if (!state.buckets.length) {
el.innerHTML = `<div style="padding:6px 10px;font-size:12px;color:var(--text3)">No buckets yet</div>`;
return;
}
el.innerHTML = state.buckets.map(b => {
const disp = (b.DisplayName || b.Name).replace(/'/g, "\\'");
return `
<div class="nav-bucket" data-bucket="${b.Name}" onclick="switchView('browser','${b.Name}','')">
<div class="nav-bucket-icon">
<svg width="10" height="10" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
<span class="nav-bucket-name">${b.DisplayName || b.Name}</span>
<div style="display:flex; gap:4px;">
<button class="nav-bucket-del" onclick="event.stopPropagation();openRenameBucketModal('${b.Name}', '${disp}')" title="Rename bucket" style="color:var(--text3); display:inline-block; margin-right:4px;">
<svg width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
</button>
<button class="nav-bucket-del" onclick="event.stopPropagation();confirmDeleteBucket('${b.Name}')" title="Delete bucket">
<svg width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14H6L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4h6v2"/></svg>
</button>
</div>
</div>
`}).join('');
}
async function createBucket() {
const inp = document.getElementById('inp-new-bucket');
const name = inp.value.trim();
if (!name) return;
const btn = document.getElementById('btn-create-bucket');
btn.disabled = true; btn.textContent = 'Creating…';
const r = await api('/oort/api/buckets', { method: 'POST', body: JSON.stringify({ name }) });
if (r) {
toast(`Bucket "${name}" created`);
inp.value = '';
closeModal('modal-create-bucket');
await loadBuckets();
switchView('browser', r.name, '');
}
btn.disabled = false; btn.textContent = 'Create Bucket';
}
function confirmDeleteBucket(name) {
const typed = prompt(`⚠️ This will permanently delete bucket "${name}" and ALL its contents.\n\nType the bucket name to confirm:`);
if (typed === name) {
_deleteBucket(name);
} else if (typed !== null) {
toast('Name did not match — deletion cancelled', 'error');
}
}
async function deleteBucket() {
const sel = document.getElementById('sel-delete-bucket');
if (sel) confirmDeleteBucket(sel.value);
}
async function _deleteBucket(name) {
const r = await api(`/oort/api/buckets?bucket=${encodeURIComponent(name)}`, { method: 'DELETE' });
if (r) {
toast(`Bucket "${name}" deleted`);
if (state.bucket === name) state.bucket = '';
await loadBuckets();
if (state.buckets.length) switchView('browser', state.buckets[0].Name, '');
else switchView('dashboard');
}
}
/* ─── GLOBE ANIMATION ─────────────────────────────────────────────── */
const countryCoords = {
'US': {lat: 37.09, lng: -95.71, name: "United States"},
'GB': {lat: 55.37, lng: -3.43, name: "United Kingdom"},
'IN': {lat: 20.59, lng: 78.96, name: "India"},
'SG': {lat: 1.35, lng: 103.81, name: "Singapore"},
'DE': {lat: 51.16, lng: 10.45, name: "Germany"},
'FR': {lat: 46.22, lng: 2.21, name: "France"},
'JP': {lat: 36.20, lng: 138.25, name: "Japan"},
'AU': {lat: -25.27, lng: 133.77, name: "Australia"},
'BR': {lat: -14.23, lng: -51.92, name: "Brazil"}
};
let analyticsChart = null;
let worldTopo = null;
let globeTimer = null;
let currentRotation = [0, 0];
let d3GlobeInstance = null;
function clearAnalyticsFilters() {
const els = ['an-filter-bucket', 'an-filter-region', 'an-filter-op'];
els.forEach(id => {
const el = document.getElementById(id);
if (el) el.value = 'all';
});
const s = document.getElementById('an-filter-date-start');
const e = document.getElementById('an-filter-date-end');
if (s) s.value = '';
if (e) e.value = '';
loadAnalytics();
}
let storageBreakdownChart = null;
async function loadStorageBreakdown() {
const canv = document.getElementById('storageBreakdownChart');
if (!canv) return;
const bEl = document.getElementById('an-filter-bucket');
const b = bEl ? bEl.value : 'all';
const r = await api(`/oort/api/storage/breakdown?bucket=${encodeURIComponent(b)}`);
if (!r || !r.categories) return;
const cats = r.categories;
const labels = ['Images', 'Videos', 'Audio', 'Documents', 'Code', 'Archives', 'Other'];
const data = [
cats.images || 0,
cats.videos || 0,
cats.audio || 0,
cats.documents || 0,
cats.code || 0,
cats.archives || 0,
cats.other || 0
];
const colors = [
'#38bdf8', // Images - sky blue
'#a855f7', // Videos - purple
'#ec4899', // Audio - pink
'#10b981', // Documents - emerald
'#f59e0b', // Code - amber
'#6366f1', // Archives - indigo
'#64748b' // Other - slate
];
if (storageBreakdownChart) {
storageBreakdownChart.destroy();
}
const total = data.reduce((a, b) => a + b, 0);
storageBreakdownChart = new Chart(canv, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: total === 0 ? [1] : data,
backgroundColor: total === 0 ? ['rgba(255,255,255,0.06)'] : colors,
borderWidth: 2,
borderColor: '#0b0f17'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutout: '70%',
plugins: {
legend: {
position: 'right',
labels: {
color: '#94a3b8',
font: { size: 11 },
boxWidth: 10,
padding: 10
}
},
tooltip: {
callbacks: {
label: function(ctx) {
if (total === 0) return ' No files yet';
const val = data[ctx.dataIndex];
const pct = total > 0 ? ((val / total) * 100).toFixed(1) : 0;
return ` ${ctx.label}: ${fmtBytes(val)} (${pct}%)`;
}
}
}
}
}
});
}
async function loadAnalytics() {
const subtitle = document.getElementById('analytics-subtitle');
if(subtitle) subtitle.textContent = 'Loading metrics…';
const bEl = document.getElementById('an-filter-bucket');
const sEl = document.getElementById('an-filter-date-start');
const eEl = document.getElementById('an-filter-date-end');
const rEl = document.getElementById('an-filter-region');
const oEl = document.getElementById('an-filter-op');
const b = bEl ? bEl.value : 'all';
const dStart = sEl ? sEl.value : '';
const dEnd = eEl ? eEl.value : '';
const r_reg = rEl ? rEl.value : 'all';
const op = oEl ? oEl.value : 'all';
const r = await api(`/oort/api/analytics?bucket=${b}&start=${dStart}&end=${dEnd}&region=${r_reg}&op=${op}`);
const totalReq = r ? r.total_requests || 0 : 0;
const totalSucc = r ? r.total_success || 0 : 0;
const total4xx = r ? r.total_4xx || 0 : 0;
const total5xx = r ? r.total_5xx || 0 : 0;
const totalBytes = r ? r.total_bytes || 0 : 0;
const totalErrors = total4xx + total5xx;
const totalReqEl = document.getElementById('an-total-req');
if(totalReqEl) totalReqEl.textContent = totalReq.toLocaleString();
const bwEl = document.getElementById('an-bandwidth');
if(bwEl) bwEl.textContent = fmtBytes(totalBytes);
const succEl = document.getElementById('an-success-rate');
if(succEl) succEl.textContent = totalReq > 0 ? ((totalSucc / totalReq) * 100).toFixed(1) + '%' : '100%';
const errEl = document.getElementById('an-errors');
if(errEl) errEl.textContent = totalErrors.toLocaleString();
if(subtitle) subtitle.textContent = 'Real-time storage performance metrics';
const ts = r && r.timeseries ? r.timeseries : {labels:[], reqs:[]};
const canv = document.getElementById('analyticsChart');
if(canv) {
if (analyticsChart) { analyticsChart.destroy(); }
analyticsChart = new Chart(canv, {
type: 'line',
data: {
labels: ts.labels,
datasets: [
{ label: 'S3 Requests', data: ts.reqs, borderColor: '#8b5cf6', backgroundColor: 'rgba(139,92,246,0.08)', borderWidth: 2, fill: true, tension: 0.4, pointRadius: 2 }
]
},
options: {
responsive: true, maintainAspectRatio: false,
interaction: { mode: 'index', intersect: false },
plugins: { legend: { labels: { color: '#94a3b8', font: { size: 11 } } } },
scales: { x: { ticks: { color: '#64748b' } }, y: { ticks: { color: '#64748b' } } }
}
});
}
loadStorageBreakdown();
const tbody = document.getElementById('analytics-bucket-tbody');
const buckets = r ? (r.buckets || []) : [];
if (bEl && bEl.options.length <= 1 && buckets.length > 0) {
buckets.forEach(bk => {
const opt = document.createElement('option');
opt.value = bk.name; opt.textContent = bk.display;
bEl.appendChild(opt);
});
}
if(tbody) {
if (!buckets.length) {
tbody.innerHTML = '<tr><td colspan="6" style="text-align:center;padding:40px;color:var(--text3);">No data found.</td></tr>';
} else {
tbody.innerHTML = buckets.map(bk => {
const bCache = bk.requests > 0 ? ((bk.cache_hits / bk.requests) * 100).toFixed(1) : '0';
const lastHit = bk.last_hit ? new Date(bk.last_hit * 1000).toLocaleString() : 'Never';
return `<tr style="border-bottom:1px solid rgba(255,255,255,0.04);">
<td style="padding:14px 16px;font-weight:600;">${bk.display || bk.name}</td>
<td style="padding:14px 16px;text-align:right;">${(bk.requests||0).toLocaleString()}</td>
<td style="padding:14px 16px;text-align:right;"><span style="color:#34d399;">Active</span></td>
<td style="padding:14px 16px;text-align:right;color:${(bk.errors||0) > 0 ? '#f87171' : 'var(--text3)'}">${(bk.errors||0).toLocaleString()}</td>
<td style="padding:14px 16px;text-align:right;">${fmtBytes(bk.bytes||0)}</td>
<td style="padding:14px 16px;font-size:12px;color:var(--text3);">${lastHit}</td>
</tr>`;
}).join('');
}
}
if (r && r.globe && r.globe.length > 0) {
window.activeGlobeNodes = r.globe.map(g => {
let coords = countryCoords[g.country] || {lat: 37, lng: -95, name: g.country};
return { lat: coords.lat, lng: coords.lng, hits: g.hits, reads: g.reads, writes: g.writes, code: g.country, name: coords.name };
});
} else {
window.activeGlobeNodes = [];
}
const clist = document.getElementById('globe-country-list');
if(clist) {
clist.innerHTML = window.activeGlobeNodes.sort((a,b)=>b.hits - a.hits).map(n => {
return `<div style="padding:12px 14px; cursor:pointer; border-radius:8px; margin-bottom:8px; background:rgba(255,255,255,0.02); border:1px solid rgba(255,255,255,0.03); transition:all 0.2s ease;"
onmouseover="this.style.background='rgba(255,255,255,0.06)'; this.style.borderColor='rgba(255,255,255,0.1)'; focusGlobeCountry('${n.code}', true);"
onmouseout="this.style.background='rgba(255,255,255,0.02)'; this.style.borderColor='rgba(255,255,255,0.03)';"
onclick="focusGlobeCountry('${n.code}', false)">
<div style="font-weight:600; color:#fff; font-size:13px; margin-bottom:6px; display:flex; justify-content:space-between;">
<span>${n.name}</span>
<span style="color:var(--text2); font-weight:500;">${n.hits.toLocaleString()}</span>
</div>
<div style="display:flex; justify-content:space-between; color:var(--text3); font-size:11.5px; font-weight:600;">
<span style="display:flex; align-items:center; gap:5px;"><span style="display:inline-block;width:6px;height:6px;border-radius:50%;background:#10b981;box-shadow:0 0 6px rgba(16,185,129,0.5);"></span>R: ${(n.reads||0).toLocaleString()}</span>
<span style="display:flex; align-items:center; gap:5px;"><span style="display:inline-block;width:6px;height:6px;border-radius:50%;background:#f59e0b;box-shadow:0 0 6px rgba(245,158,11,0.5);"></span>W: ${(n.writes||0).toLocaleString()}</span>
</div>
</div>`;
}).join('');
}
if (!worldTopo) {
worldTopo = {"type":"Topology","objects":{"countries":{"type":"GeometryCollection","geometries":[{"type":"MultiPolygon","arcs":[[[0]],[[1]]],"id":"242","properties":{"name":"Fiji"}},{"type":"Polygon","arcs":[[2,3,4,5,6,7,8,9,10]],"id":"834","properties":{"name":"Tanzania"}},{"type":"Polygon","arcs":[[11,12,13,14]],"id":"732","properties":{"name":"W. Sahara"}},{"type":"MultiPolygon","arcs":[[[15,16,17,18]],[[19]],[[20]],[[21]],[[22]],[[23]],[[24]],[[25]],[[26]],[[27]],[[28]],[[29]],[[30]],[[31]],[[32]],[[33]],[[34]],[[35]],[[36]],[[37]],[[38]],[[39]],[[40]],[[41]],[[42]],[[43]],[[44]],[[45]],[[46]],[[47]]],"id":"124","properties":{"name":"Canada"}},{"type":"MultiPolygon","arcs":[[[-19,48,49,50]],[[51]],[[52]],[[53]],[[54]],[[55]],[[56]],[[57]],[[-17,58]],[[59]]],"id":"840","properties":{"name":"United States of America"}},{"type":"Polygon","arcs":[[60,61,62,63,64,65]],"id":"398","properties":{"name":"Kazakhstan"}},{"type":"Polygon","arcs":[[-63,66,67,68,69]],"id":"860","properties":{"name":"Uzbekistan"}},{"type":"MultiPolygon","arcs":[[[70,71]],[[72]],[[73]],[[74]]],"id":"598","properties":{"name":"Papua New Guinea"}},{"type":"MultiPolygon","arcs":[[[-72,75]],[[76,77]],[[78]],[[79,80]],[[81]],[[82]],[[83]],[[84]],[[85]],[[86]],[[87]],[[88]],[[89]]],"id":"360","properties":{"name":"Indonesia"}},{"type":"MultiPolygon","arcs":[[[90,91]],[[92,93,94,95,96,97]]],"id":"032","properties":{"name":"Argentina"}},{"type":"MultiPolygon","arcs":[[[-92,98]],[[99,-95,100,101]]],"id":"152","properties":{"name":"Chile"}},{"type":"Polygon","arcs":[[-8,102,103,104,105,106,107,108,109,110,111]],"id":"180","properties":{"name":"Dem. Rep. Congo"}},{"type":"Polygon","arcs":[[112,113,114,115]],"id":"706","properties":{"name":"Somalia"}},{"type":"Polygon","arcs":[[-3,116,117,118,-113,119]],"id":"404","properties":{"name":"Kenya"}},{"type":"Polygon","arcs":[[120,121,122,123,124,125,126,127]],"id":"729","properties":{"name":"Sudan"}},{"type":"Polygon","arcs":[[-122,128,129,130,131]],"id":"148","properties":{"name":"Chad"}},{"type":"Polygon","arcs":[[132,133]],"id":"332","properties":{"name":"Haiti"}},{"type":"Polygon","arcs":[[-133,134]],"id":"214","properties":{"name":"Dominican Rep."}},{"type":"MultiPolygon","arcs":[[[135]],[[136]],[[137]],[[138]],[[139]],[[140]],[[141,142,143]],[[144]],[[145]],[[146,147,148,149,-66,150,151,152,153,154,155,156,157,158,159,160,161]],[[162]],[[163,164]]],"id":"643","properties":{"name":"Russia"}},{"type":"MultiPolygon","arcs":[[[165]],[[166]],[[167]]],"id":"044","properties":{"name":"Bahamas"}},{"type":"Polygon","arcs":[[168]],"id":"238","properties":{"name":"Falkland Is."}},{"type":"MultiPolygon","arcs":[[[169]],[[-161,170,171,172]],[[173]],[[174]]],"id":"578","properties":{"name":"Norway"}},{"type":"Polygon","arcs":[[175]],"id":"304","properties":{"name":"Greenland"}},{"type":"Polygon","arcs":[[176]],"id":"260","properties":{"name":"Fr. S. Antarctic Lands"}},{"type":"Polygon","arcs":[[177,-77]],"id":"626","properties":{"name":"Timor-Leste"}},{"type":"Polygon","arcs":[[178,179,180,181,182,183,184],[185]],"id":"710","properties":{"name":"South Africa"}},{"type":"Polygon","arcs":[[-186]],"id":"426","properties":{"name":"Lesotho"}},{"type":"Polygon","arcs":[[-50,186,187,188,189]],"id":"484","properties":{"name":"Mexico"}},{"type":"Polygon","arcs":[[190,191,-93]],"id":"858","properties":{"name":"Uruguay"}},{"type":"Polygon","arcs":[[-191,-98,192,193,194,195,196,197,198,199,200]],"id":"076","properties":{"name":"Brazil"}},{"type":"Polygon","arcs":[[-194,201,-96,-100,202]],"id":"068","properties":{"name":"Bolivia"}},{"type":"Polygon","arcs":[[-195,-203,-102,203,204,205]],"id":"604","properties":{"name":"Peru"}},{"type":"Polygon","arcs":[[-196,-206,206,207,208,209,210]],"id":"170","properties":{"name":"Colombia"}},{"type":"Polygon","arcs":[[-209,211,212,213]],"id":"591","properties":{"name":"Panama"}},{"type":"Polygon","arcs":[[-213,214,215,216]],"id":"188","properties":{"name":"Costa Rica"}},{"type":"Polygon","arcs":[[-216,217,218,219]],"id":"558","properties":{"name":"Nicaragua"}},{"type":"Polygon","arcs":[[-219,
;
}
startGlobeD3();
}
let hoverFilterTimer = null;
let smoothRotateTimer = null;
let targetRotation = null;
let lockedCountry = null;
function focusGlobeCountry(code, isHover) {
const node = window.activeGlobeNodes.find(n => n.code === code);
if(node && d3GlobeInstance) {
if (isHover) {
if (lockedCountry) return; // Don't hover-override if clicked
d3GlobeInstance.stop();
d3GlobeInstance.smoothRotateTo([-node.lng, -node.lat]);
if(hoverFilterTimer) clearTimeout(hoverFilterTimer);
hoverFilterTimer = setTimeout(() => {
const rEl = document.getElementById('an-filter-region');
if(rEl && rEl.value !== code) {
rEl.value = code;
loadAnalytics();
}
}, 400);
} else {
// Click unlocks if already locked to the same, else locks
if (lockedCountry === code) {
lockedCountry = null;
clearHoverFilter();
return;
}
lockedCountry = code;
if(hoverFilterTimer) clearTimeout(hoverFilterTimer);
const rEl = document.getElementById('an-filter-region');
if(rEl) rEl.value = code;
loadAnalytics();
d3GlobeInstance.stop();
d3GlobeInstance.smoothRotateTo([-node.lng, -node.lat]);
}
}
}
function clearHoverFilter() {
if (lockedCountry) return; // Don't clear if locked
if(hoverFilterTimer) clearTimeout(hoverFilterTimer);
hoverFilterTimer = setTimeout(() => {
const rEl = document.getElementById('an-filter-region');
if(rEl && rEl.value !== 'all') {
rEl.value = 'all';
loadAnalytics();
if(d3GlobeInstance) d3GlobeInstance.resume();
}
}, 500);
}
function startGlobeD3() {
const canvas = document.getElementById('globeCanvas');
if (!canvas || !window.d3 || !worldTopo) return;
const ctx = canvas.getContext('2d');
const width = canvas.width;
const height = canvas.height;
const projection = d3.geoOrthographic()
.scale(Math.min(width, height) / 2.2)
.translate([width / 2, height / 2])
.clipAngle(90)
.precision(0.6);
const path = d3.geoPath().projection(projection).context(ctx);
const sphere = {type: "Sphere"};
const land = topojson.feature(worldTopo, worldTopo.objects.land);
let autoRotate = true;
function render() {
ctx.clearRect(0, 0, width, height);
ctx.beginPath();
path(sphere);
ctx.fillStyle = "rgba(10, 10, 30, 0.95)";
ctx.fill();
ctx.lineWidth = 1;
ctx.strokeStyle = "rgba(124,58,237,0.4)";
ctx.stroke();
ctx.beginPath();
path(land);
ctx.fillStyle = "rgba(255,255,255,0.06)";
ctx.fill();
ctx.lineWidth = 0.5;
ctx.strokeStyle = "rgba(255,255,255,0.15)";
ctx.stroke();
const maxHits = Math.max(...(window.activeGlobeNodes.map(n=>n.hits).length ? window.activeGlobeNodes.map(n=>n.hits) : [1]));
const center = projection.invert([width/2, height/2]); // The coordinates currently in the center of the viewport
window.activeGlobeNodes.forEach(n => {
const coords = projection([n.lng, n.lat]);
if(coords) {
// Calculate angular distance to determine if node is on the front or back
const distance = d3.geoDistance(center, [n.lng, n.lat]);
const isFront = distance < Math.PI / 2;
const intensity = maxHits > 0 ? (n.hits / maxHits) : 0.5;
const r = 3 + intensity * 8;
const alpha = isFront ? 0.8 : 0.05; // Translucent if on the back
const coreAlpha = isFront ? 1.0 : 0.1;
const grad = ctx.createRadialGradient(coords[0], coords[1], 0, coords[0], coords[1], r*2);
grad.addColorStop(0, `rgba(6,182,212,${alpha})`);
grad.addColorStop(1, "rgba(6,182,212,0)");
ctx.beginPath();
ctx.arc(coords[0], coords[1], r*2, 0, 2*Math.PI);
ctx.fillStyle = grad;
ctx.fill();
ctx.beginPath();
ctx.arc(coords[0], coords[1], r, 0, 2*Math.PI);
ctx.fillStyle = `rgba(6,182,212,${coreAlpha})`;
ctx.fill();
}
});
}
let currentScale = Math.min(width, height) / 2.2;
const minScale = Math.min(width, height) / 4;
const maxScale = Math.min(width, height) * 2;
canvas.addEventListener('wheel', (e) => {
if (e.ctrlKey || e.metaKey) {
e.preventDefault();
const zoomFactor = e.deltaY > 0 ? 0.9 : 1.1;
currentScale *= zoomFactor;
if (currentScale < minScale) currentScale = minScale;
if (currentScale > maxScale) currentScale = maxScale;
projection.scale(currentScale);
render();
}
}, { passive: false });
let dragTimeout = null;
d3.select(canvas).call(d3.drag()
.on("start", (event) => {
autoRotate = false;
targetRotation = null;
if(dragTimeout) clearTimeout(dragTimeout);
})
.on("drag", (event) => {
const r = projection.rotate();
projection.rotate([r[0] + event.dx/2, r[1] - event.dy/2]);
currentRotation = projection.rotate();
render();
})
.on("end", (event) => {
dragTimeout = setTimeout(() => { autoRotate = true; }, 2000);
})
);
if(globeTimer) globeTimer.stop();
globeTimer = d3.timer((elapsed) => {
if (targetRotation) {
// Smooth interpolation
const interpolator = d3.interpolate(currentRotation, targetRotation);
currentRotation = interpolator(0.08); // easing factor
projection.rotate(currentRotation);
// Stop interpolating if very close
const diff = Math.abs(currentRotation[0] - targetRotation[0]) + Math.abs(currentRotation[1] - targetRotation[1]);
if(diff < 0.1) {
currentRotation = targetRotation;
targetRotation = null;
}
} else if (autoRotate) {
currentRotation[0] += 0.2;
projection.rotate(currentRotation);
}
render();
});
d3GlobeInstance = {
stop: () => { autoRotate = false; targetRotation = null; },
resume: () => { autoRotate = true; },
rotateTo: (rot) => {
currentRotation = rot;
targetRotation = null;
projection.rotate(rot);
render();
},
smoothRotateTo: (rot) => {
targetRotation = rot;
}
};
}
/* ─── DASHBOARD/* ─── DASHBOARD ───────────────────────────────────────────────────── */
async function loadDashboard() {
const savedBucket = state.bucket || (state.buckets[0] && state.buckets[0].Name) || '';
const origBucket = state.bucket;
if (!savedBucket) {
document.getElementById('dash-subtitle').textContent = 'No buckets — create one to get started.';
return;
}
// Sum stats across all buckets
let totalSize = 0, totalObjects = 0;
for (const b of state.buckets) {
state.bucket = b.Name;
const st = await api(`/oort/api/stats?bucket=${encodeURIComponent(b.Name)}`);
if (st) {
totalSize += st.total_size || 0;
totalObjects += st.object_count || 0;
// Use the real quota from the API (accumulated across buckets)
if (st.quota && st.quota > 0) QUOTA = Math.max(QUOTA, st.quota);
}
}
state.bucket = origBucket || savedBucket;
const pct = Math.min(100, (totalSize / QUOTA) * 100);
document.getElementById('dash-used').textContent = fmtBytes(totalSize);
document.getElementById('dash-used-pct').textContent = `${pct.toFixed(1)}% of ${fmtBytes(QUOTA)} used`;
document.getElementById('dash-objects').textContent = totalObjects.toLocaleString();
document.getElementById('dash-buckets').textContent = state.buckets.length;
document.getElementById('dash-avail').textContent = fmtBytes(Math.max(0, QUOTA - totalSize));
const hardLbl = document.getElementById('quota-hard-limit-label');
if (hardLbl) hardLbl.textContent = `Hard limit: ${fmtBytes(QUOTA)}`;
// Update quota slider min to be just above current quota
const quotaGB = Math.ceil(QUOTA / (1024*1024*1024));
const slider = document.getElementById('quota-slider');
if (slider) {
const newMin = Math.min(quotaGB + 1, 500);
slider.min = newMin;
slider.max = Math.max(500, quotaGB + 100);
if (parseInt(slider.value) <= quotaGB) slider.value = newMin;
const lbl = document.getElementById('quota-val-lbl');
if (lbl) lbl.textContent = slider.value + ' GB';
}
document.getElementById('dash-subtitle').textContent = `Last refreshed: ${new Date().toLocaleTimeString()}`;
const qf = document.getElementById('quota-fill');
qf.style.width = pct + '%';
if (pct > 80) qf.classList.add('warning'); else qf.classList.remove('warning');
document.getElementById('quota-label-used').textContent = fmtBytes(totalSize) + ' used';
document.getElementById('quota-label-pct').textContent = pct.toFixed(1) + '%';
renderUsageChart(totalSize, QUOTA - totalSize);
loadDashStorageBreakdown();
const bl = document.getElementById('dash-bucket-list');
if (state.buckets.length === 0) {
bl.innerHTML = `<div style="color:var(--text3);font-size:13px">No buckets. <button class="btn btn-ghost btn-sm" onclick="openModal('modal-create-bucket')">Create one</button></div>`;
} else {
bl.innerHTML = state.buckets.map(b => `
<div style="display:flex;align-items:center;gap:10px;padding:8px 0;border-bottom:1px solid var(--border);cursor:pointer" onclick="switchView('browser','${b.Name}','')">
<div style="width:32px;height:32px;border-radius:8px;background:var(--surface3);display:flex;align-items:center;justify-content:center;flex-shrink:0">
<svg width="14" height="14" fill="none" stroke="var(--blue)" stroke-width="2" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg>
</div>
<div style="flex:1;overflow:hidden">
<div style="font-weight:500;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${b.Name}</div>
</div>
<svg width="14" height="14" fill="none" stroke="var(--text3)" stroke-width="2" viewBox="0 0 24 24"><polyline points="9 18 15 12 9 6"/></svg>
</div>
`).join('');
}
}
function renderUsageChart(used, free) {
const ctx = document.getElementById('usageChart').getContext('2d');
if (state.chartInst) state.chartInst.destroy();
state.chartInst = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Used', 'Available'],
datasets: [{
data: [used, Math.max(0, free)],
backgroundColor: ['#3b82f6', '#1e1e24'],
borderWidth: 0, hoverOffset: 4,
}]
},
options: {
responsive: true, maintainAspectRatio: false, cutout: '78%',
plugins: {
legend: { position: 'bottom', labels: { color: '#71717a', font: { size: 12 } } },
tooltip: { callbacks: { label: ctx => fmtBytes(ctx.raw) } }
}
}
});
}
let dashBreakdownChartInst = null;
async function loadDashStorageBreakdown() {
const canv = document.getElementById('dashStorageBreakdownChart');
if (!canv) return;
const pillsEl = document.getElementById('dash-breakdown-pills');
const totalEl = document.getElementById('dash-breakdown-total');
try {
const r = await api('/oort/api/storage/breakdown?bucket=all');
if (!r || !r.categories) return;
const cats = r.categories;
const catMeta = [
{ key: 'images', label: 'Images', color: '#38bdf8' },
{ key: 'videos', label: 'Videos', color: '#a855f7' },
{ key: 'audio', label: 'Audio', color: '#ec4899' },
{ key: 'documents', label: 'Docs', color: '#10b981' },
{ key: 'code', label: 'Code', color: '#f59e0b' },
{ key: 'archives', label: 'Archives', color: '#6366f1' },
{ key: 'other', label: 'Other', color: '#64748b' }
];
const labels = catMeta.map(c => c.label);
const data = catMeta.map(c => cats[c.key] || 0);
const colors = catMeta.map(c => c.color);
const totalBytes = data.reduce((a, b) => a + b, 0);
if (totalEl) {
totalEl.textContent = fmtBytes(totalBytes);
}
if (dashBreakdownChartInst) {
dashBreakdownChartInst.destroy();
dashBreakdownChartInst = null;
}
dashBreakdownChartInst = new Chart(canv, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: totalBytes === 0 ? [1] : data,
backgroundColor: totalBytes === 0 ? ['rgba(255,255,255,0.06)'] : colors,
borderWidth: 2,
borderColor: '#0b0f17'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
cutout: '72%',
plugins: {
legend: { display: false },
tooltip: {
callbacks: {
label: function(ctx) {
if (totalBytes === 0) return ' No files yet';
const val = data[ctx.dataIndex];
const pct = totalBytes > 0 ? ((val / totalBytes) * 100).toFixed(1) : 0;
return ` ${ctx.label}: ${fmtBytes(val)} (${pct}%)`;
}
}
}
}
}
});
if (pillsEl) {
if (totalBytes === 0) {
pillsEl.innerHTML = '<span style="color:var(--text3);font-size:11.5px;">No stored files yet</span>';
} else {
pillsEl.innerHTML = catMeta.filter(c => (cats[c.key] || 0) > 0).map(c => {
const val = cats[c.key] || 0;
const pct = ((val / totalBytes) * 100).toFixed(0);
return `<span style="display:inline-flex;align-items:center;gap:5px;padding:3px 8px;border-radius:999px;background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.07);color:var(--text2);font-size:11px;">
<span style="width:6px;height:6px;border-radius:50%;background:${c.color};display:inline-block;"></span>
${c.label} <strong style="color:#fff;">${pct}%</strong>
</span>`;
}).join('');
}
}
} catch(e) {
console.error('Error loading dashboard storage breakdown:', e);
}
}
/* ─── OBJECTS / FILE BROWSER ──────────────────────────────────────── */
let uiMode = 'drive';
/* ─── MODE SWITCHER ──────────────────────────────────────────────── */
function setMode(mode, skipAnim = false) {
const wasS3 = (uiMode === 's3');
const isS3 = (mode === 's3');
if (wasS3 === isS3 && !skipAnim) return; // no change
uiMode = mode;
document.getElementById('mode-toggle').checked = isS3;
localStorage.setItem('unity_ui_mode', mode);
// Update pill buttons
const pillDrive = document.getElementById('pill-drive');
const pillS3 = document.getElementById('pill-s3');
if (pillDrive && pillS3) {
if (isS3) {
pillDrive.style.background = 'transparent';
pillDrive.style.color = 'rgba(255,255,255,0.55)';
pillDrive.style.boxShadow = 'none';
pillS3.style.background = 'linear-gradient(135deg,#7c3aed,#4f46e5)';
pillS3.style.color = 'white';
pillS3.style.boxShadow = '0 2px 8px rgba(124,58,237,0.4)';
} else {
pillS3.style.background = 'transparent';
pillS3.style.color = 'rgba(255,255,255,0.55)';
pillS3.style.boxShadow = 'none';
pillDrive.style.background = 'linear-gradient(135deg,#7c3aed,#4f46e5)';
pillDrive.style.color = 'white';
pillDrive.style.boxShadow = '0 2px 8px rgba(124,58,237,0.4)';
}
}
// Show transition overlay
const layer = document.getElementById('mode-transition-layer');
const txt = document.getElementById('transition-text');
if (!skipAnim && layer && txt) {
txt.textContent = isS3
? 'Switching to S3 Object Storage…'
: 'Switching to Cloud Drive…';
layer.style.pointerEvents = 'all';
layer.style.opacity = '1';
}
setTimeout(() => {
/* ── Update every piece of terminology in the UI ── */
// Sidebar section label (first one is the buckets section)
const sectionLabels = document.querySelectorAll('.sidebar-section-label');
if (sectionLabels[0]) {
sectionLabels[0].textContent = isS3 ? 'Buckets' : 'Drives';
}
// "Create bucket" link in sidebar
const createBucketLink = document.querySelector('.sidebar-create-bucket span');
if (createBucketLink) {
createBucketLink.textContent = isS3 ? 'Create bucket' : 'Create drive';
}
// "Create bucket" modal title
const cbTitle = document.querySelector('#modal-create-bucket .modal-title');
if (cbTitle) cbTitle.textContent = isS3 ? 'Create Bucket' : 'Create Drive';
// Stat card labels
const bucketsLabel = document.querySelector('[id="dash-buckets"] + .stat-card-meta, .stat-card-label');
// Direct: find the stat card that contains dash-buckets
const dashBuckets = document.getElementById('dash-buckets');
if (dashBuckets) {
const card = dashBuckets.closest('.stat-card');
if (card) {
const label = card.querySelector('.stat-card-label');
if (label) label.textContent = isS3 ? 'Buckets' : 'Drives';
const meta = card.querySelector('.stat-card-meta');
if (meta) meta.textContent = isS3 ? 'Active buckets' : 'Active drives';
}
}
// Dashboard bucket list card
const dbl = document.getElementById('dash-bucket-list');
if (dbl) {
const cardTitle = dbl.closest('.chart-card')?.querySelector('.chart-card-title');
const cardSub = dbl.closest('.chart-card')?.querySelector('.chart-card-sub');
if (cardTitle) cardTitle.textContent = isS3 ? 'Buckets' : 'Drives';
if (cardSub) cardSub.textContent = isS3 ? 'Your storage buckets' : 'Your cloud drives';
}
// Dashboard page title subtitle
const pageSub = document.querySelector('.page-subtitle');
if (pageSub) {
pageSub.textContent = isS3
? 'S3-compatible object storage overview'
: 'Cloud drive storage overview';
}
// User role in sidebar
const roleLabel = document.querySelector('.user-role');
if (roleLabel) roleLabel.textContent = isS3 ? 'S3 Object Storage' : 'Cloud Drive';
// Browser "New Folder" button — only show in Drive mode
const mkdirBtn = document.querySelector('[onclick="openModal(\'modal-mkdir\')"]');
if (mkdirBtn) mkdirBtn.style.display = isS3 ? 'none' : '';
// Reset prefix if going to S3 mode (flat)
if (isS3) state.prefix = '';
// Re-render sidebar buckets with correct terminology
loadBuckets();
loadDashboard();
const finishTransition = () => {
setTimeout(() => {
if (layer) {
layer.style.opacity = '0';
layer.style.pointerEvents = 'none';
}
}, 300);
};
if (document.getElementById('view-browser')?.classList.contains('active')) {
loadObjects().then(finishTransition).catch(finishTransition);
} else {
finishTransition();
}
}, skipAnim ? 0 : 500);
}
/* Keep backward compat for any old code calling toggleUIMode */
function toggleUIMode(skipAnim = false) {
const isS3 = document.getElementById('mode-toggle').checked;
setMode(isS3 ? 's3' : 'drive', skipAnim);
}
async function deleteObject(key) {
if (!confirm(`Are you sure you want to delete "${key}"?`)) return;
const apiPath = `/oort/api/delete?bucket=${encodeURIComponent(state.bucket)}&key=${encodeURIComponent(key)}`;
const r = await api(apiPath, { method: 'DELETE' });
if (r) {
toast(`Deleted "${key}"`, 'success');
loadObjects();
}
}
async function downloadFile(key) {
const r = await api(`/oort/api/presign?bucket=${encodeURIComponent(state.bucket)}&key=${encodeURIComponent(key)}`);
if (r && r.url) {
const a = document.createElement('a');
a.href = r.url;
a.download = key.split('/').pop();
a.target = '_blank';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
toast('Download started');
}
}
/* ─── SECURE EXPIRING SHARE LINKS ─── */
let currentShareKey = '';
function shareFile(key) {
openShareModal(key);
}
function openShareModal(key) {
currentShareKey = key;
const keyEl = document.getElementById('share-target-key');
if (keyEl) keyEl.textContent = key;
const expEl = document.getElementById('share-expire-select');
if (expEl) expEl.value = '86400';
const pwdEl = document.getElementById('share-password');
if (pwdEl) pwdEl.value = '';
const dlEl = document.getElementById('share-max-dl');
if (dlEl) dlEl.value = '0';
const resWrap = document.getElementById('share-result-wrap');
if (resWrap) resWrap.style.display = 'none';
const resUrl = document.getElementById('share-result-url');
if (resUrl) resUrl.value = '';
const btn = document.getElementById('btn-create-share');
if (btn) {
btn.disabled = false;
btn.textContent = 'Generate Link';
}
openModal('modal-share-link');
}
async function generateShareLink() {
if (!currentShareKey) return;
const expireSeconds = parseInt(document.getElementById('share-expire-select').value || '86400', 10);
const password = document.getElementById('share-password').value;
const maxDownloads = parseInt(document.getElementById('share-max-dl').value || '0', 10);
const btn = document.getElementById('btn-create-share');
if (btn) {
btn.disabled = true;
btn.textContent = 'Generating…';
}
const r = await api('/oort/api/shares/create', {
method: 'POST',
body: JSON.stringify({
bucket: state.bucket,
object_key: currentShareKey,
expire_seconds: expireSeconds,
password: password,
max_downloads: maxDownloads
})
});
if (btn) {
btn.disabled = false;
btn.textContent = 'Generate Link';
}
if (r && r.url) {
document.getElementById('share-result-wrap').style.display = 'block';
document.getElementById('share-result-url').value = r.url;
toast('Secure share link created!');
}
}
function copyShareResultURL() {
const url = document.getElementById('share-result-url').value;
if (!url) return;
navigator.clipboard.writeText(url).then(() => {
toast('Link copied to clipboard!');
}).catch(() => {
prompt('Share Link:', url);
});
}
function openShareFromPreview() {
if (currentPreviewKey) {
openShareModal(currentPreviewKey);
}
}
/* ─── IN-BROWSER PREVIEW & CODE/MARKDOWN EDITOR ─── */
let currentPreviewKey = '';
async function previewFile(key) {
currentPreviewKey = key;
const titleEl = document.getElementById('preview-title');
const badgeEl = document.getElementById('preview-badge');
const saveBtn = document.getElementById('btn-save-preview');
const bodyEl = document.getElementById('preview-body');
const fileName = key.split('/').pop();
if (titleEl) titleEl.textContent = fileName;
const ext = (fileName.split('.').pop() || '').toLowerCase();
if (badgeEl) badgeEl.textContent = ext ? ext.toUpperCase() : 'FILE';
if (saveBtn) saveBtn.style.display = 'none';
const previewUrl = `/oort/api/preview?bucket=${encodeURIComponent(state.bucket)}&key=${encodeURIComponent(key)}`;
const isImg = /^(jpg|jpeg|png|gif|webp|svg|bmp|ico|avif)$/.test(ext);
const isVideo = /^(mp4|webm|mov|mkv|avi|ogv)$/.test(ext);
const isAudio = /^(mp3|wav|ogg|flac|aac|m4a)$/.test(ext);
const isPdf = ext === 'pdf';
const isText = /^(txt|md|json|yaml|yml|xml|csv|log|sh|js|ts|jsx|tsx|py|go|java|html|css|sql|conf|env|ini|toml|c|cpp|h|rs|php|rb)$/.test(ext);
openModal('modal-preview-editor');
if (isImg) {
bodyEl.innerHTML = `<div style="padding:24px; display:flex; align-items:center; justify-content:center; width:100%; height:100%;">
<img src="${previewUrl}" alt="${fileName}" style="max-width:100%; max-height:75vh; object-fit:contain; border-radius:8px; box-shadow:0 8px 32px rgba(0,0,0,0.5);">
</div>`;
} else if (isVideo) {
bodyEl.innerHTML = `<div style="padding:24px; width:100%; height:100%; display:flex; align-items:center; justify-content:center;">
<video src="${previewUrl}" controls autoplay style="max-width:100%; max-height:75vh; border-radius:8px; box-shadow:0 8px 32px rgba(0,0,0,0.5);"></video>
</div>`;
} else if (isAudio) {
bodyEl.innerHTML = `<div style="padding:60px 24px; width:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:20px;">
<div style="font-size:48px;">🎵</div>
<div style="font-weight:600; font-size:16px; color:#fff;">${fileName}</div>
<audio src="${previewUrl}" controls autoplay style="width:360px; max-width:100%;"></audio>
</div>`;
} else if (isPdf) {
bodyEl.innerHTML = `<iframe src="${previewUrl}" style="width:100%; height:75vh; border:none; background:#fff; border-radius:4px;"></iframe>`;
} else if (isText) {
bodyEl.innerHTML = `<div style="padding:40px; color:var(--text3); font-size:13px;">Loading file content…</div>`;
if (saveBtn) saveBtn.style.display = 'inline-flex';
try {
const resp = await fetch(previewUrl, { headers: { 'X-Session-Id': SID } });
if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
const text = await resp.text();
bodyEl.innerHTML = `<textarea id="preview-editor-textarea" spellcheck="false" style="width:100%; height:75vh; background:#0b0f17; color:#f1f5f9; font-family:var(--mono); font-size:13px; line-height:1.6; padding:20px; border:none; outline:none; resize:none; tab-size:2;"></textarea>`;
const ta = document.getElementById('preview-editor-textarea');
if (ta) ta.value = text;
} catch(err) {
bodyEl.innerHTML = `<div style="padding:40px; color:#f87171;">Failed to load file text: ${err.message}</div>`;
}
} else {
// Non-previewable
bodyEl.innerHTML = `<div style="padding:60px 24px; text-align:center; color:var(--text2);">
<div style="font-size:48px; margin-bottom:12px;">📁</div>
<div style="font-weight:600; font-size:16px; margin-bottom:6px;">Preview not supported for this file type</div>
<div style="font-size:13px; color:var(--text3); margin-bottom:20px;">You can download this file to view it on your workstation.</div>
<button class="btn btn-primary" onclick="downloadPreviewFile()">Download File</button>
</div>`;
}
}
async function savePreviewContent() {
const ta = document.getElementById('preview-editor-textarea');
if (!ta || !currentPreviewKey) return;
const btn = document.getElementById('btn-save-preview');
const oldText = btn.innerHTML;
btn.disabled = true;
btn.textContent = 'Saving…';
const r = await api('/oort/api/preview/save', {
method: 'POST',
body: JSON.stringify({
bucket: state.bucket,
key: currentPreviewKey,
content: ta.value
})
});
btn.disabled = false;
btn.innerHTML = oldText;
if (r) {
toast(`Saved and uploaded new version of ${currentPreviewKey.split('/').pop()}!`);
loadObjects();
}
}
function downloadPreviewFile() {
if (currentPreviewKey) {
downloadFile(currentPreviewKey);
}
}
/* ─── STATIC WEBSITE HOSTING ─── */
function toggleSiteInputs(enabled) {
const f = document.getElementById('site-config-fields');
if (f) f.style.display = enabled ? 'flex' : 'none';
}
async function loadSiteConfig() {
const chk = document.getElementById('site-setting-enabled');
if (!chk) return;
const r = await api(`/oort/api/bucket/website?bucket=${encodeURIComponent(state.bucket)}`);
const enabled = r && !!r.enabled;
chk.checked = enabled;
toggleSiteInputs(enabled);
if (r) {
const idx = document.getElementById('site-index-doc');
const err = document.getElementById('site-error-doc');
const spa = document.getElementById('site-spa-mode');
if (idx) idx.value = r.index_doc || 'index.html';
if (err) err.value = r.error_doc || '404.html';
if (spa) spa.checked = !!r.spa_mode;
}
const hostLink = document.getElementById('site-hosted-url');
if (hostLink) {
hostLink.href = `/oort/site/${encodeURIComponent(state.bucket)}/`;
}
}
async function saveSiteConfig() {
const chk = document.getElementById('site-setting-enabled');
const enabled = chk ? chk.checked : false;
const idx = document.getElementById('site-index-doc');
const err = document.getElementById('site-error-doc');
const spa = document.getElementById('site-spa-mode');
const indexDoc = idx ? idx.value.trim() || 'index.html' : 'index.html';
const errorDoc = err ? err.value.trim() || '404.html' : '404.html';
const spaMode = spa ? spa.checked : false;
const r = await api('/oort/api/bucket/website', {
method: 'POST',
body: JSON.stringify({
bucket: state.bucket,
enabled: enabled,
index_doc: indexDoc,
error_doc: errorDoc,
spa_mode: spaMode
})
});
if (r) {
toast('Static website settings saved successfully!');
}
}
/* ─── S3 EVENT WEBHOOKS ─── */
async function loadWebhooks() {
const listEl = document.getElementById('bucket-webhooks-list');
if (!listEl) return;
listEl.innerHTML = '<div style="color:var(--text3); padding:8px;">Loading webhooks…</div>';
const r = await api(`/oort/api/bucket/webhooks?bucket=${encodeURIComponent(state.bucket)}`);
if (!r || !r.webhooks || !r.webhooks.length) {
listEl.innerHTML = '<div style="color:var(--text3); font-size:12px; padding:6px 0;">No webhooks configured for this bucket.</div>';
return;
}
listEl.innerHTML = r.webhooks.map(w => {
const evts = (w.events || []).join(', ');
return `
<div style="display:flex; align-items:center; justify-content:space-between; padding:10px 12px; background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.06); border-radius:8px; margin-bottom:8px;">
<div style="min-width:0; flex:1; margin-right:12px;">
<div style="font-weight:600; font-size:13px; color:var(--text); font-family:var(--mono); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">${w.target_url}</div>
<div style="font-size:11px; color:var(--text3); margin-top:2px;">Events: <span style="color:#38bdf8;">${evts || 'all'}</span> ${w.secret ? '• <span style="color:#10b981;">HMAC signed</span>' : ''}</div>
</div>
<div style="display:flex; gap:6px;">
<button class="btn btn-ghost btn-sm" onclick="testWebhook('${w.webhook_id}')" title="Send test ping">Test</button>
<button class="btn btn-ghost btn-sm" style="color:#f87171;" onclick="deleteWebhook('${w.webhook_id}')" title="Delete webhook">Delete</button>
</div>
</div>
`;
}).join('');
}
async function saveNewWebhook() {
const targetUrl = document.getElementById('webhook-target-url').value.trim();
if (!targetUrl) return toast('Target URL is required', 'error');
const secret = document.getElementById('webhook-secret').value.trim();
const evts = [];
if (document.getElementById('wh-evt-upload').checked) evts.push('object:created');
if (document.getElementById('wh-evt-delete').checked) evts.push('object:deleted');
if (!evts.length) return toast('Select at least one trigger event', 'error');
const r = await api('/oort/api/bucket/webhooks', {
method: 'POST',
body: JSON.stringify({
bucket: state.bucket,
target_url: targetUrl,
secret: secret,
events: evts
})
});
if (r) {
toast('Webhook registered successfully!');
closeModal('modal-add-webhook');
document.getElementById('webhook-target-url').value = '';
document.getElementById('webhook-secret').value = '';
loadWebhooks();
}
}
async function deleteWebhook(id) {
if (!confirm('Are you sure you want to delete this webhook?')) return;
const r = await api(`/oort/api/bucket/webhooks?bucket=${encodeURIComponent(state.bucket)}&webhook_id=${encodeURIComponent(id)}`, {
method: 'DELETE'
});
if (r) {
toast('Webhook deleted');
loadWebhooks();
}
}
async function testWebhook(id) {
toast('Dispatching test ping…');
const r = await api('/oort/api/bucket/webhooks/test', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, webhook_id: id })
});
if (r) {
toast(`Test payload delivered! (Status: ${r.status_code || 200})`);
}
}
async function changePassword() {
const p1 = document.getElementById('inp-new-password').value;
const p2 = document.getElementById('inp-confirm-password').value;
if (!p1 || p1.length < 8) return toast('Password must be at least 8 characters', 'error');
if (p1 !== p2) return toast('Passwords do not match', 'error');
const btn = document.getElementById('btn-change-pwd');
const oldText = btn.textContent;
btn.disabled = true; btn.textContent = 'Updating...';
const r = await api('/oort/api/password', { method: 'POST', body: JSON.stringify({ password: p1 }) });
btn.disabled = false; btn.textContent = oldText;
if (r) {
toast('Password updated successfully', 'success');
document.getElementById('inp-new-password').value = '';
document.getElementById('inp-confirm-password').value = '';
}
}
async function createFolder() {
const inp = document.getElementById('inp-mkdir');
if (!inp) return;
const name = inp.value.trim();
if (!name) return;
const key = state.prefix + name + '/';
const apiPath = `/oort/api/mkdir`;
const r = await api(apiPath, { method: 'POST', body: JSON.stringify({ bucket: state.bucket, key: key }) });
if (r) {
toast(`Folder "${name}" created`, 'success');
inp.value = '';
closeModal('modal-mkdir');
loadObjects();
}
}
function toggleSidebar() {
const sb = document.querySelector('.sidebar');
const ov = document.getElementById('sidebar-overlay');
sb.classList.toggle('mobile-open');
ov.classList.toggle('active');
}
function closeSidebar() {
document.querySelector('.sidebar').classList.remove('mobile-open');
document.getElementById('sidebar-overlay').classList.remove('active');
}
// Close sidebar when a nav item is clicked on mobile
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.nav-item').forEach(el => {
el.addEventListener('click', () => { if(window.innerWidth <= 800) closeSidebar(); });
});
});
function rowClick(key, isDir) {
if (isDir) {
state.prefix = key;
loadObjects();
} else {
previewFile(key);
}
}
async function loadObjects() {
const wrap = document.getElementById('file-table-wrap');
wrap.innerHTML = `<div style="padding:40px;text-align:center;color:var(--text3)">Loading…</div>`;
document.getElementById('browser-title').textContent = (typeof uiMode !== 'undefined' && uiMode === 's3' ? 'Bucket: ' : 'Drive: ') + getBucketDisplayName(state.bucket);
updateTopbar('browser');
const apiPath = `/oort/api/objects?bucket=${state.bucket}&prefix=${encodeURIComponent(state.prefix)}`;
const r = await api(apiPath);
if (!r) {
wrap.innerHTML = `<div style="padding:80px;text-align:center;"><div style="font-size:48px;margin-bottom:16px;">⚠️</div><div style="color:#f87171;font-size:18px;font-weight:700;margin-bottom:8px;">Failed to load storage</div><div style="color:var(--text3);font-size:14px;">Could not reach the storage backend. Please try refreshing the page.</div><button class="btn btn-ghost" style="margin-top:24px;" onclick="loadObjects()">Try Again</button></div>`;
return;
}
const objects = r.objects || [];
state.rawObjects = objects;
renderFilteredObjects();
}
/* ─── CATEGORY FILTERING & SEARCH ─── */
function getFileCategory(name) {
const ext = (name.split('.').pop() || '').toLowerCase();
if (/^(jpg|jpeg|png|gif|webp|svg|bmp|ico|tiff|avif)$/.test(ext)) return 'images';
if (/^(mp4|webm|mov|mkv|avi|mp3|wav|ogg|flac|aac|m4a|ogv)$/.test(ext)) return 'media';
if (/^(pdf|doc|docx|xls|xlsx|ppt|pptx|txt|rtf|odt|csv)$/.test(ext)) return 'docs';
if (/^(js|ts|jsx|tsx|py|go|html|css|json|yaml|yml|xml|sh|sql|md|c|cpp|h|rs|php|rb|conf|env|ini|toml)$/.test(ext)) return 'code';
if (/^(zip|tar|gz|tgz|bz2|7z|rar|iso)$/.test(ext)) return 'archives';
return 'other';
}
function onSearchInput(val) {
const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) {
clearBtn.style.display = val ? 'flex' : 'none';
}
filterObjectsByQuery(val);
}
function clearSearchInput() {
const inp = document.getElementById('browser-search-inp');
if (inp) {
inp.value = '';
inp.focus();
}
const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) clearBtn.style.display = 'none';
filterObjectsByQuery('');
}
function filterByCategory(cat) {
state.activeCategory = cat;
document.querySelectorAll('.cat-pill, .cat-chip').forEach(el => {
el.classList.toggle('active', el.dataset.cat === cat);
});
renderFilteredObjects();
}
function filterObjectsByQuery(q) {
state.searchQuery = (q || '').trim().toLowerCase();
renderFilteredObjects();
}
function clearFilters() {
state.searchQuery = '';
state.activeCategory = 'all';
const inp = document.getElementById('browser-search-inp');
if (inp) inp.value = '';
const clearBtn = document.getElementById('browser-search-clear');
if (clearBtn) clearBtn.style.display = 'none';
document.querySelectorAll('.cat-pill, .cat-chip').forEach(el => {
el.classList.toggle('active', el.dataset.cat === 'all');
});
renderFilteredObjects();
}
function renderFilteredObjects() {
const wrap = document.getElementById('file-table-wrap');
if (!wrap) return;
const raw = state.rawObjects || [];
const q = state.searchQuery || '';
const cat = state.activeCategory || 'all';
let filtered = raw.filter(o => {
if (o.name === '.keep' || o.name === '') return false;
if (q) {
const matchName = o.name.toLowerCase().includes(q);
const matchKey = o.key.toLowerCase().includes(q);
if (!matchName && !matchKey) return false;
}
if (cat !== 'all') {
if (o.is_dir) return false;
if (getFileCategory(o.name) !== cat) return false;
}
return true;
});
if (!filtered.length) {
if (q || cat !== 'all') {
wrap.innerHTML = `
<div class="empty-state" style="padding:60px 20px;">
<div class="empty-state-icon"><svg fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg></div>
<h3>No matching files found</h3>
<p style="color:var(--text3); font-size:13px; margin-top:6px;">Try adjusting your search query or category filter.</p>
<button class="btn btn-ghost btn-sm" style="margin-top:16px;" onclick="clearFilters()">Reset Filters</button>
</div>`;
} else {
wrap.innerHTML = `
<div class="empty-state">
<div class="empty-state-icon"><svg fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24"><path d="M21 16V8a2 2 0 00-1-1.73l-7-4a2 2 0 00-2 0l-7 4A2 2 0 003 8v8a2 2 0 001 1.73l7 4a2 2 0 002 0l7-4A2 2 0 0021 16z"/></svg></div>
<h3>Empty</h3>
<p>Upload files or create a folder to get started.</p>
<div style="margin-top:16px;display:flex;gap:8px;justify-content:center">
<button class="btn btn-ghost btn-sm" onclick="openBucketSettings()">
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" width="13" height="13"><path d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><circle cx="12" cy="12" r="3"></circle></svg>
Bucket Settings
</button>
${typeof uiMode !== 'undefined' && uiMode === 'drive' ? `<button class="btn btn-ghost btn-sm" onclick="openModal('modal-mkdir')">New Folder</button>` : ''}
<button class="btn btn-primary btn-sm" onclick="openUploader()">Upload Files</button>
</div>
</div>`;
}
updateBatchSelection();
return;
}
const sorted = [...filtered.filter(o => o.is_dir), ...filtered.filter(o => !o.is_dir)];
wrap.innerHTML = `
<div style="display:flex; flex-direction:column; gap:4px;">
<div style="display:flex; align-items:center; padding:0 16px 12px 16px; border-bottom:1px solid var(--border); font-size:12px; font-weight:600; color:var(--text3); text-transform:uppercase; letter-spacing:0.5px; margin-bottom:8px;">
<div style="width:36px; display:flex; align-items:center;" onclick="event.stopPropagation()">
<input type="checkbox" id="select-all-cb" onchange="toggleSelectAll(this)" style="cursor:pointer; accent-color:#38bdf8; width:15px; height:15px;">
</div>
<div style="flex:1;">Name</div>
<div style="width:140px; text-align:left;">Last Modified</div>
<div style="width:100px; text-align:right;">Size</div>
<div style="width:140px;"></div>
</div>
${sorted.map(o => {
const cls = o.is_dir ? 'folder' : fileIconClass(o.name);
const icon = o.is_dir ? folderSVG() : fileSVG(cls);
const dateStr = o.is_dir ? '—' : new Date(o.last_modified).toLocaleDateString('en-US',{month:'short',day:'numeric',year:'numeric'});
const sizeStr = o.is_dir ? '—' : fmtBytes(o.size);
const escKey = o.key.replace(/'/g, "\\'");
return `
<div class="drive-item" data-key="${o.key}" data-size="${o.size||0}" data-isdir="${o.is_dir}" onclick="rowClick('${escKey}',${o.is_dir})">
<div style="width:36px; display:flex; align-items:center;" onclick="event.stopPropagation()">
${o.is_dir ? '' : `<input type="checkbox" class="file-select-cb" data-key="${o.key}" data-size="${o.size||0}" onchange="updateBatchSelection()" style="cursor:pointer; accent-color:#38bdf8; width:15px; height:15px;">`}
</div>
<div style="display:flex; align-items:center; flex:1; min-width:0;">
<div class="drive-item-icon ${cls}">
${icon}
</div>
<div style="font-weight:600; font-size:14px; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">
${o.name}
</div>
</div>
<div style="width:140px; font-size:13px; color:var(--text2);">${dateStr}</div>
<div style="width:100px; font-size:13px; color:var(--text2); text-align:right; font-weight:500;">${sizeStr}</div>
<div style="width:40px; display:flex; justify-content:flex-end;" onclick="event.stopPropagation()">
<button class="btn-icon" onclick="openFileMenu(event, '${escKey}', ${o.is_dir})">${dotsSVG()}</button>
</div>
</div>`;
}).join('')}
</div>
`;
updateBatchSelection();
}
/* ─── BATCH OPERATIONS ─── */
function toggleSelectAll(masterCb) {
const cbs = document.querySelectorAll('.file-select-cb');
cbs.forEach(cb => { cb.checked = masterCb.checked; });
updateBatchSelection();
}
function updateBatchSelection() {
const cbs = Array.from(document.querySelectorAll('.file-select-cb:checked'));
const bar = document.getElementById('batch-action-bar');
if (!bar) return;
if (cbs.length > 0) {
bar.style.display = 'flex';
let totalSize = 0;
cbs.forEach(cb => {
totalSize += parseInt(cb.dataset.size || '0', 10);
});
const cntBadge = document.getElementById('batch-count-badge');
const szBadge = document.getElementById('batch-size-badge');
if (cntBadge) cntBadge.textContent = `${cbs.length} item${cbs.length === 1 ? '' : 's'} selected`;
if (szBadge) szBadge.textContent = fmtBytes(totalSize);
} else {
bar.style.display = 'none';
const master = document.getElementById('select-all-cb');
if (master) master.checked = false;
}
}
function clearBatchSelection() {
const master = document.getElementById('select-all-cb');
if (master) master.checked = false;
document.querySelectorAll('.file-select-cb').forEach(cb => { cb.checked = false; });
updateBatchSelection();
}
function batchDownloadZip() {
const cbs = Array.from(document.querySelectorAll('.file-select-cb:checked'));
if (!cbs.length) return toast('No files selected', 'error');
const params = new URLSearchParams();
params.set('bucket', state.bucket);
cbs.forEach(cb => params.append('keys', cb.dataset.key));
window.location.href = `/oort/api/batch/zip?${params.toString()}`;
}
async function batchDeleteSelected() {
const cbs = Array.from(document.querySelectorAll('.file-select-cb:checked'));
if (!cbs.length) return toast('No files selected', 'error');
if (!confirm(`Are you sure you want to permanently delete ${cbs.length} selected file(s)? This cannot be undone.`)) return;
const keys = cbs.map(cb => cb.dataset.key);
const r = await api('/oort/api/batch/delete', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, keys: keys })
});
if (r) {
toast(`Successfully deleted ${r.deleted || keys.length} file(s)`);
clearBatchSelection();
loadObjects();
}
}
function openMoveModal(sourceKey, isRenameOnly = false) {
document.getElementById('inp-move-source').value = sourceKey;
if (isRenameOnly) {
const parts = sourceKey.split('/');
const name = parts.pop();
document.getElementById('inp-move-dest').value = name;
// Store the prefix to re-append later
document.getElementById('inp-move-dest').dataset.prefix = parts.join('/') + (parts.length ? '/' : '');
} else {
document.getElementById('inp-move-dest').value = sourceKey;
document.getElementById('inp-move-dest').dataset.prefix = '';
}
openModal('modal-move');
}
async function executeMove() {
const src = document.getElementById('inp-move-source').value;
let dst = document.getElementById('inp-move-dest').value;
const pfx = document.getElementById('inp-move-dest').dataset.prefix || '';
dst = pfx + dst;
if(!dst || src === dst) return toast('Invalid destination', 'error');
closeModal('modal-move');
const r = await api('/oort/api/objects/move', {
method: 'POST',
body: JSON.stringify({ bucket: state.bucket, source_key: src, dest_key: dst })
});
if(r) {
toast('Moved successfully');
loadObjects();
}
}
/* ─── UPLOAD ──────────────────────────────────────────────────────── */
let activeUploads = 0;
function toggleUploadManager() {
const m = document.getElementById('upload-manager');
const c = document.getElementById('um-chevron');
if (m.style.transform === 'translateY(0px)' || m.style.transform === '') {
// minimize
const h = document.getElementById('upload-manager-header').offsetHeight;
m.style.transform = `translateY(calc(100% - ${h}px))`;
c.style.transform = 'rotate(180deg)';
} else {
// expand
m.style.transform = 'translateY(0px)';
c.style.transform = 'rotate(0deg)';
}
}
let dragCounter = 0;
window.addEventListener('dragenter', (e) => {
e.preventDefault();
if (!state.bucket) return;
dragCounter++;
const dz = document.getElementById('global-dropzone');
document.getElementById('global-drop-bucket').textContent = getBucketDisplayName(state.bucket);
dz.style.display = 'flex';
});
window.addEventListener('dragleave', (e) => {
e.preventDefault();
dragCounter--;
if (dragCounter <= 0) {
dragCounter = 0;
document.getElementById('global-dropzone').style.display = 'none';
}
});
window.addEventListener('dragover', (e) => e.preventDefault());
window.addEventListener('drop', (e) => {
e.preventDefault();
dragCounter = 0;
document.getElementById('global-dropzone').style.display = 'none';
if (!state.bucket) return toast('Select a bucket first', 'error');
if (e.dataTransfer.items && e.dataTransfer.items.length > 0) {
handleDropEntries(e.dataTransfer.items);
} else if (e.dataTransfer.files && e.dataTransfer.files.length > 0) {
queueFiles(e.dataTransfer.files);
}
});
async function handleDropEntries(items) {
const files = [];
async function traverse(entry, path = '') {
if (entry.isFile) {
const file = await new Promise((res, rej) => entry.file(res, rej));
Object.defineProperty(file, 'webkitRelativePath', {
value: path + file.name,
writable: true
});
files.push(file);
} else if (entry.isDirectory) {
const reader = entry.createReader();
const readAll = () => new Promise((res, rej) => {
reader.readEntries(async entries => {
if (!entries.length) return res();
for (const child of entries) {
await traverse(child, path + entry.name + '/');
}
readAll().then(res);
}, rej);
});
await readAll();
}
}
for (let i = 0; i < items.length; i++) {
const entry = items[i].webkitGetAsEntry ? items[i].webkitGetAsEntry() : null;
if (entry) {
await traverse(entry);
} else if (items[i].kind === 'file') {
const f = items[i].getAsFile();
if (f) files.push(f);
}
}
if (files.length > 0) queueFiles(files);
}
function openUploader() {
if (!state.bucket) { toast('Select a bucket first', 'error'); return; }
document.getElementById('file-input').click();
}
function queueFiles(files) {
if (!state.bucket) return toast('No bucket selected', 'error');
const mgr = document.getElementById('upload-manager');
mgr.style.display = 'flex';
mgr.style.transform = 'translateY(0px)'; // ensure expanded
document.getElementById('um-chevron').style.transform = 'rotate(0deg)';
for (let i = 0; i < files.length; i++) {
uploadFile(files[i]);
}
}
function updateUMHeader() {
const title = document.getElementById('upload-manager-title');
const spinner = document.getElementById('um-spinner');
if (activeUploads > 0) {
title.textContent = `Uploading ${activeUploads} item${activeUploads > 1 ? 's' : ''}...`;
spinner.style.display = 'block';
} else {
title.textContent = 'Uploads complete';
spinner.style.display = 'none';
setTimeout(() => {
if (activeUploads === 0) loadObjects(); // refresh view
}, 1000);
}
}
async function uploadFile(file) {
activeUploads++;
updateUMHeader();
const relPath = file.webkitRelativePath || file.name;
const key = state.prefix + relPath;
const id = 'u' + Math.random().toString(36).slice(2);
const item = document.createElement('div');
item.className = 'um-item';
item.innerHTML = `
<div class="um-icon"><svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"/><polyline points="13 2 13 9 20 9"/></svg></div>
<div class="um-content">
<div class="um-name" title="${relPath}">${relPath}</div>
<div class="um-meta"><span id="${id}-st">Preparing...</span><span>${fmtBytes(file.size)}</span></div>
<div class="um-track"><div class="um-fill" id="${id}-bar"></div></div>
</div>
<button class="um-cancel" id="${id}-btn" title="Cancel Upload"><svg width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg></button>`;
document.getElementById('upload-manager-list').prepend(item);
const bar = () => document.getElementById(`${id}-bar`);
const st = () => document.getElementById(`${id}-st`);
const set = (pct, txt) => { const b=bar(); if(b)b.style.width=pct+'%'; const s=st(); if(s)s.textContent=txt; };
let aborted = false;
document.getElementById(`${id}-btn`).onclick = () => { aborted = true; };
const init = await api('/oort/api/upload/init', {
method: 'POST',
body: JSON.stringify({ key, content_type: file.type || 'application/octet-stream', bucket: state.bucket })
});
if (!init) {
set(0,'Failed');
activeUploads--;
updateUMHeader();
return;
}
const totalChunks = Math.max(1, Math.ceil(file.size / CHUNK));
const parts = [];
let totalUploaded = 0;
for (let i = 0; i < totalChunks; i++) {
if (aborted) {
set(0, 'Canceled');
bar().style.background = 'var(--text3)';
await api('/oort/api/upload/abort', { method:'POST', body:JSON.stringify({ key, upload_id:init.upload_id, bucket:state.bucket }) });
activeUploads--; updateUMHeader(); return;
}
const start = i * CHUNK;
const end = Math.min(start + CHUNK, file.size);
const chunk = file.slice(start, end);
const chunkSize = end - start;
try {
const p = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open('POST', `/oort/api/upload/part?bucket=${encodeURIComponent(state.bucket)}&key=${encodeURIComponent(key)}&upload_id=${encodeURIComponent(init.upload_id)}&part=${i+1}&size=${chunkSize}`);
xhr.setRequestHeader('X-Session-Id', SID);
xhr.upload.onprogress = (e) => {
if (aborted) xhr.abort();
if (e.lengthComputable) {
const overallBytes = totalUploaded + e.loaded;
let pct = Math.round((overallBytes / file.size) * 100);
if (pct > 99) pct = 99;
set(pct, `Uploading... ${pct}%`);
}
};
xhr.onload = () => {
if (xhr.status >= 200 && xhr.status < 300) {
try { resolve(JSON.parse(xhr.responseText)); } catch(err) { reject(new Error('Invalid res')); }
} else {
reject(new Error(`HTTP ${xhr.status}`));
}
};
xhr.onerror = () => reject(new Error('Network Error'));
xhr.onabort = () => reject(new Error('Aborted'));
xhr.send(chunk);
});
parts.push({ part: i+1, etag: p.etag });
totalUploaded += chunkSize;
} catch (e) {
if (aborted) { set(0, 'Canceled'); bar().style.background = 'var(--text3)'; }
else { set(0, 'Upload error'); bar().style.background = 'var(--red)'; }
await api('/oort/api/upload/abort', { method:'POST', body:JSON.stringify({ key, upload_id:init.upload_id, bucket:state.bucket }) });
activeUploads--; updateUMHeader(); return;
}
}
set(100, 'Finalizing...');
const done = await api('/oort/api/upload/complete', {
method: 'POST',
body: JSON.stringify({ key, upload_id: init.upload_id, parts, bucket: state.bucket })
});
if (done) {
set(100, 'Done');
bar().style.background = 'var(--green)';
document.getElementById(`${id}-btn`).style.display = 'none'; // hide cancel btn
} else {
set(0, 'Failed complete');
bar().style.background = 'var(--red)';
}
activeUploads--;
updateUMHeader();
}
/* ─── ICON HELPERS ────────────────────────────────────────────────── */
function fileIconClass(name) {
const ext = name.split('.').pop().toLowerCase();
if (['jpg','jpeg','png','gif','webp','svg','bmp','ico'].includes(ext)) return 'img';
if (['mp4','mov','avi','mkv','webm'].includes(ext)) return 'vid';
if (['zip','tar','gz','bz2','7z','rar'].includes(ext)) return 'arc';
return 'doc';
}
function folderSVG() { return `<svg width="15" height="15" fill="none" stroke="#f59e0b" stroke-width="2" viewBox="0 0 24 24"><path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"/></svg>`; }
function fileSVG(cls) {
const col = {doc:'#3b82f6',img:'#22c55e',vid:'#ef4444',arc:'#8b5cf6'}[cls]||'#3b82f6';
return `<svg width="15" height="15" fill="none" stroke="${col}" stroke-width="2" viewBox="0 0 24 24"><path d="M13 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V9z"/><polyline points="13 2 13 9 20 9"/></svg>`;
}
function dotsSVG() { return `<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg>`; }
function moveSVG() { return `<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M5 9l4-4 4 4M9 5v14M19 15l-4 4-4-4M15 19V5"/></svg>`; }
function downloadSVG() { return `<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>`; }
function deleteSVG() { return `<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14H6L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4h6v2"/></svg>`; }
/* ─── FORMAT ──────────────────────────────────────────────────────── */
function fmtBytes(b) {
if (!b) return '0 B';
const u = ['B','KB','MB','GB','TB'];
let i = 0;
while (b >= 1024 && i < u.length - 1) { b /= 1024; i++; }
return b.toFixed(i ? 1 : 0) + ' ' + u[i];
}
</script>
<!-- Context Menu -->
<div id="file-context-menu" style="display:none; position:fixed; background:var(--surface); border:1px solid var(--border); border-radius:10px; box-shadow:0 12px 32px rgba(0,0,0,0.12); z-index:99999; padding:8px; min-width:180px; flex-direction:column; gap:4px;">
<div class="cmenu-item" id="cmenu-rename">Rename</div>
<div class="cmenu-item" id="cmenu-move">Move to...</div>
<div class="cmenu-item" id="cmenu-download">Download</div>
<div class="cmenu-item" id="cmenu-share">Secure Link</div>
<div class="cmenu-item" id="cmenu-public-url">Copy Public URL</div>
<div class="cmenu-item" id="cmenu-versions">Version History</div>
<div class="cmenu-item" id="cmenu-preview">Preview</div>
<div style="height:1px; background:var(--border); margin:4px 0;"></div>
<div class="cmenu-item danger" id="cmenu-delete">Delete</div>
</div>
<!-- Rename Bucket Modal -->
<div class="modal-bg" id="modal-rename-bucket">
<div class="modal">
<div class="modal-header">
<div class="modal-title">Rename Bucket/Drive</div>
<button class="modal-close" onclick="closeModal('modal-rename-bucket')">✕</button>
</div>
<div class="modal-body">
<input type="hidden" id="inp-rb-old">
<div class="form-row">
<label class="form-label">New Name</label>
<input type="text" class="form-control" id="inp-rb-new" placeholder="e.g. my-new-drive">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-ghost" onclick="closeModal('modal-rename-bucket')">Cancel</button>
<button class="btn btn-primary" onclick="executeRenameBucket()">Rename</button>
</div>
</div>
</div>
<style>
.cmenu-item { padding:8px 12px; border-radius:6px; cursor:pointer; font-size:13px; font-weight:500; transition:0.1s; color:var(--text); }
.cmenu-item:hover { background:var(--accent); color:white; }
.cmenu-item.danger:hover { background:var(--red); color:white; }
@media (max-width:800px) {
.layout { flex-direction: column; }
.sidebar { width: 100%; min-width: 100%; height: auto; min-height: auto; flex-shrink: 0; padding-bottom: 12px; }
.sidebar-logo { border-bottom: none; }
.sidebar-body { display: flex; flex-direction: row; overflow-x: auto; white-space: nowrap; padding: 0 16px; gap: 12px; align-items: center; }
.sidebar-section { margin-bottom: 0; display: flex; flex-direction: row; gap: 8px; align-items: center; }
.sidebar-section-label { display: none; }
.topbar { padding: 0 16px; flex-wrap: wrap; height: auto; min-height: 60px; justify-content: center; gap: 12px; border-top: 1px solid var(--border); }
.content-header { flex-direction: column; align-items: flex-start; gap: 12px; }
.data-grid { grid-template-columns: 1fr; }
.object-row { flex-wrap: wrap; gap: 8px; }
.object-name-col { flex: 1 1 100%; }
}
@media (max-width:800px) {
.file-table thead { display: none; }
.file-table, .file-table tbody, .file-table tr, .file-table td { display: block; width: 100%; }
.file-table tr { margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.file-table td { text-align: left; padding: 4px 12px; position: relative; }
.file-table td:nth-child(2)::before { content: "Size: "; font-weight: bold; }
.file-table td:nth-child(4)::before { content: "Modified: "; font-weight: bold; }
.grid { display: flex !important; flex-direction: column !important; }
}
@media (max-width:800px) {
.drive-item { flex-wrap: wrap; }
.drive-item > div:nth-child(2), .drive-item > div:nth-child(3) { display: none; }
.drive-item > div:first-child { flex: 1 1 100%; }
div[style*="text-transform:uppercase"] { display: none !important; }
}
input[type="datetime-local"], input[type="date"] {
color-scheme: dark;
}
.globe-card { flex-direction: row; }
.switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.1); transition: .4s; border-radius: 20px; }
.slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #6366f1; }
input:checked + .slider:before { transform: translateX(16px); }
/* ══════════════════════════════════════════════════════════════════
COMPREHENSIVE MOBILE RESPONSIVE OVERRIDES
══════════════════════════════════════════════════════════════════ */
/* ── Sidebar as slide-out drawer on mobile ── */
@media (max-width: 800px) {
/* Layout */
.layout { flex-direction: column !important; }
/* Sidebar becomes a slide-in drawer */
.sidebar {
position: fixed !important;
top: 0; left: 0; bottom: 0;
width: 280px !important;
min-width: 280px !important;
max-width: 280px !important;
height: 100vh !important;
z-index: 9999;
transform: translateX(-100%);
transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
overflow-y: auto;
}
.sidebar.mobile-open {
transform: translateX(0) !important;
box-shadow: 4px 0 32px rgba(0,0,0,0.5);
}
.sidebar-overlay {
display: none;
position: fixed; inset: 0; background: rgba(0,0,0,0.5);
z-index: 9998; backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block !important; }
/* Sidebar logo/body/user remain vertical (don't flip to horizontal) */
.sidebar-body { flex-direction: column !important; white-space: normal !important; overflow-x: visible !important; padding: 0 !important; }
.sidebar-section { flex-direction: column !important; }
.sidebar-section-label { display: block !important; }
/* Main takes full width */
.main { width: 100% !important; min-width: 0 !important; }
/* Mobile menu hamburger button visible */
.mobile-menu-btn { display: flex !important; }
/* Topbar */
.topbar {
flex-wrap: nowrap !important;
height: 56px !important; min-height: 56px !important;
padding: 0 12px !important; gap: 8px !important;
border-top: none !important; justify-content: flex-start !important;
}
.topbar-search {
flex: 1 !important; min-width: 0 !important;
margin: 0 8px !important;
}
.topbar-actions {
gap: 6px !important; flex-shrink: 0 !important;
}
/* Hide mode pills & new bucket on mobile - too crowded */
.topbar-actions > div:first-child { display: none !important; }
.topbar-actions > button:last-child { display: none !important; }
/* Breadcrumb inline */
#topbarBreadcrumb { display: none !important; }
/* File browser */
.browser-header { padding: 12px 16px !important; flex-wrap: wrap !important; gap: 8px !important; }
.browser-actions { gap: 6px !important; flex-wrap: wrap !important; }
.browser-actions button { font-size: 12px !important; padding: 6px 10px !important; }
/* Drive items - hide date/size columns */
.drive-item { padding: 10px 12px !important; }
.drive-item > div:nth-child(2),
.drive-item > div:nth-child(3) { display: none !important; }
/* Tables - convert to card layout */
.file-table thead { display: none !important; }
.file-table,
.file-table tbody,
.file-table tr,
.file-table td { display: block !important; width: 100% !important; }
.file-table tr { margin-bottom: 8px !important; border: 1px solid var(--border) !important; border-radius: 10px !important; padding: 8px 12px !important; }
.file-table td { padding: 4px 0 !important; }
.file-table td:nth-child(2)::before { content: "Size: "; font-weight: bold; color: var(--text3); }
.file-table td:nth-child(4)::before { content: "Modified: "; font-weight: bold; color: var(--text3); }
.file-table td:nth-child(3) { display: none !important; }
/* Stat cards */
.stats-grid, #analytics-kpi { grid-template-columns: 1fr 1fr !important; padding: 0 12px 16px !important; }
/* Analytics globe section */
#analytics-globe-row { padding: 0 12px 16px !important; }
.chart-card.globe-card { flex-direction: column !important; min-height: auto !important; }
.chart-card.globe-card > div:first-child {
width: 100% !important; max-width: 100% !important;
border-right: none !important;
border-bottom: 1px solid rgba(255,255,255,0.05) !important;
}
canvas#globeCanvas { width: 100% !important; max-width: 340px !important; height: auto !important; }
/* Analytics padding fixes */
.mobile-pad { padding: 0 12px 16px !important; }
.page-header { padding: 16px 12px 10px !important; }
.page-title { font-size: 22px !important; }
/* Forms */
.form-page { padding: 12px !important; }
.form-section-body { padding: 16px !important; }
.form-section-header { padding: 16px !important; }
/* Modals */
.modal { max-width: calc(100vw - 32px) !important; margin: 16px !important; border-radius: 16px !important; }
.modal-header { padding: 16px 20px !important; }
.modal-body { padding: 16px 20px !important; }
/* Dashboard header */
.content-header { flex-direction: column !important; gap: 12px !important; padding: 16px !important; }
.profile-hero { flex-direction: column !important; align-items: center !important; padding: 24px 16px !important; }
/* Headers column dividers */
div[style*="text-transform:uppercase"] { display: none !important; }
}
@media (max-width: 480px) {
.stats-grid, #analytics-kpi { grid-template-columns: 1fr !important; }
.stat-card-value { font-size: 24px !important; }
canvas#globeCanvas { max-width: 280px !important; }
.browser-actions button span { display: none !important; }
}
/* ══════════════════════════════════════════════════════════
MOBILE-FIRST OVERRIDES — Single authoritative block
══════════════════════════════════════════════════════════ */
/* Sidebar overlay for mobile drawer */
.sidebar-overlay {
display: none;
position: fixed; inset: 0;
background: rgba(0,0,0,0.55);
z-index: 9997;
backdrop-filter: blur(3px);
}
@media (max-width: 800px) {
/* ── Layout ── */
.layout { flex-direction: column !important; overflow: hidden !important; }
/* ── Sidebar becomes slide-out drawer ── */
.sidebar {
position: fixed !important;
top: 0 !important; left: 0 !important; bottom: 0 !important;
width: 280px !important; min-width: 280px !important; max-width: 280px !important;
height: 100dvh !important;
z-index: 9998 !important;
transform: translateX(-100%) !important;
transition: transform 0.32s cubic-bezier(0.16,1,0.3,1) !important;
flex-direction: column !important;
overflow-y: auto !important;
}
.sidebar.mobile-open { transform: translateX(0) !important; box-shadow: 6px 0 40px rgba(0,0,0,0.6) !important; }
.sidebar-overlay.active { display: block !important; }
/* Sidebar internals stay vertical */
.sidebar-body { flex-direction: column !important; white-space: normal !important; overflow-x: visible !important; padding: 8px 0 !important; }
.sidebar-section { flex-direction: column !important; align-items: stretch !important; gap: 0 !important; margin-bottom: 0 !important; }
.sidebar-section-label { display: block !important; }
/* ── Main fills screen ── */
.main { width: 100% !important; min-width: 0 !important; flex: 1 !important; overflow: hidden !important; display: flex !important; flex-direction: column !important; }
/* ── Topbar: slim single row ── */
.topbar {
flex-wrap: nowrap !important; height: 54px !important; min-height: 54px !important;
padding: 0 10px !important; gap: 6px !important;
border-top: none !important; justify-content: flex-start !important;
flex-shrink: 0 !important;
}
.mobile-menu-btn { display: flex !important; flex-shrink: 0; }
.topbar-search { flex: 1 1 0 !important; margin: 0 6px !important; min-width: 0 !important; }
.topbar-search input { font-size: 13px !important; }
/* Hide mode toggle pill, new-bucket button — keep upload */
.topbar-actions > div:first-child { display: none !important; }
.topbar-actions > button:last-child { display: none !important; }
.topbar-actions > button { padding: 6px 10px !important; font-size: 12px !important; }
#topbarBreadcrumb { display: none !important; }
/* ── Browser header ── */
.browser-header { padding: 10px 14px !important; flex-wrap: wrap !important; gap: 6px !important; }
.browser-actions { flex-wrap: wrap !important; gap: 6px !important; }
.browser-actions button { font-size: 12px !important; padding: 6px 10px !important; }
#browser-title { font-size: 13px !important; }
/* ── File list ── */
.file-table-wrap { padding: 0 10px !important; }
.drive-item { padding: 10px 12px !important; }
.drive-item > div:nth-child(2), .drive-item > div:nth-child(3) { display: none !important; }
.drive-item > div:first-child { flex: 1 1 auto !important; min-width: 0 !important; }
/* hide column headers */
.file-table-wrap > div > div:first-child { display: none !important; }
/* ── Stat / KPI cards ── */
.stats-grid, #analytics-kpi { grid-template-columns: 1fr 1fr !important; padding: 0 12px 16px !important; }
/* ── Analytics section ── */
.page-header { padding: 14px 12px 8px !important; }
.page-title { font-size: 22px !important; }
.mobile-pad, #analytics-globe-row { padding: 0 12px 16px !important; }
.chart-card.globe-card { flex-direction: column !important; min-height: unset !important; }
.chart-card.globe-card > div:first-child {
width: 100% !important; max-width: 100% !important;
border-right: none !important;
border-bottom: 1px solid rgba(255,255,255,0.06) !important;
height: 180px !important; overflow-y: auto !important;
}
canvas#globeCanvas { max-width: 320px !important; height: auto !important; margin: 0 auto !important; }
/* ── Dashboard ── */
.data-grid { grid-template-columns: 1fr !important; }
.content-header { flex-direction: column !important; gap: 10px !important; }
/* ── Profile page ── */
.profile-hero { flex-direction: column !important; align-items: center !important; padding: 20px 14px !important; }
.form-page { padding: 10px !important; }
.form-section-body { padding: 14px !important; }
.form-section-header { padding: 14px !important; }
/* ── Modals ── */
.modal, .modal-bg .modal { max-width: calc(100vw - 24px) !important; border-radius: 14px !important; }
.modal-header { padding: 14px 18px !important; }
.modal-body { padding: 14px 18px !important; }
}
@media (max-width: 480px) {
.stats-grid, #analytics-kpi { grid-template-columns: 1fr !important; }
.stat-card-value { font-size: 22px !important; }
canvas#globeCanvas { max-width: 260px !important; }
.browser-actions button > svg + * { display: none; }
}
</style>
<script>
let currentContextKey = null;
let currentContextIsDir = false;
function closeCMenu() {
const m = document.getElementById('file-context-menu');
if (m) m.style.display = 'none';
}
async function copyPublicURL() {
closeCMenu();
const key = currentContextKey;
if (!key) return;
const username = (state.profile && state.profile.username)
? state.profile.username
: document.getElementById('sidebarName').textContent.replace('@','').trim();
const disp = getBucketDisplayName(state.bucket);
const url = `https://cosmos.linuxguy.space/oort/${username}/${disp}/${key}`;
try {
await navigator.clipboard.writeText(url);
toast('Public URL copied!');
} catch(e) {
prompt('Copy this URL:', url);
}
}
function openFileMenu(e, key, isDir) {
e.stopPropagation();
currentContextKey = key;
currentContextIsDir = isDir;
const menu = document.getElementById('file-context-menu');
menu.style.display = 'flex';
// Boundary check
const menuWidth = 160;
const menuHeight = 150;
let posX = e.clientX;
let posY = e.clientY;
if (posX + menuWidth > window.innerWidth) posX = window.innerWidth - menuWidth - 10;
if (posY + menuHeight > window.innerHeight) posY = window.innerHeight - menuHeight - 10;
menu.style.left = posX + 'px';
menu.style.top = posY + 'px';
document.getElementById('cmenu-download').style.display = isDir ? 'none' : 'block';
document.getElementById('cmenu-share').style.display = isDir ? 'none' : 'block';
document.getElementById('cmenu-public-url').style.display = isDir ? 'none' : 'block';
document.getElementById('cmenu-versions').style.display = isDir ? 'none' : 'block';
const isImg = key.toLowerCase().match(/\.(jpg|jpeg|png|gif|webp|svg)$/i);
document.getElementById('cmenu-preview').style.display = isDir ? 'none' : 'block';
document.getElementById('cmenu-rename').onclick = () => { menu.style.display = 'none'; openMoveModal(key, true); };
document.getElementById('cmenu-move').onclick = () => { menu.style.display = 'none'; openMoveModal(key, false); };
document.getElementById('cmenu-download').onclick = () => { menu.style.display = 'none'; downloadFile(key); };
document.getElementById('cmenu-delete').onclick = () => { menu.style.display = 'none'; deleteObject(key); };
document.getElementById('cmenu-share').onclick = () => { menu.style.display = 'none'; shareFile(key); };
document.getElementById('cmenu-versions').onclick = () => { menu.style.display = 'none'; showVersions(key); };
document.getElementById('cmenu-preview').onclick = () => { menu.style.display = 'none'; previewFile(key); };
document.getElementById('cmenu-public-url').onclick = () => { menu.style.display = 'none'; copyPublicURL(); };
}
document.addEventListener('click', () => { document.getElementById('file-context-menu').style.display = 'none'; });
function openRenameBucketModal(oldName, oldDisplay) {
document.getElementById('inp-rb-old').value = oldName;
document.getElementById('inp-rb-new').value = oldDisplay || oldName;
openModal('modal-rename-bucket');
}
async function executeRenameBucket() {
const oldName = document.getElementById('inp-rb-old').value;
const newName = document.getElementById('inp-rb-new').value;
if (!newName || newName === oldName) return;
closeModal('modal-rename-bucket');
const btn = document.getElementById('btn-sb-create');
toast('Renaming... This may take a moment for large drives.', 'success');
const r = await api('/oort/api/buckets/rename', {
method: 'POST',
body: JSON.stringify({ old_name: oldName, new_name: newName })
});
if (r) {
toast('Renamed successfully');
if (state.bucket === oldName) state.bucket = newName;
await loadBuckets();
if (document.getElementById('view-browser').classList.contains('active')) {
loadObjects();
} else {
loadDashboard();
}
}
}
</script>
<!-- Versions Modal -->
<div class="modal-bg" id="modal-versions">
<div class="modal" style="max-width: 600px; width:100%;">
<button class="modal-close" onclick="closeModal('modal-versions')">✕</button>
<h2>Version History</h2>
<div style="font-size:13px; color:var(--text2); margin-bottom:16px;">File: <span id="versions-key" style="font-weight:600; color:var(--text);"></span></div>
<div style="background:var(--bg2); border:1px solid var(--border); border-radius:12px; overflow:hidden;">
<table class="file-table" style="width:100%; text-align:left; font-size:13px; border-collapse:collapse;">
<thead>
<tr style="border-bottom:1px solid var(--border); background:rgba(255,255,255,0.02);">
<th style="padding:12px; font-weight:600;">Date Modified</th>
<th style="padding:12px; font-weight:600;">Size</th>
<th style="padding:12px; font-weight:600;">Version ID</th>
<th style="padding:12px; text-align:right;">Action</th>
</tr>
</thead>
<tbody id="versions-tbody">
<tr><td colspan="4" style="padding:24px; text-align:center; color:var(--text3);">Loading versions...</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
async function showVersions(key) {
document.getElementById('versions-key').textContent = key;
document.getElementById('versions-tbody').innerHTML = '<tr><td colspan="4" style="padding:24px; text-align:center; color:var(--text3);">Loading versions...</td></tr>';
openModal('modal-versions');
const r = await api(`/oort/api/objects/versions?bucket=${encodeURIComponent(state.bucket)}&prefix=${encodeURIComponent(key)}`);
const tbody = document.getElementById('versions-tbody');
if (!r || !r.versions || r.versions.length === 0) {
tbody.innerHTML = '<tr><td colspan="4" style="padding:24px; text-align:center; color:var(--text3);">No version history available.</td></tr>';
return;
}
tbody.innerHTML = r.versions.map(v => {
const dateStr = new Date(v.LastModified).toLocaleString();
const sizeStr = v.IsDeleteMarker ? '<span style="color:var(--red); font-size:11px; padding:2px 6px; border-radius:4px; border:1px solid rgba(239,68,68,0.3);">DELETED</span>' : fmtBytes(v.Size);
const idStr = v.VersionID === "null" ? "Default" : v.VersionID.substring(0,8) + "...";
let btnHtml = '';
if (v.IsLatest) {
btnHtml = '<span style="color:var(--green); font-weight:600; font-size:12px;">(Current)</span>';
} else {
btnHtml = `<button class="btn-sm" style="background:rgba(255,255,255,0.1); border:none; color:#fff; border-radius:4px; cursor:pointer;" onclick="restoreVersion('${key}', '${v.VersionID}')">Restore</button>`;
}
return `<tr style="border-bottom:1px solid var(--border);">
<td style="padding:12px; color:var(--text2);">${dateStr}</td>
<td style="padding:12px; color:var(--text);">${sizeStr}</td>
<td style="padding:12px; font-family:monospace; color:var(--text3);">${idStr}</td>
<td style="padding:12px; text-align:right;">${btnHtml}</td>
</tr>`;
}).join('');
}
async function restoreVersion(key, versionId) {
if (!confirm("Are you sure you want to restore this version? It will overwrite the current active file.")) return;
const r = await api('/oort/api/objects/restore', { bucket: state.bucket, key: key, version_id: versionId });
if (r && r.success) {
showToast('Version restored successfully!', 'success');
closeModal('modal-versions');
loadObjects();
}
}
</script>
<script>
/* ─── SPACE BACKGROUND CANVAS ─────────────────────────────────────── */
(function(){
const cvs = document.getElementById('space-bg');
if (!cvs) return;
const ctx = cvs.getContext('2d');
let w, h, stars = [], nebula = [];
function resize(){
w = cvs.width = window.innerWidth;
h = cvs.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
for(let i = 0; i < 250; i++){
stars.push({
x: Math.random()*w, y: Math.random()*h,
r: Math.random()*1.4 + 0.2,
a: Math.random(), da: (Math.random()-0.5)*0.008,
speed: Math.random()*0.06 + 0.01
});
}
// Nebula "color blobs"
const nColors = ['rgba(124,58,237,', 'rgba(14,165,233,', 'rgba(99,102,241,', 'rgba(16,185,129,'];
for(let i = 0; i < 6; i++){
nebula.push({
x: Math.random()*w, y: Math.random()*h,
r: 180 + Math.random()*200,
color: nColors[i % nColors.length],
a: 0.025 + Math.random()*0.04
});
}
function draw(){
ctx.clearRect(0,0,w,h);
// Nebula
nebula.forEach(n => {
const g = ctx.createRadialGradient(n.x, n.y, 0, n.x, n.y, n.r);
g.addColorStop(0, n.color + n.a + ')');
g.addColorStop(1, n.color + '0)');
ctx.fillStyle = g;
ctx.beginPath();
ctx.arc(n.x, n.y, n.r, 0, Math.PI*2);
ctx.fill();
});
// Stars
stars.forEach(s => {
s.a += s.da;
if(s.a <= 0.1 || s.a >= 1) s.da *= -1;
s.y -= s.speed;
if(s.y < 0) { s.y = h; s.x = Math.random()*w; }
ctx.beginPath();
ctx.arc(s.x, s.y, s.r, 0, Math.PI*2);
ctx.fillStyle = `rgba(255,255,255,${Math.max(0.1, s.a)})`;
ctx.fill();
});
requestAnimationFrame(draw);
}
draw();
})();
</script>
<!-- Bucket Settings Modal -->
<div class="modal-bg" id="modal-bucket-settings">
<div class="modal" style="max-width:600px;">
<div class="modal-header">
<div class="modal-title">Bucket Settings</div>
<button class="btn-icon" onclick="closeModal('modal-bucket-settings')"><svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12"/></svg></button>
</div>
<div class="modal-body" style="padding: 24px;">
<!-- Bucket URL -->
<div style="margin-bottom: 24px;">
<label style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:8px;">Bucket Public URL</label>
<div style="display:flex; gap:8px;">
<input type="text" id="bucket-public-url-input" class="form-control" readonly style="flex:1; background:rgba(0,0,0,0.2);">
<button class="btn btn-ghost" onclick="copyBucketURL()">Copy</button>
</div>
</div>
<div style="margin-bottom: 24px;">
<label style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:8px;">Access Policy</label>
<div style="display:flex; align-items:center; justify-content:space-between; background:rgba(255,255,255,0.02); border:1px solid rgba(255,255,255,0.05); padding:16px; border-radius:8px;">
<div>
<div style="font-weight:600; font-size:14px; margin-bottom:4px;">Public Access</div>
<div style="font-size:12px; color:var(--text3);">Allow anyone to download files via public URL without authentication.</div>
</div>
<label class="switch">
<input type="checkbox" id="bucket-setting-public" onchange="toggleBucketPrivacy(this.checked)">
<span class="slider round"></span>
</label>
</div>
</div>
<div>
<label style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:8px;">Custom Domains</label>
<div style="display:flex; gap:8px; margin-bottom:12px;">
<input type="text" id="bucket-new-domain" class="form-control" placeholder="static.example.com">
<button class="btn btn-primary" onclick="addBucketDomain()">Add Domain</button>
</div>
<div id="bucket-domains-list" style="font-size:13px; color:var(--text3); padding:12px; background:rgba(0,0,0,0.2); border-radius:8px;">Loading domains...</div>
</div>
<!-- Static Website Hosting -->
<div style="margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border);">
<label style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:8px;">Static Website Hosting</label>
<div style="background:rgba(255,255,255,0.02); border:1px solid rgba(255,255,255,0.05); padding:16px; border-radius:8px;">
<div style="display:flex; align-items:center; justify-content:space-between; margin-bottom:14px;">
<div>
<div style="font-weight:600; font-size:14px; margin-bottom:4px;">Host as Static Site</div>
<div style="font-size:12px; color:var(--text3);">Serve SPAs or static sites directly from this bucket with clean URL routing.</div>
</div>
<label class="switch">
<input type="checkbox" id="site-setting-enabled" onchange="toggleSiteInputs(this.checked)">
<span class="slider round"></span>
</label>
</div>
<div id="site-config-fields" style="display:none; flex-direction:column; gap:12px;">
<div style="display:grid; grid-template-columns:1fr 1fr; gap:12px;">
<div>
<label style="font-size:11px; color:var(--text3); display:block; margin-bottom:4px;">Index Document</label>
<input type="text" id="site-index-doc" class="form-control" value="index.html">
</div>
<div>
<label style="font-size:11px; color:var(--text3); display:block; margin-bottom:4px;">Error Document</label>
<input type="text" id="site-error-doc" class="form-control" value="404.html">
</div>
</div>
<label style="display:flex; align-items:center; gap:8px; font-size:12px; color:var(--text2); cursor:pointer;">
<input type="checkbox" id="site-spa-mode" style="accent-color:var(--accent);">
<span>Enable SPA Routing (Redirect unmatched routes to Index Document)</span>
</label>
<div style="display:flex; justify-content:space-between; align-items:center; margin-top:8px;">
<a id="site-hosted-url" href="#" target="_blank" style="font-size:12px; color:#38bdf8; text-decoration:none; display:flex; align-items:center; gap:4px;">
<span>Visit Hosted Site</span> ↗
</a>
<button class="btn btn-primary btn-sm" onclick="saveSiteConfig()">Save Website Settings</button>
</div>
</div>
</div>
</div>
<!-- Event Webhooks -->
<div style="margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border);">
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:12px;">
<div>
<label style="display:block; font-size:12px; font-weight:600; color:var(--text2); margin-bottom:2px;">Event Webhooks</label>
<div style="font-size:12px; color:var(--text3);">Receive HTTP POST pings when files are uploaded or deleted.</div>
</div>
<button class="btn btn-ghost btn-sm" onclick="openModal('modal-add-webhook')">+ Add Webhook</button>
</div>
<div id="bucket-webhooks-list" style="font-size:13px; color:var(--text3); padding:12px; background:rgba(0,0,0,0.2); border-radius:8px;">Loading webhooks...</div>
</div>
<div style="margin-top: 32px; padding-top: 24px; border-top: 1px solid rgba(239,68,68,0.2);">
<label style="display:block; font-size:12px; font-weight:600; color:#ef4444; margin-bottom:8px;">Danger Zone</label>
<div style="display:flex; align-items:center; justify-content:space-between; background:rgba(239,68,68,0.05); border:1px solid rgba(239,68,68,0.1); padding:16px; border-radius:8px;">
<div>
<div style="font-weight:600; font-size:14px; margin-bottom:4px; color:#f87171;">Empty Bucket</div>
<div style="font-size:12px; color:var(--text3);">Permanently delete all objects and versions inside this bucket.</div>
</div>
<button class="btn btn-primary" style="background:#ef4444; color:white; border:none;" onclick="emptyCurrentBucket()">Empty Bucket</button>
</div>
</div>
</div>
</div>
</div>
</body>
<style>
/* ==== COSMOS RESTYLE — override layer. Delete this whole block to revert. ==== */
:root{--void:#020308;--ink0:#eef3f8;--dim:rgba(226,234,242,.55);--faint:rgba(226,234,242,.32);--hair:rgba(226,234,242,.08);--hair2:rgba(226,234,242,.14);--ok:#43e5a0;--ac:143,216,255;--mono:'JetBrains Mono',ui-monospace,monospace;--disp:'Space Grotesk',-apple-system,'Segoe UI',sans-serif;--ez:cubic-bezier(.16,1,.3,1);--cream-0:#020308;--cream-1:rgba(255,255,255,.02);--cream-2:rgba(255,255,255,.045);--cream-3:rgba(226,234,242,.08);--cream-4:rgba(226,234,242,.14);--ink-0:#eef3f8;--ink-1:#eef3f8;--ink-2:#e2eaf2;--ink-3:#c6d2de;--ink-4:#8a97a6;--accent-cyan:#8fd9ff;--accent-blue:#7cc9f5;--accent-violet:#8fd9ff;--accent-emerald:#43e5a0;--accent-indigo:#9fb2d8;--violet-light:#8fd9ff;--violet-mid:#b2e4ff;--surface-0:rgba(7,10,18,.92);--surface-1:rgba(7,10,18,.55);--surface-sm:rgba(7,10,18,.45);--border-strong:rgba(226,234,242,.14);--card-border:rgba(226,234,242,.08);--card-border-top:rgba(226,234,242,.11);--card-border-left:rgba(226,234,242,.09);--card-shadow:0 10px 30px rgba(0,0,0,.35);--card-shadow-hover:0 18px 44px rgba(0,0,0,.5);--bg:#020308;--bg2:rgba(255,255,255,.02);--surface:rgba(7,10,18,.5);--surface2:rgba(12,16,26,.6);--surface3:rgba(255,255,255,.07);--border:rgba(226,234,242,.08);--border2:rgba(226,234,242,.14);--text:#eef3f8;--text2:rgba(226,234,242,.55);--text3:rgba(226,234,242,.32);--accent:#8fd9ff;--blue:#7cc9f5;--blue2:#a9e0ff;--indigo:#9fb2d8;--green:#43e5a0;--red:#ff8580;--amber:#ffab4d;--cyan:#9fe0ff;--sidebar:260px;--topbar:70px;--radius:10px;--radius2:14px}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{background-color:var(--bg);color:var(--text);font-family:var(--disp);font-size:15px;line-height:1.6;position:relative}
::selection{background:rgba(143,216,255,.28)}
a:focus-visible,button:focus-visible{outline:1px solid rgba(238,243,248,.5);outline-offset:3px;border-radius:6px}
::-webkit-scrollbar{width:8px;height:8px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:#141b28;border:2px solid #020308;border-radius:6px}
::-webkit-scrollbar-thumb:hover{background:#1d2735}
h1,h2,h3,.page-title{font-weight:700;letter-spacing:-.03em;color:#eef3f8}
@keyframes fade-in-up{from{opacity:0;transform:translateY(24px)}to{opacity:1;transform:translateY(0)}}
@keyframes pulse-ring{0%{box-shadow:0 0 0 0 rgba(143,216,255,.4);transform:scale(1)}70%{box-shadow:0 0 0 7px rgba(143,216,255,0);transform:scale(1.12)}100%{box-shadow:0 0 0 0 rgba(143,216,255,0);transform:scale(1)}}
@keyframes gradient-border-flow{0%{background-position:0% 50%}50%{background-position:100% 50%}100%{background-position:0% 50%}}
.g-text{background:linear-gradient(135deg,#eef3f8,#8fd9ff);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text}
.layout{display:flex;height:100vh;overflow:hidden;position:relative;z-index:1}
.sidebar{width:var(--sidebar);min-width:var(--sidebar);background:rgba(4,6,12,.55);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border-right:1px solid rgba(226,234,242,.08);box-shadow:1px 0 24px rgba(0,0,0,.35);display:flex;flex-direction:column;height:100vh;overflow:hidden;flex-shrink:0;z-index:10}
.sidebar-logo{height:var(--topbar);min-height:var(--topbar);display:flex;align-items:center;gap:13px;padding:0 24px;border-bottom:1px solid rgba(226,234,242,.08);font-weight:700;font-size:17px;letter-spacing:-.02em;color:#eef3f8}
.logo-icon{width:34px;height:34px;border-radius:10px;background:rgba(143,216,255,.1);border:1px solid rgba(143,216,255,.3);display:flex;align-items:center;justify-content:center;flex-shrink:0;color:#8fd9ff}
.sidebar-body{flex:1;overflow-y:auto;padding:20px 16px}
.sidebar-section{margin-bottom:24px}
.sidebar-section-label{font-family:var(--mono);font-size:9.5px;font-weight:400;text-transform:uppercase;letter-spacing:.26em;color:rgba(226,234,242,.32);padding:8px 12px}
.nav-item,.nav-bucket{display:flex;align-items:center;gap:12px;padding:9px 13px;border-radius:9px;cursor:pointer;color:rgba(226,234,242,.55);font-size:14px;font-weight:500;transition:all .25s cubic-bezier(.16,1,.3,1);user-select:none;margin-bottom:4px}
.nav-item:hover,.nav-bucket:hover{background:rgba(255,255,255,.045);color:#eef3f8}
.nav-item.active,.nav-bucket.active{background:rgba(143,216,255,.09);color:#eef3f8;font-weight:600;box-shadow:inset 2px 0 0 #8fd9ff}
.nav-item svg{width:18px;height:18px;flex-shrink:0;opacity:.8}
.nav-item.active svg{opacity:1}
.nav-bucket-icon{width:24px;height:24px;border-radius:8px;background:rgba(255,255,255,.04);color:rgba(226,234,242,.55);display:flex;align-items:center;justify-content:center;flex-shrink:0;border:1px solid rgba(226,234,242,.08)}
.nav-bucket.active .nav-bucket-icon{background:rgba(143,216,255,.14);color:#8fd9ff;border-color:rgba(143,216,255,.35)}
.nav-bucket-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sidebar-create-bucket{display:flex;align-items:center;gap:12px;padding:10px 14px;border-radius:9px;cursor:pointer;color:rgba(226,234,242,.32);font-size:13.5px;font-weight:500;transition:all .2s;border:1px dashed rgba(226,234,242,.14);margin-top:12px;background:rgba(255,255,255,.02)}
.sidebar-create-bucket:hover{color:#8fd9ff;background:rgba(143,216,255,.07);border-color:rgba(143,216,255,.4)}
.sidebar-user{border-top:1px solid rgba(226,234,242,.08);padding:16px;cursor:pointer;background:rgba(2,3,8,.35)}
.sidebar-user-card{display:flex;align-items:center;gap:12px;padding:12px;border-radius:11px;transition:all .2s}
.sidebar-user-card:hover{background:rgba(255,255,255,.045)}
.user-avatar{width:40px;height:40px;border-radius:10px;background:linear-gradient(135deg,rgba(143,216,255,.24),rgba(143,216,255,.06));border:1px solid rgba(143,216,255,.3);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;flex-shrink:0;color:#eef3f8}
.user-name{font-weight:600;font-size:14px;color:#eef3f8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.user-role{font-family:var(--mono);font-size:10px;color:rgba(226,234,242,.32);margin-top:2px;letter-spacing:.14em;text-transform:uppercase}
.main{flex:1;display:flex;flex-direction:column;height:100vh;overflow:hidden;min-width:0;position:relative;z-index:1}
.topbar{height:var(--topbar);min-height:var(--topbar);background:rgba(4,6,12,.55);backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);border-bottom:1px solid rgba(226,234,242,.08);display:flex;align-items:center;padding:0 36px;gap:16px;z-index:50}
.breadcrumb{display:flex;align-items:center;gap:8px;flex:1;min-width:0}
.bc-item{color:rgba(226,234,242,.55);font-family:var(--mono);font-size:12px;font-weight:400;cursor:pointer;transition:.2s}
.bc-item:hover{color:#eef3f8}
.bc-item.active{color:#eef3f8;font-weight:500;cursor:default;pointer-events:none}
.bc-sep{color:rgba(226,234,242,.32);font-size:12px;margin:0 4px}
.topbar-actions{display:flex;align-items:center;gap:12px;flex-shrink:0}
.content{flex:1;overflow-y:auto;padding:0}
.view{display:none}
.view.active{display:flex;flex-direction:column;height:100%;animation:fade-in-up .5s cubic-bezier(.16,1,.3,1) both}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:10px 20px;border-radius:10px;font-size:14px;font-weight:600;cursor:pointer;border:none;transition:transform .2s cubic-bezier(.16,1,.3,1),box-shadow .25s cubic-bezier(.16,1,.3,1),background-color .2s,border-color .2s,color .2s;white-space:nowrap;position:relative;overflow:hidden}
.btn svg{width:18px;height:18px;flex-shrink:0}
.btn-sm{padding:8px 16px;font-size:13px}
.btn-primary{background:#eef3f8;color:#04060d;box-shadow:0 6px 24px rgba(238,243,248,.13)}
.btn-primary::after{content:'';position:absolute;inset:0;background:linear-gradient(to bottom,rgba(255,255,255,.35) 0%,transparent 55%);border-radius:inherit;pointer-events:none;opacity:.5}
.btn-primary:hover{transform:translateY(-1px);box-shadow:0 12px 36px rgba(238,243,248,.22)}
.btn-primary:active{transform:scale(.98)}
.btn-ghost{background:rgba(255,255,255,.04);color:#eef3f8;border:1px solid rgba(226,234,242,.14)}
.btn-ghost:hover{background:rgba(255,255,255,.08);border-color:rgba(226,234,242,.28);transform:translateY(-1px)}
.btn-danger{background:rgba(255,133,128,.08);color:#ff8580;border:1px solid rgba(255,133,128,.25)}
.btn-danger:hover{background:#ff8580;color:#fff;box-shadow:0 6px 20px rgba(255,133,128,.28)}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none!important;box-shadow:none!important}
.page-header{padding:36px 40px 10px}
.page-title{font-size:27px;font-weight:700;margin-bottom:6px;letter-spacing:-.03em}
.page-subtitle{color:rgba(226,234,242,.55);font-size:14.5px;font-weight:400}
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:22px;padding:22px 40px}
.stat-card{background:rgba(7,10,18,.55);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid rgba(226,234,242,.08);border-top-color:rgba(226,234,242,.11);border-left-color:rgba(226,234,242,.09);border-radius:14px;padding:24px;box-shadow:0 10px 30px rgba(0,0,0,.35);transition:transform .3s cubic-bezier(.16,1,.3,1),box-shadow .3s cubic-bezier(.16,1,.3,1);position:relative;overflow:hidden}
.stat-card:hover{transform:translateY(-3px);box-shadow:0 18px 44px rgba(0,0,0,.5)}
.stat-card-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:18px}
.stat-card-label{font-family:var(--mono);font-size:9.5px;color:rgba(226,234,242,.32);font-weight:400;text-transform:uppercase;letter-spacing:.22em}
.stat-card-icon{width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,.04);border:1px solid rgba(226,234,242,.08)}
.stat-card-icon svg{width:19px;height:19px}
.stat-card-value{font-family:var(--mono);font-size:29px;font-weight:500;letter-spacing:-.02em;margin-bottom:3px;color:#eef3f8;font-variant-numeric:tabular-nums}
.stat-card-meta{font-family:var(--mono);font-size:11px;color:rgba(226,234,242,.32);font-weight:400}
.charts-grid{display:grid;grid-template-columns:1fr 1fr;gap:22px;padding:0 40px 40px}
.chart-card{background:rgba(7,10,18,.55);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border:1px solid rgba(226,234,242,.08);border-top-color:rgba(226,234,242,.11);border-left-color:rgba(226,234,242,.09);border-radius:14px;padding:28px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.chart-card-header{margin-bottom:22px}
.chart-card-title{font-size:18px;font-weight:700;margin-bottom:4px;color:#eef3f8;letter-spacing:-.02em}
.chart-card-sub{font-size:13.5px;color:rgba(226,234,242,.55)}
.chart-wrap{position:relative;height:240px}
.quota-bar-wrap{margin-top:20px}
.quota-label{display:flex;justify-content:space-between;font-family:var(--mono);font-size:11.5px;font-weight:400;color:rgba(226,234,242,.55);margin-bottom:10px}
.quota-track{height:7px;background:rgba(255,255,255,.05);border-radius:4px;overflow:hidden}
.quota-fill{height:100%;border-radius:4px;background:linear-gradient(90deg,#5fb9e8,#8fd9ff);transition:width .6s cubic-bezier(.16,1,.3,1);box-shadow:0 0 12px rgba(143,216,255,.3)}
.quota-fill.warning{background:linear-gradient(90deg,#ffab4d,#ff8580);box-shadow:0 0 12px rgba(255,133,128,.3)}
.browser-header{display:flex;align-items:center;justify-content:space-between;padding:22px 40px;border-bottom:1px solid rgba(226,234,242,.08);flex-shrink:0}
#browser-title{font-size:20px;font-weight:700;letter-spacing:-.025em;color:#eef3f8}
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:80px 24px;text-align:center;color:rgba(226,234,242,.55)}
.empty-state-icon{width:88px;height:88px;border-radius:24px;background:rgba(7,10,18,.55);border:1px solid rgba(226,234,242,.08);display:flex;align-items:center;justify-content:center;margin-bottom:22px}
.empty-state-icon svg{width:36px;height:36px;color:rgba(226,234,242,.32)}
.empty-state h3{font-size:21px;font-weight:700;color:#eef3f8;margin-bottom:12px}
.file-table-wrap{flex:1;overflow-y:auto;padding:0 24px;margin-top:16px}
.file-table{width:100%;border-collapse:separate;border-spacing:0 8px}
.file-table th{padding:10px 24px;font-family:var(--mono);font-size:9.5px;font-weight:400;text-transform:uppercase;letter-spacing:.2em;color:rgba(226,234,242,.32);text-align:left;position:sticky;top:0;z-index:1;background:rgba(4,6,12,.92);backdrop-filter:blur(10px)}
.file-table td{padding:14px 24px;vertical-align:middle;font-size:14px;font-weight:400;background:rgba(7,10,18,.55);border-top:1px solid rgba(226,234,242,.11);border-bottom:1px solid rgba(226,234,242,.08)}
.file-table tbody tr td:first-child{border-left:1px solid rgba(226,234,242,.09);border-top-left-radius:12px;border-bottom-left-radius:12px}
.file-table tbody tr td:last-child{border-right:1px solid rgba(226,234,242,.08);border-top-right-radius:12px;border-bottom-right-radius:12px}
.file-table tbody tr{transition:all .25s cubic-bezier(.16,1,.3,1);cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,.18)}
.file-table tbody tr:hover{transform:translateY(-1px);box-shadow:0 10px 24px rgba(0,0,0,.3);background:rgba(10,15,26,.75)}
.file-row-name{display:flex;align-items:center;gap:14px}
.file-icon{width:38px;height:38px;border-radius:9px;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:rgba(255,255,255,.04);border:1px solid rgba(226,234,242,.08)}
.file-icon.folder{color:#ffab4d}
.file-icon.doc{color:#8fd9ff}
.file-icon.img{color:#43e5a0}
.file-icon.vid{color:#ff8580}
.file-icon.arc{color:#dce6f2}
.file-icon svg{width:19px;height:19px}
.file-name-text{font-weight:600;font-size:14px;color:#eef3f8}
.file-meta{font-family:var(--mono);font-size:11px;color:rgba(226,234,242,.32);margin-top:2px}
.row-actions{display:flex;align-items:center;gap:6px;justify-content:flex-end;opacity:0;transition:.2s}
.file-table tbody tr:hover .row-actions{opacity:1}
.icon-btn{width:34px;height:34px;border-radius:9px;background:rgba(255,255,255,.04);border:1px solid rgba(226,234,242,.08);cursor:pointer;display:flex;align-items:center;justify-content:center;color:rgba(226,234,242,.55);transition:all .2s}
.icon-btn:hover{background:rgba(226,234,242,.14);color:#eef3f8;transform:scale(1.05)}
.icon-btn.danger:hover{background:#ff8580;color:#fff;border-color:#ff8580}
.form-page{padding:36px 40px;max-width:800px}
.profile-hero{position:relative;background:rgba(7,10,18,.55);backdrop-filter:blur(16px);border-radius:14px;padding:36px;display:flex;align-items:center;gap:30px;margin-bottom:28px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.profile-hero::before{content:"";position:absolute;inset:-1.5px;border-radius:inherit;padding:1.5px;background:linear-gradient(135deg,rgba(143,216,255,.55),rgba(226,234,242,.16) 40%,rgba(143,216,255,.45));background-size:300% 300%;animation:gradient-border-flow 8s ease infinite;-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;pointer-events:none}
.profile-hero-avatar{width:96px;height:96px;border-radius:24px;background:linear-gradient(135deg,rgba(143,216,255,.24),rgba(143,216,255,.06));border:1px solid rgba(143,216,255,.35);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:34px;flex-shrink:0;color:#eef3f8}
.profile-hero-name{font-size:28px;font-weight:700;margin-bottom:6px;letter-spacing:-.03em;color:#eef3f8}
.form-section{background:rgba(7,10,18,.55);backdrop-filter:blur(16px);border:1px solid rgba(226,234,242,.08);border-radius:14px;margin-bottom:22px;box-shadow:0 10px 30px rgba(0,0,0,.35)}
.form-section-header{padding:22px 30px;border-bottom:1px solid rgba(226,234,242,.08);display:flex;align-items:center;justify-content:space-between}
.form-section-title{font-size:17px;font-weight:700;color:#eef3f8;letter-spacing:-.02em}
.form-section-subtitle{font-size:13.5px;color:rgba(226,234,242,.55);margin-top:4px}
.form-section-body{padding:28px}
.form-row{margin-bottom:20px}
.form-row:last-child{margin-bottom:0}
.form-label{display:block;font-family:var(--mono);font-size:10px;font-weight:400;color:rgba(226,234,242,.55);margin-bottom:8px;letter-spacing:.18em;text-transform:uppercase}
.form-control{width:100%;background:rgba(2,3,8,.55);border:1px solid rgba(226,234,242,.14);color:#eef3f8;padding:12px 14px;border-radius:10px;font-size:14px;font-weight:400;outline:none;transition:all .2s}
.form-control:focus{border-color:rgba(143,216,255,.6);background:rgba(2,3,8,.75);box-shadow:0 0 0 3px rgba(143,216,255,.14)}
.form-control[readonly]{background:rgba(255,255,255,.02);color:rgba(226,234,242,.55);cursor:default;font-family:var(--mono)}
.cred-box{background:rgba(2,3,8,.6);border:1px solid rgba(226,234,242,.08);border-radius:10px;padding:14px 18px;font-family:var(--mono);font-size:12.5px;color:rgba(226,234,242,.55);display:flex;align-items:center;justify-content:space-between;gap:16px}
.cred-copy{background:rgba(255,255,255,.04);border:1px solid rgba(226,234,242,.08);color:#eef3f8;cursor:pointer;padding:8px;border-radius:8px;transition:.2s}
.cred-copy:hover{background:rgba(255,255,255,.09);transform:translateY(-1px)}
.code-block{background:#01030a;border-radius:10px;padding:22px;font-family:var(--mono);font-size:13px;color:#9fe0ff;line-height:1.7;overflow-x:auto;white-space:pre;border:1px solid rgba(226,234,242,.08)}
.badge{display:inline-flex;align-items:center;padding:5px 13px;border-radius:99px;font-family:var(--mono);font-size:10px;font-weight:400;letter-spacing:.18em;text-transform:uppercase}
.badge-blue{background:rgba(143,216,255,.1);color:#8fd9ff;border:1px solid rgba(143,216,255,.3)}
.badge-green{background:rgba(67,229,160,.1);color:#43e5a0;border:1px solid rgba(67,229,160,.3)}
.modal-bg{position:fixed;inset:0;background:rgba(1,2,8,.78);backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);z-index:400;display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity .35s cubic-bezier(.16,1,.3,1)}
.modal-bg.open{opacity:1;pointer-events:auto}
.modal{background:rgba(7,10,18,.94);border:1px solid rgba(226,234,242,.08);backdrop-filter:blur(24px);-webkit-backdrop-filter:blur(24px);border-radius:16px;padding:0;width:100%;max-width:480px;transform:scale(.96) translateY(16px);transition:all .4s cubic-bezier(.16,1,.3,1);box-shadow:0 40px 100px rgba(0,0,0,.6);overflow:hidden}
.modal-bg.open .modal{transform:scale(1) translateY(0)}
.modal-header{padding:22px 30px;border-bottom:1px solid rgba(226,234,242,.08);display:flex;align-items:center;justify-content:space-between}
.modal-title{font-size:18px;font-weight:700;color:#eef3f8;letter-spacing:-.02em}
.modal-close{background:rgba(255,255,255,.04);border:1px solid rgba(226,234,242,.08);cursor:pointer;width:34px;height:34px;border-radius:9px;display:flex;align-items:center;justify-content:center;color:#eef3f8;transition:.2s}
.modal-close:hover{background:rgba(255,255,255,.09);transform:scale(1.05)}
.modal-body{padding:28px}
.modal-body p{font-size:14.5px;color:rgba(226,234,242,.55);margin-bottom:22px;line-height:1.6}
.modal-footer{padding:22px 30px;background:rgba(2,3,8,.5);border-top:1px solid rgba(226,234,242,.08);display:flex;justify-content:flex-end;gap:14px}
.toast-stack{position:fixed;bottom:40px;left:50%;transform:translateX(-50%);z-index:1000;display:flex;flex-direction:column-reverse;gap:14px;align-items:center;pointer-events:none}
.toast{background:rgba(10,14,22,.94);border:1px solid rgba(226,234,242,.14);backdrop-filter:blur(20px);color:#eef3f8;padding:14px 22px;border-radius:12px;font-size:14px;font-weight:500;display:flex;align-items:center;gap:12px;box-shadow:0 20px 44px rgba(0,0,0,.5);animation:toastIn .4s cubic-bezier(.16,1,.3,1) forwards}
@keyframes toastIn{from{opacity:0;transform:translateY(24px) scale(.96)}to{opacity:1;transform:none}}
#mode-toggle:checked + .slider{background:linear-gradient(135deg,#5fb9e8,#8fd9ff)!important}
#mode-toggle:checked + .slider .slider-dot{transform:translateX(20px)}
.slider{border-radius:34px;background:rgba(255,255,255,.1)}
.slider-dot{background:#fff}
.drive-item{display:flex;align-items:center;padding:12px 16px;border-radius:11px;transition:all .2s cubic-bezier(.16,1,.3,1);cursor:pointer;margin-bottom:4px;border:1px solid transparent;background:rgba(7,10,18,.5)}
.drive-item:hover{background:rgba(12,16,26,.6);border-color:rgba(226,234,242,.14);transform:translateY(-1px)}
.drive-item-icon{display:flex;align-items:center;justify-content:center;background:rgba(143,216,255,.08);padding:10px;border-radius:9px;color:#8fd9ff;margin-right:16px;border:1px solid rgba(143,216,255,.2)}
.drive-item-icon.folder{background:rgba(255,171,77,.12);color:#ffab4d;border-color:rgba(255,171,77,.25)}
.btn-icon{background:none;border:none;color:rgba(226,234,242,.32);cursor:pointer;padding:8px;border-radius:8px;transition:.2s;display:flex;align-items:center;justify-content:center;width:32px;height:32px}
.btn-icon:hover{background:rgba(255,255,255,.07);color:#eef3f8}
.btn-icon.danger:hover{background:rgba(255,133,128,.1);color:#ff8580}
.globe-card{flex-direction:row}
.switch{position:relative;display:inline-block;width:36px;height:20px}
.switch input{opacity:0;width:0;height:0}
input:checked + .slider{background-color:#5fb9e8}
input:checked + .slider:before{transform:translateX(16px)}
@media(max-width:800px){
.file-table thead{display:none}
.file-table,.file-table tbody,.file-table tr,.file-table td{display:block;width:100%}
.file-table tr{margin-bottom:15px;border-bottom:1px solid rgba(226,234,242,.08);padding-bottom:10px}
.file-table td{text-align:left;padding:4px 12px;position:relative}
.file-table td:nth-child(2)::before{content:"Size: ";font-weight:bold}
.file-table td:nth-child(4)::before{content:"Modified: ";font-weight:bold}
}
</style>
<style>
#cosmos-fx{position:fixed;inset:0;z-index:2000;pointer-events:none}
</style>
<script>
/* ═════════════════════════════════════════════════════════════
COSMOS FX — star-creation motion layer (Oort Console)
Hooks: fetch + XHR + breadcrumb observer. No app code touched.
═════════════════════════════════════════════════════════════ */
(function(){
'use strict';
var TAU=Math.PI*2;
var RM=matchMedia('(prefers-reduced-motion: reduce)').matches;
if(RM)return;
var cv=document.createElement('canvas');cv.id='cosmos-fx';
document.body.appendChild(cv);
var cx=cv.getContext('2d'),W=0,H=0,DPR=1;
function resize(){DPR=Math.min(devicePixelRatio||1,2);W=innerWidth;H=innerHeight;
cv.width=W*DPR;cv.height=H*DPR;cv.style.width=W+'px';cv.style.height=H+'px';
cx.setTransform(DPR,0,0,DPR,0,0)}
addEventListener('resize',resize,{passive:true});resize();
function clamp(v,a,b){return v<a?a:(v>b?b:v)}
function spr(sz,st){var c=document.createElement('canvas');c.width=c.height=sz;
var x=c.getContext('2d'),g=x.createRadialGradient(sz/2,sz/2,0,sz/2,sz/2,sz/2);
for(var i=0;i<st.length;i+=2)g.addColorStop(st[i],st[i+1]);
x.fillStyle=g;x.fillRect(0,0,sz,sz);return c}
var SP={
white:spr(64,[0,'rgba(255,255,255,1)',.25,'rgba(255,255,255,.6)',1,'rgba(255,255,255,0)']),
cyan: spr(64,[0,'rgba(215,240,255,1)',.25,'rgba(143,216,255,.55)',1,'rgba(143,216,255,0)']),
warm: spr(64,[0,'rgba(255,243,214,1)',.25,'rgba(255,171,77,.55)',1,'rgba(255,171,77,0)']),
ember:spr(64,[0,'rgba(255,196,130,1)',.3,'rgba(255,120,60,.5)',1,'rgba(255,80,40,0)'])};
/* engine — rAF runs only while effects are alive */
var sys=[],running=false,last=0;
function loop(now){
if(!sys.length){running=false;return}
var dt=Math.min(.05,(now-last)/1000);last=now;
cx.clearRect(0,0,W,H);
cx.globalCompositeOperation='lighter';
for(var i=sys.length-1;i>=0;i--)if(sys[i](dt)===false)sys.splice(i,1);
cx.globalAlpha=1;cx.globalCompositeOperation='source-over';
requestAnimationFrame(loop)
}
function add(f){sys.push(f);if(!running){running=true;last=performance.now();requestAnimationFrame(loop)}}
function draw(k,x,y,sz,a){cx.globalAlpha=clamp(a,0,1);cx.drawImage(SP[k],x-sz*.5,y-sz*.5,sz,sz)}
function ring(x,y,r,a,col,w){cx.globalAlpha=clamp(a,0,1);cx.strokeStyle=col;cx.lineWidth=w;
cx.beginPath();cx.arc(x,y,Math.max(0,r),0,TAU);cx.stroke()}
function dim(a){cx.globalCompositeOperation='source-over';
var g=cx.createRadialGradient(W/2,H/2,Math.min(W,H)*.22,W/2,H/2,Math.max(W,H)*.78);
g.addColorStop(0,'rgba(1,2,8,0)');g.addColorStop(1,'rgba(1,2,8,'+a+')');
cx.globalAlpha=1;cx.fillStyle=g;cx.fillRect(0,0,W,H);cx.globalCompositeOperation='lighter'}
var lastFire={};
function once(k,cd){var n=performance.now();
if(lastFire[k]&&n-lastFire[k]<cd)return false;lastFire[k]=n;return true}
/* ── STAR FORGE — bucket creation ── */
function fxForge(){
for(var i=sys.length-1;i>=0;i--)if(sys[i].tag==='forge')sys.splice(i,1);
var C={x:W*.5,y:H*.5},mD=Math.min(W,H),n=150,ps=[];
for(var j=0;j<n;j++)ps.push({
ca:Math.random()*TAU,r0:(0.18+Math.random()*0.34)*mD,
sp:.8+Math.random()*.8,dl:Math.random()*.3,
wq:Math.random()*TAU,ws:.8+Math.random()*1.6,
orb:12+Math.random()*26,ov:1.4+Math.random()*2.2,
sz:16+Math.random()*30,al:.22+Math.random()*.45,
k:Math.random()<.7?'cyan':'warm',u:0});
var st={t:0,dz:0,ready:false,ok:false,ign:-1,dis:false};
function ignite(){
st.ign=st.t;
var t1=0;add(function(dt){t1+=dt;if(t1>.55)return false;
draw('white',C.x,C.y,mD*.95,(1-t1/.55)*.8);return true});
var t2=0;add(function(dt){t2+=dt;if(t2>2.7)return false;
var fd=t2<1.7?1:Math.max(0,1-(t2-1.7)),pul=1+.05*Math.sin(t2*7);
draw('cyan',C.x,C.y,130*pul,.5*fd);
draw('white',C.x,C.y,40*pul,.95*fd);
cx.save();cx.translate(C.x,C.y);cx.rotate(t2*.3);
cx.globalAlpha=.45*fd;cx.strokeStyle='rgba(205,236,255,.9)';cx.lineWidth=1.3;
for(var s=0;s<4;s++){cx.rotate(Math.PI/2);
cx.beginPath();cx.moveTo(30,0);cx.lineTo(mD*.17,0);cx.stroke()}
cx.restore();return true});
var t3=0;add(function(dt){t3+=dt;if(t3>1.6)return false;
for(var r=0;r<3;r++){var k2=t3-r*.09;if(k2<0)continue;
var f=k2/1.5;
ring(C.x,C.y,22+f*f*mD*.6,(1-f)*.5,
r===0?'rgba(224,246,255,1)':(r===1?'rgba(143,216,255,1)':'rgba(255,193,120,1)'),1.7-r*.45)}
return true});
var dp=[];
for(var e=0;e<70;e++){var a=Math.random()*TAU;
dp.push({a:a,v:90+Math.random()*380,x:C.x,y:C.y,al:.5+Math.random()*.5,
sz:5+Math.random()*9,k:Math.random()<.5?'warm':'cyan'})}
var t4=0;add(function(dt){t4+=dt;if(t4>1.9)return false;
var fd=1-t4/1.9;
for(var q=0;q<dp.length;q++){var d=dp[q],sp=d.v*Math.exp(-1.1*t4);
d.x+=Math.cos(d.a)*sp*dt;d.y+=Math.sin(d.a)*sp*dt;
draw(d.k,d.x,d.y,d.sz*(.4+.6*fd),fd*d.al*.8)}
return true});
}
var main=function(dt){
st.t+=dt;
if(st.dis){
st.dz+=dt;
var fD=Math.max(0,1-st.dz/1.4);
dim(.15*fD);
for(var i2=0;i2<n;i2++){var p2=ps[i2];
p2.u=Math.max(0,p2.u-dt*.65);
var e2=p2.u*p2.u,rr=p2.r0+(p2.orb-p2.r0)*e2;
p2.ca+=dt*.3;
draw(p2.k,C.x+Math.cos(p2.ca)*rr,C.y+Math.sin(p2.ca)*rr*.6,p2.sz*(.5+.5*e2),p2.al*fD)}
draw('ember',C.x,C.y,30,.3*fD);
return st.dz<1.5;
}
if(st.ign<0&&((st.ready&&st.t>=1.15&&st.ok)||st.t>6))ignite();
if(st.ign<0&&st.ready&&!st.ok){st.dis=true;st.dz=0;return true}
var ig=st.ign>=0?st.t-st.ign:0;
if(st.ign>=0&&ig>.9)return false;
dim(.3*clamp((st.t-.2)/.9,0,1)*(st.ign>=0?Math.max(0,1-ig/.8):1));
for(var i3=0;i3<n;i3++){var p=ps[i3];
p.u=clamp((st.t-p.dl)/(p.dl+1.15*p.sp),0,1);
var e=p.u*p.u,rr=p.r0+(p.orb-p.r0)*e;
p.ca+=dt*(.2+.9*p.u+(p.u>=1?p.ov:0));
if(p.u<.7)p.ca+=Math.sin(st.t*p.ws+p.wq)*.36*(1-p.u)*dt;
var al=p.al*(.35+.65*(1-p.u*.75));
if(st.ign>=0)al*=Math.max(0,1-ig/.5);
draw(p.k,C.x+Math.cos(p.ca)*rr,C.y+Math.sin(p.ca)*rr*.6,p.sz*(1-.5*p.u)+2,al)}
if(st.t>.45&&st.ign<0){
var eg=clamp((st.t-.45)/.7,0,1);
draw('ember',C.x,C.y,20+eg*26,(0.25+eg*.45)*(0.85+0.15*Math.sin(st.t*9)));
draw('cyan',C.x,C.y,80+eg*60,.1+.14*eg);
draw('cyan',C.x,C.y,26,.15*eg)}
return true;
};
main.tag='forge';
add(main);
return {finish:function(ok){st.ready=true;st.ok=!!ok}};
}
/* ── SUPERNOVA — bucket deletion ── */
function fxNova(){
if(!once('nova',400))return;
var C={x:W*.5,y:H*.5},mD=Math.min(W,H);
var st={t:0,blast:false,dp:null};
function blast(){
st.blast=true;
var t1=0;add(function(dt){t1+=dt;if(t1>.5)return false;
draw('white',C.x,C.y,mD*1.1,(1-t1/.5)*.85);return true});
var t2=0;add(function(dt){t2+=dt;if(t2>1.7)return false;
for(var r=0;r<3;r++){var k2=t2-r*.08;if(k2<0)continue;
var f=k2/1.6;
ring(C.x,C.y,16+f*f*mD*.72,(1-f)*.55,
r===0?'rgba(255,255,255,1)':r===1?'rgba(255,205,140,1)':'rgba(255,140,80,1)',2.1-r*.5)}
return true});
st.dp=[];
for(var q=0;q<230;q++){var a=Math.random()*TAU;
st.dp.push({a:a,v:140+Math.random()*520,x:C.x,y:C.y,al:.4+Math.random()*.6,
sz:4+Math.random()*11,k:Math.random()<.3?'white':(Math.random()<.6?'warm':'ember')})}
}
add(function(dt){
st.t+=dt;
if(st.t>3)return false;
if(st.t<.5){
var u=st.t/.5;
dim(.12+.22*u);
draw('warm',C.x,C.y,40+u*80,.5*u);
draw('white',C.x,C.y,10+u*32,.9*u);
}else if(st.t<.62){
var u2=(st.t-.5)/.12;
dim(.35);
draw('white',C.x,C.y,34*(1-u2*.75)+6,1);
}else{
if(!st.blast)blast();
var k=st.t-.62,fd=Math.max(0,1-k/2.2);
dim(.4*Math.max(0,1-k/1.5));
draw('white',C.x,C.y,60*fd+16,.35*fd);
if(st.dp)for(var q2=0;q2<st.dp.length;q2++){var d=st.dp[q2];
var sp=d.v*Math.exp(-1.25*k);
d.x+=Math.cos(d.a)*sp*dt;d.y+=Math.sin(d.a)*sp*dt;
draw(d.k,d.x,d.y,d.sz*(.35+.65*fd),fd*d.al)}
}
return true});
}
/* ── IMPLOSION — empty bucket ── */
function fxImplode(){
if(!once('imp',400))return;
var C={x:W*.5,y:H*.5},mD=Math.min(W,H),ps=[];
for(var i=0;i<90;i++)ps.push({a:Math.random()*TAU,
r:(.15+Math.random()*.3)*mD,va:2+Math.random()*2.5,
sz:6+Math.random()*14,al:.3+Math.random()*.5,k:Math.random()<.6?'cyan':'white'});
var st={t:0,fl=false};
add(function(dt){
st.t+=dt;
if(st.t>1.7)return false;
dim(.25*Math.min(1,st.t*2)*(st.t>1?Math.max(0,1-(st.t-1)/.7):1));
for(var j=0;j<ps.length;j++){var p=ps[j];
p.r-=mD*.32*dt;p.a+=p.va*dt*(1+2*(1-p.r/(mD*.4)));
if(p.r<8)p.r=8;
draw(p.k,C.x+Math.cos(p.a)*p.r,C.y+Math.sin(p.a)*p.r*.6,p.sz,
Math.max(0,p.al*(1-st.t/1.4)))}
if(st.t>1&&!st.fl){st.fl=true;
var t1=0;add(function(dt){t1+=dt;if(t1>.5)return false;
draw('white',C.x,C.y,90,(1-t1/.5)*.7);
draw('cyan',C.x,C.y,200,(1-t1/.5)*.4);return true})}
return true});
}
/* ── STARDUST DISSOLVE — file deletion ── */
function fxDissolve(){
if(!once('dis',350))return;
var C={x:W*.5,y:H*.55},ps=[];
for(var i=0;i<70;i++){var a=Math.random()*TAU;
ps.push({x:C.x+Math.cos(a)*Math.random()*60,y:C.y+Math.sin(a)*Math.random()*40,
vx:Math.cos(a)*(30+Math.random()*90),vy:Math.sin(a)*(20+Math.random()*60)-40,
sz:4+Math.random()*9,al:.3+Math.random()*.5,k:Math.random()<.6?'cyan':'white'})}
var st={t:0};
add(function(dt){
st.t+=dt;
if(st.t>1.2)return false;
var fd=1-st.t/1.2;
for(var j=0;j<ps.length;j++){var p=ps[j];
p.x+=p.vx*dt;p.y+=p.vy*dt;p.vy-=10*dt;
draw(p.k,p.x,p.y,p.sz*(.5+.5*fd),fd*p.al)}
return true});
}
/* ── SPIRAL GALAXY — new folder ── */
function fxSwirl(){
if(!once('sw',350))return;
var C={x:W*.5,y:H*.5},ps=[];
for(var i=0;i<64;i++){var rr=30+Math.pow(Math.random(),.7)*140;
ps.push({a:Math.random()*TAU,r:rr,va:1.2+90/rr,sz:3+Math.random()*8,
al:.25+Math.random()*.5,k:Math.random()<.7?'cyan':'white'})}
var st={t:0};
add(function(dt){
st.t+=dt;
if(st.t>1.5)return false;
var fd=st.t<1?1:Math.max(0,1-(st.t-1)/.5);
dim(.15*fd);
for(var j=0;j<ps.length;j++){var p=ps[j];
p.a+=p.va*dt*(1+st.t*.8);p.r=Math.max(16,p.r-60*dt);
draw(p.k,C.x+Math.cos(p.a)*p.r,C.y+Math.sin(p.a)*p.r*.5,p.sz,fd*p.al)}
draw('cyan',C.x,C.y,70,.3*fd);
draw('white',C.x,C.y,18,.5*fd);
return true});
}
/* ── WARP — folder navigation (in / out) ── */
function fxWarp(dir){
if(!once('warp',350))return;
var C={x:W*.5,y:H*.5},mD=Math.min(W,H),ps=[];
for(var i=0;i<42;i++)ps.push({a:Math.random()*TAU,r0:40+Math.random()*mD*.2,
sp:mD*(.8+Math.random()*.8)});
var st={t:0};
add(function(dt){
st.t+=dt;
if(st.t>.6)return false;
var fd=Math.sin(Math.min(1,st.t/.6)*Math.PI);
cx.lineWidth=1.2;cx.strokeStyle='rgba(190,225,255,1)';
for(var j=0;j<ps.length;j++){var p=ps[j];
var R,L;
if(dir>0){R=p.r0+p.sp*st.t*2.2}
else{R=(p.r0+p.sp*.6)-p.sp*st.t*2.2;if(R<12)continue}
L=Math.min(R-6,p.sp*.22*fd+8);
cx.globalAlpha=.28*fd;
cx.beginPath();
cx.moveTo(C.x+Math.cos(p.a)*R,C.y+Math.sin(p.a)*R);
cx.lineTo(C.x+Math.cos(p.a)*(R-L),C.y+Math.sin(p.a)*(R-L));
cx.stroke()}
cx.globalAlpha=1;
draw('cyan',C.x,C.y,120*fd+20,.12*fd);
return true});
}
/* ── ACCRETION STREAM — uploads ── */
var stream={on:false,stop:false,parts:[],acc:0,live:false};
function streamTarget(){return{x:W*.5,y:H*.28}}
function streamPulse(){
if(!once('sp',400))return;
var T=streamTarget(),t1=0;
add(function(dt){t1+=dt;if(t1>.7)return false;
var fd=1-t1/.7;
draw('cyan',T.x,T.y,70,fd*.7);
draw('white',T.x,T.y,24,fd*.8);
ring(T.x,T.y,20+t1*260,fd*.4,'rgba(143,216,255,1)',1.4);
return true});
}
function streamSys(dt){
if(stream.stop&&stream.parts.length===0){stream.on=false;stream.live=false;return false}
stream.acc+=dt*14;
while(stream.acc>1&&stream.parts.length<70){stream.acc--;
var side=Math.random()<.5?-1:1;
stream.parts.push({u:0,sp:.25+Math.random()*.2,
sx:W*.5+side*(W*.42+Math.random()*60),sy:H+30+Math.random()*80,
cxp:W*.5+side*W*.28,cy:H*.55,
sz:2.5+Math.random()*4,al:.14+Math.random()*.16,
k:Math.random()<.7?'cyan':'white'})}
var T=streamTarget();
for(var j=stream.parts.length-1;j>=0;j--){var p=stream.parts[j];
p.u+=p.sp*dt;
if(p.u>=1){stream.parts.splice(j,1);continue}
var iu=1-p.u;
var x=iu*iu*p.sx+2*iu*p.u*p.cxp+p.u*p.u*T.x;
var y=iu*iu*p.sy+2*iu*p.u*p.cy+p.u*p.u*T.y;
draw(p.k,x,y,p.sz,p.al)}
draw('cyan',T.x,T.y,44+6*Math.sin(performance.now()/300),.16);
return true;
}
function fxStream(mode){
if(mode===1){stream.on=true;stream.stop=false}
else if(mode===2){streamPulse();stream.stop=true}
else{stream.stop=true}
if(stream.on&&!stream.live){stream.live=true;add(streamSys)}
}
/* ── HOOKS — transparent network interception ── */
function pathOf(u){var p=String(u||'').replace(/^https?:\/\/[^\/]+/,'').split('?')[0];
if(p==='/oort/api/buckets/')p='/oort/api/buckets';return p}
var _f=window.fetch;
if(typeof _f==='function'){
window.fetch=function(input,init){
var url='',m='GET';
try{
if(typeof input==='string')url=input;else if(input&&input.url)url=input.url;
if(init&&init.method)m=String(init.method).toUpperCase();
else if(input&&input.method)m=String(input.method).toUpperCase();
}catch(e){}
try{
var p=pathOf(url);
if(p==='/oort/api/buckets'){
if(m==='POST'){
var f=fxForge();
var pr=_f.apply(this,arguments);
pr.then(function(r){f.finish(r&&r.ok)},function(){f.finish(false)});
return pr;
}
if(m==='DELETE')fxNova();
}
else if(p==='/oort/api/bucket/empty'&&m==='POST')fxImplode();
else if(p==='/oort/api/delete'&&(m==='POST'||m==='DELETE'))fxDissolve();
else if(p==='/oort/api/mkdir'&&m==='POST')fxSwirl();
else if(p==='/oort/api/upload/init'&&m==='POST')fxStream(1);
else if(p==='/oort/api/upload/complete'&&m==='POST')fxStream(2);
else if(p==='/oort/api/upload/abort'&&m==='POST')fxStream(0);
}catch(e){}
return _f.apply(this,arguments);
};
}
var xo=XMLHttpRequest.prototype.open,xs=XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.open=function(m,u){
try{this.__fxp=pathOf(u);this.__fxm=String(m||'').toUpperCase()}catch(e){}
return xo.apply(this,arguments)};
XMLHttpRequest.prototype.send=function(){
try{
var p=this.__fxp,m=this.__fxm;
if(p&&p.indexOf('/oort/api/')===0){
if(m==='POST'&&p==='/oort/api/upload/init')fxStream(1);
else if(m==='POST'&&p==='/oort/api/upload/complete')fxStream(2);
else if(m==='POST'&&p==='/oort/api/upload/abort')fxStream(0);
else if((m==='POST'||m==='DELETE')&&p==='/oort/api/delete')fxDissolve();
else if(m==='POST'&&p==='/oort/api/mkdir')fxSwirl();
}
}catch(e){}
return xs.apply(this,arguments)};
/* ── WARP on folder navigation (breadcrumb depth observer) ── */
(function(){
var bc=document.querySelector('.breadcrumb');
if(!bc||!window.MutationObserver)return;
var depth=bc.querySelectorAll('.bc-item').length,timer=null;
new MutationObserver(function(){
clearTimeout(timer);
timer=setTimeout(function(){
var d=bc.querySelectorAll('.bc-item').length;
if(d!==depth){fxWarp(d>depth?1:-1);depth=d}
},130)
}).observe(bc,{childList:true,subtree:true,characterData:true});
})();
})();
</script>
</html>