Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat(remake): fase E — motion/espacamento/duracao tokenizados, foco visível no .btn corrigido, reduce sem transform, alvos no mínimo macOS, previews de tema atualizados

tonhowtfa6522bba9e90
diff --git a/remake/AUTOCRITICA.md b/remake/AUTOCRITICA.md
index 40eb84a2..40f00475 100644
--- a/remake/AUTOCRITICA.md
+++ b/remake/AUTOCRITICA.md
@@ -22,3 +22,10 @@ Eixos: hier(arquia) · respiro · alinh(amento) · tipo(grafia) · acab(amento)
| `/misc/studio` | 4 | 4 | 4 | 5 | 4 | 4 | Painel de stats em mono tabular (movimento Apple Fitness); botão destrutivo desabilitado legível; 2 temas ok. |
| `/misc/library` | 4 | 4 | 4 | 4 | 3* | 4 | *Sob mock, o comando de plugin nulo vaza exceção JS crua ("Cannot read properties of null") + "Loading…" simultâneo — viola a regra de copy de erro. Causa é o mock (backend real fornece dados), mas a robustez de copy é dívida real registrada no RELATORIO (correção exige tocar o catch — lógica, fora do guardrail visual). Chrome da tela (título, busca, pills) ≥4. |
| `/misc/file-clip` | 4 | 4 | 4 | 4 | 4 | 4 | Card único com ação + hint em footnote; 2 temas ok. |
+| `/study` | 4 | 4 | 4 | 4 | 4 | 4 | Refs: Apple Notes, Apple Music, Craft, Audible (21). Saudação + focus card + sub-nav alinhada ao shell; 2 temas ok. |
+| `/study/player` | 4 | 4 | 4 | 4 | 4 | 4 | Empty state direciona ("Select a lesson from the library"); breadcrumb correto; 2 temas ok. |
+| `/study/read` | 4 | 4 | 2→4 | 4 | 4 | 4 | Iteração 1: h1 com flex:1/min-width:0 colapsava e o texto vazava por baixo do botão "Folders" (colisão real nos 2 temas). Fix: flex 0 0 auto + margin-right auto; toolbar quebra em 2ª linha; recapturado light+dark. |
+| `/study/library` | 4 | 4 | 4 | 4 | 4 | 4 | Header + segmented + busca coerentes; seção "Continue where you left off" vazia sob mock (sem dados) — chrome ok nos 2 temas. |
+| `/study/music` | 4 | 4 | 4 | 4 | 2→4 | 2→4 | Iteração 1: superfície music era dark-only (branco hardcoded sobre fundo claro: título, tiles, headings, skeletons ilegíveis no light). Tokenizados +page e 6 componentes da home (NavigationTitle, SpeedDialGridItem, EmptyPlaceholder, YoutubeSkeleton, AboutLink, ChipsRow) — 30+ hardcodes → tokens; recapturado. Restante das 33 sub-rotas do music: dívida declarada no RELATORIO (~280 hardcodes em componentes profundos). |
+| `/study/watch` | 4 | 4 | 4 | 4 | 4 | 4 | Painel de player com placeholder e hint de pasta; 2 temas ok. |
+| `/_kitchen-sink` | 5 | 4 | 4 | 4 | 4 | 4 | Superfície de auditoria: todos os primitivos × estados verificados nos 2 temas (light nesta fase; dark validado na captura da Fase C com layout idêntico). Serve de prova de foco visível e estados obrigatórios. |
diff --git a/scripts/a11y-audit.mjs b/scripts/a11y-audit.mjs
new file mode 100644
index 00000000..205329dd
--- /dev/null
+++ b/scripts/a11y-audit.mjs
@@ -0,0 +1,143 @@
+#!/usr/bin/env node
+/*
+ * Behavioral a11y/motion audit for the remake (Fase 3 da auditoria).
+ * - prefers-reduced-motion: compares running animations with and without the preference
+ * and flags transform/position animations that survive `reduce`.
+ * - click targets: measures every interactive element against the macOS-desktop
+ * minimums adopted (>=28px standard controls, >=20px dense in-row targets).
+ * - keyboard: tabs through the page and reports focus-visible affordance.
+ * Reuses the Tauri IPC mock from shots.mjs via a tiny inline copy.
+ */
+import { chromium } from "playwright";
+import { spawn } from "node:child_process";
+
+const BASE = "http://localhost:1420";
+const ROUTES = (process.argv[2] || "/,/downloads,/marketplace,/settings,/_kitchen-sink").split(",");
+
+const SETTINGS = { schema_version: 1, appearance: { theme: "dark", language: "en" }, download: { default_output_dir: "/tmp", always_ask_path: false, video_quality: "1080p", skip_existing: true, download_attachments: false, download_descriptions: false, embed_metadata: true, embed_thumbnail: true, clipboard_detection: false, auto_download_on_paste: false, filename_template: "%(title)s.%(ext)s", organize_by_platform: true, download_subtitles: false, include_auto_subtitles: false, caption_locale: "en", keep_vtt: false, subtitle_format: "srt", embed_subtitles: false, keep_subtitle_files: true, skip_archived: false, continuous_lecture_numbers: false, translate_metadata: false, youtube_sponsorblock: false, sponsorblock_mode: "mark", sponsorblock_categories: [], split_by_chapters: false, live_from_start: false, speed_limit: "", hotkey_enabled: true, hotkey_binding: "CmdOrCtrl+Shift+D", music_hotkey_enabled: false, music_hotkey_binding: "", music_audio_format: "mp3", copy_to_clipboard_on_hotkey: false, cookie_file: "", always_use_managed_cookies: false, bilibili_danmaku_enabled: false, bilibili_danmaku_format: "ass", bilibili_container: "mp4", bilibili_nfo_enabled: false, bilibili_cover_sidecar: false, bilibili_cover_format: "jpg", bilibili_naming_video: "", bilibili_naming_multi_part: "", bilibili_naming_bangumi: "", bilibili_naming_cheese: "", bilibili_naming_collection: "", bilibili_cdn_hosts: "", bilibili_cdn_prefer_alternatives: false, bilibili_preferred_qn: 80, bilibili_preferred_codec: 7, bilibili_preferred_audio_qn: 30280 }, advanced: { max_concurrent_segments: 4, max_retries: 3, max_concurrent_downloads: 3, concurrent_fragments: 4, stagger_delay_ms: 500, torrent_listen_port: 6881, torrent_auto_trackers: true, torrent_upnp: true, prevent_sleep: true, cookies_from_browser: "", twitter_manual_cookie: "", user_agent: "" }, telegram: { concurrent_downloads: 2, fix_file_extensions: true }, rpc: { enabled: false, app_id: "", large_image_key: "" }, onboarding_completed: true, start_with_system: false, start_minimized: false, legal_acknowledged: true };
+
+function initScript() {
+ return `(() => {
+ const S = ${JSON.stringify(SETTINGS)};
+ let id = 4000; const listeners = {};
+ window.__TAURI_INTERNALS__ = {
+ invoke: (cmd, args = {}) => {
+ switch (cmd) {
+ case "plugin:event|listen": { const cb = window["_" + args.handler]; if (cb) (listeners[args.event] ||= []).push(cb); return Promise.resolve(++id); }
+ case "get_settings": return Promise.resolve(S);
+ case "check_ytdlp_available": return Promise.resolve(true);
+ case "list_plugins": case "register_external_frontend": case "check_plugin_updates": case "get_download_history": case "check_dependencies": case "fetch_marketplace_registry": return Promise.resolve([]);
+ case "check_cookie_error": return Promise.resolve(false);
+ case "plugin:app|version": return Promise.resolve("0.7.0");
+ default: return Promise.resolve(null);
+ }
+ },
+ transformCallback: (cb) => { const i = ++id; window["_" + i] = cb; return i; },
+ unregisterCallback: (i) => { delete window["_" + i]; },
+ convertFileSrc: (p) => p,
+ };
+ window.isTauri = true;
+ })();`;
+}
+
+async function waitForServer(url, ms) {
+ const deadline = Date.now() + ms;
+ while (Date.now() < deadline) {
+ try { if ((await fetch(url)).ok) return true; } catch {}
+ await new Promise((r) => setTimeout(r, 500));
+ }
+ return false;
+}
+
+async function collect(browser, reduced, route) {
+ const ctx = await browser.newContext({
+ viewport: { width: 1440, height: 900 },
+ colorScheme: "dark",
+ reducedMotion: reduced ? "reduce" : "no-preference",
+ });
+ await ctx.addInitScript(initScript());
+ const page = await ctx.newPage();
+ await page.goto(BASE + route, { waitUntil: "domcontentloaded", timeout: 30000 });
+ await page.waitForTimeout(900);
+ const data = await page.evaluate(() => {
+ const anims = document.getAnimations().map((a) => {
+ const kf = a.effect?.getKeyframes?.() ?? [];
+ const props = new Set();
+ for (const f of kf) for (const k of Object.keys(f)) if (!["offset", "easing", "composite", "computedOffset"].includes(k)) props.add(k);
+ return { props: [...props] };
+ });
+ const moving = anims.filter((a) => a.props.some((p) => ["transform", "translate", "left", "top", "scale"].includes(p)));
+ const sel = "button, a[href], input, select, textarea, [role='button'], [role='switch'], [role='tab']";
+ const targets = [];
+ for (const el of document.querySelectorAll(sel)) {
+ const r = el.getBoundingClientRect();
+ if (r.width === 0 || r.height === 0) continue;
+ const style = getComputedStyle(el);
+ if (style.visibility === "hidden" || style.display === "none") continue;
+ targets.push({ h: Math.round(r.height), w: Math.round(r.width), tag: el.tagName.toLowerCase(), cls: (el.className || "").toString().split(" ")[0], inRow: !!el.closest(".list-row, .download-item, td, .toast, .mac-nav-item") });
+ }
+ return { totalAnims: anims.length, movingAnims: moving.length, targets };
+ });
+ await ctx.close();
+ return data;
+}
+
+async function keyboardPass(browser, route, tabs) {
+ const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, colorScheme: "dark", reducedMotion: "reduce" });
+ await ctx.addInitScript(initScript());
+ const page = await ctx.newPage();
+ await page.goto(BASE + route, { waitUntil: "domcontentloaded", timeout: 30000 });
+ await page.waitForTimeout(700);
+ const seq = [];
+ for (let i = 0; i < tabs; i++) {
+ await page.keyboard.press("Tab");
+ const info = await page.evaluate(() => {
+ const el = document.activeElement;
+ if (!el || el === document.body) return null;
+ const s = getComputedStyle(el);
+ const visible = (s.outlineStyle !== "none" && parseFloat(s.outlineWidth) > 0) || s.boxShadow !== "none" || el.matches(".menu-item, .mac-command-item");
+ return { tag: el.tagName.toLowerCase(), cls: (el.className || "").toString().split(" ")[0], focusAffordance: visible };
+ });
+ if (info) seq.push(info);
+ }
+ await ctx.close();
+ return seq;
+}
+
+async function main() {
+ let devProc = null;
+ if (!(await waitForServer(BASE, 2000))) {
+ devProc = spawn("pnpm", ["dev"], { env: { ...process.env, OMNIGET_I18N_STRICT: "0" }, stdio: "ignore" });
+ if (!(await waitForServer(BASE, 90000))) { console.error("dev server down"); process.exit(1); }
+ }
+ const browser = await chromium.launch();
+
+ console.log("== prefers-reduced-motion ==");
+ for (const route of ROUTES) {
+ const off = await collect(browser, false, route);
+ const on = await collect(browser, true, route);
+ console.log(`${route}: sem preferência = ${off.totalAnims} animações (${off.movingAnims} de posição/escala); com reduce = ${on.totalAnims} animações (${on.movingAnims} de posição/escala) -> ${on.movingAnims === 0 ? "OK" : "FALHA"}`);
+ }
+
+ console.log("\n== alvos de clique (mínimos macOS adotados: 28px padrão / 20px densos) ==");
+ for (const route of ROUTES) {
+ const { targets } = await collect(browser, true, route);
+ const badDense = targets.filter((t) => t.inRow && t.h < 20);
+ const badStd = targets.filter((t) => !t.inRow && t.h < 28 && !(t.tag === "a" && t.h >= 16));
+ console.log(`${route}: ${targets.length} alvos; padrão <28px: ${badStd.length}; densos <20px: ${badDense.length}`);
+ for (const b of [...badStd, ...badDense].slice(0, 6)) console.log(` - ${b.tag}.${b.cls} ${b.w}x${b.h}`);
+ }
+
+ console.log("\n== teclado (Tab x20, foco visível) ==");
+ for (const route of ["/", "/settings", "/_kitchen-sink"]) {
+ const seq = await keyboardPass(browser, route, 20);
+ const noAffordance = seq.filter((s) => !s.focusAffordance);
+ console.log(`${route}: ${seq.length} paradas de foco; sem affordance visível: ${noAffordance.length}`);
+ for (const n of noAffordance.slice(0, 5)) console.log(` - ${n.tag}.${n.cls}`);
+ }
+
+ await browser.close();
+ if (devProc) devProc.kill();
+}
+
+main();
diff --git a/src/app.css b/src/app.css
index 264e3ade..afa135d3 100644
--- a/src/app.css
+++ b/src/app.css
@@ -1,1298 +1,1298 @@
-@import './lib/style/buttons.css';
-@import './lib/style/primitives.css';
-@import './lib/style/settings.css';
-@import './lib/style/macos-shell.css';
-@import '@fontsource/ibm-plex-mono/400.css';
-@import '@fontsource/ibm-plex-mono/500.css';
-
-/*
- * OmniGet design tokens.
- * Source of truth: docs/design-system.md.
- *
- * Spacing/type/radius/elevation/motion are global (don't change per theme).
- * Colors override per [data-theme="..."] block.
- * Legacy aliases (--padding, --border-radius, --button*, --primary, etc.)
- * remain functional pointing at the new tokens; they go away one PR at a time.
- */
-
-:root {
- --space-0: 0;
- --space-1: 4px;
- --space-2: 8px;
- --space-3: 12px;
- --space-4: 16px;
- --space-5: 24px;
- --space-6: 32px;
- --space-7: 48px;
- --space-8: 64px;
- --space-9: 96px;
-
- --text-caption: 10px; --leading-caption: 1.3;
- --text-xs: 11px; --leading-xs: 1.45;
- --text-sm: 12px; --leading-sm: 1.5;
- --text-base: 13px; --leading-base: 1.55;
- --text-md: 15px; --leading-md: 1.5;
- --text-lg: 17px; --leading-lg: 1.4;
- --text-xl: 20px; --leading-xl: 1.35;
- --text-2xl: 26px; --leading-2xl: 1.25;
- --text-3xl: 34px; --leading-3xl: 1.15;
- --text-display: 48px; --leading-display: 1.05;
-
- --track-tight: -0.02em;
- --track-snug: -0.01em;
- --track-caps: 0.06em;
-
- --radius-xs: 4px;
- --radius-sm: 6px;
- --radius-md: 8px;
- --radius-lg: 10px;
- --radius-xl: 16px;
- --radius-full: 9999px;
-
- --row-compact: 28px;
- --row-base: 44px;
- --hairline: 0.5px;
-
- --elev-0: none;
- --elev-1:
- 0 1px 2px rgba(0, 0, 0, 0.4),
- 0 0 0 1px rgba(255, 255, 255, 0.04);
- --elev-2:
- 0 4px 12px rgba(0, 0, 0, 0.45),
- 0 1px 2px rgba(0, 0, 0, 0.4),
- 0 0 0 1px rgba(255, 255, 255, 0.06);
- --elev-3:
- 0 24px 48px rgba(0, 0, 0, 0.55),
- 0 8px 16px rgba(0, 0, 0, 0.4),
- 0 0 0 1px rgba(255, 255, 255, 0.08);
- --elev-glow:
- 0 0 0 1px var(--accent),
- 0 4px 16px var(--accent-glow),
- 0 0 24px var(--accent-glow);
-
- --duration-fast: 120ms;
- --duration-base: 200ms;
- --duration-slow: 320ms;
- --duration-bounce: 480ms;
- --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
- --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
- --ease-in-out: cubic-bezier(0.45, 0, 0.25, 1);
-
- --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
- --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
- --font-mono: 'IBM Plex Mono', 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono', 'Ubuntu Mono', 'Courier New', monospace;
- --font-system: var(--font-body);
-
- --padding: var(--space-3);
- --border-radius: var(--radius-sm);
- --bottom-nav-height: 44px;
- --mobile-nav-clearance: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + var(--padding));
- --safe-area-top: env(safe-area-inset-top, 0px);
- --safe-area-right: env(safe-area-inset-right, 0px);
- --safe-area-bottom: env(safe-area-inset-bottom, 0px);
- --safe-area-left: env(safe-area-inset-left, 0px);
-
- font-family: var(--font-body);
- font-size: var(--text-base);
- line-height: var(--leading-base);
- font-weight: 400;
- font-synthesis: none;
- text-rendering: optimizeLegibility;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- font-feature-settings: "ss01", "cv11";
-}
-
-[data-display],
-.display {
- font-family: var(--font-display);
- letter-spacing: -0.01em;
-}
-
-[data-surface="notes"] {
- --font-display: var(--font-body);
- --leading-base: 1.65;
-}
-[data-surface="notes"] .tiptap {
- font-family: var(--font-body);
- font-size: var(--text-base);
- line-height: var(--leading-base);
- color: var(--text);
-}
-[data-surface="notes"] .tiptap > * + * {
- margin-top: var(--space-2);
-}
-[data-surface="notes"] .tiptap h1 {
- font-family: var(--font-body);
- font-size: var(--text-2xl);
- line-height: var(--leading-2xl);
- font-weight: 700;
- letter-spacing: -0.01em;
- margin-top: var(--space-5);
-}
-[data-surface="notes"] .tiptap h2 {
- font-family: var(--font-body);
- font-size: var(--text-xl);
- line-height: var(--leading-xl);
- font-weight: 700;
- letter-spacing: -0.01em;
- margin-top: var(--space-4);
-}
-[data-surface="notes"] .tiptap h3 {
- font-family: var(--font-body);
- font-size: var(--text-lg);
- line-height: var(--leading-lg);
- font-weight: 600;
- margin-top: var(--space-3);
-}
-[data-surface="notes"] .tiptap p {
- margin: 0;
-}
-[data-surface="notes"] .tiptap ul,
-[data-surface="notes"] .tiptap ol {
- padding-left: var(--space-5);
- margin: 0;
-}
-[data-surface="notes"] .tiptap blockquote {
- border-left: 3px solid var(--accent);
- padding-left: var(--space-3);
- color: var(--secondary);
- margin: 0;
-}
-[data-surface="notes"] .tiptap pre {
- background: color-mix(in oklab, var(--input-border) 30%, transparent);
- border-radius: var(--border-radius);
- padding: var(--space-3);
- font-family: var(--font-mono);
- font-size: var(--text-sm);
- overflow-x: auto;
- margin: 0;
-}
-[data-surface="notes"] .tiptap code {
- background: color-mix(in oklab, var(--accent) 8%, transparent);
- padding: 1px 5px;
- border-radius: 4px;
- font-family: var(--font-mono);
- font-size: 0.95em;
-}
-[data-surface="notes"] .tiptap pre code {
- background: transparent;
- padding: 0;
- font-size: inherit;
-}
-[data-surface="notes"] .tiptap hr {
- border: 0;
- border-top: 1px solid var(--input-border);
- margin: var(--space-4) 0;
-}
-[data-surface="notes"] .tiptap ul[data-type="taskList"] {
- list-style: none;
- padding-left: 0;
-}
-[data-surface="notes"] .tiptap ul[data-type="taskList"] li {
- display: flex;
- gap: var(--space-2);
- align-items: baseline;
-}
-[data-surface="notes"] .tiptap ul[data-type="taskList"] li > label {
- flex: 0 0 auto;
-}
-[data-surface="notes"] .tiptap ul[data-type="taskList"] li > div {
- flex: 1 1 auto;
-}
-[data-surface="notes"] .tiptap:focus-visible {
- outline: none;
-}
-[data-surface="notes"] .tiptap p.is-editor-empty:first-child::before {
- content: attr(data-placeholder);
- color: var(--tertiary);
- pointer-events: none;
- float: left;
- height: 0;
-}
-[data-surface="notes"] .tiptap h4 {
- font-family: var(--font-body);
- font-size: var(--text-md);
- font-weight: 600;
- margin-top: var(--space-3);
-}
-[data-surface="notes"] .tiptap h5 {
- font-family: var(--font-body);
- font-size: var(--text-base);
- font-weight: 600;
- margin-top: var(--space-2);
-}
-[data-surface="notes"] .tiptap h6 {
- font-family: var(--font-body);
- font-size: var(--text-sm);
- font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.04em;
- color: var(--secondary);
- margin-top: var(--space-2);
-}
-[data-surface="notes"] .tiptap img {
- max-width: 100%;
- height: auto;
- border-radius: var(--border-radius);
- display: block;
-}
-[data-surface="notes"] .tiptap .tiptap-table {
- border-collapse: collapse;
- table-layout: fixed;
- width: 100%;
- overflow: hidden;
- margin: 0;
-}
-[data-surface="notes"] .tiptap .tiptap-table th,
-[data-surface="notes"] .tiptap .tiptap-table td {
- border: 1px solid var(--input-border);
- padding: var(--space-2);
- vertical-align: top;
- position: relative;
- min-width: 1em;
-}
-[data-surface="notes"] .tiptap .tiptap-table th {
- background: color-mix(in oklab, var(--input-border) 30%, transparent);
- font-weight: 600;
- text-align: left;
-}
-[data-surface="notes"] .tiptap .tiptap-callout {
- display: flex;
- gap: var(--space-2);
- padding: var(--space-3);
- border-radius: var(--border-radius);
- border-left: 3px solid;
- background: color-mix(in oklab, var(--accent) 6%, transparent);
- margin: 0;
-}
-[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="note"] {
- border-left-color: var(--accent);
-}
-[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="tip"] {
- border-left-color: var(--success, #2ecc71);
- background: color-mix(in oklab, var(--success, #2ecc71) 8%, transparent);
-}
-[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="important"] {
- border-left-color: var(--accent);
- background: color-mix(in oklab, var(--accent) 12%, transparent);
-}
-[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="warning"] {
- border-left-color: var(--warning, #e67e22);
- background: color-mix(in oklab, var(--warning, #e67e22) 8%, transparent);
-}
-[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="caution"] {
- border-left-color: var(--error, #e74c3c);
- background: color-mix(in oklab, var(--error, #e74c3c) 8%, transparent);
-}
-[data-surface="notes"] .tiptap .tiptap-callout-icon {
- flex: 0 0 auto;
- font-size: var(--text-lg);
- user-select: none;
-}
-[data-surface="notes"] .tiptap .tiptap-callout-body {
- flex: 1 1 auto;
- display: flex;
- flex-direction: column;
- gap: var(--space-2);
-}
-[data-surface="notes"] .tiptap .tiptap-callout-body > * + * {
- margin-top: var(--space-2);
-}
-[data-surface="notes"] .tiptap .Tiptap-mathematics-render {
- display: inline-block;
- padding: 0 var(--space-1);
-}
-[data-surface="notes"] .tiptap .Tiptap-mathematics-editor {
- font-family: var(--font-mono);
- font-size: var(--text-sm);
- background: color-mix(in oklab, var(--input-border) 30%, transparent);
- padding: 1px 4px;
- border-radius: 3px;
-}
-[data-surface="notes"] .tiptap .tiptap-page-mention {
- display: inline-block;
- padding: 0 4px;
- background: color-mix(in oklab, var(--accent) 14%, transparent);
- color: var(--accent);
- border-radius: 4px;
- font-size: 0.95em;
- cursor: pointer;
- transition: background 120ms ease;
-}
-[data-surface="notes"] .tiptap .tiptap-page-mention:hover {
- background: color-mix(in oklab, var(--accent) 24%, transparent);
-}
-[data-surface="notes"] .tiptap .tiptap-page-mention::before {
- content: "[[";
- opacity: 0.4;
- margin-right: 2px;
-}
-[data-surface="notes"] .tiptap .tiptap-page-mention::after {
- content: "]]";
- opacity: 0.4;
- margin-left: 2px;
-}
-[data-surface="notes"] .tiptap .tiptap-tag-mention {
- display: inline-block;
- padding: 0 4px;
- background: color-mix(in oklab, var(--secondary) 14%, transparent);
- color: var(--secondary);
- border-radius: 999px;
- font-size: 0.9em;
- font-weight: 500;
- cursor: pointer;
-}
-[data-surface="notes"] .tiptap .tiptap-tag-mention::before {
- content: "#";
- opacity: 0.6;
- margin-right: 1px;
-}
-[data-surface="notes"] .tiptap .tiptap-query-block {
- margin: var(--space-2) 0;
- user-select: none;
-}
-[data-surface="notes"] .tiptap .tiptap-query-block.ProseMirror-selectednode {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
- border-radius: var(--border-radius);
-}
-[data-surface="notes"] .tiptap .tiptap-embed-block {
- margin: var(--space-2) 0;
- user-select: none;
-}
-[data-surface="notes"] .tiptap .tiptap-embed-block.ProseMirror-selectednode {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
- border-radius: var(--border-radius);
-}
-
-.page-title {
- font-family: var(--font-display);
- font-size: var(--text-3xl);
- line-height: var(--leading-3xl);
- font-weight: 600;
- letter-spacing: -0.02em;
- color: var(--text);
- margin: 0 0 var(--space-5) 0;
-}
-
-.section-title {
- font-family: var(--font-display);
- font-size: var(--text-lg);
- line-height: var(--leading-lg);
- font-weight: 600;
- letter-spacing: -0.01em;
- color: var(--text);
- text-transform: none;
- margin: 0 0 var(--space-3) 0;
-}
-
-.eyebrow {
- font-family: var(--font-body);
- font-size: var(--text-xs);
- font-weight: 600;
- text-transform: uppercase;
- letter-spacing: 0.08em;
- color: var(--text-muted);
- margin-bottom: var(--space-2);
-}
-
-::selection {
- background: var(--accent-soft);
- color: var(--text);
-}
-
-/*
- * Semantic token system (18 tokens, intended path-forward).
- * Each per-theme block below still defines the legacy concrete tokens
- * (--primary, --secondary, --button, etc.) for backwards compatibility.
- * The semantic tokens below alias them and survive theme switches.
- *
- * surface roles: --bg, --surface, --surface-hi
- * text levels: --text, --text-muted, --text-dim
- * lines: --border, --focus-ring (theme-defined)
- * brand & cta: --accent, --on-accent, --cta, --on-cta
- * status: --info, --success, --warning, --danger, --on-status
- *
- * Interaction states are computed at the call site, NOT stored:
- * :hover -> color-mix(in srgb, var(--surface) 92%, var(--bg-overlay))
- * :active -> color-mix(in srgb, var(--surface) 86%, var(--bg-overlay))
- * --bg-overlay is white in dark themes, black in light themes.
- */
-
-:root {
- --bg-overlay: white;
-}
-
-:root, [data-theme] {
- --bg: var(--primary);
- --surface: var(--button);
- --surface-hi: var(--button-elevated);
- --surface-mut: color-mix(in srgb, var(--button) 70%, var(--primary));
- --text: var(--secondary);
- --text-muted: color-mix(in srgb, var(--secondary) 65%, var(--tertiary));
- --text-dim: var(--tertiary);
- --border: var(--content-border);
- --border-hi: color-mix(in srgb, var(--secondary) 14%, transparent);
- --accent-hi: color-mix(in srgb, var(--accent) 88%, white);
- --accent-lo: color-mix(in srgb, var(--accent) 88%, black);
- --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
- --accent-glow: color-mix(in srgb, var(--accent) 25%, transparent);
- --info: var(--cta);
- --danger: var(--error);
- --on-status: #ffffff;
- --on-warning: #1a1a1a;
- --text-faint: color-mix(in srgb, var(--tertiary) 55%, transparent);
- --fill-1: color-mix(in srgb, var(--secondary) 8%, transparent);
- --fill-2: color-mix(in srgb, var(--secondary) 12%, transparent);
- --fill-3: color-mix(in srgb, var(--secondary) 17%, transparent);
- --material: color-mix(in srgb, var(--bg) 78%, transparent);
- --material-blur: blur(24px) saturate(180%);
-}
-
-[data-theme="light"],
-[data-theme="catppuccin-latte"],
-[data-theme="eink-day"],
-[data-theme="eink-sepia"],
-[data-theme="nyxvamp-radiance"] {
- --bg-overlay: black;
- --on-warning: #5c3d00;
- --elev-1:
- 0 1px 2px rgba(0, 0, 0, 0.08),
- 0 0 0 1px rgba(0, 0, 0, 0.04);
- --elev-2:
- 0 4px 12px rgba(0, 0, 0, 0.10),
- 0 1px 2px rgba(0, 0, 0, 0.06),
- 0 0 0 1px rgba(0, 0, 0, 0.05);
- --elev-3:
- 0 24px 48px rgba(0, 0, 0, 0.18),
- 0 8px 16px rgba(0, 0, 0, 0.08),
- 0 0 0 1px rgba(0, 0, 0, 0.06);
-}
-
-:root, [data-theme="dark"] {
- color-scheme: dark;
- --primary: #1C1C1E;
- --secondary: #F5F5F7;
- --tertiary: #98989D;
-
- --accent: #0A84FF;
- --success: #30D158;
- --error: #FF453A;
- --warning: #FF9F0A;
-
- --button: #2C2C2E;
- --button-hover: #3A3A3C;
- --button-press: #48484A;
- --button-text: var(--secondary);
- --button-stroke: rgba(255, 255, 255, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
-
- --button-elevated: #3A3A3C;
- --button-elevated-hover: #48484A;
- --button-elevated-press: #545456;
-
- --sidebar-bg: #252527;
- --sidebar-highlight: #2C2C2E;
- --content-border: #38383A;
- --input-border: #48484A;
- --input-bg: #1C1C1E;
-
- --popup-bg: #2C2C2E;
- --dialog-backdrop: rgba(0, 0, 0, 0.5);
-
- --on-primary: var(--secondary);
- --on-accent: #ffffff;
- --on-success: #1C1C1E;
- --on-error: #ffffff;
- --on-button: var(--button-text);
- --on-button-elevated: var(--secondary);
-
- --blue: var(--accent);
- --red: var(--error);
- --green: var(--success);
- --orange: var(--warning);
-
- --gray: var(--tertiary);
-
- --cta: #0071E3;
- --cta-hover: #0077ED;
- --cta-press: #0068D0;
- --on-cta: #ffffff;
-
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
-
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="light"] {
- color-scheme: light;
- --primary: #F5F5F7;
- --secondary: #1D1D1F;
- --tertiary: #67676C;
-
- --accent: #007AFF;
- --success: #217E38;
- --error: #D70015;
- --warning: #B25000;
-
- --button: #FFFFFF;
- --button-hover: #F0F0F2;
- --button-press: #E5E5EA;
- --button-text: var(--secondary);
- --button-stroke: rgba(0, 0, 0, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
-
- --button-elevated: #FFFFFF;
- --button-elevated-hover: #F5F5F7;
- --button-elevated-press: #E8E8EA;
-
- --sidebar-bg: #EBEBED;
- --sidebar-highlight: #E0E0E4;
- --content-border: #D1D1D6;
- --input-border: #D1D1D6;
- --input-bg: #FFFFFF;
-
- --popup-bg: #FFFFFF;
- --dialog-backdrop: rgba(0, 0, 0, 0.35);
-
- --on-primary: var(--secondary);
- --on-accent: #ffffff;
- --on-success: #ffffff;
- --on-error: #ffffff;
- --on-button: var(--button-text);
- --on-button-elevated: var(--secondary);
-
- --blue: var(--accent);
- --red: var(--error);
- --green: var(--success);
- --orange: var(--warning);
-
- --gray: var(--tertiary);
-
- --cta: #0071E3;
- --cta-hover: #0077ED;
- --cta-press: #0068D0;
- --on-cta: #ffffff;
-
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
-
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="catppuccin-mocha"] {
- color-scheme: dark;
- --primary: #1e1e2e;
- --secondary: #cdd6f4;
- --tertiary: #a6adc8;
- --accent: #89b4fa;
- --success: #a6e3a1;
- --error: #f38ba8;
- --warning: #f9e2af;
- --button: #313244;
- --button-hover: #45475a;
- --button-press: #585b70;
- --button-text: #cdd6f4;
- --button-stroke: rgba(205, 214, 244, 0.12);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #45475a;
- --button-elevated-hover: #585b70;
- --button-elevated-press: #6c7086;
- --sidebar-bg: #181825;
- --sidebar-highlight: #313244;
- --content-border: rgba(205, 214, 244, 0.08);
- --input-border: #585b70;
- --input-bg: #313244;
- --popup-bg: #313244;
- --dialog-backdrop: rgba(17, 17, 27, 0.7);
- --on-primary: #cdd6f4;
- --on-accent: #1e1e2e;
- --on-success: #1e1e2e;
- --on-error: #1e1e2e;
- --on-button: #cdd6f4;
- --on-button-elevated: #cdd6f4;
- --blue: #89b4fa;
- --red: #f38ba8;
- --green: #a6e3a1;
- --orange: #fab387;
- --gray: #a6adc8;
- --cta: #89b4fa;
- --cta-hover: #74c7ec;
- --cta-press: #89dceb;
- --on-cta: #1e1e2e;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="catppuccin-macchiato"] {
- color-scheme: dark;
- --primary: #24273a;
- --secondary: #cad3f5;
- --tertiary: #a5adcb;
- --accent: #8aadf4;
- --success: #a6da95;
- --error: #ed8796;
- --warning: #eed49f;
- --button: #363a4f;
- --button-hover: #494d64;
- --button-press: #5b6078;
- --button-text: #cad3f5;
- --button-stroke: rgba(202, 211, 245, 0.12);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #494d64;
- --button-elevated-hover: #5b6078;
- --button-elevated-press: #6e738d;
- --sidebar-bg: #1e2030;
- --sidebar-highlight: #363a4f;
- --content-border: rgba(202, 211, 245, 0.08);
- --input-border: #5b6078;
- --input-bg: #363a4f;
- --popup-bg: #363a4f;
- --dialog-backdrop: rgba(24, 25, 38, 0.7);
- --on-primary: #cad3f5;
- --on-accent: #24273a;
- --on-success: #24273a;
- --on-error: #24273a;
- --on-button: #cad3f5;
- --on-button-elevated: #cad3f5;
- --blue: #8aadf4;
- --red: #ed8796;
- --green: #a6da95;
- --orange: #f5a97f;
- --gray: #a5adcb;
- --cta: #8aadf4;
- --cta-hover: #7dc4e4;
- --cta-press: #91d7e3;
- --on-cta: #24273a;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="catppuccin-frappe"] {
- color-scheme: dark;
- --primary: #303446;
- --secondary: #c6d0f5;
- --tertiary: #c3cdf1;
- --accent: #8caaee;
- --success: #a6d189;
- --error: #e78284;
- --warning: #e5c890;
- --button: #414559;
- --button-hover: #51576d;
- --button-press: #626880;
- --button-text: #c6d0f5;
- --button-stroke: rgba(198, 208, 245, 0.12);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #51576d;
- --button-elevated-hover: #626880;
- --button-elevated-press: #737994;
- --sidebar-bg: #292c3c;
- --sidebar-highlight: #414559;
- --content-border: rgba(198, 208, 245, 0.08);
- --input-border: #626880;
- --input-bg: #414559;
- --popup-bg: #414559;
- --dialog-backdrop: rgba(35, 38, 52, 0.7);
- --on-primary: #c6d0f5;
- --on-accent: #303446;
- --on-success: #303446;
- --on-error: #303446;
- --on-button: #c6d0f5;
- --on-button-elevated: #c6d0f5;
- --blue: #8caaee;
- --red: #e78284;
- --green: #a6d189;
- --orange: #ef9f76;
- --gray: #a5adce;
- --cta: #8caaee;
- --cta-hover: #85c1dc;
- --cta-press: #99d1db;
- --on-cta: #303446;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="catppuccin-latte"] {
- color-scheme: light;
- --primary: #eff1f5;
- --secondary: #4c4f69;
- --tertiary: #3e4159;
- --accent: #1e66f5;
- --success: #40a02b;
- --error: #d20f39;
- --warning: #df8e1d;
- --button: #ccd0da;
- --button-hover: #bcc0cc;
- --button-press: #acb0be;
- --button-text: #4c4f69;
- --button-stroke: rgba(76, 79, 105, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #bcc0cc;
- --button-elevated-hover: #acb0be;
- --button-elevated-press: #9ca0b0;
- --sidebar-bg: #e6e9ef;
- --sidebar-highlight: #ccd0da;
- --content-border: rgba(76, 79, 105, 0.10);
- --input-border: #9ca0b0;
- --input-bg: #ffffff;
- --popup-bg: #ffffff;
- --dialog-backdrop: rgba(220, 224, 232, 0.5);
- --on-primary: #4c4f69;
- --on-accent: #ffffff;
- --on-success: #ffffff;
- --on-error: #ffffff;
- --on-button: #4c4f69;
- --on-button-elevated: #4c4f69;
- --blue: #1e66f5;
- --red: #d20f39;
- --green: #40a02b;
- --orange: #fe640b;
- --gray: #6c6f85;
- --cta: #1e66f5;
- --cta-hover: #209fb5;
- --cta-press: #04a5e5;
- --on-cta: #ffffff;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="one-dark-pro"] {
- color-scheme: dark;
- --primary: #282c34;
- --secondary: #abb2bf;
- --tertiary: #a9b0bd;
- --accent: #61afef;
- --success: #98c379;
- --error: #e06c75;
- --warning: #e5c07b;
- --button: #2c313a;
- --button-hover: #3e4452;
- --button-press: #4b5263;
- --button-text: #abb2bf;
- --button-stroke: rgba(171, 178, 191, 0.12);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #3e4452;
- --button-elevated-hover: #4b5263;
- --button-elevated-press: #5c6370;
- --sidebar-bg: #21252b;
- --sidebar-highlight: #2c313a;
- --content-border: rgba(171, 178, 191, 0.08);
- --input-border: #3e4452;
- --input-bg: #1d1f23;
- --popup-bg: #2c313a;
- --dialog-backdrop: rgba(0, 0, 0, 0.6);
- --on-primary: #abb2bf;
- --on-accent: #282c34;
- --on-success: #282c34;
- --on-error: #282c34;
- --on-button: #abb2bf;
- --on-button-elevated: #abb2bf;
- --blue: #61afef;
- --red: #e06c75;
- --green: #98c379;
- --orange: #d19a66;
- --gray: #7f849c;
- --cta: #61afef;
- --cta-hover: #528bcc;
- --cta-press: #4678a8;
- --on-cta: #282c34;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="dracula"] {
- color-scheme: dark;
- --primary: #22212C;
- --secondary: #F8F8F2;
- --tertiary: #b6b1cc;
- --accent: #9580FF;
- --success: #8AFF80;
- --error: #FF9580;
- --warning: #FFCA80;
- --button: #2B2640;
- --button-hover: #424450;
- --button-press: #504C67;
- --button-text: #F8F8F2;
- --button-stroke: rgba(248, 248, 242, 0.12);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #424450;
- --button-elevated-hover: #504C67;
- --button-elevated-press: #5E5A76;
- --sidebar-bg: #151320;
- --sidebar-highlight: #2B2640;
- --content-border: rgba(149, 128, 255, 0.12);
- --input-border: #373252;
- --input-bg: #151320;
- --popup-bg: #2B2640;
- --dialog-backdrop: rgba(11, 10, 16, 0.75);
- --on-primary: #F8F8F2;
- --on-accent: #FFFFFF;
- --on-success: #151320;
- --on-error: #FFFFFF;
- --on-button: #F8F8F2;
- --on-button-elevated: #F8F8F2;
- --blue: #9580FF;
- --red: #FF9580;
- --green: #8AFF80;
- --orange: #FFCA80;
- --gray: #7970A9;
- --cta: #9580FF;
- --cta-hover: #AA99FF;
- --cta-press: #7A6BE6;
- --on-cta: #FFFFFF;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="nyxvamp-veil"] {
- color-scheme: dark;
- --primary: #1E1E2E;
- --secondary: #D9E0EE;
- --tertiary: #9594ab;
- --accent: #F5C2E7;
- --success: #ABE9B3;
- --error: #E78284;
- --warning: #F8BD96;
- --button: #2E2E3E;
- --button-hover: #494D64;
- --button-press: #5A5E74;
- --button-text: #D9E0EE;
- --button-stroke: rgba(217, 224, 238, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #302D41;
- --button-elevated-hover: #494D64;
- --button-elevated-press: #5A5E74;
- --sidebar-bg: #181828;
- --sidebar-highlight: #302D41;
- --content-border: rgba(217, 224, 238, 0.06);
- --input-border: #6E6A86;
- --input-bg: #1E1E2E;
- --popup-bg: #302D41;
- --dialog-backdrop: rgba(10, 10, 20, 0.7);
- --on-primary: #D9E0EE;
- --on-accent: #1E1E2E;
- --on-success: #1E1E2E;
- --on-error: #1E1E2E;
- --on-button: #D9E0EE;
- --on-button-elevated: #D9E0EE;
- --blue: #96CDFB;
- --red: #E78284;
- --green: #ABE9B3;
- --orange: #F8BD96;
- --gray: #6E6A86;
- --cta: #F5C2E7;
- --cta-hover: #F8D7ED;
- --cta-press: #E8A8D4;
- --on-cta: #1E1E2E;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="nyxvamp-obsidian"] {
- color-scheme: dark;
- --primary: #000A0F;
- --secondary: #C0C0CE;
- --tertiary: #87859b;
- --accent: #F5C2E7;
- --success: #8FBF8F;
- --error: #D78284;
- --warning: #D8A080;
- --button: #1E1E20;
- --button-hover: #2E2E30;
- --button-press: #3E3E42;
- --button-text: #C0C0CE;
- --button-stroke: rgba(192, 192, 206, 0.08);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #1E1E20;
- --button-elevated-hover: #2E2E30;
- --button-elevated-press: #3E3E42;
- --sidebar-bg: #050810;
- --sidebar-highlight: #1E1E20;
- --content-border: rgba(192, 192, 206, 0.05);
- --input-border: #5E5A76;
- --input-bg: #000A0F;
- --popup-bg: #1E1E20;
- --dialog-backdrop: rgba(0, 0, 0, 0.85);
- --on-primary: #C0C0CE;
- --on-accent: #000A0F;
- --on-success: #000A0F;
- --on-error: #000A0F;
- --on-button: #C0C0CE;
- --on-button-elevated: #C0C0CE;
- --blue: #7FAFD7;
- --red: #D78284;
- --green: #8FBF8F;
- --orange: #D8A080;
- --gray: #5E5A76;
- --cta: #F5C2E7;
- --cta-hover: #F8D7ED;
- --cta-press: #E0A8D0;
- --on-cta: #000A0F;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="nyxvamp-radiance"] {
- color-scheme: light;
- --primary: #F7F7FF;
- --secondary: #1E1E2E;
- --tertiary: #5A5570;
- --accent: #9655FF;
- --success: #005F87;
- --error: #9F1239;
- --warning: #B8860B;
- --button: #E8E8F0;
- --button-hover: #DDDDE8;
- --button-press: #D0D0E0;
- --button-text: #1E1E2E;
- --button-stroke: rgba(30, 30, 46, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #E8D5FF;
- --button-elevated-hover: #DCCAF5;
- --button-elevated-press: #D0BFEB;
- --sidebar-bg: #E8E8F0;
- --sidebar-highlight: #E8D5FF;
- --content-border: rgba(30, 30, 46, 0.08);
- --input-border: #5A5570;
- --input-bg: #E8E8F0;
- --popup-bg: #F7F7FF;
- --dialog-backdrop: rgba(90, 85, 112, 0.3);
- --on-primary: #1E1E2E;
- --on-accent: #F7F7FF;
- --on-success: #F7F7FF;
- --on-error: #F7F7FF;
- --on-button: #1E1E2E;
- --on-button-elevated: #1E1E2E;
- --blue: #9655FF;
- --red: #9F1239;
- --green: #005F87;
- --orange: #C2410C;
- --gray: #5A5570;
- --cta: #9655FF;
- --cta-hover: #6B46C1;
- --cta-press: #5A3AAF;
- --on-cta: #F7F7FF;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="eink-day"] {
- color-scheme: light;
- --primary: #f5f2ea;
- --secondary: #1d1d1b;
- --tertiary: #5c5a56;
- --accent: #2b2b28;
- --success: #3d6e3d;
- --error: #8a2a2a;
- --warning: #8a5a1d;
- --button: #ebe5d7;
- --button-hover: #dfd6c2;
- --button-press: #d1c8ae;
- --button-text: var(--secondary);
- --button-stroke: rgba(29, 29, 27, 0.15);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #ebe5d7;
- --button-elevated-hover: #dfd6c2;
- --button-elevated-press: #d1c8ae;
- --sidebar-bg: #ebe5d7;
- --sidebar-highlight: #dfd6c2;
- --content-border: rgba(29, 29, 27, 0.14);
- --input-border: #c8bfa7;
- --input-bg: #ebe5d7;
- --popup-bg: #f5f2ea;
- --dialog-backdrop: rgba(29, 29, 27, 0.35);
- --on-primary: var(--secondary);
- --on-accent: #f5f2ea;
- --on-success: #f5f2ea;
- --on-error: #f5f2ea;
- --on-button: var(--secondary);
- --on-button-elevated: var(--secondary);
- --blue: #2b2b28;
- --red: #8a2a2a;
- --green: #3d6e3d;
- --orange: #8a5a1d;
- --gray: var(--tertiary);
- --cta: #2b2b28;
- --cta-hover: #1d1d1b;
- --cta-press: #141412;
- --on-cta: #f5f2ea;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="eink-sepia"] {
- color-scheme: light;
- --primary: #f0e6d2;
- --secondary: #3f2e20;
- --tertiary: #6e5440;
- --accent: #7a4a22;
- --success: #3d6e3d;
- --error: #8a2a2a;
- --warning: #8a5a1d;
- --button: #e6dcc3;
- --button-hover: #dccca8;
- --button-press: #c9b98d;
- --button-text: var(--secondary);
- --button-stroke: rgba(63, 46, 32, 0.15);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #e6dcc3;
- --button-elevated-hover: #dccca8;
- --button-elevated-press: #c9b98d;
- --sidebar-bg: #e6dcc3;
- --sidebar-highlight: #dccca8;
- --content-border: rgba(63, 46, 32, 0.14);
- --input-border: #c6b993;
- --input-bg: #e6dcc3;
- --popup-bg: #f0e6d2;
- --dialog-backdrop: rgba(63, 46, 32, 0.35);
- --on-primary: var(--secondary);
- --on-accent: #f0e6d2;
- --on-success: #f0e6d2;
- --on-error: #f0e6d2;
- --on-button: var(--secondary);
- --on-button-elevated: var(--secondary);
- --blue: #7a4a22;
- --red: #8a2a2a;
- --green: #3d6e3d;
- --orange: #8a5a1d;
- --gray: var(--tertiary);
- --cta: #7a4a22;
- --cta-hover: #5b3418;
- --cta-press: #452710;
- --on-cta: #f0e6d2;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-[data-theme="eink-night"] {
- color-scheme: dark;
- --primary: #0a0a0a;
- --secondary: #d4d4d0;
- --tertiary: #8e8e88;
- --accent: #b0b0ab;
- --success: #7eaa7e;
- --error: #c96060;
- --warning: #d0a060;
- --button: #121212;
- --button-hover: #1c1c1c;
- --button-press: #262626;
- --button-text: var(--secondary);
- --button-stroke: rgba(212, 212, 208, 0.10);
- --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
- --button-elevated: #121212;
- --button-elevated-hover: #1c1c1c;
- --button-elevated-press: #262626;
- --sidebar-bg: #121212;
- --sidebar-highlight: #1c1c1c;
- --content-border: rgba(212, 212, 208, 0.10);
- --input-border: #2c2c2c;
- --input-bg: #121212;
- --popup-bg: #121212;
- --dialog-backdrop: rgba(0, 0, 0, 0.6);
- --on-primary: var(--secondary);
- --on-accent: #0a0a0a;
- --on-success: #0a0a0a;
- --on-error: #0a0a0a;
- --on-button: var(--secondary);
- --on-button-elevated: var(--secondary);
- --blue: #b0b0ab;
- --red: #c96060;
- --green: #7eaa7e;
- --orange: #d0a060;
- --gray: var(--tertiary);
- --cta: #d4d4d0;
- --cta-hover: #c0c0bc;
- --cta-press: #a8a8a4;
- --on-cta: #0a0a0a;
- --focus-ring: solid 2px var(--accent);
- --focus-ring-offset: 2px;
- color: var(--secondary);
- background-color: var(--primary);
-}
-
-*,
-*::before,
-*::after {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- user-select: auto;
- scrollbar-width: none;
-}
-
-::-webkit-scrollbar {
- display: none;
-}
-
-.button, img, svg, [data-no-select] {
- user-select: none;
-}
-
-body {
- min-height: 100vh;
- overflow: hidden;
- background-color: var(--primary);
-}
-
-h1, h2, h3, h4, h5, h6 {
- font-weight: 500;
- margin-block: 0;
-}
-
-h1 { font-size: 24px; letter-spacing: -1px; }
-h2 { font-size: 20px; letter-spacing: -1px; }
-h3 { font-size: 16px; }
-h4 { font-size: 14.5px; }
-h5 { font-size: 12px; }
-h6 { font-size: 11px; }
-
-a {
- color: inherit;
- text-decoration: none;
-}
-
-button {
- font-family: inherit;
- cursor: pointer;
- border: none;
- background: none;
- color: inherit;
-}
-
-input, textarea {
- font-family: inherit;
- border: none;
- outline: none;
- background: none;
- color: inherit;
- user-select: text;
-}
-
-select {
- font-family: inherit;
- color: var(--secondary);
- background-color: var(--input-bg);
-}
-
-option {
- color: var(--secondary);
- background-color: var(--input-bg);
-}
-
-img, svg {
- pointer-events: none;
-}
-
-.button {
- font-size: 14.5px;
- font-weight: 500;
- padding: var(--padding);
- border-radius: var(--border-radius);
- background: var(--button);
- color: var(--button-text);
- box-shadow: var(--button-box-shadow);
- border: none;
- cursor: pointer;
-}
-
-@media (hover: hover) {
- .button:hover {
- background: var(--button-hover);
- }
-}
-
-.button:active {
- background: var(--button-press);
-}
-
-.button:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
-}
-
-.button.elevated {
- background: var(--button-elevated);
- box-shadow: none;
-}
-
-@media (hover: hover) {
- .button.elevated:hover {
- background: var(--button-elevated-hover);
- }
-}
-
-.button.elevated:active {
- background: var(--button-elevated-press);
-}
-
-.button.active {
- background: var(--secondary);
- color: var(--primary);
-}
-
-.button:disabled {
- cursor: default;
-}
-
-/* Hide WebView2 / Edge / Chromium native video controls (we use custom UI in PlayerShell). */
-video::-webkit-media-controls,
-video::-webkit-media-controls-enclosure,
-video::-webkit-media-controls-overlay-enclosure,
-video::-webkit-media-controls-panel,
-video::-webkit-media-controls-loading-panel,
-video::-webkit-media-controls-overlay-play-button,
-video::-webkit-media-controls-overlay-cast-button,
-video::-webkit-media-controls-play-button,
-video::-webkit-media-controls-pause-button,
-video::-webkit-media-controls-start-playback-button,
-video::-webkit-media-controls-fullscreen-button,
-video::-webkit-media-controls-picture-in-picture-button,
-video::-webkit-media-controls-volume-slider,
-video::-webkit-media-controls-mute-button,
-video::-webkit-media-controls-timeline,
-video::-webkit-media-controls-current-time-display,
-video::-webkit-media-controls-time-remaining-display,
-video::-internal-media-controls-overlay-cast-button,
-video::-internal-media-controls-button-panel-spacer {
- display: none !important;
- visibility: hidden !important;
- opacity: 0 !important;
- width: 0 !important;
- height: 0 !important;
- -webkit-appearance: none !important;
- appearance: none !important;
- pointer-events: none !important;
-}
-
-video {
- -webkit-tap-highlight-color: transparent;
- outline: none;
-}
-
+@import './lib/style/buttons.css';
+@import './lib/style/primitives.css';
+@import './lib/style/settings.css';
+@import './lib/style/macos-shell.css';
+@import '@fontsource/ibm-plex-mono/400.css';
+@import '@fontsource/ibm-plex-mono/500.css';
+
+/*
+ * OmniGet design tokens.
+ * Source of truth: docs/design-system.md.
+ *
+ * Spacing/type/radius/elevation/motion are global (don't change per theme).
+ * Colors override per [data-theme="..."] block.
+ * Legacy aliases (--padding, --border-radius, --button*, --primary, etc.)
+ * remain functional pointing at the new tokens; they go away one PR at a time.
+ */
+
+:root {
+ --space-0: 0;
+ --space-1: 4px;
+ --space-2: 8px;
+ --space-3: 12px;
+ --space-4: 16px;
+ --space-5: 24px;
+ --space-6: 32px;
+ --space-7: 48px;
+ --space-8: 64px;
+ --space-9: 96px;
+
+ --text-caption: 10px; --leading-caption: 1.3;
+ --text-xs: 11px; --leading-xs: 1.45;
+ --text-sm: 12px; --leading-sm: 1.5;
+ --text-base: 13px; --leading-base: 1.55;
+ --text-md: 15px; --leading-md: 1.5;
+ --text-lg: 17px; --leading-lg: 1.4;
+ --text-xl: 20px; --leading-xl: 1.35;
+ --text-2xl: 26px; --leading-2xl: 1.25;
+ --text-3xl: 34px; --leading-3xl: 1.15;
+ --text-display: 48px; --leading-display: 1.05;
+
+ --track-tight: -0.02em;
+ --track-snug: -0.01em;
+ --track-caps: 0.06em;
+
+ --radius-xs: 4px;
+ --radius-sm: 6px;
+ --radius-md: 8px;
+ --radius-lg: 10px;
+ --radius-xl: 16px;
+ --radius-full: 9999px;
+
+ --row-compact: 28px;
+ --row-base: 44px;
+ --hairline: 0.5px;
+
+ --elev-0: none;
+ --elev-1:
+ 0 1px 2px rgba(0, 0, 0, 0.4),
+ 0 0 0 1px rgba(255, 255, 255, 0.04);
+ --elev-2:
+ 0 4px 12px rgba(0, 0, 0, 0.45),
+ 0 1px 2px rgba(0, 0, 0, 0.4),
+ 0 0 0 1px rgba(255, 255, 255, 0.06);
+ --elev-3:
+ 0 24px 48px rgba(0, 0, 0, 0.55),
+ 0 8px 16px rgba(0, 0, 0, 0.4),
+ 0 0 0 1px rgba(255, 255, 255, 0.08);
+ --elev-glow:
+ 0 0 0 1px var(--accent),
+ 0 4px 16px var(--accent-glow),
+ 0 0 24px var(--accent-glow);
+
+ --duration-fast: 120ms;
+ --duration-base: 200ms;
+ --duration-slow: 320ms;
+ --duration-bounce: 480ms;
+ --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
+ --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
+ --ease-in-out: cubic-bezier(0.45, 0, 0.25, 1);
+
+ --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
+ --font-body: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
+ --font-mono: 'IBM Plex Mono', 'DejaVu Sans Mono', 'Liberation Mono', 'Noto Sans Mono', 'Ubuntu Mono', 'Courier New', monospace;
+ --font-system: var(--font-body);
+
+ --padding: var(--space-3);
+ --border-radius: var(--radius-sm);
+ --bottom-nav-height: 44px;
+ --mobile-nav-clearance: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + var(--padding));
+ --safe-area-top: env(safe-area-inset-top, 0px);
+ --safe-area-right: env(safe-area-inset-right, 0px);
+ --safe-area-bottom: env(safe-area-inset-bottom, 0px);
+ --safe-area-left: env(safe-area-inset-left, 0px);
+
+ font-family: var(--font-body);
+ font-size: var(--text-base);
+ line-height: var(--leading-base);
+ font-weight: 400;
+ font-synthesis: none;
+ text-rendering: optimizeLegibility;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ font-feature-settings: "ss01", "cv11";
+}
+
+[data-display],
+.display {
+ font-family: var(--font-display);
+ letter-spacing: -0.01em;
+}
+
+[data-surface="notes"] {
+ --font-display: var(--font-body);
+ --leading-base: 1.65;
+}
+[data-surface="notes"] .tiptap {
+ font-family: var(--font-body);
+ font-size: var(--text-base);
+ line-height: var(--leading-base);
+ color: var(--text);
+}
+[data-surface="notes"] .tiptap > * + * {
+ margin-top: var(--space-2);
+}
+[data-surface="notes"] .tiptap h1 {
+ font-family: var(--font-body);
+ font-size: var(--text-2xl);
+ line-height: var(--leading-2xl);
+ font-weight: 700;
+ letter-spacing: -0.01em;
+ margin-top: var(--space-5);
+}
+[data-surface="notes"] .tiptap h2 {
+ font-family: var(--font-body);
+ font-size: var(--text-xl);
+ line-height: var(--leading-xl);
+ font-weight: 700;
+ letter-spacing: -0.01em;
+ margin-top: var(--space-4);
+}
+[data-surface="notes"] .tiptap h3 {
+ font-family: var(--font-body);
+ font-size: var(--text-lg);
+ line-height: var(--leading-lg);
+ font-weight: 600;
+ margin-top: var(--space-3);
+}
+[data-surface="notes"] .tiptap p {
+ margin: 0;
+}
+[data-surface="notes"] .tiptap ul,
+[data-surface="notes"] .tiptap ol {
+ padding-left: var(--space-5);
+ margin: 0;
+}
+[data-surface="notes"] .tiptap blockquote {
+ border-left: 3px solid var(--accent);
+ padding-left: var(--space-3);
+ color: var(--secondary);
+ margin: 0;
+}
+[data-surface="notes"] .tiptap pre {
+ background: color-mix(in oklab, var(--input-border) 30%, transparent);
+ border-radius: var(--border-radius);
+ padding: var(--space-3);
+ font-family: var(--font-mono);
+ font-size: var(--text-sm);
+ overflow-x: auto;
+ margin: 0;
+}
+[data-surface="notes"] .tiptap code {
+ background: color-mix(in oklab, var(--accent) 8%, transparent);
+ padding: 1px calc(var(--space-1) * 1.25);
+ border-radius: 4px;
+ font-family: var(--font-mono);
+ font-size: 0.95em;
+}
+[data-surface="notes"] .tiptap pre code {
+ background: transparent;
+ padding: 0;
+ font-size: inherit;
+}
+[data-surface="notes"] .tiptap hr {
+ border: 0;
+ border-top: 1px solid var(--input-border);
+ margin: var(--space-4) 0;
+}
+[data-surface="notes"] .tiptap ul[data-type="taskList"] {
+ list-style: none;
+ padding-left: 0;
+}
+[data-surface="notes"] .tiptap ul[data-type="taskList"] li {
+ display: flex;
+ gap: var(--space-2);
+ align-items: baseline;
+}
+[data-surface="notes"] .tiptap ul[data-type="taskList"] li > label {
+ flex: 0 0 auto;
+}
+[data-surface="notes"] .tiptap ul[data-type="taskList"] li > div {
+ flex: 1 1 auto;
+}
+[data-surface="notes"] .tiptap:focus-visible {
+ outline: none;
+}
+[data-surface="notes"] .tiptap p.is-editor-empty:first-child::before {
+ content: attr(data-placeholder);
+ color: var(--tertiary);
+ pointer-events: none;
+ float: left;
+ height: 0;
+}
+[data-surface="notes"] .tiptap h4 {
+ font-family: var(--font-body);
+ font-size: var(--text-md);
+ font-weight: 600;
+ margin-top: var(--space-3);
+}
+[data-surface="notes"] .tiptap h5 {
+ font-family: var(--font-body);
+ font-size: var(--text-base);
+ font-weight: 600;
+ margin-top: var(--space-2);
+}
+[data-surface="notes"] .tiptap h6 {
+ font-family: var(--font-body);
+ font-size: var(--text-sm);
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+ color: var(--secondary);
+ margin-top: var(--space-2);
+}
+[data-surface="notes"] .tiptap img {
+ max-width: 100%;
+ height: auto;
+ border-radius: var(--border-radius);
+ display: block;
+}
+[data-surface="notes"] .tiptap .tiptap-table {
+ border-collapse: collapse;
+ table-layout: fixed;
+ width: 100%;
+ overflow: hidden;
+ margin: 0;
+}
+[data-surface="notes"] .tiptap .tiptap-table th,
+[data-surface="notes"] .tiptap .tiptap-table td {
+ border: 1px solid var(--input-border);
+ padding: var(--space-2);
+ vertical-align: top;
+ position: relative;
+ min-width: 1em;
+}
+[data-surface="notes"] .tiptap .tiptap-table th {
+ background: color-mix(in oklab, var(--input-border) 30%, transparent);
+ font-weight: 600;
+ text-align: left;
+}
+[data-surface="notes"] .tiptap .tiptap-callout {
+ display: flex;
+ gap: var(--space-2);
+ padding: var(--space-3);
+ border-radius: var(--border-radius);
+ border-left: 3px solid;
+ background: color-mix(in oklab, var(--accent) 6%, transparent);
+ margin: 0;
+}
+[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="note"] {
+ border-left-color: var(--accent);
+}
+[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="tip"] {
+ border-left-color: var(--success, #2ecc71);
+ background: color-mix(in oklab, var(--success, #2ecc71) 8%, transparent);
+}
+[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="important"] {
+ border-left-color: var(--accent);
+ background: color-mix(in oklab, var(--accent) 12%, transparent);
+}
+[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="warning"] {
+ border-left-color: var(--warning, #e67e22);
+ background: color-mix(in oklab, var(--warning, #e67e22) 8%, transparent);
+}
+[data-surface="notes"] .tiptap .tiptap-callout[data-callout-kind="caution"] {
+ border-left-color: var(--error, #e74c3c);
+ background: color-mix(in oklab, var(--error, #e74c3c) 8%, transparent);
+}
+[data-surface="notes"] .tiptap .tiptap-callout-icon {
+ flex: 0 0 auto;
+ font-size: var(--text-lg);
+ user-select: none;
+}
+[data-surface="notes"] .tiptap .tiptap-callout-body {
+ flex: 1 1 auto;
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-2);
+}
+[data-surface="notes"] .tiptap .tiptap-callout-body > * + * {
+ margin-top: var(--space-2);
+}
+[data-surface="notes"] .tiptap .Tiptap-mathematics-render {
+ display: inline-block;
+ padding: 0 var(--space-1);
+}
+[data-surface="notes"] .tiptap .Tiptap-mathematics-editor {
+ font-family: var(--font-mono);
+ font-size: var(--text-sm);
+ background: color-mix(in oklab, var(--input-border) 30%, transparent);
+ padding: 1px var(--space-1);
+ border-radius: 3px;
+}
+[data-surface="notes"] .tiptap .tiptap-page-mention {
+ display: inline-block;
+ padding: 0 var(--space-1);
+ background: color-mix(in oklab, var(--accent) 14%, transparent);
+ color: var(--accent);
+ border-radius: 4px;
+ font-size: 0.95em;
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out);
+}
+[data-surface="notes"] .tiptap .tiptap-page-mention:hover {
+ background: color-mix(in oklab, var(--accent) 24%, transparent);
+}
+[data-surface="notes"] .tiptap .tiptap-page-mention::before {
+ content: "[[";
+ opacity: 0.4;
+ margin-right: calc(var(--space-1) / 2);
+}
+[data-surface="notes"] .tiptap .tiptap-page-mention::after {
+ content: "]]";
+ opacity: 0.4;
+ margin-left: calc(var(--space-1) / 2);
+}
+[data-surface="notes"] .tiptap .tiptap-tag-mention {
+ display: inline-block;
+ padding: 0 var(--space-1);
+ background: color-mix(in oklab, var(--secondary) 14%, transparent);
+ color: var(--secondary);
+ border-radius: 999px;
+ font-size: 0.9em;
+ font-weight: 500;
+ cursor: pointer;
+}
+[data-surface="notes"] .tiptap .tiptap-tag-mention::before {
+ content: "#";
+ opacity: 0.6;
+ margin-right: 1px;
+}
+[data-surface="notes"] .tiptap .tiptap-query-block {
+ margin: var(--space-2) 0;
+ user-select: none;
+}
+[data-surface="notes"] .tiptap .tiptap-query-block.ProseMirror-selectednode {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+ border-radius: var(--border-radius);
+}
+[data-surface="notes"] .tiptap .tiptap-embed-block {
+ margin: var(--space-2) 0;
+ user-select: none;
+}
+[data-surface="notes"] .tiptap .tiptap-embed-block.ProseMirror-selectednode {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+ border-radius: var(--border-radius);
+}
+
+.page-title {
+ font-family: var(--font-display);
+ font-size: var(--text-3xl);
+ line-height: var(--leading-3xl);
+ font-weight: 600;
+ letter-spacing: -0.02em;
+ color: var(--text);
+ margin: 0 0 var(--space-5) 0;
+}
+
+.section-title {
+ font-family: var(--font-display);
+ font-size: var(--text-lg);
+ line-height: var(--leading-lg);
+ font-weight: 600;
+ letter-spacing: -0.01em;
+ color: var(--text);
+ text-transform: none;
+ margin: 0 0 var(--space-3) 0;
+}
+
+.eyebrow {
+ font-family: var(--font-body);
+ font-size: var(--text-xs);
+ font-weight: 600;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--text-muted);
+ margin-bottom: var(--space-2);
+}
+
+::selection {
+ background: var(--accent-soft);
+ color: var(--text);
+}
+
+/*
+ * Semantic token system (18 tokens, intended path-forward).
+ * Each per-theme block below still defines the legacy concrete tokens
+ * (--primary, --secondary, --button, etc.) for backwards compatibility.
+ * The semantic tokens below alias them and survive theme switches.
+ *
+ * surface roles: --bg, --surface, --surface-hi
+ * text levels: --text, --text-muted, --text-dim
+ * lines: --border, --focus-ring (theme-defined)
+ * brand & cta: --accent, --on-accent, --cta, --on-cta
+ * status: --info, --success, --warning, --danger, --on-status
+ *
+ * Interaction states are computed at the call site, NOT stored:
+ * :hover -> color-mix(in srgb, var(--surface) 92%, var(--bg-overlay))
+ * :active -> color-mix(in srgb, var(--surface) 86%, var(--bg-overlay))
+ * --bg-overlay is white in dark themes, black in light themes.
+ */
+
+:root {
+ --bg-overlay: white;
+}
+
+:root, [data-theme] {
+ --bg: var(--primary);
+ --surface: var(--button);
+ --surface-hi: var(--button-elevated);
+ --surface-mut: color-mix(in srgb, var(--button) 70%, var(--primary));
+ --text: var(--secondary);
+ --text-muted: color-mix(in srgb, var(--secondary) 65%, var(--tertiary));
+ --text-dim: var(--tertiary);
+ --border: var(--content-border);
+ --border-hi: color-mix(in srgb, var(--secondary) 14%, transparent);
+ --accent-hi: color-mix(in srgb, var(--accent) 88%, white);
+ --accent-lo: color-mix(in srgb, var(--accent) 88%, black);
+ --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
+ --accent-glow: color-mix(in srgb, var(--accent) 25%, transparent);
+ --info: var(--cta);
+ --danger: var(--error);
+ --on-status: #ffffff;
+ --on-warning: #1a1a1a;
+ --text-faint: color-mix(in srgb, var(--tertiary) 55%, transparent);
+ --fill-1: color-mix(in srgb, var(--secondary) 8%, transparent);
+ --fill-2: color-mix(in srgb, var(--secondary) 12%, transparent);
+ --fill-3: color-mix(in srgb, var(--secondary) 17%, transparent);
+ --material: color-mix(in srgb, var(--bg) 78%, transparent);
+ --material-blur: blur(24px) saturate(180%);
+}
+
+[data-theme="light"],
+[data-theme="catppuccin-latte"],
+[data-theme="eink-day"],
+[data-theme="eink-sepia"],
+[data-theme="nyxvamp-radiance"] {
+ --bg-overlay: black;
+ --on-warning: #5c3d00;
+ --elev-1:
+ 0 1px 2px rgba(0, 0, 0, 0.08),
+ 0 0 0 1px rgba(0, 0, 0, 0.04);
+ --elev-2:
+ 0 4px 12px rgba(0, 0, 0, 0.10),
+ 0 1px 2px rgba(0, 0, 0, 0.06),
+ 0 0 0 1px rgba(0, 0, 0, 0.05);
+ --elev-3:
+ 0 24px 48px rgba(0, 0, 0, 0.18),
+ 0 8px 16px rgba(0, 0, 0, 0.08),
+ 0 0 0 1px rgba(0, 0, 0, 0.06);
+}
+
+:root, [data-theme="dark"] {
+ color-scheme: dark;
+ --primary: #1C1C1E;
+ --secondary: #F5F5F7;
+ --tertiary: #98989D;
+
+ --accent: #0A84FF;
+ --success: #30D158;
+ --error: #FF453A;
+ --warning: #FF9F0A;
+
+ --button: #2C2C2E;
+ --button-hover: #3A3A3C;
+ --button-press: #48484A;
+ --button-text: var(--secondary);
+ --button-stroke: rgba(255, 255, 255, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+
+ --button-elevated: #3A3A3C;
+ --button-elevated-hover: #48484A;
+ --button-elevated-press: #545456;
+
+ --sidebar-bg: #252527;
+ --sidebar-highlight: #2C2C2E;
+ --content-border: #38383A;
+ --input-border: #48484A;
+ --input-bg: #1C1C1E;
+
+ --popup-bg: #2C2C2E;
+ --dialog-backdrop: rgba(0, 0, 0, 0.5);
+
+ --on-primary: var(--secondary);
+ --on-accent: #ffffff;
+ --on-success: #1C1C1E;
+ --on-error: #ffffff;
+ --on-button: var(--button-text);
+ --on-button-elevated: var(--secondary);
+
+ --blue: var(--accent);
+ --red: var(--error);
+ --green: var(--success);
+ --orange: var(--warning);
+
+ --gray: var(--tertiary);
+
+ --cta: #0071E3;
+ --cta-hover: #0077ED;
+ --cta-press: #0068D0;
+ --on-cta: #ffffff;
+
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="light"] {
+ color-scheme: light;
+ --primary: #F5F5F7;
+ --secondary: #1D1D1F;
+ --tertiary: #67676C;
+
+ --accent: #007AFF;
+ --success: #217E38;
+ --error: #D70015;
+ --warning: #B25000;
+
+ --button: #FFFFFF;
+ --button-hover: #F0F0F2;
+ --button-press: #E5E5EA;
+ --button-text: var(--secondary);
+ --button-stroke: rgba(0, 0, 0, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+
+ --button-elevated: #FFFFFF;
+ --button-elevated-hover: #F5F5F7;
+ --button-elevated-press: #E8E8EA;
+
+ --sidebar-bg: #EBEBED;
+ --sidebar-highlight: #E0E0E4;
+ --content-border: #D1D1D6;
+ --input-border: #D1D1D6;
+ --input-bg: #FFFFFF;
+
+ --popup-bg: #FFFFFF;
+ --dialog-backdrop: rgba(0, 0, 0, 0.35);
+
+ --on-primary: var(--secondary);
+ --on-accent: #ffffff;
+ --on-success: #ffffff;
+ --on-error: #ffffff;
+ --on-button: var(--button-text);
+ --on-button-elevated: var(--secondary);
+
+ --blue: var(--accent);
+ --red: var(--error);
+ --green: var(--success);
+ --orange: var(--warning);
+
+ --gray: var(--tertiary);
+
+ --cta: #0071E3;
+ --cta-hover: #0077ED;
+ --cta-press: #0068D0;
+ --on-cta: #ffffff;
+
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="catppuccin-mocha"] {
+ color-scheme: dark;
+ --primary: #1e1e2e;
+ --secondary: #cdd6f4;
+ --tertiary: #a6adc8;
+ --accent: #89b4fa;
+ --success: #a6e3a1;
+ --error: #f38ba8;
+ --warning: #f9e2af;
+ --button: #313244;
+ --button-hover: #45475a;
+ --button-press: #585b70;
+ --button-text: #cdd6f4;
+ --button-stroke: rgba(205, 214, 244, 0.12);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #45475a;
+ --button-elevated-hover: #585b70;
+ --button-elevated-press: #6c7086;
+ --sidebar-bg: #181825;
+ --sidebar-highlight: #313244;
+ --content-border: rgba(205, 214, 244, 0.08);
+ --input-border: #585b70;
+ --input-bg: #313244;
+ --popup-bg: #313244;
+ --dialog-backdrop: rgba(17, 17, 27, 0.7);
+ --on-primary: #cdd6f4;
+ --on-accent: #1e1e2e;
+ --on-success: #1e1e2e;
+ --on-error: #1e1e2e;
+ --on-button: #cdd6f4;
+ --on-button-elevated: #cdd6f4;
+ --blue: #89b4fa;
+ --red: #f38ba8;
+ --green: #a6e3a1;
+ --orange: #fab387;
+ --gray: #a6adc8;
+ --cta: #89b4fa;
+ --cta-hover: #74c7ec;
+ --cta-press: #89dceb;
+ --on-cta: #1e1e2e;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="catppuccin-macchiato"] {
+ color-scheme: dark;
+ --primary: #24273a;
+ --secondary: #cad3f5;
+ --tertiary: #a5adcb;
+ --accent: #8aadf4;
+ --success: #a6da95;
+ --error: #ed8796;
+ --warning: #eed49f;
+ --button: #363a4f;
+ --button-hover: #494d64;
+ --button-press: #5b6078;
+ --button-text: #cad3f5;
+ --button-stroke: rgba(202, 211, 245, 0.12);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #494d64;
+ --button-elevated-hover: #5b6078;
+ --button-elevated-press: #6e738d;
+ --sidebar-bg: #1e2030;
+ --sidebar-highlight: #363a4f;
+ --content-border: rgba(202, 211, 245, 0.08);
+ --input-border: #5b6078;
+ --input-bg: #363a4f;
+ --popup-bg: #363a4f;
+ --dialog-backdrop: rgba(24, 25, 38, 0.7);
+ --on-primary: #cad3f5;
+ --on-accent: #24273a;
+ --on-success: #24273a;
+ --on-error: #24273a;
+ --on-button: #cad3f5;
+ --on-button-elevated: #cad3f5;
+ --blue: #8aadf4;
+ --red: #ed8796;
+ --green: #a6da95;
+ --orange: #f5a97f;
+ --gray: #a5adcb;
+ --cta: #8aadf4;
+ --cta-hover: #7dc4e4;
+ --cta-press: #91d7e3;
+ --on-cta: #24273a;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="catppuccin-frappe"] {
+ color-scheme: dark;
+ --primary: #303446;
+ --secondary: #c6d0f5;
+ --tertiary: #c3cdf1;
+ --accent: #8caaee;
+ --success: #a6d189;
+ --error: #e78284;
+ --warning: #e5c890;
+ --button: #414559;
+ --button-hover: #51576d;
+ --button-press: #626880;
+ --button-text: #c6d0f5;
+ --button-stroke: rgba(198, 208, 245, 0.12);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #51576d;
+ --button-elevated-hover: #626880;
+ --button-elevated-press: #737994;
+ --sidebar-bg: #292c3c;
+ --sidebar-highlight: #414559;
+ --content-border: rgba(198, 208, 245, 0.08);
+ --input-border: #626880;
+ --input-bg: #414559;
+ --popup-bg: #414559;
+ --dialog-backdrop: rgba(35, 38, 52, 0.7);
+ --on-primary: #c6d0f5;
+ --on-accent: #303446;
+ --on-success: #303446;
+ --on-error: #303446;
+ --on-button: #c6d0f5;
+ --on-button-elevated: #c6d0f5;
+ --blue: #8caaee;
+ --red: #e78284;
+ --green: #a6d189;
+ --orange: #ef9f76;
+ --gray: #a5adce;
+ --cta: #8caaee;
+ --cta-hover: #85c1dc;
+ --cta-press: #99d1db;
+ --on-cta: #303446;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="catppuccin-latte"] {
+ color-scheme: light;
+ --primary: #eff1f5;
+ --secondary: #4c4f69;
+ --tertiary: #3e4159;
+ --accent: #1e66f5;
+ --success: #40a02b;
+ --error: #d20f39;
+ --warning: #df8e1d;
+ --button: #ccd0da;
+ --button-hover: #bcc0cc;
+ --button-press: #acb0be;
+ --button-text: #4c4f69;
+ --button-stroke: rgba(76, 79, 105, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #bcc0cc;
+ --button-elevated-hover: #acb0be;
+ --button-elevated-press: #9ca0b0;
+ --sidebar-bg: #e6e9ef;
+ --sidebar-highlight: #ccd0da;
+ --content-border: rgba(76, 79, 105, 0.10);
+ --input-border: #9ca0b0;
+ --input-bg: #ffffff;
+ --popup-bg: #ffffff;
+ --dialog-backdrop: rgba(220, 224, 232, 0.5);
+ --on-primary: #4c4f69;
+ --on-accent: #ffffff;
+ --on-success: #ffffff;
+ --on-error: #ffffff;
+ --on-button: #4c4f69;
+ --on-button-elevated: #4c4f69;
+ --blue: #1e66f5;
+ --red: #d20f39;
+ --green: #40a02b;
+ --orange: #fe640b;
+ --gray: #6c6f85;
+ --cta: #1e66f5;
+ --cta-hover: #209fb5;
+ --cta-press: #04a5e5;
+ --on-cta: #ffffff;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="one-dark-pro"] {
+ color-scheme: dark;
+ --primary: #282c34;
+ --secondary: #abb2bf;
+ --tertiary: #a9b0bd;
+ --accent: #61afef;
+ --success: #98c379;
+ --error: #e06c75;
+ --warning: #e5c07b;
+ --button: #2c313a;
+ --button-hover: #3e4452;
+ --button-press: #4b5263;
+ --button-text: #abb2bf;
+ --button-stroke: rgba(171, 178, 191, 0.12);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #3e4452;
+ --button-elevated-hover: #4b5263;
+ --button-elevated-press: #5c6370;
+ --sidebar-bg: #21252b;
+ --sidebar-highlight: #2c313a;
+ --content-border: rgba(171, 178, 191, 0.08);
+ --input-border: #3e4452;
+ --input-bg: #1d1f23;
+ --popup-bg: #2c313a;
+ --dialog-backdrop: rgba(0, 0, 0, 0.6);
+ --on-primary: #abb2bf;
+ --on-accent: #282c34;
+ --on-success: #282c34;
+ --on-error: #282c34;
+ --on-button: #abb2bf;
+ --on-button-elevated: #abb2bf;
+ --blue: #61afef;
+ --red: #e06c75;
+ --green: #98c379;
+ --orange: #d19a66;
+ --gray: #7f849c;
+ --cta: #61afef;
+ --cta-hover: #528bcc;
+ --cta-press: #4678a8;
+ --on-cta: #282c34;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="dracula"] {
+ color-scheme: dark;
+ --primary: #22212C;
+ --secondary: #F8F8F2;
+ --tertiary: #b6b1cc;
+ --accent: #9580FF;
+ --success: #8AFF80;
+ --error: #FF9580;
+ --warning: #FFCA80;
+ --button: #2B2640;
+ --button-hover: #424450;
+ --button-press: #504C67;
+ --button-text: #F8F8F2;
+ --button-stroke: rgba(248, 248, 242, 0.12);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #424450;
+ --button-elevated-hover: #504C67;
+ --button-elevated-press: #5E5A76;
+ --sidebar-bg: #151320;
+ --sidebar-highlight: #2B2640;
+ --content-border: rgba(149, 128, 255, 0.12);
+ --input-border: #373252;
+ --input-bg: #151320;
+ --popup-bg: #2B2640;
+ --dialog-backdrop: rgba(11, 10, 16, 0.75);
+ --on-primary: #F8F8F2;
+ --on-accent: #FFFFFF;
+ --on-success: #151320;
+ --on-error: #FFFFFF;
+ --on-button: #F8F8F2;
+ --on-button-elevated: #F8F8F2;
+ --blue: #9580FF;
+ --red: #FF9580;
+ --green: #8AFF80;
+ --orange: #FFCA80;
+ --gray: #7970A9;
+ --cta: #9580FF;
+ --cta-hover: #AA99FF;
+ --cta-press: #7A6BE6;
+ --on-cta: #FFFFFF;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="nyxvamp-veil"] {
+ color-scheme: dark;
+ --primary: #1E1E2E;
+ --secondary: #D9E0EE;
+ --tertiary: #9594ab;
+ --accent: #F5C2E7;
+ --success: #ABE9B3;
+ --error: #E78284;
+ --warning: #F8BD96;
+ --button: #2E2E3E;
+ --button-hover: #494D64;
+ --button-press: #5A5E74;
+ --button-text: #D9E0EE;
+ --button-stroke: rgba(217, 224, 238, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #302D41;
+ --button-elevated-hover: #494D64;
+ --button-elevated-press: #5A5E74;
+ --sidebar-bg: #181828;
+ --sidebar-highlight: #302D41;
+ --content-border: rgba(217, 224, 238, 0.06);
+ --input-border: #6E6A86;
+ --input-bg: #1E1E2E;
+ --popup-bg: #302D41;
+ --dialog-backdrop: rgba(10, 10, 20, 0.7);
+ --on-primary: #D9E0EE;
+ --on-accent: #1E1E2E;
+ --on-success: #1E1E2E;
+ --on-error: #1E1E2E;
+ --on-button: #D9E0EE;
+ --on-button-elevated: #D9E0EE;
+ --blue: #96CDFB;
+ --red: #E78284;
+ --green: #ABE9B3;
+ --orange: #F8BD96;
+ --gray: #6E6A86;
+ --cta: #F5C2E7;
+ --cta-hover: #F8D7ED;
+ --cta-press: #E8A8D4;
+ --on-cta: #1E1E2E;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="nyxvamp-obsidian"] {
+ color-scheme: dark;
+ --primary: #000A0F;
+ --secondary: #C0C0CE;
+ --tertiary: #87859b;
+ --accent: #F5C2E7;
+ --success: #8FBF8F;
+ --error: #D78284;
+ --warning: #D8A080;
+ --button: #1E1E20;
+ --button-hover: #2E2E30;
+ --button-press: #3E3E42;
+ --button-text: #C0C0CE;
+ --button-stroke: rgba(192, 192, 206, 0.08);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #1E1E20;
+ --button-elevated-hover: #2E2E30;
+ --button-elevated-press: #3E3E42;
+ --sidebar-bg: #050810;
+ --sidebar-highlight: #1E1E20;
+ --content-border: rgba(192, 192, 206, 0.05);
+ --input-border: #5E5A76;
+ --input-bg: #000A0F;
+ --popup-bg: #1E1E20;
+ --dialog-backdrop: rgba(0, 0, 0, 0.85);
+ --on-primary: #C0C0CE;
+ --on-accent: #000A0F;
+ --on-success: #000A0F;
+ --on-error: #000A0F;
+ --on-button: #C0C0CE;
+ --on-button-elevated: #C0C0CE;
+ --blue: #7FAFD7;
+ --red: #D78284;
+ --green: #8FBF8F;
+ --orange: #D8A080;
+ --gray: #5E5A76;
+ --cta: #F5C2E7;
+ --cta-hover: #F8D7ED;
+ --cta-press: #E0A8D0;
+ --on-cta: #000A0F;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="nyxvamp-radiance"] {
+ color-scheme: light;
+ --primary: #F7F7FF;
+ --secondary: #1E1E2E;
+ --tertiary: #5A5570;
+ --accent: #9655FF;
+ --success: #005F87;
+ --error: #9F1239;
+ --warning: #B8860B;
+ --button: #E8E8F0;
+ --button-hover: #DDDDE8;
+ --button-press: #D0D0E0;
+ --button-text: #1E1E2E;
+ --button-stroke: rgba(30, 30, 46, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #E8D5FF;
+ --button-elevated-hover: #DCCAF5;
+ --button-elevated-press: #D0BFEB;
+ --sidebar-bg: #E8E8F0;
+ --sidebar-highlight: #E8D5FF;
+ --content-border: rgba(30, 30, 46, 0.08);
+ --input-border: #5A5570;
+ --input-bg: #E8E8F0;
+ --popup-bg: #F7F7FF;
+ --dialog-backdrop: rgba(90, 85, 112, 0.3);
+ --on-primary: #1E1E2E;
+ --on-accent: #F7F7FF;
+ --on-success: #F7F7FF;
+ --on-error: #F7F7FF;
+ --on-button: #1E1E2E;
+ --on-button-elevated: #1E1E2E;
+ --blue: #9655FF;
+ --red: #9F1239;
+ --green: #005F87;
+ --orange: #C2410C;
+ --gray: #5A5570;
+ --cta: #9655FF;
+ --cta-hover: #6B46C1;
+ --cta-press: #5A3AAF;
+ --on-cta: #F7F7FF;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="eink-day"] {
+ color-scheme: light;
+ --primary: #f5f2ea;
+ --secondary: #1d1d1b;
+ --tertiary: #5c5a56;
+ --accent: #2b2b28;
+ --success: #3d6e3d;
+ --error: #8a2a2a;
+ --warning: #8a5a1d;
+ --button: #ebe5d7;
+ --button-hover: #dfd6c2;
+ --button-press: #d1c8ae;
+ --button-text: var(--secondary);
+ --button-stroke: rgba(29, 29, 27, 0.15);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #ebe5d7;
+ --button-elevated-hover: #dfd6c2;
+ --button-elevated-press: #d1c8ae;
+ --sidebar-bg: #ebe5d7;
+ --sidebar-highlight: #dfd6c2;
+ --content-border: rgba(29, 29, 27, 0.14);
+ --input-border: #c8bfa7;
+ --input-bg: #ebe5d7;
+ --popup-bg: #f5f2ea;
+ --dialog-backdrop: rgba(29, 29, 27, 0.35);
+ --on-primary: var(--secondary);
+ --on-accent: #f5f2ea;
+ --on-success: #f5f2ea;
+ --on-error: #f5f2ea;
+ --on-button: var(--secondary);
+ --on-button-elevated: var(--secondary);
+ --blue: #2b2b28;
+ --red: #8a2a2a;
+ --green: #3d6e3d;
+ --orange: #8a5a1d;
+ --gray: var(--tertiary);
+ --cta: #2b2b28;
+ --cta-hover: #1d1d1b;
+ --cta-press: #141412;
+ --on-cta: #f5f2ea;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="eink-sepia"] {
+ color-scheme: light;
+ --primary: #f0e6d2;
+ --secondary: #3f2e20;
+ --tertiary: #6e5440;
+ --accent: #7a4a22;
+ --success: #3d6e3d;
+ --error: #8a2a2a;
+ --warning: #8a5a1d;
+ --button: #e6dcc3;
+ --button-hover: #dccca8;
+ --button-press: #c9b98d;
+ --button-text: var(--secondary);
+ --button-stroke: rgba(63, 46, 32, 0.15);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #e6dcc3;
+ --button-elevated-hover: #dccca8;
+ --button-elevated-press: #c9b98d;
+ --sidebar-bg: #e6dcc3;
+ --sidebar-highlight: #dccca8;
+ --content-border: rgba(63, 46, 32, 0.14);
+ --input-border: #c6b993;
+ --input-bg: #e6dcc3;
+ --popup-bg: #f0e6d2;
+ --dialog-backdrop: rgba(63, 46, 32, 0.35);
+ --on-primary: var(--secondary);
+ --on-accent: #f0e6d2;
+ --on-success: #f0e6d2;
+ --on-error: #f0e6d2;
+ --on-button: var(--secondary);
+ --on-button-elevated: var(--secondary);
+ --blue: #7a4a22;
+ --red: #8a2a2a;
+ --green: #3d6e3d;
+ --orange: #8a5a1d;
+ --gray: var(--tertiary);
+ --cta: #7a4a22;
+ --cta-hover: #5b3418;
+ --cta-press: #452710;
+ --on-cta: #f0e6d2;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+[data-theme="eink-night"] {
+ color-scheme: dark;
+ --primary: #0a0a0a;
+ --secondary: #d4d4d0;
+ --tertiary: #8e8e88;
+ --accent: #b0b0ab;
+ --success: #7eaa7e;
+ --error: #c96060;
+ --warning: #d0a060;
+ --button: #121212;
+ --button-hover: #1c1c1c;
+ --button-press: #262626;
+ --button-text: var(--secondary);
+ --button-stroke: rgba(212, 212, 208, 0.10);
+ --button-box-shadow: 0 0 0 1px var(--button-stroke) inset;
+ --button-elevated: #121212;
+ --button-elevated-hover: #1c1c1c;
+ --button-elevated-press: #262626;
+ --sidebar-bg: #121212;
+ --sidebar-highlight: #1c1c1c;
+ --content-border: rgba(212, 212, 208, 0.10);
+ --input-border: #2c2c2c;
+ --input-bg: #121212;
+ --popup-bg: #121212;
+ --dialog-backdrop: rgba(0, 0, 0, 0.6);
+ --on-primary: var(--secondary);
+ --on-accent: #0a0a0a;
+ --on-success: #0a0a0a;
+ --on-error: #0a0a0a;
+ --on-button: var(--secondary);
+ --on-button-elevated: var(--secondary);
+ --blue: #b0b0ab;
+ --red: #c96060;
+ --green: #7eaa7e;
+ --orange: #d0a060;
+ --gray: var(--tertiary);
+ --cta: #d4d4d0;
+ --cta-hover: #c0c0bc;
+ --cta-press: #a8a8a4;
+ --on-cta: #0a0a0a;
+ --focus-ring: solid 2px var(--accent);
+ --focus-ring-offset: 2px;
+ color: var(--secondary);
+ background-color: var(--primary);
+}
+
+*,
+*::before,
+*::after {
+ margin: 0;
+ padding: 0;
+ box-sizing: border-box;
+ user-select: auto;
+ scrollbar-width: none;
+}
+
+::-webkit-scrollbar {
+ display: none;
+}
+
+.button, img, svg, [data-no-select] {
+ user-select: none;
+}
+
+body {
+ min-height: 100vh;
+ overflow: hidden;
+ background-color: var(--primary);
+}
+
+h1, h2, h3, h4, h5, h6 {
+ font-weight: 500;
+ margin-block: 0;
+}
+
+h1 { font-size: 24px; letter-spacing: -1px; }
+h2 { font-size: 20px; letter-spacing: -1px; }
+h3 { font-size: 16px; }
+h4 { font-size: 14.5px; }
+h5 { font-size: 12px; }
+h6 { font-size: 11px; }
+
+a {
+ color: inherit;
+ text-decoration: none;
+}
+
+button {
+ font-family: inherit;
+ cursor: pointer;
+ border: none;
+ background: none;
+ color: inherit;
+}
+
+input, textarea {
+ font-family: inherit;
+ border: none;
+ outline: none;
+ background: none;
+ color: inherit;
+ user-select: text;
+}
+
+select {
+ font-family: inherit;
+ color: var(--secondary);
+ background-color: var(--input-bg);
+}
+
+option {
+ color: var(--secondary);
+ background-color: var(--input-bg);
+}
+
+img, svg {
+ pointer-events: none;
+}
+
+.button {
+ font-size: 14.5px;
+ font-weight: 500;
+ padding: var(--padding);
+ border-radius: var(--border-radius);
+ background: var(--button);
+ color: var(--button-text);
+ box-shadow: var(--button-box-shadow);
+ border: none;
+ cursor: pointer;
+}
+
+@media (hover: hover) {
+ .button:hover {
+ background: var(--button-hover);
+ }
+}
+
+.button:active {
+ background: var(--button-press);
+}
+
+.button:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+}
+
+.button.elevated {
+ background: var(--button-elevated);
+ box-shadow: none;
+}
+
+@media (hover: hover) {
+ .button.elevated:hover {
+ background: var(--button-elevated-hover);
+ }
+}
+
+.button.elevated:active {
+ background: var(--button-elevated-press);
+}
+
+.button.active {
+ background: var(--secondary);
+ color: var(--primary);
+}
+
+.button:disabled {
+ cursor: default;
+}
+
+/* Hide WebView2 / Edge / Chromium native video controls (we use custom UI in PlayerShell). */
+video::-webkit-media-controls,
+video::-webkit-media-controls-enclosure,
+video::-webkit-media-controls-overlay-enclosure,
+video::-webkit-media-controls-panel,
+video::-webkit-media-controls-loading-panel,
+video::-webkit-media-controls-overlay-play-button,
+video::-webkit-media-controls-overlay-cast-button,
+video::-webkit-media-controls-play-button,
+video::-webkit-media-controls-pause-button,
+video::-webkit-media-controls-start-playback-button,
+video::-webkit-media-controls-fullscreen-button,
+video::-webkit-media-controls-picture-in-picture-button,
+video::-webkit-media-controls-volume-slider,
+video::-webkit-media-controls-mute-button,
+video::-webkit-media-controls-timeline,
+video::-webkit-media-controls-current-time-display,
+video::-webkit-media-controls-time-remaining-display,
+video::-internal-media-controls-overlay-cast-button,
+video::-internal-media-controls-button-panel-spacer {
+ display: none !important;
+ visibility: hidden !important;
+ opacity: 0 !important;
+ width: 0 !important;
+ height: 0 !important;
+ -webkit-appearance: none !important;
+ appearance: none !important;
+ pointer-events: none !important;
+}
+
+video {
+ -webkit-tap-highlight-color: transparent;
+ outline: none;
+}
+
diff --git a/src/components/hints/ContextHint.svelte b/src/components/hints/ContextHint.svelte
index 24760e3b..b9f6d242 100644
--- a/src/components/hints/ContextHint.svelte
+++ b/src/components/hints/ContextHint.svelte
@@ -65,9 +65,9 @@
display: inline-flex;
align-items: center;
justify-content: center;
- width: 18px;
- height: 18px;
- border-radius: 50%;
+ width: 20px;
+ height: 20px;
+ border-radius: var(--radius-full);
background: none;
border: none;
color: var(--gray);
diff --git a/src/components/settings/SettingsPlugins.svelte b/src/components/settings/SettingsPlugins.svelte
index 6619b1f1..80b71913 100644
--- a/src/components/settings/SettingsPlugins.svelte
+++ b/src/components/settings/SettingsPlugins.svelte
@@ -1,211 +1,211 @@
-<script lang="ts">
- import { onMount } from "svelte";
- import { invoke } from "@tauri-apps/api/core";
- import { t } from "$lib/i18n";
- import { getSettings, type DependencyStatus } from "./settings-helpers";
- import { showToast } from "$lib/stores/toast-store.svelte";
- import DependencyRow from "./DependencyRow.svelte";
-
- let { deps = [], installingDep = null, onInstallDep, onRefresh }: {
- deps?: DependencyStatus[];
- installingDep?: string | null;
- onInstallDep: (name: string, variant: string | null) => void;
- onRefresh?: () => void | Promise<void>;
- } = $props();
-
- let settings = $derived(getSettings());
-
- type BrowserExtStatus = {
- browser: string;
- supported: boolean;
- bundled_version: string | null;
- installable: boolean;
- install_hint: string;
- store_url: string | null;
- };
-
- let extStatuses = $state<BrowserExtStatus[]>([]);
- let busyBrowser = $state<string | null>(null);
- let installModal = $state<{ browser: string; path: string; hint: string } | null>(null);
-
- onMount(async () => {
- try {
- extStatuses = await invoke<BrowserExtStatus[]>("browser_extension_status");
- } catch (e) {
- console.warn("[ext] status failed", e);
- }
- });
-
- async function exportExtension(browser: string) {
- if (busyBrowser) return;
- busyBrowser = browser;
- try {
- const res = await invoke<{ path: string; version: string | null; browser: string }>(
- "browser_extension_export",
- { browser },
- );
- const status = extStatuses.find((s) => s.browser === browser);
- installModal = {
- browser,
- path: res.path,
- hint: status?.install_hint ?? "",
- };
- } catch (e) {
- showToast("error", e instanceof Error ? e.message : String(e));
- } finally {
- busyBrowser = null;
- }
- }
-
- async function openFolder(path: string) {
- try {
- await invoke("browser_extension_open_folder", { path });
- } catch (e) {
- showToast("error", e instanceof Error ? e.message : String(e));
- }
- }
-
- function closeInstall() {
- installModal = null;
- }
-
- function browserLabel(b: string): string {
- if (b === "chrome") return "Chrome / Edge / Brave";
- if (b === "firefox") return "Firefox";
- if (b === "safari") return "Safari";
- return b;
- }
-</script>
-
-{#if settings}
- <section class="section">
- <h5 class="section-title">Extensão de navegador</h5>
- <p class="muted">A extensão envia cookies e URLs do seu navegador para o OmniGet. Auto-update direto pelo app só funciona via lojas oficiais — enquanto não publicamos, use os botões abaixo para extrair a versão atual e (re)instalar manualmente.</p>
- <div class="card">
- {#each extStatuses as ext, i (ext.browser)}
- {#if i > 0}<div class="divider"></div>{/if}
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{browserLabel(ext.browser)}</span>
- <span class="setting-path">
- {#if ext.bundled_version}
- Versão empacotada: v{ext.bundled_version}
- {:else}
- {ext.install_hint}
- {/if}
- </span>
- </div>
- {#if ext.installable}
- <button
- class="button"
- disabled={busyBrowser === ext.browser}
- onclick={() => exportExtension(ext.browser)}
- >
- {busyBrowser === ext.browser ? "Extraindo..." : "Atualizar / Instalar"}
- </button>
- {:else if ext.store_url}
- <a class="button" href={ext.store_url} target="_blank" rel="noreferrer">Abrir loja</a>
- {:else}
- <span class="muted small">Indisponível</span>
- {/if}
- </div>
- {/each}
- </div>
- </section>
-
- {#if deps.length > 0}
- <section class="section">
- <div class="settings-section-head section-title">
- <h5 class="section-title">{$t('settings.dependencies.title')}</h5>
- </div>
- <div class="deps-table-wrap">
- <table class="deps-table">
- <thead>
- <tr>
- <th scope="col">{$t('settings.dependencies.col_name')}</th>
- <th scope="col">{$t('settings.dependencies.col_version')}</th>
- <th scope="col">{$t('settings.dependencies.col_status')}</th>
- <th scope="col" class="deps-col-action">{$t('settings.dependencies.col_action')}</th>
- </tr>
- </thead>
- <tbody>
- {#each deps as dep (dep.name)}
- <DependencyRow
- name={dep.name}
- installed={dep.installed}
- version={dep.version}
- outdated={dep.outdated}
- busy={installingDep === dep.name}
- onInstall={(variant) => onInstallDep(dep.name, variant)}
- onAfterCustomFile={onRefresh}
- />
- {/each}
- </tbody>
- </table>
- </div>
- </section>
- {/if}
-{/if}
-
-{#if installModal}
- <div class="overlay" role="presentation" onclick={(e) => { if (e.target === e.currentTarget) closeInstall(); }}>
- <div class="dialog" role="dialog" aria-modal="true">
- <header class="head">
- <h3>Instalar / Atualizar extensão — {browserLabel(installModal.browser)}</h3>
- <button class="close" onclick={closeInstall} aria-label="fechar">×</button>
- </header>
- <div class="body">
- <p>A extensão foi extraída para:</p>
- <code class="path">{installModal.path}</code>
- <button class="button" onclick={() => openFolder(installModal!.path)}>Abrir pasta</button>
- <h4>Como instalar / atualizar</h4>
- <p class="hint">{installModal.hint}</p>
- <p class="hint small">
- Se a extensão já está instalada, clique em "Recarregar" no <code>{installModal.browser === 'firefox' ? 'about:debugging' : 'chrome://extensions'}</code> apontando pra essa pasta — ou remova a antiga e adicione a nova.
- </p>
- </div>
- <footer class="foot">
- <button class="button" onclick={closeInstall}>Fechar</button>
- </footer>
- </div>
- </div>
-{/if}
-
-<style>
- .muted { color: rgba(255, 255, 255, 0.6); font-size: 12px; line-height: 1.4; margin: 0 0 8px; }
- .small { font-size: 11px; }
- .overlay {
- position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
- display: grid; place-items: center; z-index: 999;
- }
- .dialog {
- background: var(--bg-card, #1a1a1a);
- border: 1px solid rgba(255, 255, 255, 0.1);
- border-radius: 12px;
- width: min(560px, 90vw);
- max-height: 80vh; overflow: auto;
- display: flex; flex-direction: column;
- }
- .head {
- display: flex; justify-content: space-between; align-items: center;
- padding: 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
- }
- .head h3 { margin: 0; font-size: 16px; }
- .close {
- background: transparent; border: 0; color: rgba(255, 255, 255, 0.6);
- font-size: 22px; line-height: 1; cursor: pointer;
- }
- .body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
- .body h4 { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
- .body p { margin: 0; font-size: 13px; line-height: 1.5; }
- .body .hint { color: rgba(255, 255, 255, 0.7); }
- .path {
- display: block; padding: 8px 10px; background: rgba(0, 0, 0, 0.4);
- border-radius: 6px; font-family: var(--font-mono, monospace); font-size: 11px;
- word-break: break-all;
- }
- .foot {
- padding: 12px 20px; border-top: 1px solid rgba(255, 255, 255, 0.05);
- display: flex; justify-content: flex-end;
- }
-</style>
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { invoke } from "@tauri-apps/api/core";
+ import { t } from "$lib/i18n";
+ import { getSettings, type DependencyStatus } from "./settings-helpers";
+ import { showToast } from "$lib/stores/toast-store.svelte";
+ import DependencyRow from "./DependencyRow.svelte";
+
+ let { deps = [], installingDep = null, onInstallDep, onRefresh }: {
+ deps?: DependencyStatus[];
+ installingDep?: string | null;
+ onInstallDep: (name: string, variant: string | null) => void;
+ onRefresh?: () => void | Promise<void>;
+ } = $props();
+
+ let settings = $derived(getSettings());
+
+ type BrowserExtStatus = {
+ browser: string;
+ supported: boolean;
+ bundled_version: string | null;
+ installable: boolean;
+ install_hint: string;
+ store_url: string | null;
+ };
+
+ let extStatuses = $state<BrowserExtStatus[]>([]);
+ let busyBrowser = $state<string | null>(null);
+ let installModal = $state<{ browser: string; path: string; hint: string } | null>(null);
+
+ onMount(async () => {
+ try {
+ extStatuses = await invoke<BrowserExtStatus[]>("browser_extension_status");
+ } catch (e) {
+ console.warn("[ext] status failed", e);
+ }
+ });
+
+ async function exportExtension(browser: string) {
+ if (busyBrowser) return;
+ busyBrowser = browser;
+ try {
+ const res = await invoke<{ path: string; version: string | null; browser: string }>(
+ "browser_extension_export",
+ { browser },
+ );
+ const status = extStatuses.find((s) => s.browser === browser);
+ installModal = {
+ browser,
+ path: res.path,
+ hint: status?.install_hint ?? "",
+ };
+ } catch (e) {
+ showToast("error", e instanceof Error ? e.message : String(e));
+ } finally {
+ busyBrowser = null;
+ }
+ }
+
+ async function openFolder(path: string) {
+ try {
+ await invoke("browser_extension_open_folder", { path });
+ } catch (e) {
+ showToast("error", e instanceof Error ? e.message : String(e));
+ }
+ }
+
+ function closeInstall() {
+ installModal = null;
+ }
+
+ function browserLabel(b: string): string {
+ if (b === "chrome") return "Chrome / Edge / Brave";
+ if (b === "firefox") return "Firefox";
+ if (b === "safari") return "Safari";
+ return b;
+ }
+</script>
+
+{#if settings}
+ <section class="section">
+ <h5 class="section-title">Extensão de navegador</h5>
+ <p class="muted">A extensão envia cookies e URLs do seu navegador para o OmniGet. Auto-update direto pelo app só funciona via lojas oficiais — enquanto não publicamos, use os botões abaixo para extrair a versão atual e (re)instalar manualmente.</p>
+ <div class="card">
+ {#each extStatuses as ext, i (ext.browser)}
+ {#if i > 0}<div class="divider"></div>{/if}
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{browserLabel(ext.browser)}</span>
+ <span class="setting-path">
+ {#if ext.bundled_version}
+ Versão empacotada: v{ext.bundled_version}
+ {:else}
+ {ext.install_hint}
+ {/if}
+ </span>
+ </div>
+ {#if ext.installable}
+ <button
+ class="button"
+ disabled={busyBrowser === ext.browser}
+ onclick={() => exportExtension(ext.browser)}
+ >
+ {busyBrowser === ext.browser ? "Extraindo..." : "Atualizar / Instalar"}
+ </button>
+ {:else if ext.store_url}
+ <a class="button" href={ext.store_url} target="_blank" rel="noreferrer">Abrir loja</a>
+ {:else}
+ <span class="muted small">Indisponível</span>
+ {/if}
+ </div>
+ {/each}
+ </div>
+ </section>
+
+ {#if deps.length > 0}
+ <section class="section">
+ <div class="settings-section-head section-title">
+ <h5 class="section-title">{$t('settings.dependencies.title')}</h5>
+ </div>
+ <div class="deps-table-wrap">
+ <table class="deps-table">
+ <thead>
+ <tr>
+ <th scope="col">{$t('settings.dependencies.col_name')}</th>
+ <th scope="col">{$t('settings.dependencies.col_version')}</th>
+ <th scope="col">{$t('settings.dependencies.col_status')}</th>
+ <th scope="col" class="deps-col-action">{$t('settings.dependencies.col_action')}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {#each deps as dep (dep.name)}
+ <DependencyRow
+ name={dep.name}
+ installed={dep.installed}
+ version={dep.version}
+ outdated={dep.outdated}
+ busy={installingDep === dep.name}
+ onInstall={(variant) => onInstallDep(dep.name, variant)}
+ onAfterCustomFile={onRefresh}
+ />
+ {/each}
+ </tbody>
+ </table>
+ </div>
+ </section>
+ {/if}
+{/if}
+
+{#if installModal}
+ <div class="overlay" role="presentation" onclick={(e) => { if (e.target === e.currentTarget) closeInstall(); }}>
+ <div class="dialog" role="dialog" aria-modal="true">
+ <header class="head">
+ <h3>Instalar / Atualizar extensão — {browserLabel(installModal.browser)}</h3>
+ <button class="close" onclick={closeInstall} aria-label="fechar">×</button>
+ </header>
+ <div class="body">
+ <p>A extensão foi extraída para:</p>
+ <code class="path">{installModal.path}</code>
+ <button class="button" onclick={() => openFolder(installModal!.path)}>Abrir pasta</button>
+ <h4>Como instalar / atualizar</h4>
+ <p class="hint">{installModal.hint}</p>
+ <p class="hint small">
+ Se a extensão já está instalada, clique em "Recarregar" no <code>{installModal.browser === 'firefox' ? 'about:debugging' : 'chrome://extensions'}</code> apontando pra essa pasta — ou remova a antiga e adicione a nova.
+ </p>
+ </div>
+ <footer class="foot">
+ <button class="button" onclick={closeInstall}>Fechar</button>
+ </footer>
+ </div>
+ </div>
+{/if}
+
+<style>
+ .muted { color: rgba(255, 255, 255, 0.6); font-size: 12px; line-height: 1.4; margin: 0 0 8px; }
+ .small { font-size: 11px; }
+ .overlay {
+ position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
+ display: grid; place-items: center; z-index: 999;
+ }
+ .dialog {
+ background: var(--bg-card, #1a1a1a);
+ border: 1px solid rgba(255, 255, 255, 0.1);
+ border-radius: 12px;
+ width: min(560px, 90vw);
+ max-height: 80vh; overflow: auto;
+ display: flex; flex-direction: column;
+ }
+ .head {
+ display: flex; justify-content: space-between; align-items: center;
+ padding: 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
+ }
+ .head h3 { margin: 0; font-size: 16px; }
+ .close {
+ background: transparent; border: 0; color: rgba(255, 255, 255, 0.6);
+ font-size: 22px; line-height: 1; cursor: pointer;
+ }
+ .body { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
+ .body h4 { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
+ .body p { margin: 0; font-size: 13px; line-height: 1.5; }
+ .body .hint { color: rgba(255, 255, 255, 0.7); }
+ .path {
+ display: block; padding: 8px 10px; background: rgba(0, 0, 0, 0.4);
+ border-radius: 6px; font-family: var(--font-mono, monospace); font-size: 11px;
+ word-break: break-all;
+ }
+ .foot {
+ padding: 12px 20px; border-top: 1px solid rgba(255, 255, 255, 0.05);
+ display: flex; justify-content: flex-end;
+ }
+</style>
diff --git a/src/components/settings/downloads/ClipboardHotkeysSection.svelte b/src/components/settings/downloads/ClipboardHotkeysSection.svelte
index e97d5cc4..90fa63fe 100644
--- a/src/components/settings/downloads/ClipboardHotkeysSection.svelte
+++ b/src/components/settings/downloads/ClipboardHotkeysSection.svelte
@@ -1,215 +1,215 @@
-<script lang="ts">
- import { t } from "$lib/i18n";
- import ContextHint from "$components/hints/ContextHint.svelte";
- import { getSettings, updateSettings, toggleBool } from "../settings-helpers";
-
- let { embedded = false }: { embedded?: boolean } = $props();
-
- let settings = $derived(getSettings());
-
- let hotkeyInput = $state("");
- let hotkeyTimer: ReturnType<typeof setTimeout> | null = null;
- let hotkeyMode = $state<"record" | "type">("record");
- let hotkeyRecording = $state(false);
- let musicHotkeyInput = $state("");
- let musicHotkeyTimer: ReturnType<typeof setTimeout> | null = null;
- let musicHotkeyMode = $state<"record" | "type">("record");
- let musicHotkeyRecording = $state(false);
-
- $effect(() => {
- if (settings) {
- hotkeyInput = settings.download.hotkey_binding;
- musicHotkeyInput = settings.download.music_hotkey_binding;
- }
- });
-
- function handleHotkeyInput(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- hotkeyInput = value;
- if (hotkeyTimer) clearTimeout(hotkeyTimer);
- hotkeyTimer = setTimeout(async () => {
- if (value.trim()) {
- await updateSettings({ download: { hotkey_binding: value } });
- }
- }, 800);
- }
-
- function mapKeyName(key: string): string | null {
- if (key.length === 1 && /[a-zA-Z]/.test(key)) return key.toUpperCase();
- if (key.length === 1 && /[0-9]/.test(key)) return key;
- if (/^F([1-9]|1[0-2])$/.test(key)) return key;
- const map: Record<string, string> = {
- " ": "Space", ArrowUp: "Up", ArrowDown: "Down", ArrowLeft: "Left", ArrowRight: "Right",
- Enter: "Enter", Tab: "Tab", Escape: "Escape", Backspace: "Backspace", Delete: "Delete",
- Home: "Home", End: "End", PageUp: "PageUp", PageDown: "PageDown", Insert: "Insert",
- };
- return map[key] ?? null;
- }
-
- // O WebKit do macOS não dá foco a um `<button>` ao clicar, então o keydown
- // nunca chegava e o gravador ficava preso em "Pressione as teclas…".
- function startRecording(e: MouseEvent) {
- (e.currentTarget as HTMLButtonElement | null)?.focus();
- }
-
- function handleHotkeyKeyDown(e: KeyboardEvent) {
- e.preventDefault();
- e.stopPropagation();
- if (e.key === "Escape") {
- hotkeyRecording = false;
- return;
- }
- if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
- const keyName = mapKeyName(e.key);
- if (!keyName) return;
- const parts: string[] = [];
- if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
- if (e.shiftKey) parts.push("Shift");
- if (e.altKey) parts.push("Alt");
- parts.push(keyName);
- const value = parts.join("+");
- hotkeyInput = value;
- hotkeyRecording = false;
- updateSettings({ download: { hotkey_binding: value } });
- }
-
- function handleMusicHotkeyInput(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- musicHotkeyInput = value;
- if (musicHotkeyTimer) clearTimeout(musicHotkeyTimer);
- musicHotkeyTimer = setTimeout(async () => {
- if (value.trim()) {
- await updateSettings({ download: { music_hotkey_binding: value } });
- }
- }, 800);
- }
-
- function handleMusicHotkeyKeyDown(e: KeyboardEvent) {
- e.preventDefault();
- e.stopPropagation();
- if (e.key === "Escape") {
- musicHotkeyRecording = false;
- return;
- }
- if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
- const keyName = mapKeyName(e.key);
- if (!keyName) return;
- const parts: string[] = [];
- if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
- if (e.shiftKey) parts.push("Shift");
- if (e.altKey) parts.push("Alt");
- parts.push(keyName);
- const value = parts.join("+");
- musicHotkeyInput = value;
- musicHotkeyRecording = false;
- updateSettings({ download: { music_hotkey_binding: value } });
- }
-
- function changeMusicAudioFormat(e: Event) {
- const value = (e.target as HTMLSelectElement).value;
- updateSettings({ download: { music_audio_format: value } });
- }
-</script>
-
-{#if settings}
- {#if !embedded}
- <div class="settings-section-head section-title">
- <h5 class="section-title">{$t('settings.download.section_clipboard_hotkeys')}</h5>
- <p class="settings-section-hint">{$t('settings.download.section_clipboard_hotkeys_desc')}</p>
- </div>
- {/if}
-
- <div class="card">
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.clipboard_detection')} <ContextHint text={$t('hints.clipboard') as string} dismissKey="clipboard" /></span>
- <span class="setting-path">{$t('settings.download.clipboard_detection_desc')}</span>
- </div>
- <button class="toggle" class:on={settings.download.clipboard_detection} onclick={() => toggleBool("download", "clipboard_detection", settings.download.clipboard_detection)} role="switch" aria-checked={settings.download.clipboard_detection} aria-label={$t('settings.download.clipboard_detection') as string}><span class="toggle-knob"></span></button>
- </div>
- <div class="divider"></div>
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.auto_download_on_paste')}</span>
- <span class="setting-path">{$t('settings.download.auto_download_on_paste_desc')}</span>
- </div>
- <button class="toggle" class:on={settings.download.auto_download_on_paste} onclick={() => toggleBool("download", "auto_download_on_paste", settings.download.auto_download_on_paste)} role="switch" aria-checked={settings.download.auto_download_on_paste} aria-label={$t('settings.download.auto_download_on_paste') as string}><span class="toggle-knob"></span></button>
- </div>
- <div class="divider"></div>
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.hotkey_enabled')} <ContextHint text={$t('hints.hotkey') as string} dismissKey="hotkey" /></span>
- <span class="setting-path">{$t('settings.download.hotkey_enabled_desc')}</span>
- </div>
- <button class="toggle" class:on={settings.download.hotkey_enabled} onclick={() => toggleBool("download", "hotkey_enabled", settings.download.hotkey_enabled)} role="switch" aria-checked={settings.download.hotkey_enabled} aria-label={$t('settings.download.hotkey_enabled') as string}><span class="toggle-knob"></span></button>
- </div>
- {#if settings.download.hotkey_enabled}
- <div class="divider"></div>
- <div class="setting-row hotkey-row">
- <span class="setting-label">{$t('settings.download.hotkey_binding')}</span>
- <div class="hotkey-controls">
- <div class="hotkey-mode-switch">
- <button class="hotkey-mode-btn" class:active={hotkeyMode === 'record'} onclick={() => { hotkeyMode = 'record'; hotkeyRecording = false; }}>{$t('settings.download.hotkey_record')}</button>
- <button class="hotkey-mode-btn" class:active={hotkeyMode === 'type'} onclick={() => { hotkeyMode = 'type'; hotkeyRecording = false; }}>{$t('settings.download.hotkey_type')}</button>
- </div>
- {#if hotkeyMode === 'type'}
- <input type="text" class="input-hotkey" value={hotkeyInput} oninput={handleHotkeyInput} spellcheck="false" />
- {:else}
- <button class="input-hotkey hotkey-record-btn" class:recording={hotkeyRecording} onclick={(e) => { hotkeyRecording = true; startRecording(e); }} onkeydown={hotkeyRecording ? handleHotkeyKeyDown : undefined} onblur={() => { hotkeyRecording = false; }}>
- {hotkeyRecording ? $t('settings.download.hotkey_press') : (hotkeyInput || $t('settings.download.hotkey_press'))}
- </button>
- {/if}
- </div>
- </div>
- <div class="divider"></div>
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.copy_to_clipboard_on_hotkey')}</span>
- <span class="setting-path">{$t('settings.download.copy_to_clipboard_on_hotkey_desc')}</span>
- </div>
- <button class="toggle" class:on={settings.download.copy_to_clipboard_on_hotkey} onclick={() => toggleBool("download", "copy_to_clipboard_on_hotkey", settings.download.copy_to_clipboard_on_hotkey)} role="switch" aria-checked={settings.download.copy_to_clipboard_on_hotkey} aria-label={$t('settings.download.copy_to_clipboard_on_hotkey') as string}><span class="toggle-knob"></span></button>
- </div>
- {/if}
- <div class="divider"></div>
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.music_hotkey_enabled')}</span>
- <span class="setting-path">{$t('settings.download.music_hotkey_enabled_desc')}</span>
- </div>
- <button class="toggle" class:on={settings.download.music_hotkey_enabled} onclick={() => toggleBool("download", "music_hotkey_enabled", settings.download.music_hotkey_enabled)} role="switch" aria-checked={settings.download.music_hotkey_enabled} aria-label={$t('settings.download.music_hotkey_enabled') as string}><span class="toggle-knob"></span></button>
- </div>
- {#if settings.download.music_hotkey_enabled}
- <div class="divider"></div>
- <div class="setting-row hotkey-row">
- <span class="setting-label">{$t('settings.download.music_hotkey_binding')}</span>
- <div class="hotkey-controls">
- <div class="hotkey-mode-switch">
- <button class="hotkey-mode-btn" class:active={musicHotkeyMode === 'record'} onclick={() => { musicHotkeyMode = 'record'; musicHotkeyRecording = false; }}>{$t('settings.download.hotkey_record')}</button>
- <button class="hotkey-mode-btn" class:active={musicHotkeyMode === 'type'} onclick={() => { musicHotkeyMode = 'type'; musicHotkeyRecording = false; }}>{$t('settings.download.hotkey_type')}</button>
- </div>
- {#if musicHotkeyMode === 'type'}
- <input type="text" class="input-hotkey" value={musicHotkeyInput} oninput={handleMusicHotkeyInput} spellcheck="false" />
- {:else}
- <button class="input-hotkey hotkey-record-btn" class:recording={musicHotkeyRecording} onclick={(e) => { musicHotkeyRecording = true; startRecording(e); }} onkeydown={musicHotkeyRecording ? handleMusicHotkeyKeyDown : undefined} onblur={() => { musicHotkeyRecording = false; }}>
- {musicHotkeyRecording ? $t('settings.download.hotkey_press') : (musicHotkeyInput || $t('settings.download.hotkey_press'))}
- </button>
- {/if}
- </div>
- </div>
- {/if}
- <div class="divider"></div>
- <div class="setting-row">
- <div class="setting-col">
- <span class="setting-label">{$t('settings.download.music_audio_format')}</span>
- <span class="setting-path">{$t('settings.download.music_audio_format_desc')}</span>
- </div>
- <select class="select" value={settings.download.music_audio_format} onchange={changeMusicAudioFormat}>
- <option value="m4a">M4A (AAC)</option>
- <option value="mp3">MP3</option>
- <option value="flac">FLAC (lossless)</option>
- <option value="opus">Opus</option>
- <option value="wav">WAV</option>
- </select>
- </div>
- </div>
-{/if}
+<script lang="ts">
+ import { t } from "$lib/i18n";
+ import ContextHint from "$components/hints/ContextHint.svelte";
+ import { getSettings, updateSettings, toggleBool } from "../settings-helpers";
+
+ let { embedded = false }: { embedded?: boolean } = $props();
+
+ let settings = $derived(getSettings());
+
+ let hotkeyInput = $state("");
+ let hotkeyTimer: ReturnType<typeof setTimeout> | null = null;
+ let hotkeyMode = $state<"record" | "type">("record");
+ let hotkeyRecording = $state(false);
+ let musicHotkeyInput = $state("");
+ let musicHotkeyTimer: ReturnType<typeof setTimeout> | null = null;
+ let musicHotkeyMode = $state<"record" | "type">("record");
+ let musicHotkeyRecording = $state(false);
+
+ $effect(() => {
+ if (settings) {
+ hotkeyInput = settings.download.hotkey_binding;
+ musicHotkeyInput = settings.download.music_hotkey_binding;
+ }
+ });
+
+ function handleHotkeyInput(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ hotkeyInput = value;
+ if (hotkeyTimer) clearTimeout(hotkeyTimer);
+ hotkeyTimer = setTimeout(async () => {
+ if (value.trim()) {
+ await updateSettings({ download: { hotkey_binding: value } });
+ }
+ }, 800);
+ }
+
+ function mapKeyName(key: string): string | null {
+ if (key.length === 1 && /[a-zA-Z]/.test(key)) return key.toUpperCase();
+ if (key.length === 1 && /[0-9]/.test(key)) return key;
+ if (/^F([1-9]|1[0-2])$/.test(key)) return key;
+ const map: Record<string, string> = {
+ " ": "Space", ArrowUp: "Up", ArrowDown: "Down", ArrowLeft: "Left", ArrowRight: "Right",
+ Enter: "Enter", Tab: "Tab", Escape: "Escape", Backspace: "Backspace", Delete: "Delete",
+ Home: "Home", End: "End", PageUp: "PageUp", PageDown: "PageDown", Insert: "Insert",
+ };
+ return map[key] ?? null;
+ }
+
+ // O WebKit do macOS não dá foco a um `<button>` ao clicar, então o keydown
+ // nunca chegava e o gravador ficava preso em "Pressione as teclas…".
+ function startRecording(e: MouseEvent) {
+ (e.currentTarget as HTMLButtonElement | null)?.focus();
+ }
+
+ function handleHotkeyKeyDown(e: KeyboardEvent) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (e.key === "Escape") {
+ hotkeyRecording = false;
+ return;
+ }
+ if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
+ const keyName = mapKeyName(e.key);
+ if (!keyName) return;
+ const parts: string[] = [];
+ if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
+ if (e.shiftKey) parts.push("Shift");
+ if (e.altKey) parts.push("Alt");
+ parts.push(keyName);
+ const value = parts.join("+");
+ hotkeyInput = value;
+ hotkeyRecording = false;
+ updateSettings({ download: { hotkey_binding: value } });
+ }
+
+ function handleMusicHotkeyInput(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ musicHotkeyInput = value;
+ if (musicHotkeyTimer) clearTimeout(musicHotkeyTimer);
+ musicHotkeyTimer = setTimeout(async () => {
+ if (value.trim()) {
+ await updateSettings({ download: { music_hotkey_binding: value } });
+ }
+ }, 800);
+ }
+
+ function handleMusicHotkeyKeyDown(e: KeyboardEvent) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (e.key === "Escape") {
+ musicHotkeyRecording = false;
+ return;
+ }
+ if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
+ const keyName = mapKeyName(e.key);
+ if (!keyName) return;
+ const parts: string[] = [];
+ if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
+ if (e.shiftKey) parts.push("Shift");
+ if (e.altKey) parts.push("Alt");
+ parts.push(keyName);
+ const value = parts.join("+");
+ musicHotkeyInput = value;
+ musicHotkeyRecording = false;
+ updateSettings({ download: { music_hotkey_binding: value } });
+ }
+
+ function changeMusicAudioFormat(e: Event) {
+ const value = (e.target as HTMLSelectElement).value;
+ updateSettings({ download: { music_audio_format: value } });
+ }
+</script>
+
+{#if settings}
+ {#if !embedded}
+ <div class="settings-section-head section-title">
+ <h5 class="section-title">{$t('settings.download.section_clipboard_hotkeys')}</h5>
+ <p class="settings-section-hint">{$t('settings.download.section_clipboard_hotkeys_desc')}</p>
+ </div>
+ {/if}
+
+ <div class="card">
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.clipboard_detection')} <ContextHint text={$t('hints.clipboard') as string} dismissKey="clipboard" /></span>
+ <span class="setting-path">{$t('settings.download.clipboard_detection_desc')}</span>
+ </div>
+ <button class="toggle" class:on={settings.download.clipboard_detection} onclick={() => toggleBool("download", "clipboard_detection", settings.download.clipboard_detection)} role="switch" aria-checked={settings.download.clipboard_detection} aria-label={$t('settings.download.clipboard_detection') as string}><span class="toggle-knob"></span></button>
+ </div>
+ <div class="divider"></div>
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.auto_download_on_paste')}</span>
+ <span class="setting-path">{$t('settings.download.auto_download_on_paste_desc')}</span>
+ </div>
+ <button class="toggle" class:on={settings.download.auto_download_on_paste} onclick={() => toggleBool("download", "auto_download_on_paste", settings.download.auto_download_on_paste)} role="switch" aria-checked={settings.download.auto_download_on_paste} aria-label={$t('settings.download.auto_download_on_paste') as string}><span class="toggle-knob"></span></button>
+ </div>
+ <div class="divider"></div>
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.hotkey_enabled')} <ContextHint text={$t('hints.hotkey') as string} dismissKey="hotkey" /></span>
+ <span class="setting-path">{$t('settings.download.hotkey_enabled_desc')}</span>
+ </div>
+ <button class="toggle" class:on={settings.download.hotkey_enabled} onclick={() => toggleBool("download", "hotkey_enabled", settings.download.hotkey_enabled)} role="switch" aria-checked={settings.download.hotkey_enabled} aria-label={$t('settings.download.hotkey_enabled') as string}><span class="toggle-knob"></span></button>
+ </div>
+ {#if settings.download.hotkey_enabled}
+ <div class="divider"></div>
+ <div class="setting-row hotkey-row">
+ <span class="setting-label">{$t('settings.download.hotkey_binding')}</span>
+ <div class="hotkey-controls">
+ <div class="hotkey-mode-switch">
+ <button class="hotkey-mode-btn" class:active={hotkeyMode === 'record'} onclick={() => { hotkeyMode = 'record'; hotkeyRecording = false; }}>{$t('settings.download.hotkey_record')}</button>
+ <button class="hotkey-mode-btn" class:active={hotkeyMode === 'type'} onclick={() => { hotkeyMode = 'type'; hotkeyRecording = false; }}>{$t('settings.download.hotkey_type')}</button>
+ </div>
+ {#if hotkeyMode === 'type'}
+ <input type="text" class="input-hotkey" value={hotkeyInput} oninput={handleHotkeyInput} spellcheck="false" />
+ {:else}
+ <button class="input-hotkey hotkey-record-btn" class:recording={hotkeyRecording} onclick={(e) => { hotkeyRecording = true; startRecording(e); }} onkeydown={hotkeyRecording ? handleHotkeyKeyDown : undefined} onblur={() => { hotkeyRecording = false; }}>
+ {hotkeyRecording ? $t('settings.download.hotkey_press') : (hotkeyInput || $t('settings.download.hotkey_press'))}
+ </button>
+ {/if}
+ </div>
+ </div>
+ <div class="divider"></div>
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.copy_to_clipboard_on_hotkey')}</span>
+ <span class="setting-path">{$t('settings.download.copy_to_clipboard_on_hotkey_desc')}</span>
+ </div>
+ <button class="toggle" class:on={settings.download.copy_to_clipboard_on_hotkey} onclick={() => toggleBool("download", "copy_to_clipboard_on_hotkey", settings.download.copy_to_clipboard_on_hotkey)} role="switch" aria-checked={settings.download.copy_to_clipboard_on_hotkey} aria-label={$t('settings.download.copy_to_clipboard_on_hotkey') as string}><span class="toggle-knob"></span></button>
+ </div>
+ {/if}
+ <div class="divider"></div>
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.music_hotkey_enabled')}</span>
+ <span class="setting-path">{$t('settings.download.music_hotkey_enabled_desc')}</span>
+ </div>
+ <button class="toggle" class:on={settings.download.music_hotkey_enabled} onclick={() => toggleBool("download", "music_hotkey_enabled", settings.download.music_hotkey_enabled)} role="switch" aria-checked={settings.download.music_hotkey_enabled} aria-label={$t('settings.download.music_hotkey_enabled') as string}><span class="toggle-knob"></span></button>
+ </div>
+ {#if settings.download.music_hotkey_enabled}
+ <div class="divider"></div>
+ <div class="setting-row hotkey-row">
+ <span class="setting-label">{$t('settings.download.music_hotkey_binding')}</span>
+ <div class="hotkey-controls">
+ <div class="hotkey-mode-switch">
+ <button class="hotkey-mode-btn" class:active={musicHotkeyMode === 'record'} onclick={() => { musicHotkeyMode = 'record'; musicHotkeyRecording = false; }}>{$t('settings.download.hotkey_record')}</button>
+ <button class="hotkey-mode-btn" class:active={musicHotkeyMode === 'type'} onclick={() => { musicHotkeyMode = 'type'; musicHotkeyRecording = false; }}>{$t('settings.download.hotkey_type')}</button>
+ </div>
+ {#if musicHotkeyMode === 'type'}
+ <input type="text" class="input-hotkey" value={musicHotkeyInput} oninput={handleMusicHotkeyInput} spellcheck="false" />
+ {:else}
+ <button class="input-hotkey hotkey-record-btn" class:recording={musicHotkeyRecording} onclick={(e) => { musicHotkeyRecording = true; startRecording(e); }} onkeydown={musicHotkeyRecording ? handleMusicHotkeyKeyDown : undefined} onblur={() => { musicHotkeyRecording = false; }}>
+ {musicHotkeyRecording ? $t('settings.download.hotkey_press') : (musicHotkeyInput || $t('settings.download.hotkey_press'))}
+ </button>
+ {/if}
+ </div>
+ </div>
+ {/if}
+ <div class="divider"></div>
+ <div class="setting-row">
+ <div class="setting-col">
+ <span class="setting-label">{$t('settings.download.music_audio_format')}</span>
+ <span class="setting-path">{$t('settings.download.music_audio_format_desc')}</span>
+ </div>
+ <select class="select" value={settings.download.music_audio_format} onchange={changeMusicAudioFormat}>
+ <option value="m4a">M4A (AAC)</option>
+ <option value="mp3">MP3</option>
+ <option value="flac">FLAC (lossless)</option>
+ <option value="opus">Opus</option>
+ <option value="wav">WAV</option>
+ </select>
+ </div>
+ </div>
+{/if}
diff --git a/src/components/settings/settings-helpers.ts b/src/components/settings/settings-helpers.ts
index 1d9e8aa5..0b48e2fa 100644
--- a/src/components/settings/settings-helpers.ts
+++ b/src/components/settings/settings-helpers.ts
@@ -86,8 +86,8 @@ export async function installDep(name: string): Promise<void> {
export const CORE_THEMES = [
{ id: "system", labelKey: "settings.appearance.theme_system", colors: null as string[] | null },
- { id: "light", labelKey: null, label: "Light", colors: ["#fafafa", "#1a1a1a", "#E05500"] },
- { id: "dark", labelKey: null, label: "Dark", colors: ["#0a0a0a", "#e8e8e8", "#FF7D38"] },
+ { id: "light", labelKey: null, label: "Light", colors: ["#F5F5F7", "#1D1D1F", "#007AFF"] },
+ { id: "dark", labelKey: null, label: "Dark", colors: ["#1C1C1E", "#F5F5F7", "#0A84FF"] },
];
export const MORE_THEMES = [
diff --git a/src/components/shell/AppToolbar.svelte b/src/components/shell/AppToolbar.svelte
index 7da3fbfe..b9d2d56f 100644
--- a/src/components/shell/AppToolbar.svelte
+++ b/src/components/shell/AppToolbar.svelte
@@ -14,8 +14,8 @@
});
</script>
-<header class="mac-titlebar">
- <span class="mac-titlebar-title">{pageTitle}</span>
+<header class="mac-titlebar" data-tauri-drag-region>
+ <span class="mac-titlebar-title" data-tauri-drag-region>{pageTitle}</span>
<div class="mac-titlebar-actions">
<button type="button" class="btn btn-ghost btn-sm" onclick={() => openCommandPalette()}>
{$t("command_palette.open")}
diff --git a/src/lib/study-telegram-bridge.ts b/src/lib/study-telegram-bridge.ts
index 47f29a92..be155266 100644
--- a/src/lib/study-telegram-bridge.ts
+++ b/src/lib/study-telegram-bridge.ts
@@ -777,6 +777,7 @@ export function studyMediaThumbSet(args: {
}
const TG_PEER_COLORS: Array<[string, string]> = [
+// Paleta oficial de avatares do Telegram (dado da plataforma, não é cor de UI do app).
["#ff845e", "#d45246"],
["#febb5b", "#f68136"],
["#5caffa", "#408acf"],
diff --git a/src/lib/style/buttons.css b/src/lib/style/buttons.css
index 183705a9..c057f347 100644
--- a/src/lib/style/buttons.css
+++ b/src/lib/style/buttons.css
@@ -32,8 +32,8 @@
}
.btn:focus-visible {
- outline: none;
- box-shadow: var(--focus-ring);
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
}
.btn:disabled {
diff --git a/src/lib/style/macos-shell.css b/src/lib/style/macos-shell.css
index 2fb15b3d..32fcb242 100644
--- a/src/lib/style/macos-shell.css
+++ b/src/lib/style/macos-shell.css
@@ -1,572 +1,574 @@
-[data-shell="mac"] {
- --sidebar-width: 220px; --titlebar-height: 44px;
- --toolbar-height: 44px;
- --inspector-width: 320px;
-}
-
-.mac-shell {
- display: flex;
- flex-direction: column;
- height: 100vh;
- overflow: hidden;
- background: var(--bg);
-}
-
-.mac-shell-body {
- display: flex;
- flex: 1;
- min-height: 0;
- overflow: hidden;
-}
-
-.mac-titlebar {
- display: flex;
- align-items: center;
- height: var(--titlebar-height);
- padding: 0 var(--space-4);
- padding-left: calc(var(--space-4) + 78px);
- border-bottom: 1px solid var(--border);
- background: var(--bg);
- flex-shrink: 0;
- -webkit-app-region: drag;
- user-select: none;
-}
-
-.mac-titlebar-title {
- font-size: var(--text-md);
- font-weight: 600;
- color: var(--text);
- letter-spacing: -0.01em;
-}
-
-.mac-titlebar-actions {
- margin-left: auto;
- display: flex;
- align-items: center;
- gap: var(--space-2);
- -webkit-app-region: no-drag;
-}
-
-.mac-toolbar {
- display: flex;
- align-items: center;
- gap: var(--space-3);
- min-height: var(--toolbar-height);
- padding: var(--space-2) var(--space-5);
- border-bottom: 1px solid var(--border);
- background: var(--surface);
- flex-shrink: 0;
-}
-
-.mac-content {
- flex: 1;
- overflow-y: auto;
- padding: var(--space-4);
- min-width: 0;
-}
-
-.mac-content--home {
- padding: var(--space-3);
- display: flex;
- flex-direction: column;
- min-height: 0;
-}
-
-.mac-content--pane {
- padding: 0;
- display: flex;
- flex-direction: column;
- min-height: 0;
- overflow: hidden;
-}
-
-.mac-source-list {
- width: var(--sidebar-width);
- min-width: var(--sidebar-width);
- display: flex;
- flex-direction: column;
- background: var(--sidebar-bg);
- border-right: 1px solid var(--border);
- padding: var(--space-3) var(--space-2);
- overflow-y: auto;
- flex-shrink: 0;
-}
-
-.mac-nav-section {
- margin-bottom: var(--space-3);
-}
-
-.mac-nav-section-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: var(--space-1) var(--space-3);
- font-size: var(--text-caption);
- font-weight: 600;
- letter-spacing: var(--track-caps);
- text-transform: uppercase;
- color: var(--text-dim);
-}
-
-.mac-nav-item {
- display: flex;
- align-items: center;
- gap: var(--space-2);
- min-height: var(--row-compact);
- padding: 0 var(--space-3);
- border-radius: var(--radius-sm);
- color: var(--text);
- font-size: var(--text-base);
- font-weight: 500;
- text-decoration: none;
- transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
- position: relative;
-}
-
-@media (hover: hover) {
- .mac-nav-item:hover {
- background: var(--sidebar-highlight);
- }
-}
-
-.mac-nav-item.active {
- background: color-mix(in srgb, var(--accent) 18%, transparent);
- color: var(--accent);
-}
-
-.mac-nav-item:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
-}
-
-.mac-nav-label {
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.mac-nav-badge {
- min-width: 18px;
- height: 18px;
- padding: 0 5px;
- font-size: 11px;
- font-weight: 600;
- line-height: 18px;
- text-align: center;
- color: var(--on-accent);
- background: var(--accent);
- border-radius: var(--radius-full);
-}
-
-.mac-plugins-toggle {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 22px;
- height: 22px;
- border: none;
- background: transparent;
- color: var(--text-dim);
- border-radius: var(--radius-xs);
- cursor: pointer;
- padding: 0;
-}
-
-@media (hover: hover) {
- .mac-plugins-toggle:hover {
- background: var(--sidebar-highlight);
- color: var(--text);
- }
-}
-
-.mac-segmented {
- display: inline-flex;
- padding: 2px;
- background: var(--surface-mut);
- border-radius: var(--radius-md);
- border: 1px solid var(--border);
-}
-
-.mac-segmented-btn {
- padding: 5px 12px;
- font-size: var(--text-sm);
- font-weight: 500;
- border: none;
- background: transparent;
- color: var(--text-muted);
- border-radius: calc(var(--radius-md) - 2px);
- cursor: pointer;
- transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
-}
-
-.mac-segmented-btn.active {
- background: var(--surface);
- color: var(--text);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
-}
-
-.mac-inspector {
- width: var(--inspector-width);
- min-width: var(--inspector-width);
- border-left: 1px solid var(--border);
- background: var(--surface);
- overflow-y: auto;
- padding: var(--space-4);
- flex-shrink: 0;
-}
-
-.mac-command-backdrop {
- position: fixed;
- inset: 0;
- background: color-mix(in srgb, var(--bg) 30%, transparent);
- z-index: 200;
- display: flex;
- align-items: flex-start;
- justify-content: center;
- padding-top: 18vh;
-}
-
-.mac-command-palette {
- width: min(560px, calc(100vw - 48px));
- background: var(--material);
- backdrop-filter: var(--material-blur);
- -webkit-backdrop-filter: var(--material-blur);
- border: 1px solid var(--border);
- border-radius: var(--radius-xl);
- box-shadow: var(--elev-3);
- overflow: hidden;
-}
-
-.mac-command-input-row {
- display: flex;
- align-items: center;
- gap: var(--space-3);
- padding: var(--space-3) var(--space-4);
- border-bottom: 1px solid var(--border);
-}
-
-.mac-command-input {
- flex: 1;
- border: none;
- background: transparent;
- font-size: var(--text-md);
- color: var(--text);
- outline: none;
-}
-
-.mac-command-input::placeholder {
- color: var(--text-dim);
-}
-
-.mac-command-list {
- max-height: 320px;
- overflow-y: auto;
- padding: var(--space-2);
-}
-
-.mac-command-item {
- display: flex;
- align-items: center;
- gap: var(--space-3);
- width: 100%;
- padding: 8px var(--space-3);
- border: none;
- background: transparent;
- border-radius: var(--radius-sm);
- color: var(--text);
- font-size: var(--text-base);
- text-align: left;
- cursor: pointer;
-}
-
-@media (hover: hover) {
- .mac-command-item:hover {
- background: color-mix(in srgb, var(--accent) 12%, transparent);
- }
-}
-
-.mac-command-item.selected {
- background: color-mix(in srgb, var(--accent) 18%, transparent);
-}
-
-.mac-command-footer {
- display: flex;
- gap: var(--space-4);
- padding: var(--space-2) var(--space-4);
- border-top: 1px solid var(--border);
- font-size: 11px;
- color: var(--text-dim);
-}
-
-.mac-kbd {
- display: inline-flex;
- align-items: center;
- padding: 1px 5px;
- border-radius: 4px;
- background: var(--surface-mut);
- border: 1px solid var(--border);
- font-size: 10px;
- font-family: var(--font-mono);
-}
-
-.settings-mac {
- display: flex;
- flex-direction: column;
- flex: 1;
- min-height: 0;
- gap: 0;
-}
-
-.settings-mac-sidebar {
- width: 200px;
- flex-shrink: 0;
- padding: var(--space-2);
- border-right: 1px solid var(--border);
- overflow-y: auto;
-}
-
-.settings-mac-body {
- display: flex;
- flex: 1;
- min-height: 0;
- overflow: hidden;
-}
-
-.settings-mac-cat {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--space-2);
- width: 100%;
- text-align: left;
- padding: 6px var(--space-3);
- border: none;
- background: transparent;
- border-radius: var(--radius-sm);
- font-size: var(--text-base);
- color: var(--text);
- cursor: pointer;
-}
-
-.settings-mac-cat-label {
- flex: 1;
- min-width: 0;
-}
-
-.settings-mac-cat.search-match {
- color: var(--accent);
- font-weight: 600;
-}
-
-.settings-cat-match-count {
- flex-shrink: 0;
- min-width: 1.25rem;
- padding: 0 6px;
- font-size: 11px;
- font-weight: 600;
- line-height: 1.4;
- text-align: center;
- border-radius: 999px;
- background: color-mix(in srgb, var(--accent) 20%, transparent);
- color: var(--accent);
-}
-
-.settings-mac-cat.active {
- background: color-mix(in srgb, var(--accent) 18%, transparent);
- color: var(--accent);
- font-weight: 600;
-}
-
-.settings-mac-nav-group {
- margin-bottom: var(--space-3);
-}
-
-.settings-mac-nav-group:last-child {
- margin-bottom: 0;
-}
-
-.settings-mac-nav-group .mac-nav-section-header {
- padding-left: var(--space-2);
- padding-right: var(--space-2);
-}
-
-.settings-mac-content {
- flex: 1;
- min-width: 0;
- padding: var(--space-4);
- overflow-y: auto;
-}
-
-.downloads-mac.downloads-page {
- max-width: none;
- margin: 0;
- padding: var(--space-4);
- gap: var(--space-3);
- flex: 1;
- min-height: 0;
- overflow-y: auto;
-}
-
-.downloads-mac .downloads-header {
- gap: var(--space-3);
-}
-
-.downloads-mac .downloads-header:not(:has(.downloads-stats)) {
- justify-content: flex-end;
-}
-
-.downloads-mac .downloads-stats {
- font-size: var(--text-sm);
- color: var(--text-muted);
-}
-
-.downloads-mac .filter-pills {
- width: fit-content;
- max-width: 100%;
-}
-
-.downloads-mac-empty {
- flex: 1;
- min-height: 0;
- padding: var(--space-6) var(--space-4);
- gap: var(--space-4);
-}
-
-.downloads-mac .downloads-empty {
- min-height: 0;
- flex: 1;
- padding: var(--space-6) 0;
-}
-
-.downloads-table-wrap {
- border: 1px solid var(--border);
- border-radius: var(--radius-md);
- overflow: hidden;
- background: var(--surface);
-}
-
-.downloads-table {
- width: 100%;
- border-collapse: collapse;
- font-size: var(--text-sm);
-}
-
-.downloads-table th {
- text-align: left;
- padding: 8px var(--space-3);
- font-weight: 600;
- color: var(--text-muted);
- background: var(--surface-mut);
- border-bottom: 1px solid var(--border);
- font-size: 11px;
- text-transform: uppercase;
- letter-spacing: 0.03em;
-}
-
-.downloads-table td {
- padding: 10px var(--space-3);
- border-bottom: 1px solid var(--border);
- color: var(--text);
- vertical-align: middle;
-}
-
-.downloads-table tr:last-child td {
- border-bottom: none;
-}
-
-@media (hover: hover) {
- .downloads-table tbody tr:hover {
- background: color-mix(in srgb, var(--accent) 6%, transparent);
- }
-}
-
-.home-mac {
- display: flex;
- flex-direction: column;
- gap: var(--space-3);
- width: 100%;
- flex: 1;
- min-height: 0;
-}
-
-.home-mac-workspace {
- display: flex;
- flex: 0 1 auto;
- gap: 0;
- min-width: 0;
- min-height: 0;
- border: 1px solid var(--border);
- border-radius: var(--radius-md);
- overflow: visible;
- background: var(--surface);
-}
-
-.home-mac-hero {
- flex-shrink: 0;
- width: 132px;
- padding: var(--space-5) var(--space-3) var(--space-4);
- border-right: 1px solid var(--border);
- display: flex;
- align-items: flex-start;
- justify-content: center;
- background: color-mix(in srgb, var(--surface) 92%, var(--bg));
- overflow: visible;
-}
-
-.home-mac-hero .mascot-bubble {
- max-width: 100%;
- font-size: var(--text-xs);
- padding: var(--space-1) var(--space-2);
- line-height: 1.35;
-}
-
-.home-mac-main {
- flex: 1;
- min-width: 0;
- min-height: 0;
- padding: var(--space-4);
- display: flex;
- flex-direction: column;
- gap: var(--space-3);
- overflow-y: auto;
-}
-
-@media (max-width: 900px) {
- .home-mac-workspace {
- flex-direction: column;
- }
-
- .home-mac-hero {
- width: 100%;
- border-right: none;
- border-bottom: 1px solid var(--border);
- padding: var(--space-3);
- justify-content: flex-start;
- }
-
- .mac-inspector {
- width: 100%;
- min-width: 0;
- border-left: none;
- border-top: 1px solid var(--border);
- }
-}
-
-@media (max-width: 860px) {
- .mac-source-list {
- width: 72px;
- min-width: 72px;
- }
-
- .mac-nav-label,
- .mac-nav-section-header {
- display: none;
- }
-
- .mac-nav-item {
- justify-content: center;
- padding: 8px;
- }
-}
+[data-shell="mac"] {
+ --sidebar-width: 220px; --titlebar-height: 44px;
+ --toolbar-height: 44px;
+ --inspector-width: 320px;
+}
+
+.mac-shell {
+ display: flex;
+ flex-direction: column;
+ height: 100vh;
+ overflow: hidden;
+ background: var(--bg);
+}
+
+.mac-shell-body {
+ display: flex;
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.mac-titlebar {
+ display: flex;
+ align-items: center;
+ height: var(--titlebar-height);
+ padding: 0 var(--space-4);
+ padding-left: calc(var(--space-4) + 78px);
+ border-bottom: 1px solid var(--border);
+ background: var(--bg);
+ flex-shrink: 0;
+ /* Arrastar é feito por `data-tauri-drag-region` no markup, não por
+ `-webkit-app-region` — essa propriedade é do Chromium/Electron e o WKWebView
+ do macOS a ignora, o que deixava a janela impossível de arrastar. */
+ user-select: none;
+}
+
+.mac-titlebar-title {
+ font-size: var(--text-md);
+ font-weight: 600;
+ color: var(--text);
+ letter-spacing: -0.01em;
+}
+
+.mac-titlebar-actions {
+ margin-left: auto;
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+}
+
+.mac-toolbar {
+ display: flex;
+ align-items: center;
+ gap: var(--space-3);
+ min-height: var(--toolbar-height);
+ padding: var(--space-2) var(--space-5);
+ border-bottom: 1px solid var(--border);
+ background: var(--surface);
+ flex-shrink: 0;
+}
+
+.mac-content {
+ flex: 1;
+ overflow-y: auto;
+ padding: var(--space-4);
+ min-width: 0;
+}
+
+.mac-content--home {
+ padding: var(--space-3);
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+}
+
+.mac-content--pane {
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.mac-source-list {
+ width: var(--sidebar-width);
+ min-width: var(--sidebar-width);
+ display: flex;
+ flex-direction: column;
+ background: var(--sidebar-bg);
+ border-right: 1px solid var(--border);
+ padding: var(--space-3) var(--space-2);
+ overflow-y: auto;
+ flex-shrink: 0;
+}
+
+.mac-nav-section {
+ margin-bottom: var(--space-3);
+}
+
+.mac-nav-section-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: var(--space-1) var(--space-3);
+ font-size: var(--text-caption);
+ font-weight: 600;
+ letter-spacing: var(--track-caps);
+ text-transform: uppercase;
+ color: var(--text-dim);
+}
+
+.mac-nav-item {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ min-height: var(--row-compact);
+ padding: 0 var(--space-3);
+ border-radius: var(--radius-sm);
+ color: var(--text);
+ font-size: var(--text-base);
+ font-weight: 500;
+ text-decoration: none;
+ transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
+ position: relative;
+}
+
+@media (hover: hover) {
+ .mac-nav-item:hover {
+ background: var(--sidebar-highlight);
+ }
+}
+
+.mac-nav-item.active {
+ background: color-mix(in srgb, var(--accent) 18%, transparent);
+ color: var(--accent);
+}
+
+.mac-nav-item:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+}
+
+.mac-nav-label {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.mac-nav-badge {
+ min-width: 18px;
+ height: 18px;
+ padding: 0 calc(var(--space-1) * 1.25);
+ font-size: 11px;
+ font-weight: 600;
+ line-height: 18px;
+ text-align: center;
+ color: var(--on-accent);
+ background: var(--accent);
+ border-radius: var(--radius-full);
+}
+
+.mac-plugins-toggle {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 22px;
+ height: 22px;
+ border: none;
+ background: transparent;
+ color: var(--text-dim);
+ border-radius: var(--radius-xs);
+ cursor: pointer;
+ padding: 0;
+}
+
+@media (hover: hover) {
+ .mac-plugins-toggle:hover {
+ background: var(--sidebar-highlight);
+ color: var(--text);
+ }
+}
+
+.mac-segmented {
+ display: inline-flex;
+ padding: calc(var(--space-1) / 2);
+ background: var(--surface-mut);
+ border-radius: var(--radius-md);
+ border: 1px solid var(--border);
+}
+
+.mac-segmented-btn {
+ min-height: 24px;
+ padding: calc(var(--space-1) * 1.25) var(--space-3);
+ font-size: var(--text-sm);
+ font-weight: 500;
+ border: none;
+ background: transparent;
+ color: var(--text-muted);
+ border-radius: calc(var(--radius-md) - 2px);
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
+}
+
+.mac-segmented-btn.active {
+ background: var(--surface);
+ color: var(--text);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
+}
+
+.mac-inspector {
+ width: var(--inspector-width);
+ min-width: var(--inspector-width);
+ border-left: 1px solid var(--border);
+ background: var(--surface);
+ overflow-y: auto;
+ padding: var(--space-4);
+ flex-shrink: 0;
+}
+
+.mac-command-backdrop {
+ position: fixed;
+ inset: 0;
+ background: color-mix(in srgb, var(--bg) 30%, transparent);
+ z-index: 200;
+ display: flex;
+ align-items: flex-start;
+ justify-content: center;
+ padding-top: 18vh;
+}
+
+.mac-command-palette {
+ width: min(560px, calc(100vw - 48px));
+ background: var(--material);
+ backdrop-filter: var(--material-blur);
+ -webkit-backdrop-filter: var(--material-blur);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-xl);
+ box-shadow: var(--elev-3);
+ overflow: hidden;
+}
+
+.mac-command-input-row {
+ display: flex;
+ align-items: center;
+ gap: var(--space-3);
+ padding: var(--space-3) var(--space-4);
+ border-bottom: 1px solid var(--border);
+}
+
+.mac-command-input {
+ flex: 1;
+ border: none;
+ background: transparent;
+ font-size: var(--text-md);
+ color: var(--text);
+ outline: none;
+}
+
+.mac-command-input::placeholder {
+ color: var(--text-dim);
+}
+
+.mac-command-list {
+ max-height: 320px;
+ overflow-y: auto;
+ padding: var(--space-2);
+}
+
+.mac-command-item {
+ display: flex;
+ align-items: center;
+ gap: var(--space-3);
+ width: 100%;
+ padding: var(--space-2) var(--space-3);
+ border: none;
+ background: transparent;
+ border-radius: var(--radius-sm);
+ color: var(--text);
+ font-size: var(--text-base);
+ text-align: left;
+ cursor: pointer;
+}
+
+@media (hover: hover) {
+ .mac-command-item:hover {
+ background: color-mix(in srgb, var(--accent) 12%, transparent);
+ }
+}
+
+.mac-command-item.selected {
+ background: color-mix(in srgb, var(--accent) 18%, transparent);
+}
+
+.mac-command-footer {
+ display: flex;
+ gap: var(--space-4);
+ padding: var(--space-2) var(--space-4);
+ border-top: 1px solid var(--border);
+ font-size: 11px;
+ color: var(--text-dim);
+}
+
+.mac-kbd {
+ display: inline-flex;
+ align-items: center;
+ padding: 1px calc(var(--space-1) * 1.25);
+ border-radius: 4px;
+ background: var(--surface-mut);
+ border: 1px solid var(--border);
+ font-size: 10px;
+ font-family: var(--font-mono);
+}
+
+.settings-mac {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ min-height: 0;
+ gap: 0;
+}
+
+.settings-mac-sidebar {
+ width: 200px;
+ flex-shrink: 0;
+ padding: var(--space-2);
+ border-right: 1px solid var(--border);
+ overflow-y: auto;
+}
+
+.settings-mac-body {
+ display: flex;
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+}
+
+.settings-mac-cat {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--space-2);
+ width: 100%;
+ text-align: left;
+ padding: calc(var(--space-3) / 2) var(--space-3);
+ border: none;
+ background: transparent;
+ border-radius: var(--radius-sm);
+ font-size: var(--text-base);
+ color: var(--text);
+ cursor: pointer;
+}
+
+.settings-mac-cat-label {
+ flex: 1;
+ min-width: 0;
+}
+
+.settings-mac-cat.search-match {
+ color: var(--accent);
+ font-weight: 600;
+}
+
+.settings-cat-match-count {
+ flex-shrink: 0;
+ min-width: 1.25rem;
+ padding: 0 calc(var(--space-3) / 2);
+ font-size: 11px;
+ font-weight: 600;
+ line-height: 1.4;
+ text-align: center;
+ border-radius: 999px;
+ background: color-mix(in srgb, var(--accent) 20%, transparent);
+ color: var(--accent);
+}
+
+.settings-mac-cat.active {
+ background: color-mix(in srgb, var(--accent) 18%, transparent);
+ color: var(--accent);
+ font-weight: 600;
+}
+
+.settings-mac-nav-group {
+ margin-bottom: var(--space-3);
+}
+
+.settings-mac-nav-group:last-child {
+ margin-bottom: 0;
+}
+
+.settings-mac-nav-group .mac-nav-section-header {
+ padding-left: var(--space-2);
+ padding-right: var(--space-2);
+}
+
+.settings-mac-content {
+ flex: 1;
+ min-width: 0;
+ padding: var(--space-4);
+ overflow-y: auto;
+}
+
+.downloads-mac.downloads-page {
+ max-width: none;
+ margin: 0;
+ padding: var(--space-4);
+ gap: var(--space-3);
+ flex: 1;
+ min-height: 0;
+ overflow-y: auto;
+}
+
+.downloads-mac .downloads-header {
+ gap: var(--space-3);
+}
+
+.downloads-mac .downloads-header:not(:has(.downloads-stats)) {
+ justify-content: flex-end;
+}
+
+.downloads-mac .downloads-stats {
+ font-size: var(--text-sm);
+ color: var(--text-muted);
+}
+
+.downloads-mac .filter-pills {
+ width: fit-content;
+ max-width: 100%;
+}
+
+.downloads-mac-empty {
+ flex: 1;
+ min-height: 0;
+ padding: var(--space-6) var(--space-4);
+ gap: var(--space-4);
+}
+
+.downloads-mac .downloads-empty {
+ min-height: 0;
+ flex: 1;
+ padding: var(--space-6) 0;
+}
+
+.downloads-table-wrap {
+ border: 1px solid var(--border);
+ border-radius: var(--radius-md);
+ overflow: hidden;
+ background: var(--surface);
+}
+
+.downloads-table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: var(--text-sm);
+}
+
+.downloads-table th {
+ text-align: left;
+ padding: var(--space-2) var(--space-3);
+ font-weight: 600;
+ color: var(--text-muted);
+ background: var(--surface-mut);
+ border-bottom: 1px solid var(--border);
+ font-size: 11px;
+ text-transform: uppercase;
+ letter-spacing: 0.03em;
+}
+
+.downloads-table td {
+ padding: calc(var(--space-5) / 2.4) var(--space-3);
+ border-bottom: 1px solid var(--border);
+ color: var(--text);
+ vertical-align: middle;
+}
+
+.downloads-table tr:last-child td {
+ border-bottom: none;
+}
+
+@media (hover: hover) {
+ .downloads-table tbody tr:hover {
+ background: color-mix(in srgb, var(--accent) 6%, transparent);
+ }
+}
+
+.home-mac {
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-3);
+ width: 100%;
+ flex: 1;
+ min-height: 0;
+}
+
+.home-mac-workspace {
+ display: flex;
+ flex: 0 1 auto;
+ gap: 0;
+ min-width: 0;
+ min-height: 0;
+ border: 1px solid var(--border);
+ border-radius: var(--radius-md);
+ overflow: visible;
+ background: var(--surface);
+}
+
+.home-mac-hero {
+ flex-shrink: 0;
+ width: 132px;
+ padding: var(--space-5) var(--space-3) var(--space-4);
+ border-right: 1px solid var(--border);
+ display: flex;
+ align-items: flex-start;
+ justify-content: center;
+ background: color-mix(in srgb, var(--surface) 92%, var(--bg));
+ overflow: visible;
+}
+
+.home-mac-hero .mascot-bubble {
+ max-width: 100%;
+ font-size: var(--text-xs);
+ padding: var(--space-1) var(--space-2);
+ line-height: 1.35;
+}
+
+.home-mac-main {
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ padding: var(--space-4);
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-3);
+ overflow-y: auto;
+}
+
+@media (max-width: 900px) {
+ .home-mac-workspace {
+ flex-direction: column;
+ }
+
+ .home-mac-hero {
+ width: 100%;
+ border-right: none;
+ border-bottom: 1px solid var(--border);
+ padding: var(--space-3);
+ justify-content: flex-start;
+ }
+
+ .mac-inspector {
+ width: 100%;
+ min-width: 0;
+ border-left: none;
+ border-top: 1px solid var(--border);
+ }
+}
+
+@media (max-width: 860px) {
+ .mac-source-list {
+ width: 72px;
+ min-width: 72px;
+ }
+
+ .mac-nav-label,
+ .mac-nav-section-header {
+ display: none;
+ }
+
+ .mac-nav-item {
+ justify-content: center;
+ padding: var(--space-2);
+ }
+}
diff --git a/src/lib/style/primitives.css b/src/lib/style/primitives.css
index 49b3eaa4..42bdd19f 100644
--- a/src/lib/style/primitives.css
+++ b/src/lib/style/primitives.css
@@ -155,7 +155,7 @@ textarea.input {
justify-content: center;
min-width: 18px;
height: 18px;
- padding: 0 5px;
+ padding: 0 calc(var(--space-1) * 1.25);
font-size: var(--text-xs);
font-weight: 600;
line-height: 1;
@@ -511,14 +511,14 @@ textarea.input {
.segmented {
display: inline-flex;
- padding: 2px;
+ padding: calc(var(--space-1) / 2);
background: var(--fill-1);
border-radius: var(--radius-md);
- gap: 2px;
+ gap: calc(var(--space-1) / 2);
}
.segmented-btn {
- padding: 4px 12px;
+ padding: var(--space-1) var(--space-3);
font-size: var(--text-sm);
font-weight: 500;
border: none;
@@ -567,7 +567,7 @@ textarea.input {
inset: 0;
transform: translateX(-100%);
background: linear-gradient(90deg, transparent, var(--fill-1), transparent);
- animation: skeleton-sweep 1.4s var(--ease-out) infinite;
+ animation: skeleton-sweep calc(var(--duration-bounce) * 3) var(--ease-out) infinite;
}
.skeleton.circle {
@@ -640,7 +640,7 @@ textarea.input {
.progress.indeterminate .progress-fill {
width: 40%;
- animation: progress-slide 1.2s var(--ease-in-out) infinite;
+ animation: progress-slide calc(var(--duration-bounce) * 2.5) var(--ease-in-out) infinite;
}
@keyframes progress-slide {
@@ -648,12 +648,6 @@ textarea.input {
100% { transform: translateX(350%); }
}
-@media (prefers-reduced-motion: reduce) {
- .progress.indeterminate .progress-fill {
- animation-duration: 2.4s;
- }
-}
-
.spinner {
display: inline-block;
width: 16px;
@@ -661,7 +655,7 @@ textarea.input {
border: 2px solid var(--fill-2);
border-top-color: var(--accent);
border-radius: var(--radius-full);
- animation: spin 0.7s linear infinite;
+ animation: spin calc(var(--duration-bounce) * 1.5) linear infinite;
flex-shrink: 0;
}
@@ -669,6 +663,24 @@ textarea.input {
to { transform: rotate(360deg); }
}
+@keyframes soft-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.45; }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .progress.indeterminate .progress-fill {
+ animation: soft-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
+ transform: none;
+ width: 100%;
+ }
+
+ .spinner {
+ animation: soft-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
+ border-top-color: var(--accent);
+ }
+}
+
/* ---------- Toast ---------- */
.toast-card {
@@ -695,7 +707,7 @@ textarea.input {
.kbd {
display: inline-flex;
align-items: center;
- padding: 1px 5px;
+ padding: 1px calc(var(--space-1) * 1.25);
border-radius: var(--radius-xs);
background: var(--fill-1);
border: 1px solid var(--border);
diff --git a/src/lib/style/queue-kinds.css b/src/lib/style/queue-kinds.css
index 088ac81e..49ce5ac8 100644
--- a/src/lib/style/queue-kinds.css
+++ b/src/lib/style/queue-kinds.css
@@ -1,3 +1,5 @@
+/* Definições de token da paleta de tipos de fila (--queue-kind-*): valores-fonte
+ em hex por serem a própria definição, como os blocos de tema em app.css. */
:root {
--queue-kind-video-bg: color-mix(in oklab, var(--accent) 18%, transparent);
--queue-kind-video-fg: var(--accent);
diff --git a/src/lib/style/settings.css b/src/lib/style/settings.css
index bf1ae963..13bce82e 100644
--- a/src/lib/style/settings.css
+++ b/src/lib/style/settings.css
@@ -72,11 +72,12 @@
border-radius: var(--border-radius);
font-size: 0.95rem;
outline: none;
- transition: border-color 0.15s ease;
+ transition: border-color var(--duration-fast) var(--ease-out);
}
.settings-search:focus {
- border-color: var(--blue);
+ border-color: var(--accent);
+ box-shadow: 0 0 0 3px var(--accent-soft);
}
.settings-content :global(mark.settings-search-hit) {
@@ -104,7 +105,7 @@
border: 2px solid var(--input-border);
border-top-color: var(--blue);
border-radius: 50%;
- animation: spin 0.6s linear infinite;
+ animation: spin var(--duration-slow) linear infinite;
}
@keyframes spin {
@@ -122,7 +123,7 @@
.settings-section-head {
display: flex;
flex-direction: column;
- gap: 2px;
+ gap: calc(var(--space-1) / 2);
padding-top: var(--space-4);
margin-top: var(--space-2);
border-top: 1px solid var(--border);
@@ -160,7 +161,7 @@
.preset-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: 8px;
+ gap: var(--space-2);
}
@media (max-width: 720px) {
@@ -173,15 +174,15 @@
display: flex;
flex-direction: column;
align-items: flex-start;
- gap: 4px;
- padding: 10px 12px;
+ gap: var(--space-1);
+ padding: calc(var(--space-5) / 2.4) var(--space-3);
border: 1px solid var(--border);
border-radius: var(--radius-md, 6px);
background: var(--surface);
color: var(--text);
cursor: pointer;
text-align: left;
- transition: border-color 0.12s ease, background 0.12s ease;
+ transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}
@media (hover: hover) {
@@ -208,12 +209,12 @@
.sb-chips {
display: flex;
flex-wrap: wrap;
- gap: 6px;
- padding: 4px 0 8px;
+ gap: calc(var(--space-3) / 2);
+ padding: var(--space-1) 0 var(--space-2);
}
.sb-chip {
- padding: 5px 12px;
+ padding: calc(var(--space-1) * 1.25) var(--space-3);
border: 1px solid var(--border);
border-radius: 999px;
background: var(--surface);
@@ -221,7 +222,7 @@
font: inherit;
font-size: 12px;
cursor: pointer;
- transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
+ transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
@media (hover: hover) {
@@ -242,7 +243,7 @@
}
.ghost-btn {
- padding: 6px 12px;
+ padding: calc(var(--space-3) / 2) var(--space-3);
border-radius: 8px;
border: 1px solid var(--border);
background: transparent;
@@ -258,16 +259,16 @@
}
.naming-block {
- padding: 14px 16px 4px;
+ padding: calc(var(--space-2) * 1.75) var(--space-4) var(--space-1);
display: flex;
flex-direction: column;
- gap: 10px;
+ gap: calc(var(--space-5) / 2.4);
}
.naming-row {
display: flex;
flex-direction: column;
- gap: 4px;
+ gap: var(--space-1);
}
.naming-label {
@@ -276,7 +277,7 @@
}
.naming-input {
- padding: 6px 10px;
+ padding: calc(var(--space-3) / 2) calc(var(--space-5) / 2.4);
border-radius: 6px;
border: 1px solid var(--border);
background: var(--surface);
@@ -294,15 +295,15 @@
.naming-help {
font-size: 0.72rem;
color: var(--text-dim, var(--gray));
- margin: 4px 0 0;
+ margin: var(--space-1) 0 0;
line-height: 1.4;
}
.path-warning {
display: flex;
align-items: flex-start;
- gap: 6px;
- margin-top: 6px;
+ gap: calc(var(--space-3) / 2);
+ margin-top: calc(var(--space-3) / 2);
color: var(--warning);
font-size: 12px;
line-height: 1.4;
@@ -316,12 +317,12 @@
.speed-limit {
display: flex;
align-items: center;
- gap: 6px;
+ gap: calc(var(--space-3) / 2);
}
.downloads-speed-input {
width: 88px;
- padding: 6px 8px;
+ padding: calc(var(--space-3) / 2) var(--space-2);
background: var(--surface);
color: var(--text);
border: 1px solid var(--border);
@@ -340,7 +341,7 @@
list-style: none;
display: flex;
flex-direction: column;
- gap: 2px;
+ gap: calc(var(--space-1) / 2);
padding-top: var(--space-4);
margin-top: var(--space-2);
border-top: 1px solid var(--border);
@@ -353,8 +354,8 @@
.settings-disclosure > summary::before {
content: "▸";
display: inline-block;
- margin-right: 6px;
- transition: transform 0.15s ease;
+ margin-right: calc(var(--space-3) / 2);
+ transition: transform var(--duration-fast) var(--ease-out);
color: var(--text-dim, var(--gray));
}
@@ -388,7 +389,7 @@
justify-content: space-between;
gap: var(--space-3);
width: 100%;
- padding: 12px var(--space-4);
+ padding: var(--space-3) var(--space-4);
border: none;
border-bottom: 1px solid var(--border);
background: transparent;
@@ -416,7 +417,7 @@
.settings-drill-item-text {
display: flex;
flex-direction: column;
- gap: 2px;
+ gap: calc(var(--space-1) / 2);
min-width: 0;
flex: 1;
}
@@ -452,9 +453,9 @@
.settings-drill-back-btn {
display: inline-flex;
align-items: center;
- gap: 2px;
+ gap: calc(var(--space-1) / 2);
align-self: flex-start;
- padding: 4px 8px 4px 4px;
+ padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1);
border: none;
background: transparent;
color: var(--accent);
@@ -517,7 +518,7 @@
}
.deps-table th {
- padding: 8px 12px;
+ padding: var(--space-2) var(--space-3);
text-align: left;
font-size: var(--text-xs);
font-weight: 600;
@@ -540,7 +541,7 @@
}
.deps-table :global(td) {
- padding: 10px 12px;
+ padding: calc(var(--space-5) / 2.4) var(--space-3);
vertical-align: middle;
}
@@ -576,7 +577,7 @@
.setting-col {
display: flex;
flex-direction: column;
- gap: 4px;
+ gap: var(--space-1);
min-width: 0;
flex: 1;
}
@@ -602,7 +603,7 @@
}
.select {
- padding: calc(var(--padding) / 2) 28px calc(var(--padding) / 2) var(--padding);
+ padding: calc(var(--padding) / 2) calc(var(--space-4) + var(--space-3)) calc(var(--padding) / 2) var(--padding);
font-size: var(--text-base);
font-weight: 500;
background: var(--button-elevated);
@@ -666,7 +667,7 @@
.hotkey-controls {
display: flex;
flex-direction: column;
- gap: 6px;
+ gap: calc(var(--space-3) / 2);
align-items: flex-end;
}
@@ -677,7 +678,7 @@
}
.hotkey-mode-btn {
- padding: 3px 10px;
+ padding: calc(var(--space-3) / 4) calc(var(--space-5) / 2.4);
font-size: 12px;
font-weight: 500;
background: transparent;
@@ -712,7 +713,7 @@
.hotkey-record-btn.recording {
border-color: var(--blue);
- animation: hotkey-pulse 1.5s ease-in-out infinite;
+ animation: hotkey-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
}
@keyframes hotkey-pulse {
@@ -743,7 +744,7 @@
}
.template-preview {
- padding: 0 0 calc(var(--padding) + 2px);
+ padding: 0 0 calc(var(--padding) + var(--space-1) / 2);
}
.template-preview .setting-path {
@@ -774,7 +775,7 @@
width: 20px;
height: 20px;
border-radius: var(--radius-full);
- background: #fff;
+ background: var(--on-status);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
transition: transform var(--duration-base) var(--ease-out);
pointer-events: none;
@@ -814,7 +815,7 @@
.update-text {
font-size: var(--text-base);
font-weight: 500;
- color: #fff;
+ color: var(--on-accent);
}
.update-btn {
@@ -825,7 +826,7 @@
padding: calc(var(--padding) / 2) var(--padding);
font-size: var(--text-sm);
font-weight: 500;
- background: #fff;
+ background: var(--on-status);
color: var(--blue);
border: none;
border-radius: calc(var(--border-radius) - 2px);
@@ -845,7 +846,7 @@
}
.update-btn:focus-visible {
- outline: 2px solid #fff;
+ outline: 2px solid var(--on-accent);
outline-offset: 2px;
}
@@ -855,7 +856,7 @@
border: 2px solid var(--content-border);
border-top-color: var(--blue);
border-radius: 50%;
- animation: spin 0.6s linear infinite;
+ animation: spin var(--duration-slow) linear infinite;
}
.dep-ok {
@@ -878,7 +879,7 @@
border: 2px solid var(--input-border);
border-top-color: var(--blue);
border-radius: 50%;
- animation: spin 0.6s linear infinite;
+ animation: spin var(--duration-slow) linear infinite;
flex-shrink: 0;
}
@@ -902,14 +903,14 @@
.flag-grid {
display: flex;
flex-wrap: wrap;
- gap: 6px;
- padding: calc(var(--padding) + 2px);
+ gap: calc(var(--space-3) / 2);
+ padding: calc(var(--padding) + var(--space-1) / 2);
}
.flag-chip {
display: inline-flex;
align-items: center;
- gap: 4px;
- padding: 4px 10px;
+ gap: var(--space-1);
+ padding: var(--space-1) calc(var(--space-5) / 2.4);
font-size: 12px;
font-weight: 500;
border-radius: 6px;
@@ -917,7 +918,7 @@
color: var(--gray);
cursor: pointer;
border: 1px solid transparent;
- transition: all 0.15s;
+ transition: all var(--duration-fast) var(--ease-out);
user-select: none;
}
@media (hover: hover) {
@@ -930,7 +931,7 @@
}
.flag-value-input {
width: 70px;
- padding: 2px 6px;
+ padding: calc(var(--space-1) / 2) calc(var(--space-3) / 2);
font-size: var(--text-xs);
background: var(--button-elevated);
color: var(--secondary);
@@ -946,14 +947,14 @@
.category-tabs {
display: flex;
flex-wrap: wrap;
- gap: 4px;
- padding: 3px;
+ gap: var(--space-1);
+ padding: calc(var(--space-3) / 4);
background: var(--button);
border-radius: var(--border-radius);
}
.cat-tab {
- padding: 6px 12px;
+ padding: calc(var(--space-3) / 2) var(--space-3);
font-size: 12px;
font-weight: 500;
color: var(--gray);
@@ -983,7 +984,7 @@
.theme-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
- gap: 8px;
+ gap: var(--space-2);
padding: 0 var(--padding) var(--padding);
}
@@ -995,7 +996,7 @@
display: block;
width: calc(100% - var(--padding) * 2);
margin: 0 var(--padding) var(--padding);
- padding: 8px 12px;
+ padding: var(--space-2) var(--space-3);
text-align: left;
font-size: var(--text-base);
font-weight: 500;
@@ -1019,7 +1020,7 @@
.more-themes > summary {
cursor: pointer;
- padding: 8px 4px;
+ padding: var(--space-2) var(--space-1);
font-size: 12px;
color: var(--tertiary);
user-select: none;
@@ -1031,7 +1032,7 @@
}
.more-themes[open] > summary {
- margin-bottom: 4px;
+ margin-bottom: var(--space-1);
color: var(--secondary);
}
@@ -1043,7 +1044,7 @@
display: flex;
flex-direction: column;
align-items: center;
- gap: 6px;
+ gap: calc(var(--space-3) / 2);
padding: var(--space-2);
border: 2px solid transparent;
border-radius: var(--radius-md);
@@ -1115,3 +1116,16 @@
color: var(--tertiary);
text-align: center;
}
+
+ @media (prefers-reduced-motion: reduce) {
+ .spinner,
+ .update-spinner,
+ .dep-spinner {
+ animation: settings-soft-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
+ }
+ }
+
+ @keyframes settings-soft-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.45; }
+ }
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 98612cd3..4ed2ed72 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -1,1929 +1,1940 @@
-<script lang="ts">
- import { invoke } from "@tauri-apps/api/core";
- import { open } from "@tauri-apps/plugin-dialog";
- import { goto } from "$app/navigation";
- import { onMount } from "svelte";
- import SupportedServices from "$components/services/SupportedServices.svelte";
- import BilibiliPreviewExtras from "$components/omnibox/BilibiliPreviewExtras.svelte";
- import DownloadModeSelector from "$components/omnibox/DownloadModeSelector.svelte";
- import QualityPicker from "$components/omnibox/QualityPicker.svelte";
- import FormatSelector from "$components/omnibox/FormatSelector.svelte";
- import CookieAccountPicker from "$components/omnibox/CookieAccountPicker.svelte";
- import OmniboxAdvanced from "$components/omnibox/OmniboxAdvanced.svelte";
- import MediaPreview from "$components/omnibox/MediaPreview.svelte";
- import BatchDownload from "$components/omnibox/BatchDownload.svelte";
- import SearchResults from "$components/omnibox/SearchResults.svelte";
- import P2pSendDialog from "$components/p2p/P2pSendDialog.svelte";
- import P2pReceiveDialog from "$components/p2p/P2pReceiveDialog.svelte";
- import HomeHero from "$components/home/HomeHero.svelte";
- import HomeUrlBar from "$components/home/HomeUrlBar.svelte";
- import HomeInspector from "$components/home/HomeInspector.svelte";
- import {
- type OmniState,
- type PlatformInfo,
- type SearchResult,
- type HomeInputMode,
- showInspectorForState,
- showOmniboxForState,
- isUrl,
- } from "$lib/home/omnibox-controller";
- import { getDownloads, formatBytes } from "$lib/stores/download-store.svelte";
- import { getSettings, updateSettings } from "$lib/stores/settings-store.svelte";
- import { showToast } from "$lib/stores/toast-store.svelte";
- import { onClipboardUrl } from "$lib/stores/clipboard-monitor";
- import { getMediaPreview, clearMediaPreview } from "$lib/stores/media-preview-store.svelte";
- import { clearPendingExternalPrefill, getPendingExternalPrefill, type ExternalUrlEvent } from "$lib/stores/external-url-store.svelte";
- import { getOmniboxDraftUrl, setOmniboxDraftUrl } from "$lib/stores/omnibox-draft-store.svelte";
- import { t } from "$lib/i18n";
- import { translateBackendError } from "$lib/error-translate";
- import { platformDisplayName } from "$lib/platform-display-names";
- import { STUDY_MAINTENANCE_NOTICE } from "$lib/study-feature-flags";
-
- type DownloadStarted = {
- id: number;
- title: string;
- };
-
- type FormatInfo = {
- format_id: string;
- ext: string;
- resolution: string | null;
- width: number | null;
- height: number | null;
- fps: number | null;
- vcodec: string | null;
- acodec: string | null;
- filesize: number | null;
- tbr: number | null;
- has_video: boolean;
- has_audio: boolean;
- format_note: string | null;
- };
-
- // Platforms whose content is downloaded via the Courses page (courses
- // plugin + logged-in account), not from a pasted URL.
- const COURSE_PLATFORMS = new Set(["hotmart", "udemy"]);
-
- let url = $state(getOmniboxDraftUrl());
- let homeInputMode = $state<HomeInputMode>("url");
- let omniState = $state<OmniState>({ kind: "idle" });
- let debounceTimer = $state<ReturnType<typeof setTimeout> | null>(null);
- let downloadMode = $state<"auto" | "audio" | "mute">("auto");
- let selectedQuality = $state("best");
- let clipStart = $state("");
- let clipEnd = $state("");
- let scheduleAt = $state("");
- let scheduleStop = $state("");
- let playlistEntries = $state<{ index: number; title: string; url: string }[]>([]);
- let selectedPlaylistItems = $state<Set<number>>(new Set());
- let playlistLoading = $state(false);
- let torrentEntries = $state<{ index: number; path: string; size_bytes: number }[]>([]);
- let selectedTorrentFiles = $state<Set<number>>(new Set());
- let torrentLoading = $state(false);
- let selectedFormatId = $state<string | null>(null);
- let formats = $state<FormatInfo[]>([]);
- let loadingFormats = $state(false);
- let formatError = $state<string | null>(null);
- let formatFetchGeneration = $state(0);
- let referer = $state("");
-
- type CookieAccount = {
- slug: string;
- alias: string;
- captured_at_ms: number;
- cookie_count: number;
- last_used_at_ms: number | null;
- };
- let cookieAccounts = $state<CookieAccount[]>([]);
- let selectedCookieSlug = $state<string | null>(null);
- let cookieHint = $state<"stale" | "expired" | null>(null);
- let advancedMode = $state(false);
- const STUDY_NOTICE_DISMISS_KEY = "omniget.study_maintenance_notice_dismissed_v1";
- let studyNoticeDismissed = $state(
- typeof localStorage !== "undefined"
- && localStorage.getItem(STUDY_NOTICE_DISMISS_KEY) === "1"
- );
- function dismissStudyNotice() {
- studyNoticeDismissed = true;
- try { localStorage.setItem(STUDY_NOTICE_DISMISS_KEY, "1"); } catch {}
- }
- let mediaPreview = $derived(getMediaPreview());
- let pendingExternalPrefill = $derived(getPendingExternalPrefill());
- let previewImageLoading = $state(true);
- let showP2pSendDialog = $state(false);
- let p2pReceiveCode = $state<string | null>(null);
- let p2pReceiveUrl = $state("");
- let externalNotice = $state<ExternalUrlEvent | null>(null);
- let lastExternalPrefillId = $state<number | null>(null);
- let pendingAutoDownload = $state(false);
-
- onMount(() => {
- onClipboardUrl((detectedUrl) => {
- if (omniState.kind === "preparing") return;
- url = detectedUrl;
- const settings = getSettings();
- const autoDownload = !!(settings?.download.auto_download_on_paste && settings?.download.clipboard_detection);
- pendingAutoDownload = autoDownload;
- handleInput();
- showToast("info", $t(autoDownload ? "toast.auto_download_started" : "toast.clipboard_url_detected"));
- });
- if (url.trim()) {
- queueMicrotask(() => handleInput());
- }
- return () => {
- onClipboardUrl(null);
- };
- });
-
- $effect(() => {
- setOmniboxDraftUrl(url);
- });
-
- const AUTO_DOWNLOAD_DELAY_MS = 2000;
-
- $effect(() => {
- if (!pendingAutoDownload) return;
- if (omniState.kind === "detected") {
- const info = omniState.info;
- if (COURSE_PLATFORMS.has(info.platform) || info.platform === "p2p") {
- pendingAutoDownload = false;
- return;
- }
- pendingAutoDownload = false;
- const snapshotUrl = url;
- setTimeout(() => {
- if (url === snapshotUrl && omniState.kind === "detected") {
- handleAction();
- }
- }, AUTO_DOWNLOAD_DELAY_MS);
- } else if (
- omniState.kind === "unsupported" ||
- omniState.kind === "error" ||
- omniState.kind === "batch" ||
- omniState.kind === "search-results" ||
- omniState.kind === "search-empty" ||
- omniState.kind === "idle"
- ) {
- pendingAutoDownload = false;
- }
- });
-
- const STALL_THRESHOLD = 30_000;
- let downloads = $derived(getDownloads());
- let stallTick = $state(0);
- let lastCompletionAt = $state(0);
- let firstCompletionOfSession = $state(false);
- let completionSeenIds = new Set<string | number>();
-
- $effect(() => {
- for (const [id, item] of downloads.entries()) {
- if (item.status === "complete" && !completionSeenIds.has(id)) {
- completionSeenIds.add(id);
- lastCompletionAt = Date.now();
- if (!firstCompletionOfSession) {
- firstCompletionOfSession = true;
- }
- break;
- }
- }
- });
-
- $effect(() => {
- const interval = setInterval(() => { stallTick++; }, 5000);
- return () => clearInterval(interval);
- });
-
-
- $effect(() => {
- if (mediaPreview) {
- previewImageLoading = true;
- }
- });
-
- $effect(() => {
- const incoming = pendingExternalPrefill;
- if (!incoming || incoming.id === lastExternalPrefillId) {
- return;
- }
-
- lastExternalPrefillId = incoming.id;
- clearPendingExternalPrefill(incoming.id);
- externalNotice = incoming;
-
- if (incoming.action !== "prefill") {
- return;
- }
-
- url = incoming.url;
- if (getSettings()?.download.auto_download_on_paste) {
- pendingAutoDownload = true;
- }
- handleInput();
- });
-
- let mascotEmotion = $derived.by((): "idle" | "downloading" | "error" | "stalled" | "queue" | "complete" | "amazed" => {
- void stallTick;
-
- if (lastCompletionAt > 0 && Date.now() - lastCompletionAt < 5000) {
- return firstCompletionOfSession && completionSeenIds.size === 1 ? "amazed" : "complete";
- }
-
- if (omniState.kind === "preparing") return "downloading";
- if (omniState.kind === "error") return "error";
-
- let hasActiveDownloading = false;
- let hasActiveStalled = false;
- let hasItems = false;
- for (const item of downloads.values()) {
- hasItems = true;
- if (item.status === "downloading") {
- hasActiveDownloading = true;
- const elapsed = Date.now() - item.lastUpdateAt;
- if (elapsed > STALL_THRESHOLD) {
- hasActiveStalled = true;
- }
- }
- }
-
- if (hasActiveStalled) return "stalled";
- if (hasActiveDownloading) return "downloading";
- if (hasItems) return "queue";
- return "idle";
- });
-
- let mascotCompact = $derived(omniState.kind !== "idle");
-
- function pickRandom(raw: string): string {
- if (raw.includes("|")) {
- const opts = raw.split("|");
- return opts[Math.floor(Math.random() * opts.length)];
- }
- return raw;
- }
-
- let lastBubbleKey = $state("");
- let bubbleText = $state("");
-
- $effect(() => {
- let key: string;
- if (mascotEmotion === "amazed") key = "amazed";
- else if (mascotEmotion === "complete") key = "complete";
- else if (mascotEmotion === "queue") key = "queue";
- else if (mascotEmotion === "downloading") key = "downloading";
- else if (mascotEmotion === "stalled") key = "stalled";
- else {
- switch (omniState.kind) {
- case "idle": key = "idle"; break;
- case "detecting": key = "detecting"; break;
- case "detected": key = "detected"; break;
- case "preparing": key = "preparing"; break;
- case "searching":
- case "search-results": key = "search"; break;
- case "error": key = "error"; break;
- default: key = ""; break;
- }
- }
- if (key && key !== lastBubbleKey) {
- lastBubbleKey = key;
- bubbleText = pickRandom($t(`mascot.${key}`));
- } else if (!key) {
- lastBubbleKey = "";
- bubbleText = "";
- }
- });
-
- let showLoopIcon = $derived(
- omniState.kind === "detected" ||
- omniState.kind === "preparing" ||
- omniState.kind === "batch"
- );
-
- let showOmnibox = $derived(showOmniboxForState(omniState));
- let showInspector = $derived(showInspectorForState(omniState));
-
- function isValidTimeBound(v: string): boolean {
- return /^(\d+:)?\d{1,2}:\d{1,2}(\.\d+)?$|^\d+(\.\d+)?$/.test(v.trim());
- }
-
- function buildTimeRange(): string | null {
- const s = clipStart.trim();
- const e = clipEnd.trim();
- if (!s && !e) return null;
- if (s && !isValidTimeBound(s)) return null;
- if (e && !isValidTimeBound(e)) return null;
- return `${s || "0"}-${e || "inf"}`;
- }
-
- function toEpochMs(v: string): number | null {
- if (!v) return null;
- const ms = new Date(v.includes("T") ? v : `${v}T00:00`).getTime();
- if (Number.isNaN(ms)) return null;
- return ms;
- }
-
- function schedulePart(v: string, part: "date" | "time"): string {
- if (!v) return "";
- const [date, time = ""] = v.split("T");
- return part === "date" ? date : time;
- }
-
- function withSchedulePart(current: string, part: "date" | "time", value: string): string {
- const pad = (n: number) => String(n).padStart(2, "0");
- let [date, time = ""] = current ? current.split("T") : ["", ""];
- if (part === "date") date = value;
- else time = value;
- if (!date && !time) return "";
- if (!date) {
- const now = new Date();
- date = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
- }
- if (!time) time = "00:00";
- return `${date}T${time}`;
- }
-
- function setSchedulePreset(kind: "1h" | "tonight" | "1d") {
- const d = new Date();
- if (kind === "1h") d.setHours(d.getHours() + 1);
- else if (kind === "1d") d.setDate(d.getDate() + 1);
- else {
- d.setHours(22, 0, 0, 0);
- if (d.getTime() < Date.now()) d.setDate(d.getDate() + 1);
- }
- const pad = (n: number) => String(n).padStart(2, "0");
- scheduleAt = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
- }
-
- function handleInput() {
- if (debounceTimer) clearTimeout(debounceTimer);
- clearMediaPreview();
- clipStart = "";
- clipEnd = "";
- scheduleAt = "";
- scheduleStop = "";
- cookieHint = null;
- playlistEntries = [];
- selectedPlaylistItems = new Set();
- playlistLoading = false;
- torrentEntries = [];
- selectedTorrentFiles = new Set();
- torrentLoading = false;
- const currentSettings = getSettings();
- const saved = currentSettings?.last_download_options;
- const savedMode = saved?.mode;
- const settingsQuality = currentSettings?.download.video_quality;
- selectedQuality = settingsQuality && typeof settingsQuality === "string"
- ? settingsQuality
- : "best";
- downloadMode = savedMode === "audio" || savedMode === "mute" ? savedMode : "auto";
- selectedFormatId = null;
- formats = [];
- loadingFormats = false;
- formatError = null;
- formatFetchGeneration++;
- referer = "";
-
- const trimmed = url.trim();
- if (!trimmed) {
- omniState = { kind: "idle" };
- return;
- }
-
- const urls = trimmed.split(/[\s\n]+/).filter(isUrl);
-
- if (urls.length > 1) {
- omniState = { kind: "batch", urls };
- return;
- }
-
- if (isUrl(trimmed)) {
- omniState = { kind: "detecting" };
- if (getSettings()?.download.auto_download_on_paste) {
- pendingAutoDownload = true;
- }
- debounceTimer = setTimeout(() => {
- detectPlatform(trimmed);
- }, 500);
- return;
- }
-
- if (trimmed.length >= 2) {
- omniState = { kind: "searching" };
- debounceTimer = setTimeout(() => {
- performSearch(trimmed);
- }, 600);
- } else {
- omniState = { kind: "idle" };
- }
- }
-
- async function detectPlatform(value: string) {
- try {
- const result = await invoke<PlatformInfo>("detect_platform", { url: value });
- if (result.supported) {
- omniState = { kind: "detected", info: result };
- if (!COURSE_PLATFORMS.has(result.platform)) {
- invoke("prefetch_media_info", { url: value }).catch(() => {});
- }
- loadCookieAccounts(value);
- if (result.content_type === "playlist") {
- loadPlaylistEntries(value);
- }
- if (isTorrentUrl(value)) {
- loadTorrentContents(value);
- }
- } else {
- omniState = { kind: "unsupported" };
- }
- } catch {
- omniState = { kind: "unsupported" };
- }
- }
-
- async function loadPlaylistEntries(targetUrl: string) {
- playlistEntries = [];
- selectedPlaylistItems = new Set();
- playlistLoading = true;
- try {
- const entries = await invoke<{ index: number; title: string; url: string }[]>(
- "playlist_entries",
- { url: targetUrl }
- );
- playlistEntries = entries;
- selectedPlaylistItems = new Set(entries.map((e) => e.index));
- } catch {
- playlistEntries = [];
- } finally {
- playlistLoading = false;
- }
- }
-
- function togglePlaylistItem(idx: number) {
- const next = new Set(selectedPlaylistItems);
- if (next.has(idx)) next.delete(idx);
- else next.add(idx);
- selectedPlaylistItems = next;
- }
-
- function selectAllPlaylist() {
- selectedPlaylistItems = new Set(playlistEntries.map((e) => e.index));
- }
-
- function selectNonePlaylist() {
- selectedPlaylistItems = new Set();
- }
-
- function isTorrentUrl(value: string): boolean {
- const v = value.trim().toLowerCase();
- return v.startsWith("magnet:") || v.endsWith(".torrent");
- }
-
- async function loadTorrentContents(targetUrl: string) {
- torrentEntries = [];
- selectedTorrentFiles = new Set();
- torrentLoading = true;
- try {
- const entries = await invoke<{ index: number; path: string; size_bytes: number }[]>(
- "torrent_contents",
- { url: targetUrl }
- );
- torrentEntries = entries;
- selectedTorrentFiles = new Set(entries.map((e) => e.index));
- } catch {
- torrentEntries = [];
- } finally {
- torrentLoading = false;
- }
- }
-
- function toggleTorrentFile(idx: number) {
- const next = new Set(selectedTorrentFiles);
- if (next.has(idx)) next.delete(idx);
- else next.add(idx);
- selectedTorrentFiles = next;
- }
-
- function selectAllTorrent() {
- selectedTorrentFiles = new Set(torrentEntries.map((e) => e.index));
- }
-
- function selectNoneTorrent() {
- selectedTorrentFiles = new Set();
- }
-
- async function loadCookieAccounts(targetUrl: string) {
- try {
- const result = await invoke<{ domain: string; accounts: CookieAccount[] }>(
- "cookies_accounts_for_url",
- { url: targetUrl }
- );
- const accounts = result.accounts.slice().sort((a, b) => {
- const lhs = a.last_used_at_ms ?? a.captured_at_ms;
- const rhs = b.last_used_at_ms ?? b.captured_at_ms;
- return rhs - lhs;
- });
- cookieAccounts = accounts;
- selectedCookieSlug = accounts[0]?.slug ?? null;
- cookieHint = null;
- if (accounts.length > 0) {
- try {
- const h = await invoke<{ items: { domain: string; slug: string; status: string }[] }>(
- "cookies_health"
- );
- const slug = selectedCookieSlug ?? "_default";
- const item =
- h.items.find((it) => it.domain === result.domain && it.slug === slug) ??
- h.items.find((it) => it.domain === result.domain);
- if (item && item.status !== "fresh") {
- cookieHint = item.status === "expired" ? "expired" : "stale";
- }
- } catch {}
- }
- } catch {
- cookieAccounts = [];
- selectedCookieSlug = null;
- cookieHint = null;
- }
- }
-
- async function performSearch(query: string) {
- try {
- const results = await invoke<SearchResult[]>("search_videos", {
- query,
- platform: "youtube",
- maxResults: 6,
- });
- if (url.trim() !== query) return;
- if (results.length > 0) {
- omniState = { kind: "search-results", results };
- } else {
- omniState = { kind: "search-empty" };
- }
- } catch {
- if (url.trim() === query) {
- omniState = { kind: "search-empty" };
- }
- }
- }
-
- function selectSearchResult(result: SearchResult) {
- url = result.url;
- omniState = { kind: "detecting" };
- detectPlatform(result.url);
- }
-
- function getContentTypeLabel(contentType: string | null): string {
- if (!contentType) return $t("omnibox.content_type.unknown");
- const key = `omnibox.content_type.${contentType}`;
- const result = $t(key);
- if (result === key) return $t("omnibox.content_type.unknown");
- return result;
- }
-
-
- async function loadFormats() {
- if (loadingFormats) return;
- if (formats.length > 0) {
- formats = [];
- selectedFormatId = null;
- formatError = null;
- return;
- }
- const targetUrl = url.trim();
- if (!targetUrl) {
- formatError = $t("omnibox.formats_error");
- return;
- }
- loadingFormats = true;
- formatError = null;
- const gen = ++formatFetchGeneration;
- try {
- const result = await invoke<FormatInfo[]>("get_media_formats", { url: targetUrl });
- if (gen !== formatFetchGeneration) return;
- formats = result;
- if (result.length === 0) {
- formatError = $t("omnibox.no_formats");
- }
- } catch (e: any) {
- if (gen !== formatFetchGeneration) return;
- formats = [];
- const msg = typeof e === "string" ? e : e.message ?? "";
- formatError = msg ? translateBackendError(msg, $t) : $t("omnibox.formats_error");
- } finally {
- loadingFormats = false;
- }
- }
-
- function selectFormat(formatId: string) {
- selectedFormatId = formatId;
- }
-
- function clearFormatSelection() {
- selectedFormatId = null;
- }
-
- function presetBest() {
- selectedFormatId = null;
- downloadMode = "auto";
- selectedQuality = "best";
- }
-
- function presetMusic() {
- selectedFormatId = null;
- downloadMode = "audio";
- }
-
- function persistLastDownloadOptions() {
- const saved = getSettings()?.last_download_options;
- const nextMode = downloadMode;
- if (saved?.mode === nextMode) return;
- updateSettings({
- last_download_options: {
- mode: nextMode,
- quality: saved?.quality ?? "best",
- },
- }).catch(() => {});
- }
-
- async function handleAction() {
- if (omniState.kind !== "detected") return;
- const info = omniState.info;
-
- if (COURSE_PLATFORMS.has(info.platform)) {
- goto(`/courses/${encodeURIComponent(info.platform)}`);
- return;
- }
-
- if (info.platform === "p2p") {
- const trimmed = url.trim();
- const code = trimmed.replace(/^p2p:/, "");
- p2pReceiveUrl = trimmed;
- p2pReceiveCode = code;
- return;
- }
-
- const isPlaylist = info.content_type === "playlist" && playlistEntries.length > 0;
- if (isPlaylist && selectedPlaylistItems.size === 0) {
- showToast("error", $t("omnibox.playlist_none_selected") as string);
- return;
- }
-
- const isTorrent = torrentEntries.length > 0;
- if (isTorrent && selectedTorrentFiles.size === 0) {
- showToast("error", $t("omnibox.torrent_none_selected") as string);
- return;
- }
-
- const settings = getSettings();
- let outputDir = settings?.download.default_output_dir ?? "";
-
- if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
- const selected = await open({
- directory: true,
- title: $t("settings.download.default_output_dir"),
- });
- if (!selected) return;
- outputDir = selected;
- }
-
- const currentUrl = url.trim();
- const platform = info.platform;
- omniState = { kind: "preparing", platform };
- url = "";
-
- try {
- await invoke<DownloadStarted>("download_from_url", {
- url: currentUrl,
- outputDir,
- downloadMode: downloadMode === "auto" ? null : downloadMode,
- quality: selectedQuality,
- formatId: selectedFormatId,
- referer: referer.trim() || null,
- cookieSlug: selectedCookieSlug,
- timeRange: buildTimeRange(),
- playlistItems: isPlaylist ? [...selectedPlaylistItems] : null,
- torrentFiles: isTorrent ? [...selectedTorrentFiles] : null,
- scheduledAt: toEpochMs(scheduleAt),
- stopAt: toEpochMs(scheduleStop),
- });
- persistLastDownloadOptions();
- omniState = { kind: "idle" };
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
- omniState = {
- kind: "error",
- message: msg,
- originalUrl: currentUrl,
- platform,
- };
- }
- }
-
- async function handleBatchDownload() {
- if (omniState.kind !== "batch") return;
- const batchUrls = omniState.urls;
-
- const settings = getSettings();
- let outputDir = settings?.download.default_output_dir ?? "";
-
- if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
- const selected = await open({
- directory: true,
- title: $t("settings.download.default_output_dir"),
- });
- if (!selected) return;
- outputDir = selected;
- }
-
- omniState = { kind: "idle" };
- url = "";
-
- const results = await Promise.allSettled(
- batchUrls.map(u => invoke<DownloadStarted>("download_from_url", {
- url: u,
- outputDir,
- downloadMode: downloadMode === "auto" ? null : downloadMode,
- quality: selectedQuality,
- formatId: null,
- referer: null,
- cookieSlug: null,
- }))
- );
-
- const queued = results.filter(r => r.status === "fulfilled").length;
- if (queued > 0) {
- showToast("info", $t("omnibox.batch_queued", { count: queued }));
- persistLastDownloadOptions();
- }
- }
-
- function handleRetry() {
- if (omniState.kind !== "error") return;
- url = omniState.originalUrl;
- omniState = { kind: "detecting" };
- detectPlatform(url.trim());
- }
-
- async function handleP2pAccept() {
- const currentUrl = p2pReceiveUrl;
- p2pReceiveCode = null;
- p2pReceiveUrl = "";
-
- const settings = getSettings();
- let outputDir = settings?.download.default_output_dir ?? "";
-
- if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
- const selected = await open({
- directory: true,
- title: $t("settings.download.default_output_dir"),
- });
- if (!selected) return;
- outputDir = selected;
- }
-
- omniState = { kind: "preparing", platform: "p2p" };
- url = "";
-
- try {
- await invoke("download_from_url", {
- url: currentUrl,
- outputDir,
- downloadMode: null,
- quality: "best",
- formatId: null,
- referer: null,
- cookieSlug: null,
- });
- omniState = { kind: "idle" };
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
- omniState = { kind: "error", message: msg, originalUrl: currentUrl, platform: "p2p" };
- }
- }
-
- function handleP2pReject() {
- p2pReceiveCode = null;
- p2pReceiveUrl = "";
- }
-
- async function openTorrentFile() {
- const selected = await open({
- title: "Select .torrent file",
- filters: [{ name: "Torrent", extensions: ["torrent"] }],
- multiple: false,
- });
- if (selected && typeof selected === "string") {
- url = selected;
- handleInput();
- }
- }
-
- async function openBatchFile() {
- const selected = await open({
- title: $t("omnibox.batch_file_title"),
- filters: [{ name: "Text", extensions: ["txt"] }],
- multiple: false,
- });
- if (!selected || typeof selected !== "string") return;
- try {
- const urls = await invoke<string[]>("parse_batch_file", { path: selected });
- if (urls.length === 0) {
- showToast("info", $t("omnibox.batch_file_empty"));
- return;
- }
- if (urls.length === 1) {
- url = urls[0];
- handleInput();
- return;
- }
- url = urls.join("\n");
- omniState = { kind: "batch", urls };
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
- showToast("error", msg);
- }
- }
-
- function handleHomeModeChange(mode: HomeInputMode) {
- // batch/torrent/p2p are momentary actions, not persistent input modes:
- // return to "url" so the tab bar never strands on an empty state when
- // the picker/dialog is cancelled
- if (mode === "p2p") {
- showP2pSendDialog = true;
- homeInputMode = "url";
- } else if (mode === "torrent") {
- void openTorrentFile().finally(() => {
- homeInputMode = "url";
- });
- } else if (mode === "batch") {
- void openBatchFile().finally(() => {
- homeInputMode = "url";
- });
- }
- }
-
- function handleDismiss() {
- clearMediaPreview();
- omniState = { kind: "idle" };
- url = "";
- }
-</script>
-
-<div class="home-mac">
- {#if STUDY_MAINTENANCE_NOTICE && !studyNoticeDismissed}
- <div class="study-maintenance-banner" role="status">
- <div class="study-maintenance-text">
- <strong>{$t("study.maintenance.home_banner_title")}</strong>
- <span>{$t("study.maintenance.home_banner_body")}</span>
- </div>
- <button
- type="button"
- class="study-maintenance-dismiss"
- onclick={dismissStudyNotice}
- aria-label={$t('common.close')}
- >
- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- </div>
- {/if}
-
- <div class="home-mac-workspace">
- <div class="home-mac-hero">
- <HomeHero
- emotion={mascotEmotion}
- compact={mascotCompact}
- bubbleText={bubbleText || undefined}
- celebrate={mascotEmotion === "amazed"}
- />
- </div>
- <div class="home-mac-main">
- <div class="mode-toggle-row">
- <button
- type="button"
- class="mode-toggle-btn"
- class:active={!advancedMode}
- onclick={() => { advancedMode = false; }}
- >
- {$t('omnibox.mode_normal')}
- </button>
- <button
- type="button"
- class="mode-toggle-btn"
- class:active={advancedMode}
- onclick={() => { advancedMode = true; }}
- >
- {$t('omnibox.mode_advanced')}
- </button>
- </div>
-
- {#if advancedMode}
- <OmniboxAdvanced />
- {:else}
- {#if externalNotice}
- <div class="feedback-card feedback-enter external-url-card">
- <div class="card-row">
- <svg class="card-status-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M12 5v14" />
- <path d="M5 12h14" />
- </svg>
- <span class="card-title">{$t('omnibox.external_url_ready')}</span>
- <button class="dismiss-btn" onclick={() => { externalNotice = null; }} aria-label={$t('common.close')}>
- <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- </div>
- <div class="card-row">
- <span class="card-subtext external-url-text">{externalNotice.url}</span>
- </div>
- </div>
- {/if}
-
- {#if showLoopIcon}
- <img
- src="/loop.png"
- alt=""
- width="40"
- height="40"
- class="loop-icon"
- class:loop-bounce={omniState.kind === "detected" || omniState.kind === "batch"}
- class:loop-pulse={omniState.kind === "preparing"}
- />
- {/if}
-
- {#if omniState.kind === "detecting"}
- <div class="feedback feedback-enter">
- <span class="feedback-spinner"></span>
- </div>
-
- {:else if omniState.kind === "detected"}
- <div class="feedback feedback-enter" data-supported="true">
- <span class="feedback-text">
- {platformDisplayName(omniState.info.platform)}
- {#if omniState.info.content_type}
- <span class="feedback-sep">&middot;</span>
- {getContentTypeLabel(omniState.info.content_type)}
- {/if}
- </span>
- </div>
- {/if}
-
- {#if showOmnibox}
- <HomeUrlBar bind:url bind:mode={homeInputMode} onInput={handleInput} onModeChange={handleHomeModeChange} />
- {/if}
-
- {#if omniState.kind === "batch"}
- <div class="batch-options">
- <DownloadModeSelector bind:downloadMode />
- <BatchDownload count={omniState.urls.length} onDownload={handleBatchDownload} />
- </div>
-
- {:else if omniState.kind === "searching"}
- <div class="feedback feedback-enter">
- <span class="feedback-spinner"></span>
- <span class="feedback-text search-hint">{$t('omnibox.searching')}</span>
- </div>
-
- {:else if omniState.kind === "search-results"}
- <SearchResults results={omniState.results} onSelect={selectSearchResult} />
-
- {:else if omniState.kind === "search-empty"}
- <div class="feedback feedback-enter" data-supported="false">
- <svg class="feedback-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="11" cy="11" r="8" />
- <path d="M21 21l-4.35-4.35" />
- </svg>
- <span class="feedback-text">{$t('omnibox.search_empty')}</span>
- </div>
-
- {:else if omniState.kind === "unsupported"}
- <div class="feedback feedback-enter" data-supported="false">
- <svg class="feedback-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="12" cy="12" r="10" />
- <path d="M12 8v4m0 4h.01" />
- </svg>
- <span class="feedback-text">{$t('omnibox.unsupported')}</span>
- </div>
- {/if}
- {/if}
-
- {#if omniState.kind === "idle"}
- <SupportedServices />
- {/if}
- </div>
-
- <HomeInspector open={showInspector} title={$t('home.inspector_title')}>
- {#if omniState.kind === "detected"}
- <MediaPreview bind:mediaPreview bind:imageLoading={previewImageLoading} />
- {#if omniState.info.content_type === "playlist"}
- <div class="playlist-picker">
- <div class="playlist-head">
- <span class="playlist-count">
- {$t('omnibox.playlist_selected', { selected: selectedPlaylistItems.size, total: playlistEntries.length })}
- </span>
- {#if !playlistLoading && playlistEntries.length > 0}
- <div class="playlist-bulk">
- <button type="button" class="playlist-link" onclick={selectAllPlaylist}>{$t('omnibox.playlist_all')}</button>
- <button type="button" class="playlist-link" onclick={selectNonePlaylist}>{$t('omnibox.playlist_none')}</button>
- </div>
- {/if}
- </div>
- {#if playlistLoading}
- <div class="playlist-status"><span class="feedback-spinner"></span> {$t('omnibox.playlist_loading')}</div>
- {:else if playlistEntries.length === 0}
- <span class="playlist-status">{$t('omnibox.playlist_empty')}</span>
- {:else}
- <ul class="playlist-list">
- {#each playlistEntries as entry (entry.index)}
- <li>
- <label class="playlist-item">
- <input type="checkbox" checked={selectedPlaylistItems.has(entry.index)} onchange={() => togglePlaylistItem(entry.index)} />
- <span class="playlist-idx">{entry.index}.</span>
- <span class="playlist-title">{entry.title}</span>
- </label>
- </li>
- {/each}
- </ul>
- {/if}
- </div>
- {/if}
- {#if torrentLoading || torrentEntries.length > 0}
- <div class="playlist-picker">
- <div class="playlist-head">
- <span class="playlist-count">
- {$t('omnibox.torrent_selected', { selected: selectedTorrentFiles.size, total: torrentEntries.length })}
- </span>
- {#if !torrentLoading && torrentEntries.length > 0}
- <div class="playlist-bulk">
- <button type="button" class="playlist-link" onclick={selectAllTorrent}>{$t('omnibox.playlist_all')}</button>
- <button type="button" class="playlist-link" onclick={selectNoneTorrent}>{$t('omnibox.playlist_none')}</button>
- </div>
- {/if}
- </div>
- {#if torrentLoading}
- <div class="playlist-status"><span class="feedback-spinner"></span> {$t('omnibox.torrent_loading')}</div>
- {:else}
- <ul class="playlist-list">
- {#each torrentEntries as entry (entry.index)}
- <li>
- <label class="playlist-item">
- <input type="checkbox" checked={selectedTorrentFiles.has(entry.index)} onchange={() => toggleTorrentFile(entry.index)} />
- <span class="playlist-title">{entry.path}</span>
- <span class="torrent-size">{formatBytes(entry.size_bytes)}</span>
- </label>
- </li>
- {/each}
- </ul>
- {/if}
- </div>
- {/if}
- {#if cookieHint}
- <p class="cookie-hint" class:expired={cookieHint === "expired"} role="status">
- <span>{cookieHint === "expired" ? $t("omnibox.cookie_hint_expired") : $t("omnibox.cookie_hint_stale")}</span>
- <button type="button" class="cookie-hint-link" onclick={() => goto("/settings?tab=cookies")}>{$t("omnibox.cookie_hint_action")}</button>
- </p>
- {/if}
- {#if COURSE_PLATFORMS.has(omniState.info.platform)}
- <button class="button action-btn" onclick={handleAction}>{$t(omniState.info.platform === "udemy" ? 'omnibox.go_to_udemy' : 'omnibox.go_to_hotmart')}</button>
- {:else}
- {@const playlistBlocked = omniState.info.content_type === "playlist" && playlistEntries.length > 0 && selectedPlaylistItems.size === 0}
- {@const torrentBlocked = torrentEntries.length > 0 && selectedTorrentFiles.size === 0}
- {#if omniState.info.platform === "bilibili"}
- <BilibiliPreviewExtras {url} accountSlug={selectedCookieSlug && selectedCookieSlug !== "_anonymous" ? selectedCookieSlug : null} />
- {/if}
- <button class="download-primary-btn" disabled={playlistBlocked || torrentBlocked} onclick={handleAction}>{$t('omnibox.download')}</button>
- {#if omniState.info.platform !== "direct_file"}
- <details class="options-panel">
- <summary class="options-toggle">{$t('omnibox.options')}</summary>
- <div class="options-content">
- <DownloadModeSelector bind:downloadMode onChange={() => { selectedFormatId = null; }} />
- <QualityPicker bind:selectedQuality selectedFormatId />
- {#if cookieAccounts.length > 1}
- <CookieAccountPicker accounts={cookieAccounts} bind:selectedSlug={selectedCookieSlug} />
- {/if}
- <details class="options-panel">
- <summary class="options-toggle">{$t('omnibox.advanced')}</summary>
- <div class="options-content">
- {#if omniState.info.platform === "vimeo" || omniState.info.platform === "generic"}
- <div class="referer-input-wrapper">
- <label class="referer-label" for="referer-input">{$t('omnibox.referer_label')}</label>
- <input id="referer-input" class="referer-input" type="text" placeholder={$t('omnibox.referer_placeholder')} bind:value={referer} spellcheck="false" />
- </div>
- {/if}
- {#if omniState.info.content_type !== "playlist"}
- <div class="timerange-wrapper">
- <span class="timerange-label">{$t('omnibox.timerange_label')}</span>
- <div class="timerange-inputs">
- <input class="timerange-input" type="text" placeholder={$t('omnibox.timerange_start')} bind:value={clipStart} spellcheck="false" inputmode="numeric" aria-label={$t('omnibox.timerange_start') as string} />
- <span class="timerange-sep" aria-hidden="true">—</span>
- <input class="timerange-input" type="text" placeholder={$t('omnibox.timerange_end')} bind:value={clipEnd} spellcheck="false" inputmode="numeric" aria-label={$t('omnibox.timerange_end') as string} />
- </div>
- <span class="timerange-hint">{$t('omnibox.timerange_hint')}</span>
- </div>
- {/if}
- <div class="timerange-wrapper">
- <span class="timerange-label">{$t('omnibox.schedule_label')}</span>
- <div class="schedule-presets">
- <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('1h')}>{$t('omnibox.schedule_1h')}</button>
- <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('tonight')}>{$t('omnibox.schedule_tonight')}</button>
- <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('1d')}>{$t('omnibox.schedule_1d')}</button>
- {#if scheduleAt || scheduleStop}
- <button type="button" class="schedule-preset" onclick={() => { scheduleAt = ""; scheduleStop = ""; }}>{$t('omnibox.schedule_clear')}</button>
- {/if}
- </div>
- <div class="timerange-inputs schedule-row">
- <input class="timerange-input schedule-date" type="date" value={schedulePart(scheduleAt, "date")} oninput={(e) => { scheduleAt = withSchedulePart(scheduleAt, "date", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_start') as string} />
- <input class="timerange-input schedule-time" type="time" step="60" value={schedulePart(scheduleAt, "time")} oninput={(e) => { scheduleAt = withSchedulePart(scheduleAt, "time", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_start') as string} />
- <span class="timerange-sep" aria-hidden="true">—</span>
- <input class="timerange-input schedule-date" type="date" value={schedulePart(scheduleStop, "date")} oninput={(e) => { scheduleStop = withSchedulePart(scheduleStop, "date", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_stop') as string} />
- <input class="timerange-input schedule-time" type="time" step="60" value={schedulePart(scheduleStop, "time")} oninput={(e) => { scheduleStop = withSchedulePart(scheduleStop, "time", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_stop') as string} />
- </div>
- <span class="timerange-hint">{$t('omnibox.schedule_hint')}</span>
- </div>
- <FormatSelector
- platform={omniState.info.platform}
- isPlaylist={omniState.info.content_type === "playlist"}
- bind:formats
- bind:selectedFormatId
- {loadingFormats}
- {formatError}
- onLoadFormats={loadFormats}
- onSelectFormat={selectFormat}
- onClearFormat={clearFormatSelection}
- onPresetBest={presetBest}
- onPresetMusic={presetMusic}
- />
- </div>
- </details>
- </div>
- </details>
- {/if}
- {/if}
- {:else if omniState.kind === "preparing"}
- <div class="feedback-card feedback-enter">
- <div class="card-row">
- <span class="feedback-spinner"></span>
- <span class="card-text">{$t('omnibox.preparing')}</span>
- </div>
- </div>
- {:else if omniState.kind === "error"}
- <div class="feedback-card feedback-enter" data-status="error">
- <div class="card-row">
- <span class="card-title card-error-text">{omniState.message}</span>
- </div>
- <div class="card-row card-actions">
- <button class="button card-action-btn" onclick={handleRetry}>{$t('omnibox.retry')}</button>
- </div>
- </div>
- {/if}
- </HomeInspector>
- </div>
-
- {#if showP2pSendDialog}
- <P2pSendDialog onClose={() => { showP2pSendDialog = false; }} />
- {/if}
-
- {#if p2pReceiveCode}
- <P2pReceiveDialog
- code={p2pReceiveCode}
- onAccept={handleP2pAccept}
- onReject={handleP2pReject}
- />
- {/if}
-
- <div class="terms-note">
- {$t('terms_note.agreement')}
- <a href="/about/terms" class="terms-link">{$t('terms_note.link')}</a>
- </div>
-</div>
-
-<style>
- .home-mac {
- width: 100%;
- }
-
- .study-maintenance-banner {
- display: flex;
- align-items: center;
- gap: var(--space-2);
- width: 100%;
- max-width: 640px;
- padding: 8px 12px;
- background: color-mix(in oklab, var(--secondary) 8%, transparent);
- border: 1px solid color-mix(in oklab, var(--secondary) 18%, transparent);
- border-radius: var(--border-radius);
- color: var(--secondary);
- font-size: 12px;
- line-height: 1.4;
- }
-
- .study-maintenance-text {
- display: flex;
- flex-direction: column;
- gap: 1px;
- flex: 1;
- min-width: 0;
- }
-
- .study-maintenance-text strong {
- font-weight: 500;
- font-size: var(--text-sm);
- color: var(--text);
- }
-
- .study-maintenance-text span {
- color: var(--secondary);
- font-size: 11.5px;
- }
-
- .study-maintenance-dismiss {
- background: transparent;
- border: none;
- padding: 4px;
- margin: -4px;
- border-radius: 4px;
- color: var(--secondary);
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- opacity: 0.55;
- transition: opacity 0.15s ease, background 0.15s ease;
- }
-
- .study-maintenance-dismiss:hover {
- opacity: 1;
- background: color-mix(in oklab, var(--text) 6%, transparent);
- }
-
- .omnibox-area {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: var(--space-3);
- width: 100%;
- max-width: 640px;
- }
-
- .mode-toggle-row {
- display: inline-flex;
- background: var(--fill-1);
- border-radius: var(--radius-md);
- padding: 2px;
- gap: 2px;
- margin-bottom: 4px;
- }
- .mode-toggle-btn {
- padding: 4px 12px;
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--text-muted);
- background: transparent;
- border: none;
- border-radius: calc(var(--radius-md) - 2px);
- cursor: pointer;
- transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
- }
- .mode-toggle-btn.active {
- background: var(--surface-hi);
- color: var(--text);
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
- }
- .mode-toggle-btn:not(.active):hover {
- color: var(--text);
- }
- .mode-toggle-btn:focus-visible {
- outline: var(--focus-ring);
- outline-offset: -1px;
- }
-
- .loop-icon {
- pointer-events: none;
- border-radius: 10px;
- user-select: none;
- }
-
- .loop-bounce {
- animation: loopBounce 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
- }
-
- @keyframes loopBounce {
- 0% {
- opacity: 0;
- transform: scale(0.6) translateY(6px);
- }
- 60% {
- opacity: 1;
- transform: scale(1.08) translateY(-2px);
- }
- 100% {
- transform: scale(1) translateY(0);
- }
- }
-
- .loop-pulse {
- animation: loopPulse 1.8s ease-in-out infinite;
- }
-
- @keyframes loopPulse {
- 0%, 100% {
- opacity: 1;
- transform: scale(1);
- }
- 50% {
- opacity: 0.7;
- transform: scale(0.95);
- }
- }
-
- .batch-options {
- display: flex;
- flex-direction: column;
- gap: var(--padding);
- }
-
- .feedback {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 2);
- }
-
- .feedback-icon {
- flex-shrink: 0;
- pointer-events: none;
- }
-
- .feedback[data-supported="true"] {
- color: var(--green);
- }
-
- .feedback[data-supported="false"] {
- color: var(--gray);
- }
-
- .feedback-text {
- font-size: var(--text-sm);
- font-weight: 500;
- }
-
- .feedback-sep {
- opacity: 0.5;
- margin: 0 2px;
- }
-
- .feedback-spinner {
- width: 16px;
- height: 16px;
- border: 2px solid var(--input-border);
- border-top-color: var(--secondary);
- border-radius: 50%;
- animation: spin 0.8s linear infinite;
- }
-
- @keyframes spin {
- to {
- transform: rotate(360deg);
- }
- }
-
- .feedback-enter {
- animation: feedbackEnter 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
- }
-
- @keyframes feedbackEnter {
- from {
- opacity: 0;
- transform: scale(0.9);
- }
- to {
- opacity: 1;
- transform: scale(1);
- }
- }
-
- .download-primary-btn {
- background: var(--cta);
- color: var(--on-cta);
- font-size: 15px;
- font-weight: 500;
- padding: 12px 32px;
- border-radius: var(--border-radius);
- border: none;
- cursor: pointer;
- width: 100%;
- max-width: 300px;
- transition: background 150ms;
- }
-
- @media (hover: hover) {
- .download-primary-btn:hover {
- background: var(--cta-hover);
- }
- }
-
- .download-primary-btn:active {
- background: var(--cta-press);
- }
-
- .download-primary-btn:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .download-primary-btn:disabled {
- opacity: 0.5;
- cursor: not-allowed;
- }
-
- .playlist-picker {
- width: 100%;
- display: flex;
- flex-direction: column;
- gap: 8px;
- padding: 10px 12px;
- background: var(--button);
- border: 1px solid var(--input-border);
- border-radius: var(--border-radius);
- }
-
- .playlist-head {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 8px;
- }
-
- .playlist-count {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--secondary);
- }
-
- .playlist-bulk {
- display: flex;
- gap: 10px;
- }
-
- .playlist-link {
- background: none;
- border: none;
- padding: 0;
- font: inherit;
- font-size: 12px;
- color: var(--accent);
- cursor: pointer;
- }
-
- .playlist-link:hover {
- text-decoration: underline;
- }
-
- .playlist-status {
- display: flex;
- align-items: center;
- gap: 6px;
- font-size: var(--text-sm);
- color: var(--gray);
- }
-
- .playlist-list {
- list-style: none;
- margin: 0;
- padding: 0;
- max-height: 220px;
- overflow-y: auto;
- display: flex;
- flex-direction: column;
- gap: 2px;
- }
-
- .playlist-item {
- display: flex;
- align-items: center;
- gap: 8px;
- padding: 5px 4px;
- border-radius: calc(var(--border-radius) - 3px);
- cursor: pointer;
- font-size: 13px;
- color: var(--secondary);
- }
-
- .playlist-item:hover {
- background: var(--button-elevated);
- }
-
- .playlist-idx {
- color: var(--gray);
- font-variant-numeric: tabular-nums;
- flex-shrink: 0;
- }
-
- .playlist-title {
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .torrent-size {
- margin-left: auto;
- flex-shrink: 0;
- padding-left: 8px;
- color: var(--gray);
- font-variant-numeric: tabular-nums;
- }
-
- .options-panel {
- width: 100%;
- }
-
- .options-toggle {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- cursor: pointer;
- list-style: none;
- text-align: center;
- padding: 4px 0;
- user-select: none;
- }
-
- .options-toggle::-webkit-details-marker {
- display: none;
- }
-
- .options-toggle::marker {
- content: "";
- }
-
- @media (hover: hover) {
- .options-toggle:hover {
- color: var(--secondary);
- }
- }
-
- .options-content {
- display: flex;
- flex-direction: column;
- gap: var(--padding);
- padding-top: var(--padding);
- width: 100%;
- }
-
- .referer-input-wrapper {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
-
- .referer-label {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- }
-
- .referer-input {
- padding: 6px var(--padding);
- font-size: 13px;
- background: var(--button);
- border: 1px solid var(--input-border);
- border-radius: calc(var(--border-radius) - 2px);
- color: var(--secondary);
- }
-
- .referer-input::placeholder {
- color: var(--gray);
- }
-
- .referer-input:focus-visible {
- border-color: var(--secondary);
- outline: none;
- }
-
- .timerange-wrapper {
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
-
- .timerange-label {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- }
-
- .timerange-inputs {
- display: flex;
- align-items: center;
- gap: 8px;
- }
-
- .timerange-input {
- width: 96px;
- padding: 6px var(--padding);
- font-size: 13px;
- background: var(--button);
- border: 1px solid var(--input-border);
- border-radius: calc(var(--border-radius) - 2px);
- color: var(--secondary);
- text-align: center;
- }
-
- .timerange-input::placeholder {
- color: var(--gray);
- }
-
- .timerange-input:focus-visible {
- border-color: var(--secondary);
- outline: none;
- }
-
- .timerange-sep {
- color: var(--gray);
- }
-
- .timerange-hint {
- font-size: 11.5px;
- color: var(--gray);
- }
-
- .schedule-presets {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- margin-bottom: 6px;
- }
-
- .schedule-preset {
- padding: 4px 10px;
- font-size: 12px;
- background: var(--button);
- border: 1px solid var(--input-border);
- border-radius: calc(var(--border-radius) - 2px);
- color: var(--text);
- cursor: pointer;
- }
-
- .schedule-preset:hover {
- background: var(--button-elevated);
- }
-
- .schedule-row {
- flex-wrap: wrap;
- }
-
- .schedule-date {
- width: auto;
- flex: 1 1 auto;
- min-width: 8.6em;
- }
-
- .schedule-time {
- width: auto;
- flex: 0 1 auto;
- min-width: 5.4em;
- }
-
- .cookie-hint {
- display: flex;
- align-items: center;
- gap: 6px;
- margin: 0;
- font-size: 12px;
- color: #f4a72b;
- }
- .cookie-hint.expired {
- color: #e0564f;
- }
- .cookie-hint svg {
- flex-shrink: 0;
- }
- .cookie-hint-link {
- background: none;
- border: 0;
- padding: 0;
- font: inherit;
- font-size: 12px;
- color: var(--accent);
- cursor: pointer;
- text-decoration: underline;
- text-underline-offset: 2px;
- }
- .cookie-hint-link:hover {
- filter: brightness(1.15);
- }
-
- .action-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 6px;
- padding: var(--padding) calc(var(--padding) * 2);
- font-size: var(--text-base);
- font-weight: 500;
- background: var(--button);
- border: none;
- border-radius: var(--border-radius);
- color: var(--button-text);
- cursor: pointer;
- box-shadow: var(--button-box-shadow);
- }
-
- @media (hover: hover) {
- .action-btn:hover {
- background: var(--button-hover);
- }
- }
-
- .action-btn:active {
- background: var(--button-press);
- }
-
- .action-btn:disabled {
- cursor: default;
- }
-
- .feedback-card {
- display: flex;
- flex-direction: column;
- gap: var(--padding);
- padding: var(--padding) calc(var(--padding) * 1.5);
- background: var(--button-elevated);
- border-radius: var(--border-radius);
- border-left: 3px solid var(--blue);
- }
-
- .feedback-card[data-status="error"] {
- border-left-color: var(--red);
- }
-
- .external-url-card {
- width: 100%;
- border-left-color: var(--accent);
- }
-
- .card-row {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 2);
- }
-
- .card-text {
- font-size: 13px;
- font-weight: 500;
- color: var(--secondary);
- }
-
- .card-title {
- font-size: 13px;
- font-weight: 500;
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .card-error-text {
- color: var(--secondary);
- }
-
- .card-status-icon {
- flex-shrink: 0;
- pointer-events: none;
- color: var(--blue);
- }
-
- .card-status-icon.error {
- color: var(--red);
- }
-
- .card-actions {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--padding);
- }
-
- .card-subtext {
- font-size: 11.5px;
- font-weight: 500;
- color: var(--gray);
- }
-
- .external-url-text {
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .card-action-btn {
- padding: 6px 12px;
- font-size: 13px;
- }
-
- .dismiss-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 24px;
- height: 24px;
- background: transparent;
- border: none;
- cursor: pointer;
- color: var(--secondary);
- padding: 0;
- }
-
- .search-hint {
- color: var(--gray);
- }
-
- .quick-actions {
- display: flex;
- gap: var(--space-2);
- margin-bottom: var(--space-3);
- }
-
- .quick-action-btn {
- display: flex;
- align-items: center;
- gap: var(--space-2);
- padding: var(--space-2) var(--space-4);
- font-size: var(--text-sm);
- border: 1px solid var(--border);
- border-radius: var(--radius-sm);
- background: var(--surface);
- color: var(--text);
- cursor: pointer;
- transition: background var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
- }
-
- @media (hover: hover) {
- .quick-action-btn:hover {
- background: var(--surface-hi);
- transform: translateY(-1px);
- }
- }
-
- .quick-action-btn:active {
- transform: scale(0.98);
- background: var(--surface-hi);
- }
-
- .quick-action-btn svg {
- opacity: 0.7;
- flex-shrink: 0;
- }
-
- @media (prefers-reduced-motion: reduce) {
- .quick-action-btn {
- transition: none;
- }
- .quick-action-btn:hover,
- .quick-action-btn:active {
- transform: none;
- }
- }
-
- .terms-note {
- flex-shrink: 0;
- font-size: 9px;
- color: var(--gray);
- text-align: left;
- opacity: 0.35;
- padding: 0 var(--space-1);
- }
-
- .terms-link {
- color: var(--blue);
- text-decoration: none;
- }
-
- @media (hover: hover) {
- .terms-link:hover {
- text-decoration: underline;
- }
- }
-
- @media (prefers-reduced-motion: reduce) {
- .feedback-enter {
- animation: none;
- }
-
- .feedback-spinner {
- animation-duration: 1.5s;
- }
-
- .loop-bounce {
- animation: none;
- }
-
- .loop-pulse {
- animation: none;
- }
- }
-</style>
+<script lang="ts">
+ import { invoke } from "@tauri-apps/api/core";
+ import { open } from "@tauri-apps/plugin-dialog";
+ import { goto } from "$app/navigation";
+ import { onMount } from "svelte";
+ import SupportedServices from "$components/services/SupportedServices.svelte";
+ import BilibiliPreviewExtras from "$components/omnibox/BilibiliPreviewExtras.svelte";
+ import DownloadModeSelector from "$components/omnibox/DownloadModeSelector.svelte";
+ import QualityPicker from "$components/omnibox/QualityPicker.svelte";
+ import FormatSelector from "$components/omnibox/FormatSelector.svelte";
+ import CookieAccountPicker from "$components/omnibox/CookieAccountPicker.svelte";
+ import OmniboxAdvanced from "$components/omnibox/OmniboxAdvanced.svelte";
+ import MediaPreview from "$components/omnibox/MediaPreview.svelte";
+ import BatchDownload from "$components/omnibox/BatchDownload.svelte";
+ import SearchResults from "$components/omnibox/SearchResults.svelte";
+ import P2pSendDialog from "$components/p2p/P2pSendDialog.svelte";
+ import P2pReceiveDialog from "$components/p2p/P2pReceiveDialog.svelte";
+ import HomeHero from "$components/home/HomeHero.svelte";
+ import HomeUrlBar from "$components/home/HomeUrlBar.svelte";
+ import HomeInspector from "$components/home/HomeInspector.svelte";
+ import {
+ type OmniState,
+ type PlatformInfo,
+ type SearchResult,
+ type HomeInputMode,
+ showInspectorForState,
+ showOmniboxForState,
+ isUrl,
+ } from "$lib/home/omnibox-controller";
+ import { getDownloads, formatBytes } from "$lib/stores/download-store.svelte";
+ import { getSettings, updateSettings } from "$lib/stores/settings-store.svelte";
+ import { showToast } from "$lib/stores/toast-store.svelte";
+ import { onClipboardUrl } from "$lib/stores/clipboard-monitor";
+ import { getMediaPreview, clearMediaPreview } from "$lib/stores/media-preview-store.svelte";
+ import { clearPendingExternalPrefill, getPendingExternalPrefill, type ExternalUrlEvent } from "$lib/stores/external-url-store.svelte";
+ import { getOmniboxDraftUrl, setOmniboxDraftUrl } from "$lib/stores/omnibox-draft-store.svelte";
+ import { t } from "$lib/i18n";
+ import { translateBackendError } from "$lib/error-translate";
+ import { platformDisplayName } from "$lib/platform-display-names";
+ import { STUDY_MAINTENANCE_NOTICE } from "$lib/study-feature-flags";
+
+ type DownloadStarted = {
+ id: number;
+ title: string;
+ };
+
+ type FormatInfo = {
+ format_id: string;
+ ext: string;
+ resolution: string | null;
+ width: number | null;
+ height: number | null;
+ fps: number | null;
+ vcodec: string | null;
+ acodec: string | null;
+ filesize: number | null;
+ tbr: number | null;
+ has_video: boolean;
+ has_audio: boolean;
+ format_note: string | null;
+ };
+
+ // Platforms whose content is downloaded via the Courses page (courses
+ // plugin + logged-in account), not from a pasted URL.
+ const COURSE_PLATFORMS = new Set(["hotmart", "udemy"]);
+
+ let url = $state(getOmniboxDraftUrl());
+ let homeInputMode = $state<HomeInputMode>("url");
+ let omniState = $state<OmniState>({ kind: "idle" });
+ let debounceTimer = $state<ReturnType<typeof setTimeout> | null>(null);
+ let downloadMode = $state<"auto" | "audio" | "mute">("auto");
+ let selectedQuality = $state("best");
+ let clipStart = $state("");
+ let clipEnd = $state("");
+ let scheduleAt = $state("");
+ let scheduleStop = $state("");
+ let playlistEntries = $state<{ index: number; title: string; url: string }[]>([]);
+ let selectedPlaylistItems = $state<Set<number>>(new Set());
+ let playlistLoading = $state(false);
+ let torrentEntries = $state<{ index: number; path: string; size_bytes: number }[]>([]);
+ let selectedTorrentFiles = $state<Set<number>>(new Set());
+ let torrentLoading = $state(false);
+ let selectedFormatId = $state<string | null>(null);
+ let formats = $state<FormatInfo[]>([]);
+ let loadingFormats = $state(false);
+ let formatError = $state<string | null>(null);
+ let formatFetchGeneration = $state(0);
+ let referer = $state("");
+
+ type CookieAccount = {
+ slug: string;
+ alias: string;
+ captured_at_ms: number;
+ cookie_count: number;
+ last_used_at_ms: number | null;
+ };
+ let cookieAccounts = $state<CookieAccount[]>([]);
+ let selectedCookieSlug = $state<string | null>(null);
+ let cookieHint = $state<"stale" | "expired" | null>(null);
+ let advancedMode = $state(false);
+ const STUDY_NOTICE_DISMISS_KEY = "omniget.study_maintenance_notice_dismissed_v1";
+ let studyNoticeDismissed = $state(
+ typeof localStorage !== "undefined"
+ && localStorage.getItem(STUDY_NOTICE_DISMISS_KEY) === "1"
+ );
+ function dismissStudyNotice() {
+ studyNoticeDismissed = true;
+ try { localStorage.setItem(STUDY_NOTICE_DISMISS_KEY, "1"); } catch {}
+ }
+ let mediaPreview = $derived(getMediaPreview());
+ let pendingExternalPrefill = $derived(getPendingExternalPrefill());
+ let previewImageLoading = $state(true);
+ let showP2pSendDialog = $state(false);
+ let p2pReceiveCode = $state<string | null>(null);
+ let p2pReceiveUrl = $state("");
+ let externalNotice = $state<ExternalUrlEvent | null>(null);
+ let lastExternalPrefillId = $state<number | null>(null);
+ let pendingAutoDownload = $state(false);
+
+ onMount(() => {
+ onClipboardUrl((detectedUrl) => {
+ if (omniState.kind === "preparing") return;
+ url = detectedUrl;
+ const settings = getSettings();
+ const autoDownload = !!(settings?.download.auto_download_on_paste && settings?.download.clipboard_detection);
+ pendingAutoDownload = autoDownload;
+ handleInput();
+ showToast("info", $t(autoDownload ? "toast.auto_download_started" : "toast.clipboard_url_detected"));
+ });
+ if (url.trim()) {
+ queueMicrotask(() => handleInput());
+ }
+ return () => {
+ onClipboardUrl(null);
+ };
+ });
+
+ $effect(() => {
+ setOmniboxDraftUrl(url);
+ });
+
+ const AUTO_DOWNLOAD_DELAY_MS = 2000;
+
+ $effect(() => {
+ if (!pendingAutoDownload) return;
+ if (omniState.kind === "detected") {
+ const info = omniState.info;
+ if (COURSE_PLATFORMS.has(info.platform) || info.platform === "p2p") {
+ pendingAutoDownload = false;
+ return;
+ }
+ pendingAutoDownload = false;
+ const snapshotUrl = url;
+ setTimeout(() => {
+ if (url === snapshotUrl && omniState.kind === "detected") {
+ handleAction();
+ }
+ }, AUTO_DOWNLOAD_DELAY_MS);
+ } else if (
+ omniState.kind === "unsupported" ||
+ omniState.kind === "error" ||
+ omniState.kind === "batch" ||
+ omniState.kind === "search-results" ||
+ omniState.kind === "search-empty" ||
+ omniState.kind === "idle"
+ ) {
+ pendingAutoDownload = false;
+ }
+ });
+
+ const STALL_THRESHOLD = 30_000;
+ let downloads = $derived(getDownloads());
+ let stallTick = $state(0);
+ let lastCompletionAt = $state(0);
+ let firstCompletionOfSession = $state(false);
+ let completionSeenIds = new Set<string | number>();
+
+ $effect(() => {
+ for (const [id, item] of downloads.entries()) {
+ if (item.status === "complete" && !completionSeenIds.has(id)) {
+ completionSeenIds.add(id);
+ lastCompletionAt = Date.now();
+ if (!firstCompletionOfSession) {
+ firstCompletionOfSession = true;
+ }
+ break;
+ }
+ }
+ });
+
+ $effect(() => {
+ const interval = setInterval(() => { stallTick++; }, 5000);
+ return () => clearInterval(interval);
+ });
+
+
+ $effect(() => {
+ if (mediaPreview) {
+ previewImageLoading = true;
+ }
+ });
+
+ $effect(() => {
+ const incoming = pendingExternalPrefill;
+ if (!incoming || incoming.id === lastExternalPrefillId) {
+ return;
+ }
+
+ lastExternalPrefillId = incoming.id;
+ clearPendingExternalPrefill(incoming.id);
+ externalNotice = incoming;
+
+ if (incoming.action !== "prefill") {
+ return;
+ }
+
+ url = incoming.url;
+ if (getSettings()?.download.auto_download_on_paste) {
+ pendingAutoDownload = true;
+ }
+ handleInput();
+ });
+
+ let mascotEmotion = $derived.by((): "idle" | "downloading" | "error" | "stalled" | "queue" | "complete" | "amazed" => {
+ void stallTick;
+
+ if (lastCompletionAt > 0 && Date.now() - lastCompletionAt < 5000) {
+ return firstCompletionOfSession && completionSeenIds.size === 1 ? "amazed" : "complete";
+ }
+
+ if (omniState.kind === "preparing") return "downloading";
+ if (omniState.kind === "error") return "error";
+
+ let hasActiveDownloading = false;
+ let hasActiveStalled = false;
+ let hasItems = false;
+ for (const item of downloads.values()) {
+ hasItems = true;
+ if (item.status === "downloading") {
+ hasActiveDownloading = true;
+ const elapsed = Date.now() - item.lastUpdateAt;
+ if (elapsed > STALL_THRESHOLD) {
+ hasActiveStalled = true;
+ }
+ }
+ }
+
+ if (hasActiveStalled) return "stalled";
+ if (hasActiveDownloading) return "downloading";
+ if (hasItems) return "queue";
+ return "idle";
+ });
+
+ let mascotCompact = $derived(omniState.kind !== "idle");
+
+ function pickRandom(raw: string): string {
+ if (raw.includes("|")) {
+ const opts = raw.split("|");
+ return opts[Math.floor(Math.random() * opts.length)];
+ }
+ return raw;
+ }
+
+ let lastBubbleKey = $state("");
+ let bubbleText = $state("");
+
+ $effect(() => {
+ let key: string;
+ if (mascotEmotion === "amazed") key = "amazed";
+ else if (mascotEmotion === "complete") key = "complete";
+ else if (mascotEmotion === "queue") key = "queue";
+ else if (mascotEmotion === "downloading") key = "downloading";
+ else if (mascotEmotion === "stalled") key = "stalled";
+ else {
+ switch (omniState.kind) {
+ case "idle": key = "idle"; break;
+ case "detecting": key = "detecting"; break;
+ case "detected": key = "detected"; break;
+ case "preparing": key = "preparing"; break;
+ case "searching":
+ case "search-results": key = "search"; break;
+ case "error": key = "error"; break;
+ default: key = ""; break;
+ }
+ }
+ if (key && key !== lastBubbleKey) {
+ lastBubbleKey = key;
+ bubbleText = pickRandom($t(`mascot.${key}`));
+ } else if (!key) {
+ lastBubbleKey = "";
+ bubbleText = "";
+ }
+ });
+
+ let showLoopIcon = $derived(
+ omniState.kind === "detected" ||
+ omniState.kind === "preparing" ||
+ omniState.kind === "batch"
+ );
+
+ let showOmnibox = $derived(showOmniboxForState(omniState));
+ let showInspector = $derived(showInspectorForState(omniState));
+
+ function isValidTimeBound(v: string): boolean {
+ return /^(\d+:)?\d{1,2}:\d{1,2}(\.\d+)?$|^\d+(\.\d+)?$/.test(v.trim());
+ }
+
+ function buildTimeRange(): string | null {
+ const s = clipStart.trim();
+ const e = clipEnd.trim();
+ if (!s && !e) return null;
+ if (s && !isValidTimeBound(s)) return null;
+ if (e && !isValidTimeBound(e)) return null;
+ return `${s || "0"}-${e || "inf"}`;
+ }
+
+ function toEpochMs(v: string): number | null {
+ if (!v) return null;
+ const ms = new Date(v.includes("T") ? v : `${v}T00:00`).getTime();
+ if (Number.isNaN(ms)) return null;
+ return ms;
+ }
+
+ function schedulePart(v: string, part: "date" | "time"): string {
+ if (!v) return "";
+ const [date, time = ""] = v.split("T");
+ return part === "date" ? date : time;
+ }
+
+ function withSchedulePart(current: string, part: "date" | "time", value: string): string {
+ const pad = (n: number) => String(n).padStart(2, "0");
+ let [date, time = ""] = current ? current.split("T") : ["", ""];
+ if (part === "date") date = value;
+ else time = value;
+ if (!date && !time) return "";
+ if (!date) {
+ const now = new Date();
+ date = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
+ }
+ if (!time) time = "00:00";
+ return `${date}T${time}`;
+ }
+
+ function setSchedulePreset(kind: "1h" | "tonight" | "1d") {
+ const d = new Date();
+ if (kind === "1h") d.setHours(d.getHours() + 1);
+ else if (kind === "1d") d.setDate(d.getDate() + 1);
+ else {
+ d.setHours(22, 0, 0, 0);
+ if (d.getTime() < Date.now()) d.setDate(d.getDate() + 1);
+ }
+ const pad = (n: number) => String(n).padStart(2, "0");
+ scheduleAt = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}`;
+ }
+
+ function handleInput() {
+ if (debounceTimer) clearTimeout(debounceTimer);
+ clearMediaPreview();
+ clipStart = "";
+ clipEnd = "";
+ scheduleAt = "";
+ scheduleStop = "";
+ cookieHint = null;
+ playlistEntries = [];
+ selectedPlaylistItems = new Set();
+ playlistLoading = false;
+ torrentEntries = [];
+ selectedTorrentFiles = new Set();
+ torrentLoading = false;
+ const currentSettings = getSettings();
+ const saved = currentSettings?.last_download_options;
+ const savedMode = saved?.mode;
+ const settingsQuality = currentSettings?.download.video_quality;
+ selectedQuality = settingsQuality && typeof settingsQuality === "string"
+ ? settingsQuality
+ : "best";
+ downloadMode = savedMode === "audio" || savedMode === "mute" ? savedMode : "auto";
+ selectedFormatId = null;
+ formats = [];
+ loadingFormats = false;
+ formatError = null;
+ formatFetchGeneration++;
+ referer = "";
+
+ const trimmed = url.trim();
+ if (!trimmed) {
+ omniState = { kind: "idle" };
+ return;
+ }
+
+ const urls = trimmed.split(/[\s\n]+/).filter(isUrl);
+
+ if (urls.length > 1) {
+ omniState = { kind: "batch", urls };
+ return;
+ }
+
+ if (isUrl(trimmed)) {
+ omniState = { kind: "detecting" };
+ if (getSettings()?.download.auto_download_on_paste) {
+ pendingAutoDownload = true;
+ }
+ debounceTimer = setTimeout(() => {
+ detectPlatform(trimmed);
+ }, 500);
+ return;
+ }
+
+ if (trimmed.length >= 2) {
+ omniState = { kind: "searching" };
+ debounceTimer = setTimeout(() => {
+ performSearch(trimmed);
+ }, 600);
+ } else {
+ omniState = { kind: "idle" };
+ }
+ }
+
+ async function detectPlatform(value: string) {
+ try {
+ const result = await invoke<PlatformInfo>("detect_platform", { url: value });
+ if (result.supported) {
+ omniState = { kind: "detected", info: result };
+ if (!COURSE_PLATFORMS.has(result.platform)) {
+ invoke("prefetch_media_info", { url: value }).catch(() => {});
+ }
+ loadCookieAccounts(value);
+ if (result.content_type === "playlist") {
+ loadPlaylistEntries(value);
+ }
+ if (isTorrentUrl(value)) {
+ loadTorrentContents(value);
+ }
+ } else {
+ omniState = { kind: "unsupported" };
+ }
+ } catch {
+ omniState = { kind: "unsupported" };
+ }
+ }
+
+ async function loadPlaylistEntries(targetUrl: string) {
+ playlistEntries = [];
+ selectedPlaylistItems = new Set();
+ playlistLoading = true;
+ try {
+ const entries = await invoke<{ index: number; title: string; url: string }[]>(
+ "playlist_entries",
+ { url: targetUrl }
+ );
+ playlistEntries = entries;
+ selectedPlaylistItems = new Set(entries.map((e) => e.index));
+ } catch {
+ playlistEntries = [];
+ } finally {
+ playlistLoading = false;
+ }
+ }
+
+ function togglePlaylistItem(idx: number) {
+ const next = new Set(selectedPlaylistItems);
+ if (next.has(idx)) next.delete(idx);
+ else next.add(idx);
+ selectedPlaylistItems = next;
+ }
+
+ function selectAllPlaylist() {
+ selectedPlaylistItems = new Set(playlistEntries.map((e) => e.index));
+ }
+
+ function selectNonePlaylist() {
+ selectedPlaylistItems = new Set();
+ }
+
+ function isTorrentUrl(value: string): boolean {
+ const v = value.trim().toLowerCase();
+ return v.startsWith("magnet:") || v.endsWith(".torrent");
+ }
+
+ async function loadTorrentContents(targetUrl: string) {
+ torrentEntries = [];
+ selectedTorrentFiles = new Set();
+ torrentLoading = true;
+ try {
+ const entries = await invoke<{ index: number; path: string; size_bytes: number }[]>(
+ "torrent_contents",
+ { url: targetUrl }
+ );
+ torrentEntries = entries;
+ selectedTorrentFiles = new Set(entries.map((e) => e.index));
+ } catch {
+ torrentEntries = [];
+ } finally {
+ torrentLoading = false;
+ }
+ }
+
+ function toggleTorrentFile(idx: number) {
+ const next = new Set(selectedTorrentFiles);
+ if (next.has(idx)) next.delete(idx);
+ else next.add(idx);
+ selectedTorrentFiles = next;
+ }
+
+ function selectAllTorrent() {
+ selectedTorrentFiles = new Set(torrentEntries.map((e) => e.index));
+ }
+
+ function selectNoneTorrent() {
+ selectedTorrentFiles = new Set();
+ }
+
+ async function loadCookieAccounts(targetUrl: string) {
+ try {
+ const result = await invoke<{ domain: string; accounts: CookieAccount[] }>(
+ "cookies_accounts_for_url",
+ { url: targetUrl }
+ );
+ const accounts = result.accounts.slice().sort((a, b) => {
+ const lhs = a.last_used_at_ms ?? a.captured_at_ms;
+ const rhs = b.last_used_at_ms ?? b.captured_at_ms;
+ return rhs - lhs;
+ });
+ cookieAccounts = accounts;
+ selectedCookieSlug = accounts[0]?.slug ?? null;
+ cookieHint = null;
+ if (accounts.length > 0) {
+ try {
+ const h = await invoke<{ items: { domain: string; slug: string; status: string }[] }>(
+ "cookies_health"
+ );
+ const slug = selectedCookieSlug ?? "_default";
+ const item =
+ h.items.find((it) => it.domain === result.domain && it.slug === slug) ??
+ h.items.find((it) => it.domain === result.domain);
+ if (item && item.status !== "fresh") {
+ cookieHint = item.status === "expired" ? "expired" : "stale";
+ }
+ } catch {}
+ }
+ } catch {
+ cookieAccounts = [];
+ selectedCookieSlug = null;
+ cookieHint = null;
+ }
+ }
+
+ async function performSearch(query: string) {
+ try {
+ const results = await invoke<SearchResult[]>("search_videos", {
+ query,
+ platform: "youtube",
+ maxResults: 6,
+ });
+ if (url.trim() !== query) return;
+ if (results.length > 0) {
+ omniState = { kind: "search-results", results };
+ } else {
+ omniState = { kind: "search-empty" };
+ }
+ } catch {
+ if (url.trim() === query) {
+ omniState = { kind: "search-empty" };
+ }
+ }
+ }
+
+ function selectSearchResult(result: SearchResult) {
+ url = result.url;
+ omniState = { kind: "detecting" };
+ detectPlatform(result.url);
+ }
+
+ function getContentTypeLabel(contentType: string | null): string {
+ if (!contentType) return $t("omnibox.content_type.unknown");
+ const key = `omnibox.content_type.${contentType}`;
+ const result = $t(key);
+ if (result === key) return $t("omnibox.content_type.unknown");
+ return result;
+ }
+
+
+ async function loadFormats() {
+ if (loadingFormats) return;
+ if (formats.length > 0) {
+ formats = [];
+ selectedFormatId = null;
+ formatError = null;
+ return;
+ }
+ const targetUrl = url.trim();
+ if (!targetUrl) {
+ formatError = $t("omnibox.formats_error");
+ return;
+ }
+ loadingFormats = true;
+ formatError = null;
+ const gen = ++formatFetchGeneration;
+ try {
+ const result = await invoke<FormatInfo[]>("get_media_formats", { url: targetUrl });
+ if (gen !== formatFetchGeneration) return;
+ formats = result;
+ if (result.length === 0) {
+ formatError = $t("omnibox.no_formats");
+ }
+ } catch (e: any) {
+ if (gen !== formatFetchGeneration) return;
+ formats = [];
+ const msg = typeof e === "string" ? e : e.message ?? "";
+ formatError = msg ? translateBackendError(msg, $t) : $t("omnibox.formats_error");
+ } finally {
+ loadingFormats = false;
+ }
+ }
+
+ function selectFormat(formatId: string) {
+ selectedFormatId = formatId;
+ }
+
+ function clearFormatSelection() {
+ selectedFormatId = null;
+ }
+
+ function presetBest() {
+ selectedFormatId = null;
+ downloadMode = "auto";
+ selectedQuality = "best";
+ }
+
+ function presetMusic() {
+ selectedFormatId = null;
+ downloadMode = "audio";
+ }
+
+ function persistLastDownloadOptions() {
+ const saved = getSettings()?.last_download_options;
+ const nextMode = downloadMode;
+ if (saved?.mode === nextMode) return;
+ updateSettings({
+ last_download_options: {
+ mode: nextMode,
+ quality: saved?.quality ?? "best",
+ },
+ }).catch(() => {});
+ }
+
+ async function handleAction() {
+ if (omniState.kind !== "detected") return;
+ const info = omniState.info;
+
+ if (COURSE_PLATFORMS.has(info.platform)) {
+ goto(`/courses/${encodeURIComponent(info.platform)}`);
+ return;
+ }
+
+ if (info.platform === "p2p") {
+ const trimmed = url.trim();
+ const code = trimmed.replace(/^p2p:/, "");
+ p2pReceiveUrl = trimmed;
+ p2pReceiveCode = code;
+ return;
+ }
+
+ const isPlaylist = info.content_type === "playlist" && playlistEntries.length > 0;
+ if (isPlaylist && selectedPlaylistItems.size === 0) {
+ showToast("error", $t("omnibox.playlist_none_selected") as string);
+ return;
+ }
+
+ const isTorrent = torrentEntries.length > 0;
+ if (isTorrent && selectedTorrentFiles.size === 0) {
+ showToast("error", $t("omnibox.torrent_none_selected") as string);
+ return;
+ }
+
+ const settings = getSettings();
+ let outputDir = settings?.download.default_output_dir ?? "";
+
+ if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
+ const selected = await open({
+ directory: true,
+ title: $t("settings.download.default_output_dir"),
+ });
+ if (!selected) return;
+ outputDir = selected;
+ }
+
+ const currentUrl = url.trim();
+ const platform = info.platform;
+ omniState = { kind: "preparing", platform };
+ url = "";
+
+ try {
+ await invoke<DownloadStarted>("download_from_url", {
+ url: currentUrl,
+ outputDir,
+ downloadMode: downloadMode === "auto" ? null : downloadMode,
+ quality: selectedQuality,
+ formatId: selectedFormatId,
+ referer: referer.trim() || null,
+ cookieSlug: selectedCookieSlug,
+ timeRange: buildTimeRange(),
+ playlistItems: isPlaylist ? [...selectedPlaylistItems] : null,
+ torrentFiles: isTorrent ? [...selectedTorrentFiles] : null,
+ scheduledAt: toEpochMs(scheduleAt),
+ stopAt: toEpochMs(scheduleStop),
+ });
+ persistLastDownloadOptions();
+ omniState = { kind: "idle" };
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
+ omniState = {
+ kind: "error",
+ message: msg,
+ originalUrl: currentUrl,
+ platform,
+ };
+ }
+ }
+
+ async function handleBatchDownload() {
+ if (omniState.kind !== "batch") return;
+ const batchUrls = omniState.urls;
+
+ const settings = getSettings();
+ let outputDir = settings?.download.default_output_dir ?? "";
+
+ if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
+ const selected = await open({
+ directory: true,
+ title: $t("settings.download.default_output_dir"),
+ });
+ if (!selected) return;
+ outputDir = selected;
+ }
+
+ omniState = { kind: "idle" };
+ url = "";
+
+ const results = await Promise.allSettled(
+ batchUrls.map(u => invoke<DownloadStarted>("download_from_url", {
+ url: u,
+ outputDir,
+ downloadMode: downloadMode === "auto" ? null : downloadMode,
+ quality: selectedQuality,
+ formatId: null,
+ referer: null,
+ cookieSlug: null,
+ }))
+ );
+
+ const queued = results.filter(r => r.status === "fulfilled").length;
+ if (queued > 0) {
+ showToast("info", $t("omnibox.batch_queued", { count: queued }));
+ persistLastDownloadOptions();
+ }
+ }
+
+ function handleRetry() {
+ if (omniState.kind !== "error") return;
+ url = omniState.originalUrl;
+ omniState = { kind: "detecting" };
+ detectPlatform(url.trim());
+ }
+
+ async function handleP2pAccept() {
+ const currentUrl = p2pReceiveUrl;
+ p2pReceiveCode = null;
+ p2pReceiveUrl = "";
+
+ const settings = getSettings();
+ let outputDir = settings?.download.default_output_dir ?? "";
+
+ if ((settings?.download.always_ask_path && !settings?.download.auto_download_on_paste) || !outputDir) {
+ const selected = await open({
+ directory: true,
+ title: $t("settings.download.default_output_dir"),
+ });
+ if (!selected) return;
+ outputDir = selected;
+ }
+
+ omniState = { kind: "preparing", platform: "p2p" };
+ url = "";
+
+ try {
+ await invoke("download_from_url", {
+ url: currentUrl,
+ outputDir,
+ downloadMode: null,
+ quality: "best",
+ formatId: null,
+ referer: null,
+ cookieSlug: null,
+ });
+ omniState = { kind: "idle" };
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
+ omniState = { kind: "error", message: msg, originalUrl: currentUrl, platform: "p2p" };
+ }
+ }
+
+ function handleP2pReject() {
+ p2pReceiveCode = null;
+ p2pReceiveUrl = "";
+ }
+
+ async function openTorrentFile() {
+ const selected = await open({
+ title: "Select .torrent file",
+ filters: [{ name: "Torrent", extensions: ["torrent"] }],
+ multiple: false,
+ });
+ if (selected && typeof selected === "string") {
+ url = selected;
+ handleInput();
+ }
+ }
+
+ async function openBatchFile() {
+ const selected = await open({
+ title: $t("omnibox.batch_file_title"),
+ filters: [{ name: "Text", extensions: ["txt"] }],
+ multiple: false,
+ });
+ if (!selected || typeof selected !== "string") return;
+ try {
+ const urls = await invoke<string[]>("parse_batch_file", { path: selected });
+ if (urls.length === 0) {
+ showToast("info", $t("omnibox.batch_file_empty"));
+ return;
+ }
+ if (urls.length === 1) {
+ url = urls[0];
+ handleInput();
+ return;
+ }
+ url = urls.join("\n");
+ omniState = { kind: "batch", urls };
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("omnibox.error");
+ showToast("error", msg);
+ }
+ }
+
+ function handleHomeModeChange(mode: HomeInputMode) {
+ // batch/torrent/p2p are momentary actions, not persistent input modes:
+ // return to "url" so the tab bar never strands on an empty state when
+ // the picker/dialog is cancelled
+ if (mode === "p2p") {
+ showP2pSendDialog = true;
+ homeInputMode = "url";
+ } else if (mode === "torrent") {
+ void openTorrentFile().finally(() => {
+ homeInputMode = "url";
+ });
+ } else if (mode === "batch") {
+ void openBatchFile().finally(() => {
+ homeInputMode = "url";
+ });
+ }
+ }
+
+ function handleDismiss() {
+ clearMediaPreview();
+ omniState = { kind: "idle" };
+ url = "";
+ }
+</script>
+
+<div class="home-mac">
+ {#if STUDY_MAINTENANCE_NOTICE && !studyNoticeDismissed}
+ <div class="study-maintenance-banner" role="status">
+ <div class="study-maintenance-text">
+ <strong>{$t("study.maintenance.home_banner_title")}</strong>
+ <span>{$t("study.maintenance.home_banner_body")}</span>
+ </div>
+ <button
+ type="button"
+ class="study-maintenance-dismiss"
+ onclick={dismissStudyNotice}
+ aria-label={$t('common.close')}
+ >
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ </div>
+ {/if}
+
+ <div class="home-mac-workspace">
+ <div class="home-mac-hero">
+ <HomeHero
+ emotion={mascotEmotion}
+ compact={mascotCompact}
+ bubbleText={bubbleText || undefined}
+ celebrate={mascotEmotion === "amazed"}
+ />
+ </div>
+ <div class="home-mac-main">
+ <div class="mode-toggle-row">
+ <button
+ type="button"
+ class="mode-toggle-btn"
+ class:active={!advancedMode}
+ onclick={() => { advancedMode = false; }}
+ >
+ {$t('omnibox.mode_normal')}
+ </button>
+ <button
+ type="button"
+ class="mode-toggle-btn"
+ class:active={advancedMode}
+ onclick={() => { advancedMode = true; }}
+ >
+ {$t('omnibox.mode_advanced')}
+ </button>
+ </div>
+
+ {#if advancedMode}
+ <OmniboxAdvanced />
+ {:else}
+ {#if externalNotice}
+ <div class="feedback-card feedback-enter external-url-card">
+ <div class="card-row">
+ <svg class="card-status-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M12 5v14" />
+ <path d="M5 12h14" />
+ </svg>
+ <span class="card-title">{$t('omnibox.external_url_ready')}</span>
+ <button class="dismiss-btn" onclick={() => { externalNotice = null; }} aria-label={$t('common.close')}>
+ <svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ </div>
+ <div class="card-row">
+ <span class="card-subtext external-url-text">{externalNotice.url}</span>
+ </div>
+ </div>
+ {/if}
+
+ {#if showLoopIcon}
+ <img
+ src="/loop.png"
+ alt=""
+ width="40"
+ height="40"
+ class="loop-icon"
+ class:loop-bounce={omniState.kind === "detected" || omniState.kind === "batch"}
+ class:loop-pulse={omniState.kind === "preparing"}
+ />
+ {/if}
+
+ {#if omniState.kind === "detecting"}
+ <div class="feedback feedback-enter">
+ <span class="feedback-spinner"></span>
+ </div>
+
+ {:else if omniState.kind === "detected"}
+ <div class="feedback feedback-enter" data-supported="true">
+ <span class="feedback-text">
+ {platformDisplayName(omniState.info.platform)}
+ {#if omniState.info.content_type}
+ <span class="feedback-sep">&middot;</span>
+ {getContentTypeLabel(omniState.info.content_type)}
+ {/if}
+ </span>
+ </div>
+ {/if}
+
+ {#if showOmnibox}
+ <HomeUrlBar bind:url bind:mode={homeInputMode} onInput={handleInput} onModeChange={handleHomeModeChange} />
+ {/if}
+
+ {#if omniState.kind === "batch"}
+ <div class="batch-options">
+ <DownloadModeSelector bind:downloadMode />
+ <BatchDownload count={omniState.urls.length} onDownload={handleBatchDownload} />
+ </div>
+
+ {:else if omniState.kind === "searching"}
+ <div class="feedback feedback-enter">
+ <span class="feedback-spinner"></span>
+ <span class="feedback-text search-hint">{$t('omnibox.searching')}</span>
+ </div>
+
+ {:else if omniState.kind === "search-results"}
+ <SearchResults results={omniState.results} onSelect={selectSearchResult} />
+
+ {:else if omniState.kind === "search-empty"}
+ <div class="feedback feedback-enter" data-supported="false">
+ <svg class="feedback-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="11" cy="11" r="8" />
+ <path d="M21 21l-4.35-4.35" />
+ </svg>
+ <span class="feedback-text">{$t('omnibox.search_empty')}</span>
+ </div>
+
+ {:else if omniState.kind === "unsupported"}
+ <div class="feedback feedback-enter" data-supported="false">
+ <svg class="feedback-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="12" cy="12" r="10" />
+ <path d="M12 8v4m0 4h.01" />
+ </svg>
+ <span class="feedback-text">{$t('omnibox.unsupported')}</span>
+ </div>
+ {/if}
+ {/if}
+
+ {#if omniState.kind === "idle"}
+ <SupportedServices />
+ {/if}
+ </div>
+
+ <HomeInspector open={showInspector} title={$t('home.inspector_title')}>
+ {#if omniState.kind === "detected"}
+ <MediaPreview bind:mediaPreview bind:imageLoading={previewImageLoading} />
+ {#if omniState.info.content_type === "playlist"}
+ <div class="playlist-picker">
+ <div class="playlist-head">
+ <span class="playlist-count">
+ {$t('omnibox.playlist_selected', { selected: selectedPlaylistItems.size, total: playlistEntries.length })}
+ </span>
+ {#if !playlistLoading && playlistEntries.length > 0}
+ <div class="playlist-bulk">
+ <button type="button" class="playlist-link" onclick={selectAllPlaylist}>{$t('omnibox.playlist_all')}</button>
+ <button type="button" class="playlist-link" onclick={selectNonePlaylist}>{$t('omnibox.playlist_none')}</button>
+ </div>
+ {/if}
+ </div>
+ {#if playlistLoading}
+ <div class="playlist-status"><span class="feedback-spinner"></span> {$t('omnibox.playlist_loading')}</div>
+ {:else if playlistEntries.length === 0}
+ <span class="playlist-status">{$t('omnibox.playlist_empty')}</span>
+ {:else}
+ <ul class="playlist-list">
+ {#each playlistEntries as entry (entry.index)}
+ <li>
+ <label class="playlist-item">
+ <input type="checkbox" checked={selectedPlaylistItems.has(entry.index)} onchange={() => togglePlaylistItem(entry.index)} />
+ <span class="playlist-idx">{entry.index}.</span>
+ <span class="playlist-title">{entry.title}</span>
+ </label>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ </div>
+ {/if}
+ {#if torrentLoading || torrentEntries.length > 0}
+ <div class="playlist-picker">
+ <div class="playlist-head">
+ <span class="playlist-count">
+ {$t('omnibox.torrent_selected', { selected: selectedTorrentFiles.size, total: torrentEntries.length })}
+ </span>
+ {#if !torrentLoading && torrentEntries.length > 0}
+ <div class="playlist-bulk">
+ <button type="button" class="playlist-link" onclick={selectAllTorrent}>{$t('omnibox.playlist_all')}</button>
+ <button type="button" class="playlist-link" onclick={selectNoneTorrent}>{$t('omnibox.playlist_none')}</button>
+ </div>
+ {/if}
+ </div>
+ {#if torrentLoading}
+ <div class="playlist-status"><span class="feedback-spinner"></span> {$t('omnibox.torrent_loading')}</div>
+ {:else}
+ <ul class="playlist-list">
+ {#each torrentEntries as entry (entry.index)}
+ <li>
+ <label class="playlist-item">
+ <input type="checkbox" checked={selectedTorrentFiles.has(entry.index)} onchange={() => toggleTorrentFile(entry.index)} />
+ <span class="playlist-title">{entry.path}</span>
+ <span class="torrent-size">{formatBytes(entry.size_bytes)}</span>
+ </label>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ </div>
+ {/if}
+ {#if cookieHint}
+ <p class="cookie-hint" class:expired={cookieHint === "expired"} role="status">
+ <span>{cookieHint === "expired" ? $t("omnibox.cookie_hint_expired") : $t("omnibox.cookie_hint_stale")}</span>
+ <button type="button" class="cookie-hint-link" onclick={() => goto("/settings?tab=cookies")}>{$t("omnibox.cookie_hint_action")}</button>
+ </p>
+ {/if}
+ {#if COURSE_PLATFORMS.has(omniState.info.platform)}
+ <button class="button action-btn" onclick={handleAction}>{$t(omniState.info.platform === "udemy" ? 'omnibox.go_to_udemy' : 'omnibox.go_to_hotmart')}</button>
+ {:else}
+ {@const playlistBlocked = omniState.info.content_type === "playlist" && playlistEntries.length > 0 && selectedPlaylistItems.size === 0}
+ {@const torrentBlocked = torrentEntries.length > 0 && selectedTorrentFiles.size === 0}
+ {#if omniState.info.platform === "bilibili"}
+ <BilibiliPreviewExtras {url} accountSlug={selectedCookieSlug && selectedCookieSlug !== "_anonymous" ? selectedCookieSlug : null} />
+ {/if}
+ <button class="download-primary-btn" disabled={playlistBlocked || torrentBlocked} onclick={handleAction}>{$t('omnibox.download')}</button>
+ {#if omniState.info.platform !== "direct_file"}
+ <details class="options-panel">
+ <summary class="options-toggle">{$t('omnibox.options')}</summary>
+ <div class="options-content">
+ <DownloadModeSelector bind:downloadMode onChange={() => { selectedFormatId = null; }} />
+ <QualityPicker bind:selectedQuality selectedFormatId />
+ {#if cookieAccounts.length > 1}
+ <CookieAccountPicker accounts={cookieAccounts} bind:selectedSlug={selectedCookieSlug} />
+ {/if}
+ <details class="options-panel">
+ <summary class="options-toggle">{$t('omnibox.advanced')}</summary>
+ <div class="options-content">
+ {#if omniState.info.platform === "vimeo" || omniState.info.platform === "generic"}
+ <div class="referer-input-wrapper">
+ <label class="referer-label" for="referer-input">{$t('omnibox.referer_label')}</label>
+ <input id="referer-input" class="referer-input" type="text" placeholder={$t('omnibox.referer_placeholder')} bind:value={referer} spellcheck="false" />
+ </div>
+ {/if}
+ {#if omniState.info.content_type !== "playlist"}
+ <div class="timerange-wrapper">
+ <span class="timerange-label">{$t('omnibox.timerange_label')}</span>
+ <div class="timerange-inputs">
+ <input class="timerange-input" type="text" placeholder={$t('omnibox.timerange_start')} bind:value={clipStart} spellcheck="false" inputmode="numeric" aria-label={$t('omnibox.timerange_start') as string} />
+ <span class="timerange-sep" aria-hidden="true">—</span>
+ <input class="timerange-input" type="text" placeholder={$t('omnibox.timerange_end')} bind:value={clipEnd} spellcheck="false" inputmode="numeric" aria-label={$t('omnibox.timerange_end') as string} />
+ </div>
+ <span class="timerange-hint">{$t('omnibox.timerange_hint')}</span>
+ </div>
+ {/if}
+ <div class="timerange-wrapper">
+ <span class="timerange-label">{$t('omnibox.schedule_label')}</span>
+ <div class="schedule-presets">
+ <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('1h')}>{$t('omnibox.schedule_1h')}</button>
+ <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('tonight')}>{$t('omnibox.schedule_tonight')}</button>
+ <button type="button" class="schedule-preset" onclick={() => setSchedulePreset('1d')}>{$t('omnibox.schedule_1d')}</button>
+ {#if scheduleAt || scheduleStop}
+ <button type="button" class="schedule-preset" onclick={() => { scheduleAt = ""; scheduleStop = ""; }}>{$t('omnibox.schedule_clear')}</button>
+ {/if}
+ </div>
+ <div class="timerange-inputs schedule-row">
+ <input class="timerange-input schedule-date" type="date" value={schedulePart(scheduleAt, "date")} oninput={(e) => { scheduleAt = withSchedulePart(scheduleAt, "date", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_start') as string} />
+ <input class="timerange-input schedule-time" type="time" step="60" value={schedulePart(scheduleAt, "time")} oninput={(e) => { scheduleAt = withSchedulePart(scheduleAt, "time", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_start') as string} />
+ <span class="timerange-sep" aria-hidden="true">—</span>
+ <input class="timerange-input schedule-date" type="date" value={schedulePart(scheduleStop, "date")} oninput={(e) => { scheduleStop = withSchedulePart(scheduleStop, "date", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_stop') as string} />
+ <input class="timerange-input schedule-time" type="time" step="60" value={schedulePart(scheduleStop, "time")} oninput={(e) => { scheduleStop = withSchedulePart(scheduleStop, "time", e.currentTarget.value); }} aria-label={$t('omnibox.schedule_stop') as string} />
+ </div>
+ <span class="timerange-hint">{$t('omnibox.schedule_hint')}</span>
+ </div>
+ <FormatSelector
+ platform={omniState.info.platform}
+ isPlaylist={omniState.info.content_type === "playlist"}
+ bind:formats
+ bind:selectedFormatId
+ {loadingFormats}
+ {formatError}
+ onLoadFormats={loadFormats}
+ onSelectFormat={selectFormat}
+ onClearFormat={clearFormatSelection}
+ onPresetBest={presetBest}
+ onPresetMusic={presetMusic}
+ />
+ </div>
+ </details>
+ </div>
+ </details>
+ {/if}
+ {/if}
+ {:else if omniState.kind === "preparing"}
+ <div class="feedback-card feedback-enter">
+ <div class="card-row">
+ <span class="feedback-spinner"></span>
+ <span class="card-text">{$t('omnibox.preparing')}</span>
+ </div>
+ </div>
+ {:else if omniState.kind === "error"}
+ <div class="feedback-card feedback-enter" data-status="error">
+ <div class="card-row">
+ <span class="card-title card-error-text">{omniState.message}</span>
+ </div>
+ <div class="card-row card-actions">
+ <button class="button card-action-btn" onclick={handleRetry}>{$t('omnibox.retry')}</button>
+ </div>
+ </div>
+ {/if}
+ </HomeInspector>
+ </div>
+
+ {#if showP2pSendDialog}
+ <P2pSendDialog onClose={() => { showP2pSendDialog = false; }} />
+ {/if}
+
+ {#if p2pReceiveCode}
+ <P2pReceiveDialog
+ code={p2pReceiveCode}
+ onAccept={handleP2pAccept}
+ onReject={handleP2pReject}
+ />
+ {/if}
+
+ <div class="terms-note">
+ {$t('terms_note.agreement')}
+ <a href="/about/terms" class="terms-link">{$t('terms_note.link')}</a>
+ </div>
+</div>
+
+<style>
+ .home-mac {
+ width: 100%;
+ }
+
+ .study-maintenance-banner {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ width: 100%;
+ max-width: 640px;
+ padding: 8px 12px;
+ background: color-mix(in oklab, var(--secondary) 8%, transparent);
+ border: 1px solid color-mix(in oklab, var(--secondary) 18%, transparent);
+ border-radius: var(--border-radius);
+ color: var(--secondary);
+ font-size: 12px;
+ line-height: 1.4;
+ }
+
+ .study-maintenance-text {
+ display: flex;
+ flex-direction: column;
+ gap: 1px;
+ flex: 1;
+ min-width: 0;
+ }
+
+ .study-maintenance-text strong {
+ font-weight: 500;
+ font-size: var(--text-sm);
+ color: var(--text);
+ }
+
+ .study-maintenance-text span {
+ color: var(--secondary);
+ font-size: 11.5px;
+ }
+
+ .study-maintenance-dismiss {
+ background: transparent;
+ border: none;
+ padding: 4px;
+ margin: -4px;
+ border-radius: 4px;
+ color: var(--secondary);
+ cursor: pointer;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ opacity: 0.55;
+ transition: opacity 0.15s ease, background 0.15s ease;
+ }
+
+ .study-maintenance-dismiss:hover {
+ opacity: 1;
+ background: color-mix(in oklab, var(--text) 6%, transparent);
+ }
+
+ .omnibox-area {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: var(--space-3);
+ width: 100%;
+ max-width: 640px;
+ }
+
+ .mode-toggle-row {
+ display: inline-flex;
+ background: var(--fill-1);
+ border-radius: var(--radius-md);
+ padding: 2px;
+ gap: 2px;
+ margin-bottom: 4px;
+ }
+ .mode-toggle-btn {
+ min-height: 24px;
+ padding: 4px 12px;
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--text-muted);
+ background: transparent;
+ border: none;
+ border-radius: calc(var(--radius-md) - 2px);
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
+ }
+ .mode-toggle-btn.active {
+ background: var(--surface-hi);
+ color: var(--text);
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
+ }
+ .mode-toggle-btn:not(.active):hover {
+ color: var(--text);
+ }
+ .mode-toggle-btn:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: -1px;
+ }
+
+ .loop-icon {
+ pointer-events: none;
+ border-radius: 10px;
+ user-select: none;
+ }
+
+ .loop-bounce {
+ animation: loopBounce 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
+ }
+
+ @keyframes loopBounce {
+ 0% {
+ opacity: 0;
+ transform: scale(0.6) translateY(6px);
+ }
+ 60% {
+ opacity: 1;
+ transform: scale(1.08) translateY(-2px);
+ }
+ 100% {
+ transform: scale(1) translateY(0);
+ }
+ }
+
+ .loop-pulse {
+ animation: loopPulse 1.8s ease-in-out infinite;
+ }
+
+ @keyframes loopPulse {
+ 0%, 100% {
+ opacity: 1;
+ transform: scale(1);
+ }
+ 50% {
+ opacity: 0.7;
+ transform: scale(0.95);
+ }
+ }
+
+ .batch-options {
+ display: flex;
+ flex-direction: column;
+ gap: var(--padding);
+ }
+
+ .feedback {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 2);
+ }
+
+ .feedback-icon {
+ flex-shrink: 0;
+ pointer-events: none;
+ }
+
+ .feedback[data-supported="true"] {
+ color: var(--green);
+ }
+
+ .feedback[data-supported="false"] {
+ color: var(--gray);
+ }
+
+ .feedback-text {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ }
+
+ .feedback-sep {
+ opacity: 0.5;
+ margin: 0 2px;
+ }
+
+ .feedback-spinner {
+ width: 16px;
+ height: 16px;
+ border: 2px solid var(--input-border);
+ border-top-color: var(--secondary);
+ border-radius: 50%;
+ animation: spin 0.8s linear infinite;
+ }
+
+ @keyframes spin {
+ to {
+ transform: rotate(360deg);
+ }
+ }
+
+ .feedback-enter {
+ animation: feedbackEnter 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
+ }
+
+ @keyframes feedbackEnter {
+ from {
+ opacity: 0;
+ transform: scale(0.9);
+ }
+ to {
+ opacity: 1;
+ transform: scale(1);
+ }
+ }
+
+ .download-primary-btn {
+ background: var(--cta);
+ color: var(--on-cta);
+ font-size: 15px;
+ font-weight: 500;
+ padding: 12px 32px;
+ border-radius: var(--border-radius);
+ border: none;
+ cursor: pointer;
+ width: 100%;
+ max-width: 300px;
+ transition: background 150ms;
+ }
+
+ @media (hover: hover) {
+ .download-primary-btn:hover {
+ background: var(--cta-hover);
+ }
+ }
+
+ .download-primary-btn:active {
+ background: var(--cta-press);
+ }
+
+ .download-primary-btn:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+ }
+
+ .download-primary-btn:disabled {
+ opacity: 0.5;
+ cursor: not-allowed;
+ }
+
+ .playlist-picker {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ padding: 10px 12px;
+ background: var(--button);
+ border: 1px solid var(--input-border);
+ border-radius: var(--border-radius);
+ }
+
+ .playlist-head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ }
+
+ .playlist-count {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--secondary);
+ }
+
+ .playlist-bulk {
+ display: flex;
+ gap: 10px;
+ }
+
+ .playlist-link {
+ background: none;
+ border: none;
+ padding: 0;
+ font: inherit;
+ font-size: 12px;
+ color: var(--accent);
+ cursor: pointer;
+ }
+
+ .playlist-link:hover {
+ text-decoration: underline;
+ }
+
+ .playlist-status {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ font-size: var(--text-sm);
+ color: var(--gray);
+ }
+
+ .playlist-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ max-height: 220px;
+ overflow-y: auto;
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ }
+
+ .playlist-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 5px 4px;
+ border-radius: calc(var(--border-radius) - 3px);
+ cursor: pointer;
+ font-size: 13px;
+ color: var(--secondary);
+ }
+
+ .playlist-item:hover {
+ background: var(--button-elevated);
+ }
+
+ .playlist-idx {
+ color: var(--gray);
+ font-variant-numeric: tabular-nums;
+ flex-shrink: 0;
+ }
+
+ .playlist-title {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .torrent-size {
+ margin-left: auto;
+ flex-shrink: 0;
+ padding-left: 8px;
+ color: var(--gray);
+ font-variant-numeric: tabular-nums;
+ }
+
+ .options-panel {
+ width: 100%;
+ }
+
+ .options-toggle {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ cursor: pointer;
+ list-style: none;
+ text-align: center;
+ padding: 4px 0;
+ user-select: none;
+ }
+
+ .options-toggle::-webkit-details-marker {
+ display: none;
+ }
+
+ .options-toggle::marker {
+ content: "";
+ }
+
+ @media (hover: hover) {
+ .options-toggle:hover {
+ color: var(--secondary);
+ }
+ }
+
+ .options-content {
+ display: flex;
+ flex-direction: column;
+ gap: var(--padding);
+ padding-top: var(--padding);
+ width: 100%;
+ }
+
+ .referer-input-wrapper {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+
+ .referer-label {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ }
+
+ .referer-input {
+ padding: 6px var(--padding);
+ font-size: 13px;
+ background: var(--button);
+ border: 1px solid var(--input-border);
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--secondary);
+ }
+
+ .referer-input::placeholder {
+ color: var(--gray);
+ }
+
+ .referer-input:focus-visible {
+ border-color: var(--secondary);
+ outline: none;
+ }
+
+ .timerange-wrapper {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+
+ .timerange-label {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ }
+
+ .timerange-inputs {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ }
+
+ .timerange-input {
+ width: 96px;
+ padding: 6px var(--padding);
+ font-size: 13px;
+ background: var(--button);
+ border: 1px solid var(--input-border);
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--secondary);
+ text-align: center;
+ }
+
+ .timerange-input::placeholder {
+ color: var(--gray);
+ }
+
+ .timerange-input:focus-visible {
+ border-color: var(--secondary);
+ outline: none;
+ }
+
+ .timerange-sep {
+ color: var(--gray);
+ }
+
+ .timerange-hint {
+ font-size: 11.5px;
+ color: var(--gray);
+ }
+
+ .schedule-presets {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: 6px;
+ }
+
+ .schedule-preset {
+ padding: 4px 10px;
+ font-size: 12px;
+ background: var(--button);
+ border: 1px solid var(--input-border);
+ border-radius: calc(var(--border-radius) - 2px);
+ color: var(--text);
+ cursor: pointer;
+ }
+
+ .schedule-preset:hover {
+ background: var(--button-elevated);
+ }
+
+ .schedule-row {
+ flex-wrap: wrap;
+ }
+
+ .schedule-date {
+ width: auto;
+ flex: 1 1 auto;
+ min-width: 8.6em;
+ }
+
+ .schedule-time {
+ width: auto;
+ flex: 0 1 auto;
+ min-width: 5.4em;
+ }
+
+ .cookie-hint {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ margin: 0;
+ font-size: 12px;
+ color: #f4a72b;
+ }
+ .cookie-hint.expired {
+ color: #e0564f;
+ }
+ .cookie-hint svg {
+ flex-shrink: 0;
+ }
+ .cookie-hint-link {
+ background: none;
+ border: 0;
+ padding: 0;
+ font: inherit;
+ font-size: 12px;
+ color: var(--accent);
+ cursor: pointer;
+ text-decoration: underline;
+ text-underline-offset: 2px;
+ }
+ .cookie-hint-link:hover {
+ filter: brightness(1.15);
+ }
+
+ .action-btn {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ padding: var(--padding) calc(var(--padding) * 2);
+ font-size: var(--text-base);
+ font-weight: 500;
+ background: var(--button);
+ border: none;
+ border-radius: var(--border-radius);
+ color: var(--button-text);
+ cursor: pointer;
+ box-shadow: var(--button-box-shadow);
+ }
+
+ @media (hover: hover) {
+ .action-btn:hover {
+ background: var(--button-hover);
+ }
+ }
+
+ .action-btn:active {
+ background: var(--button-press);
+ }
+
+ .action-btn:disabled {
+ cursor: default;
+ }
+
+ .feedback-card {
+ display: flex;
+ flex-direction: column;
+ gap: var(--padding);
+ padding: var(--padding) calc(var(--padding) * 1.5);
+ background: var(--button-elevated);
+ border-radius: var(--border-radius);
+ border-left: 3px solid var(--blue);
+ }
+
+ .feedback-card[data-status="error"] {
+ border-left-color: var(--red);
+ }
+
+ .external-url-card {
+ width: 100%;
+ border-left-color: var(--accent);
+ }
+
+ .card-row {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 2);
+ }
+
+ .card-text {
+ font-size: 13px;
+ font-weight: 500;
+ color: var(--secondary);
+ }
+
+ .card-title {
+ font-size: 13px;
+ font-weight: 500;
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .card-error-text {
+ color: var(--secondary);
+ }
+
+ .card-status-icon {
+ flex-shrink: 0;
+ pointer-events: none;
+ color: var(--blue);
+ }
+
+ .card-status-icon.error {
+ color: var(--red);
+ }
+
+ .card-actions {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--padding);
+ }
+
+ .card-subtext {
+ font-size: 11.5px;
+ font-weight: 500;
+ color: var(--gray);
+ }
+
+ .external-url-text {
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .card-action-btn {
+ padding: 6px 12px;
+ font-size: 13px;
+ }
+
+ .dismiss-btn {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 24px;
+ height: 24px;
+ background: transparent;
+ border: none;
+ cursor: pointer;
+ color: var(--secondary);
+ padding: 0;
+ }
+
+ .search-hint {
+ color: var(--gray);
+ }
+
+ .quick-actions {
+ display: flex;
+ gap: var(--space-2);
+ margin-bottom: var(--space-3);
+ }
+
+ .quick-action-btn {
+ display: flex;
+ align-items: center;
+ gap: var(--space-2);
+ padding: var(--space-2) var(--space-4);
+ font-size: var(--text-sm);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-sm);
+ background: var(--surface);
+ color: var(--text);
+ cursor: pointer;
+ transition: background var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
+ }
+
+ @media (hover: hover) {
+ .quick-action-btn:hover {
+ background: var(--surface-hi);
+ transform: translateY(-1px);
+ }
+ }
+
+ .quick-action-btn:active {
+ transform: scale(0.98);
+ background: var(--surface-hi);
+ }
+
+ .quick-action-btn svg {
+ opacity: 0.7;
+ flex-shrink: 0;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .quick-action-btn {
+ transition: none;
+ }
+ .quick-action-btn:hover,
+ .quick-action-btn:active {
+ transform: none;
+ }
+ }
+
+ .terms-note {
+ flex-shrink: 0;
+ font-size: 9px;
+ color: var(--gray);
+ text-align: left;
+ opacity: 0.35;
+ padding: 0 var(--space-1);
+ }
+
+ .terms-link {
+ color: var(--blue);
+ text-decoration: none;
+ }
+
+ @media (hover: hover) {
+ .terms-link:hover {
+ text-decoration: underline;
+ }
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .feedback-enter {
+ animation: none;
+ }
+
+ .feedback-spinner {
+ animation-duration: 1.5s;
+ }
+
+ .loop-bounce {
+ animation: none;
+ }
+
+ .loop-pulse {
+ animation: none;
+ }
+ }
+ @media (prefers-reduced-motion: reduce) {
+ .feedback-spinner {
+ animation: feedback-soft-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
+ }
+ }
+
+ @keyframes feedback-soft-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.45; }
+ }
+</style>
diff --git a/src/routes/downloads/+page.svelte b/src/routes/downloads/+page.svelte
index 169997b1..7a0eb64e 100644
--- a/src/routes/downloads/+page.svelte
+++ b/src/routes/downloads/+page.svelte
@@ -1,1756 +1,1757 @@
-<script lang="ts">
- import { onMount } from "svelte";
- import { goto } from "$app/navigation";
- import { invoke } from "@tauri-apps/api/core";
- import { pluginInvoke } from "$lib/plugin-invoke";
- import { t } from "$lib/i18n";
- import { translateBackendError } from "$lib/error-translate";
- import { showToast } from "$lib/stores/toast-store.svelte";
- import {
- getDownloads,
- formatBytes,
- formatSpeed,
- formatEta,
- getFinishedCount,
- getSpeedHistory,
- type CourseDownloadItem,
- type GenericDownloadItem,
- type QueueKind,
- } from "$lib/stores/download-store.svelte";
- import { getDownloadStats } from "$lib/stores/download-stats.svelte";
- import PlatformIcon from "$components/icons/PlatformIcon.svelte";
- import QueueKindBadge from "$lib/study-components/QueueKindBadge.svelte";
- import Mascot from "$components/mascot/Mascot.svelte";
- import ContextHint from "$components/hints/ContextHint.svelte";
- import DownloadSpeedGraph from "$components/download/DownloadSpeedGraph.svelte";
- import DownloadLog from "$components/download/DownloadLog.svelte";
- import ReencodeDialog from "$components/dialog/ReencodeDialog.svelte";
- import ToolsPanel from "$components/downloads/ToolsPanel.svelte";
- import VideoOpsOverlay from "$components/downloads/VideoOpsOverlay.svelte";
- import { locale as i18nLocale } from "$lib/i18n";
- import { get } from "svelte/store";
- import timeAgo from "$lib/time-ago";
-
- let studyAvailable = $state(false);
-
- onMount(async () => {
- try {
- const plugins = await invoke<{
- id: string;
- enabled: boolean;
- loaded: boolean;
- }[]>("list_plugins");
- studyAvailable = plugins.some(
- (p) => p.id === "study" && p.enabled && p.loaded,
- );
- } catch {
- studyAvailable = false;
- }
- });
-
- const VIDEO_EXTENSIONS = new Set([
- "mp4", "mkv", "webm", "mov", "avi", "ts", "m4v", "flv", "wmv", "mpg", "mpeg", "3gp", "ogv", "m2ts", "mts",
- ]);
-
- function fileExtension(path: string): string | null {
- const name = path.replace(/\\/g, "/").split("/").pop() ?? "";
- const dot = name.lastIndexOf(".");
- if (dot <= 0 || dot === name.length - 1) return null;
- return name.slice(dot + 1).toLowerCase();
- }
-
- function isVideoItem(item: GenericDownloadItem): boolean {
- if (item.filePath && (item.fileCount ?? 1) <= 1) {
- const ext = fileExtension(item.filePath);
- if (ext) return VIDEO_EXTENSIONS.has(ext);
- }
- if (item.downloadMode === "video") return true;
- return item.queueKind === "video";
- }
-
- function qualityChip(item: GenericDownloadItem): string | null {
- if (item.downloadMode === "audio") return $t('omnibox.quality_audio') as string;
- if (!item.quality) return null;
- const q = item.quality.toLowerCase();
- if (q === "audio") return $t('omnibox.quality_audio') as string;
- if (!isVideoItem(item)) return null;
- if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;
- return item.quality;
- }
-
- function canOpenInStudy(item: GenericDownloadItem): boolean {
- return (
- studyAvailable &&
- item.status === "complete" &&
- !!item.filePath &&
- (item.queueKind === "video" || item.queueKind === "audio")
- );
- }
-
- function openInStudy(filePath: string) {
- const parts = filePath.replace(/\\/g, "/").split("/");
- const name = parts[parts.length - 1] ?? "";
- const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;
- goto(url);
- }
-
- let downloads = $derived(getDownloads());
- let courseList = $derived(
- [...downloads.values()].filter((d): d is CourseDownloadItem => d.kind === "course")
- );
- let genericList = $derived(
- [...downloads.values()].filter((d): d is GenericDownloadItem => d.kind === "generic")
- );
-
- let grouped = $derived.by(() => {
- const active: GenericDownloadItem[] = [];
- const paused: GenericDownloadItem[] = [];
- const queued: GenericDownloadItem[] = [];
- const finished: GenericDownloadItem[] = [];
- const errored: GenericDownloadItem[] = [];
- const completed: GenericDownloadItem[] = [];
- for (const d of genericList) {
- if (d.status === "downloading" || d.status === "seeding") active.push(d);
- else if (d.status === "paused") paused.push(d);
- else if (d.status === "queued") queued.push(d);
- else {
- finished.push(d);
- if (d.status === "error") errored.push(d);
- else if (d.status === "complete") completed.push(d);
- }
- }
- return { active, paused, queued, finished, errored, completed };
- });
-
- type StatusFilter = "all" | "active" | "queued" | "completed" | "failed";
- let statusFilter = $state<StatusFilter>("all");
-
- let filterCounts = $derived({
- all: genericList.length,
- active: grouped.active.length + grouped.paused.length,
- queued: grouped.queued.length,
- completed: grouped.completed.length,
- failed: grouped.errored.length,
- });
-
- let showSection = $derived({
- active: statusFilter === "all" || statusFilter === "active",
- queued: statusFilter === "all" || statusFilter === "queued",
- completed: statusFilter === "all" || statusFilter === "completed",
- failed: statusFilter === "all" || statusFilter === "failed",
- });
-
- let finishedFiltered = $derived.by(() => {
- if (statusFilter === "completed") return grouped.completed;
- if (statusFilter === "failed") return grouped.errored;
- return grouped.finished;
- });
-
- const FINISHED_PAGE_SIZE = 20;
- let finishedVisibleCount = $state(FINISHED_PAGE_SIZE);
-
- let visibleFinished = $derived(
- finishedFiltered.length <= finishedVisibleCount
- ? finishedFiltered
- : finishedFiltered.slice(0, finishedVisibleCount)
- );
-
- let hasDownloads = $derived(courseList.length > 0 || genericList.length > 0);
- let finishedCount = $derived(getFinishedCount());
- let dlStats = $derived(getDownloadStats());
-
- async function cancelDownload(courseId: number) {
- try {
- await pluginInvoke("courses", "cancel_course_download", { courseId });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function cancelGenericDownload(id: number) {
- try {
- await invoke("cancel_generic_download", { downloadId: id });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function pauseDownload(id: number) {
- try {
- await invoke("pause_download", { downloadId: id });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function resumeDownload(id: number) {
- try {
- await invoke("resume_download", { downloadId: id });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function retryDownload(id: number) {
- try {
- await invoke("retry_download", { downloadId: id });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- let pendingRemove = $state<number | null>(null);
- let pendingRemoveTimer = $state<ReturnType<typeof setTimeout> | null>(null);
-
- function removeItem(id: number) {
- if (pendingRemove === id) {
- if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);
- pendingRemove = null;
- pendingRemoveTimer = null;
- invoke("remove_download", { downloadId: id }).catch((e: any) => {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- });
- } else {
- if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);
- pendingRemove = id;
- pendingRemoveTimer = setTimeout(() => {
- pendingRemove = null;
- pendingRemoveTimer = null;
- }, 3000);
- }
- }
-
- async function removeItemWithFile(id: number) {
- if (!confirm($t("downloads.delete_file_confirm"))) return;
- try {
- await invoke("remove_download", { downloadId: id, deleteFile: true });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function clearFinished() {
- if (!confirm($t("downloads.clear_confirm"))) return;
- try {
- await invoke("clear_finished_downloads");
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function pauseAll() {
- try {
- await invoke("pause_all_downloads");
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function resumeAll() {
- try {
- await invoke("resume_all_downloads");
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- async function revealFile(path: string) {
- try {
- await invoke("reveal_file", { path });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- let reencodePath = $state<string | null>(null);
-
- function openReencode(path: string) {
- reencodePath = path;
- }
-
- let vopPath = $state<string | null>(null);
-
- type HistoryEntry = {
- id: number;
- url: string;
- platform: string;
- title: string;
- file_path: string | null;
- file_size_bytes: number | null;
- total_bytes: number | null;
- success: boolean;
- error: string | null;
- completed_at: number;
- thumbnail_url: string | null;
- kind: QueueKind | null;
- };
-
- let viewMode = $state<"active" | "history" | "tools">("active");
- let historyEntries = $state<HistoryEntry[]>([]);
- let historyLoading = $state(false);
-
- async function loadHistory() {
- historyLoading = true;
- try {
- historyEntries = await invoke<HistoryEntry[]>("get_download_history");
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- } finally {
- historyLoading = false;
- }
- }
-
- async function clearHistory() {
- if (!confirm($t("downloads.history_clear_confirm") as string)) return;
- try {
- await invoke("clear_download_history");
- historyEntries = [];
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- function toggleHistoryView() {
- if (viewMode === "history") {
- viewMode = "active";
- } else {
- viewMode = "history";
- loadHistory();
- }
- }
-
- function toggleToolsView() {
- viewMode = viewMode === "tools" ? "active" : "tools";
- }
-
- async function historyRetry(url: string, platform: string) {
- try {
- const settings = (await import("$lib/stores/settings-store.svelte")).getSettings();
- const outputDir = settings?.download.default_output_dir ?? "";
- if (!outputDir) {
- showToast("error", $t("common.error") as string);
- return;
- }
- await invoke("download_from_url", {
- url,
- outputDir,
- downloadMode: null,
- quality: settings?.download.video_quality ?? "best",
- formatId: null,
- referer: null,
- });
- viewMode = "active";
- showToast("info", $t("downloads.history_requeued") as string);
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- function fmtHistoryTime(unixSec: number): string {
- const ms = unixSec * 1000;
- const loc = get(i18nLocale) || "en";
- const lookup = loc.startsWith("pt") ? "pt" : "en";
- return timeAgo(ms, lookup);
- }
-
- function canPlayInStudyHistory(entry: HistoryEntry): boolean {
- return (
- studyAvailable &&
- entry.success &&
- !!entry.file_path &&
- (entry.kind === "video" || entry.kind === "audio")
- );
- }
-
- function openHistoryInStudy(filePath: string) {
- const parts = filePath.replace(/\\/g, "/").split("/");
- const name = parts[parts.length - 1] ?? "";
- const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;
- goto(url);
- }
-
- let dragId = $state<number | null>(null);
- let dropTargetId = $state<number | null>(null);
- let dropPosition = $state<"before" | "after">("before");
-
- function onDragStart(e: DragEvent, id: number) {
- dragId = id;
- if (e.dataTransfer) {
- e.dataTransfer.effectAllowed = "move";
- e.dataTransfer.setData("text/plain", String(id));
- }
- }
-
- function onDragOver(e: DragEvent, id: number) {
- if (dragId === null || dragId === id) return;
- e.preventDefault();
- if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
- const target = e.currentTarget as HTMLElement;
- const rect = target.getBoundingClientRect();
- const midpoint = rect.top + rect.height / 2;
- dropPosition = e.clientY < midpoint ? "before" : "after";
- dropTargetId = id;
- }
-
- function onDragLeave(e: DragEvent, id: number) {
- if (dropTargetId === id) {
- dropTargetId = null;
- }
- }
-
- async function onDrop(e: DragEvent, targetId: number) {
- e.preventDefault();
- const movingId = dragId;
- const position = dropPosition;
- dragId = null;
- dropTargetId = null;
- if (movingId === null || movingId === targetId) return;
-
- const order = grouped.queued.map((q) => q.id);
- const fromIdx = order.indexOf(movingId);
- if (fromIdx === -1) return;
- order.splice(fromIdx, 1);
- let targetIdx = order.indexOf(targetId);
- if (targetIdx === -1) return;
- if (position === "after") targetIdx += 1;
- order.splice(targetIdx, 0, movingId);
-
- try {
- await invoke<boolean>("reorder_queue", { ids: order });
- } catch (e: any) {
- const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
- showToast("error", msg);
- }
- }
-
- function onDragEnd() {
- dragId = null;
- dropTargetId = null;
- }
-
- function onKeydown(e: KeyboardEvent) {
- const target = e.target as HTMLElement | null;
- const tag = target?.tagName?.toLowerCase();
- const isEditable =
- tag === "input" ||
- tag === "textarea" ||
- tag === "select" ||
- target?.isContentEditable;
- if (isEditable) return;
- if (e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey && (e.key === "h" || e.key === "H")) {
- e.preventDefault();
- toggleHistoryView();
- }
- }
-
- onMount(() => {
- window.addEventListener("keydown", onKeydown);
- return () => window.removeEventListener("keydown", onKeydown);
- });
-
- // Relógio de 1s, ligado apenas enquanto algum item espera por rate limit.
- // Sem isso a contagem regressiva ficaria parada até o próximo evento.
- let nowTick = $state(Date.now());
-
- let hasWaitingItem = $derived(
- [...getDownloads().values()].some(
- (d) => d.kind === "generic" && d.phase === "waiting_rate_limit" && (d.waitUntil ?? 0) > nowTick,
- ),
- );
-
- $effect(() => {
- if (!hasWaitingItem) return;
- const timer = setInterval(() => (nowTick = Date.now()), 1000);
- return () => clearInterval(timer);
- });
-
- function waitRemaining(waitUntil: number | null | undefined): number {
- if (!waitUntil) return 0;
- return Math.max(0, Math.ceil((waitUntil - nowTick) / 1000));
- }
-</script>
-
-{#if hasDownloads || viewMode !== "active"}
- <div class="downloads-page downloads-mac">
- <div class="downloads-header">
- {#if dlStats.totalDownloads > 0}
- <span class="downloads-stats">{$t('downloads.stats_line', { count: String(dlStats.totalDownloads), size: formatBytes(dlStats.totalBytes) })}</span>
- {/if}
- <div class="bulk-actions">
- {#if viewMode === "active"}
- {#if grouped.active.length > 0}
- <button class="clear-btn" onclick={pauseAll} title={$t('downloads.pause_all') as string}>
- {$t('downloads.pause_all')}
- </button>
- {/if}
- {#if grouped.paused.length > 0}
- <button class="clear-btn" onclick={resumeAll} title={$t('downloads.resume_all') as string}>
- {$t('downloads.resume_all')}
- </button>
- {/if}
- {#if finishedCount > 0}
- <button class="clear-btn" onclick={clearFinished}>
- {$t('downloads.clear_finished')}
- </button>
- {/if}
- {:else if historyEntries.length > 0}
- <button class="clear-btn" onclick={clearHistory}>
- {$t('downloads.history_clear')}
- </button>
- {/if}
- <button
- class="history-toggle"
- class:on={viewMode === "history"}
- onclick={toggleHistoryView}
- aria-label={$t('downloads.history_toggle') as string}
- title={$t('downloads.history_toggle_hint') as string}
- >
- <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="12" cy="12" r="9" />
- <polyline points="12 7 12 12 15 14" />
- </svg>
- </button>
- <button
- class="history-toggle"
- class:on={viewMode === "tools"}
- onclick={toggleToolsView}
- aria-label={$t('tools.tab') as string}
- title={$t('tools.tab') as string}
- >
- <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />
- </svg>
- </button>
- </div>
- </div>
-
- {#if viewMode === "active"}
- <div class="filter-pills" role="tablist" aria-label={$t('downloads.filter_label')}>
- {#each [
- { value: 'all', labelKey: 'downloads.filter.all', count: filterCounts.all },
- { value: 'active', labelKey: 'downloads.filter.active', count: filterCounts.active },
- { value: 'queued', labelKey: 'downloads.filter.queued', count: filterCounts.queued },
- { value: 'completed', labelKey: 'downloads.filter.completed', count: filterCounts.completed },
- { value: 'failed', labelKey: 'downloads.filter.failed', count: filterCounts.failed },
- ] as pill}
- <button
- type="button"
- class="filter-pill"
- class:active={statusFilter === pill.value}
- role="tab"
- aria-selected={statusFilter === pill.value}
- onclick={() => { statusFilter = pill.value as StatusFilter; finishedVisibleCount = FINISHED_PAGE_SIZE; }}
- >
- <span>{$t(pill.labelKey)}</span>
- <span class="filter-count">{pill.count}</span>
- </button>
- {/each}
- </div>
-
- <div class="download-list">
- {#if showSection.active}
- {#each grouped.active as item (item.id)}
- {@render genericItem(item)}
- {/each}
-
- {#each grouped.paused as item (item.id)}
- {@render genericItem(item)}
- {/each}
-
- {#each courseList as item (item.id)}
- {@render courseItem(item)}
- {/each}
- {/if}
-
- {#if showSection.queued && grouped.queued.length > 0}
- <h5 class="section-label">
- {$t('downloads.section_queued')}
- {#if grouped.queued.length > 1}
- <span class="queue-reorder-hint">{$t('downloads.reorder_hint')}</span>
- {/if}
- </h5>
- {#each grouped.queued as item (item.id)}
- <div
- class="queue-drop-zone"
- class:drop-before={dropTargetId === item.id && dropPosition === "before"}
- class:drop-after={dropTargetId === item.id && dropPosition === "after"}
- class:dragging={dragId === item.id}
- draggable="true"
- role="listitem"
- ondragstart={(e) => onDragStart(e, item.id)}
- ondragover={(e) => onDragOver(e, item.id)}
- ondragleave={(e) => onDragLeave(e, item.id)}
- ondrop={(e) => onDrop(e, item.id)}
- ondragend={onDragEnd}
- >
- {@render genericItem(item)}
- </div>
- {/each}
- {/if}
-
- {#if (showSection.completed || showSection.failed) && finishedFiltered.length > 0}
- <h5 class="section-label">{$t('downloads.section_finished')}</h5>
- {#each visibleFinished as item (item.id)}
- {@render genericItem(item)}
- {/each}
- {#if finishedFiltered.length > finishedVisibleCount}
- <button
- class="button show-more-btn"
- onclick={() => { finishedVisibleCount += FINISHED_PAGE_SIZE; }}
- >
- {$t('downloads.show_more', { count: finishedFiltered.length - finishedVisibleCount })}
- </button>
- {/if}
- {/if}
- </div>
- {:else if viewMode === "history"}
- <div class="history-view">
- {#if historyLoading}
- <p class="history-empty">{$t('downloads.history_loading')}</p>
- {:else if historyEntries.length === 0}
- <div class="history-empty-state">
- <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <circle cx="12" cy="12" r="9" />
- <polyline points="12 7 12 12 15 14" />
- </svg>
- <p class="history-empty-text">{$t('downloads.history_empty')}</p>
- </div>
- {:else}
- <ul class="history-list">
- {#each historyEntries as entry (entry.id)}
- <li class="history-item" data-success={entry.success}>
- <div class="history-item-head">
- {#if entry.thumbnail_url}
- <img
- src={entry.thumbnail_url}
- alt=""
- class="queue-thumb"
- loading="lazy"
- onerror={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}
- />
- {/if}
- <PlatformIcon platform={entry.platform} size={16} />
- {#if entry.kind}
- <QueueKindBadge kind={entry.kind} size={14} />
- {/if}
- <span class="history-title">{entry.title || entry.url}</span>
- <span class="history-time">{fmtHistoryTime(entry.completed_at)}</span>
- </div>
- <div class="history-item-meta">
- {#if entry.success && entry.file_size_bytes}
- <span class="history-meta-chip">{formatBytes(entry.file_size_bytes)}</span>
- {/if}
- {#if !entry.success && entry.error}
- <span class="history-meta-chip history-meta-error">{entry.error}</span>
- {/if}
- </div>
- <div class="history-item-actions">
- {#if canPlayInStudyHistory(entry) && entry.file_path}
- <button
- class="action-icon-btn"
- onclick={() => openHistoryInStudy(entry.file_path!)}
- aria-label={$t('downloads.open_in_study')}
- title={$t('downloads.open_in_study')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="12" cy="12" r="10" />
- <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />
- </svg>
- </button>
- {/if}
- {#if entry.success && entry.file_path}
- <button
- class="action-icon-btn"
- onclick={() => revealFile(entry.file_path!)}
- aria-label={$t('downloads.open_folder')}
- title={$t('downloads.open_folder')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
- </svg>
- </button>
- {/if}
- {#if entry.success && entry.file_path && entry.kind === "video"}
- <button
- class="action-icon-btn"
- onclick={() => openReencode(entry.file_path!)}
- aria-label={$t('reencode.action_label')}
- title={$t('reencode.action_label')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polyline points="4 14 10 14 10 20" />
- <polyline points="20 10 14 10 14 4" />
- <line x1="14" y1="10" x2="21" y2="3" />
- <line x1="3" y1="21" x2="10" y2="14" />
- </svg>
- </button>
- {/if}
- <button
- class="action-icon-btn"
- onclick={() => historyRetry(entry.url, entry.platform)}
- aria-label={$t('downloads.history_redownload')}
- title={$t('downloads.history_redownload')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polyline points="23 4 23 10 17 10" />
- <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />
- </svg>
- </button>
- </div>
- </li>
- {/each}
- </ul>
- {/if}
- </div>
- {:else}
- <ToolsPanel />
- {/if}
- </div>
-{:else}
- <div class="downloads-empty downloads-mac-empty">
- <Mascot emotion="idle" />
- <p class="empty-text">{$t('downloads.empty')} <ContextHint text={$t('hints.downloads_empty')} dismissKey="downloads_empty" /></p>
- <div class="empty-links">
- <button class="history-link" onclick={toggleHistoryView}>
- <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <circle cx="12" cy="12" r="9" />
- <polyline points="12 7 12 12 15 14" />
- </svg>
- {$t('downloads.history_view_link')}
- </button>
- <button class="history-link" onclick={toggleToolsView}>
- <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
- <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />
- </svg>
- {$t('tools.tab')}
- </button>
- </div>
- </div>
-{/if}
-
-<ReencodeDialog bind:inputPath={reencodePath} />
-
-{#if vopPath}
- <VideoOpsOverlay filePath={vopPath} onClose={() => (vopPath = null)} />
-{/if}
-
-{#snippet genericItem(item: GenericDownloadItem)}
- <div class="download-item" data-status={item.status}>
- <div class="item-header">
- <div class="item-header-left">
- {#if item.thumbnail_url}
- <img
- src={item.thumbnail_url}
- alt=""
- class="queue-thumb"
- loading="lazy"
- onerror={(e) => {
- (e.target as HTMLImageElement).style.display = 'none';
- }}
- />
- {/if}
- <PlatformIcon platform={item.platform} size={16} />
- <QueueKindBadge kind={item.queueKind} size={14} />
- <span class="item-name">{item.name}</span>
- {#if qualityChip(item)}
- <span class="quality-chip" title={$t('downloads.quality_hint')}>{qualityChip(item)}</span>
- {/if}
- </div>
- <div class="item-header-actions">
- {#if item.status === "downloading"}
- <button
- class="action-icon-btn"
- onclick={() => pauseDownload(item.id)}
- aria-label={$t('downloads.pause')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <rect x="6" y="4" width="4" height="16" />
- <rect x="14" y="4" width="4" height="16" />
- </svg>
- </button>
- <button
- class="action-icon-btn"
- onclick={() => cancelGenericDownload(item.id)}
- aria-label={$t('downloads.cancel')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- {:else if item.status === "seeding"}
- {#if item.filePath}
- <button
- class="action-icon-btn"
- onclick={() => revealFile(item.filePath!)}
- aria-label={$t('downloads.open_folder')}
- title={$t('downloads.open_folder')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
- </svg>
- </button>
- {/if}
- <button
- class="action-icon-btn"
- onclick={() => removeItem(item.id)}
- aria-label={$t('downloads.stop')}
- title={$t('downloads.stop')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
- <rect x="6" y="6" width="12" height="12" />
- </svg>
- </button>
- {:else if item.status === "paused"}
- <button
- class="action-icon-btn"
- onclick={() => resumeDownload(item.id)}
- aria-label={$t('downloads.resume')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polygon points="5 3 19 12 5 21 5 3" />
- </svg>
- </button>
- <button
- class="action-icon-btn"
- onclick={() => cancelGenericDownload(item.id)}
- aria-label={$t('downloads.cancel')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- {:else if item.status === "error"}
- <button
- class="action-icon-btn"
- onclick={() => retryDownload(item.id)}
- aria-label={$t('downloads.retry')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polyline points="23 4 23 10 17 10" />
- <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />
- </svg>
- </button>
- <button
- class="action-icon-btn"
- class:confirm-remove={pendingRemove === item.id}
- onclick={() => removeItem(item.id)}
- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
- >
- {#if pendingRemove === item.id}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M5 12l5 5L20 7" />
- </svg>
- {:else}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- {/if}
- </button>
- {:else if item.status === "complete" && item.filePath}
- {#if canOpenInStudy(item)}
- <button
- class="action-icon-btn"
- onclick={() => openInStudy(item.filePath!)}
- aria-label={$t('downloads.open_in_study')}
- title={$t('downloads.open_in_study')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <circle cx="12" cy="12" r="10" />
- <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />
- </svg>
- </button>
- {/if}
- <button
- class="action-icon-btn"
- onclick={() => revealFile(item.filePath!)}
- aria-label={$t('downloads.open_folder')}
- title={$t('downloads.open_folder')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
- </svg>
- </button>
- {#if item.queueKind === "video"}
- <button
- class="action-icon-btn"
- onclick={() => openReencode(item.filePath!)}
- aria-label={$t('reencode.action_label')}
- title={$t('reencode.action_label')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polyline points="4 14 10 14 10 20" />
- <polyline points="20 10 14 10 14 4" />
- <line x1="14" y1="10" x2="21" y2="3" />
- <line x1="3" y1="21" x2="10" y2="14" />
- </svg>
- </button>
- {/if}
- <button
- class="action-icon-btn"
- class:confirm-remove={pendingRemove === item.id}
- onclick={() => removeItem(item.id)}
- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
- >
- {#if pendingRemove === item.id}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M5 12l5 5L20 7" />
- </svg>
- {:else}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- {/if}
- </button>
- {:else if item.status === "complete"}
- {#if item.filePath && item.queueKind === "video"}
- <button
- class="action-icon-btn"
- onclick={() => (vopPath = item.filePath!)}
- aria-label={$t('downloads.vop.action_label')}
- title={$t('downloads.vop.action_label')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M12 2 2 7l10 5 10-5-10-5Z" />
- <path d="m2 17 10 5 10-5M2 12l10 5 10-5" />
- </svg>
- </button>
- {/if}
- {#if item.filePath}
- <button
- class="action-icon-btn"
- onclick={() => removeItemWithFile(item.id)}
- aria-label={$t('downloads.delete_file')}
- title={$t('downloads.delete_file')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <polyline points="3 6 5 6 21 6" />
- <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
- <line x1="10" y1="11" x2="10" y2="17" />
- <line x1="14" y1="11" x2="14" y2="17" />
- </svg>
- </button>
- {/if}
- <button
- class="action-icon-btn"
- class:confirm-remove={pendingRemove === item.id}
- onclick={() => removeItem(item.id)}
- aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
- title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
- >
- {#if pendingRemove === item.id}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M5 12l5 5L20 7" />
- </svg>
- {:else}
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- {/if}
- </button>
- {:else if item.status === "queued"}
- <button
- class="action-icon-btn"
- onclick={() => cancelGenericDownload(item.id)}
- aria-label={$t('downloads.cancel')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- {/if}
- <span class="item-status" data-status={item.status}>
- {$t(`downloads.status.${item.status}`)}
- </span>
- </div>
- </div>
-
- {#if item.status === "downloading"}
- {#if item.phase === "preparing"}
- <span class="item-detail">{$t('downloads.phase_preparing')}</span>
- {:else if item.phase === "fetching_info"}
- <span class="item-detail">{$t('downloads.phase_fetching_info')}</span>
- {:else if item.phase === "starting"}
- <span class="item-detail">{$t('downloads.phase_starting')}</span>
- {:else if item.phase === "connecting"}
- <span class="item-detail">{$t('downloads.phase_connecting')}</span>
- {:else if item.phase === "waiting_rate_limit"}
- <span class="item-detail">
- {#if waitRemaining(item.waitUntil) > 0}
- {$t('downloads.phase_waiting_rate_limit_countdown', { seconds: waitRemaining(item.waitUntil) })}
- {:else}
- {$t('downloads.phase_waiting_rate_limit')}
- {/if}
- </span>
- {:else if item.phase === "merging"}
- <span class="item-detail">{$t('downloads.phase_merging')}</span>
- {:else if item.phase === "extracting_audio"}
- <span class="item-detail">{$t('downloads.phase_extracting_audio')}</span>
- {:else if item.phase === "embedding_subtitles"}
- <span class="item-detail">{$t('downloads.phase_embedding_subtitles')}</span>
- {:else}
- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
- <div class="item-stats">
- {#if item.downloadedBytes > 0}
- <span>
- {formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}
- </span>
- <span class="stats-sep">&middot;</span>
- {/if}
- {#if item.speed > 0}
- <span>{formatSpeed(item.speed)}</span>
- {#if formatEta(item.etaSeconds)}
- <span class="stats-sep">&middot;</span>
- <span>ETA {formatEta(item.etaSeconds)}</span>
- {/if}
- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
- {/if}
- </div>
- {/if}
- {:else if item.status === "seeding"}
- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
- <div class="item-stats">
- {#if item.totalBytes}
- <span>{formatBytes(item.totalBytes)}</span>
- <span class="stats-sep">&middot;</span>
- {/if}
- {#if item.speed > 0}
- <span>{formatSpeed(item.speed)}</span>
- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
- {/if}
- </div>
- {:else if item.status === "paused"}
- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
- {#if item.downloadedBytes > 0}
- <div class="item-stats">
- <span>{formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}</span>
- </div>
- {/if}
- {:else if item.status === "queued"}
- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
- {:else}
- <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
- {/if}
-
- {#if item.status === "complete" && item.totalBytes}
- <span class="item-detail">{formatBytes(item.totalBytes)}</span>
- {/if}
-
- {#if item.status === "error" && item.error}
- <span class="item-error">{translateBackendError(item.error, $t)}</span>
- {/if}
-
- {#if item.status !== "queued"}
- <div class="progress-track">
- <div
- class="progress-fill"
- data-status={item.status}
- style="width: {Math.max(0, item.percent).toFixed(1)}%"
- ></div>
- </div>
- <span class="item-percent">{Math.max(0, item.percent).toFixed(0)}%</span>
- {/if}
-
- {#if item.status !== "queued"}
- <DownloadLog id={item.id} />
- {/if}
- </div>
-{/snippet}
-
-{#snippet courseItem(item: CourseDownloadItem)}
- <div class="download-item" data-status={item.status}>
- <div class="item-header">
- <span class="item-name">{item.name}</span>
- <div class="item-header-actions">
- {#if item.status === "downloading"}
- <button
- class="action-icon-btn"
- onclick={() => cancelDownload(item.id)}
- aria-label={$t('downloads.cancel')}
- >
- <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
- <path d="M18 6L6 18M6 6l12 12" />
- </svg>
- </button>
- {/if}
- <span class="item-status" data-status={item.status}>
- {$t(`downloads.status.${item.status}`)}
- </span>
- </div>
- </div>
-
- {#if item.status === "downloading"}
- {#if item.currentModule}
- <span class="item-detail">
- {item.currentModule} &middot; {item.currentPage}
- </span>
- {/if}
-
- <div class="item-stats">
- {#if item.totalPages > 0}
- <span>{$t('downloads.page_progress', { current: item.completedPages, total: item.totalPages })}</span>
- <span class="stats-sep">&middot;</span>
- <span>{$t('downloads.module_progress', { current: item.currentModuleIndex, total: item.totalModules })}</span>
- {/if}
- {#if item.bytesDownloaded > 0}
- <span class="stats-sep">&middot;</span>
- <span>{formatBytes(item.bytesDownloaded)}</span>
- {/if}
- </div>
-
- <div class="item-stats">
- <span>{formatSpeed(item.speed)}</span>
- {#if item.speed > 0}
- <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
- {/if}
- </div>
- {/if}
-
- {#if item.status === "complete" && item.bytesDownloaded > 0}
- <span class="item-detail">{formatBytes(item.bytesDownloaded)}</span>
- {/if}
-
- {#if item.status === "error" && item.error}
- <span class="item-error">{translateBackendError(item.error, $t)}</span>
- {/if}
-
- <div class="progress-track">
- <div
- class="progress-fill"
- data-status={item.status}
- style="width: {Math.max(0, item.percent).toFixed(1)}%"
- ></div>
- </div>
-
- <span class="item-percent">{Math.max(0, item.percent).toFixed(1)}%</span>
-
- {#if item.status !== "queued"}
- <DownloadLog id={item.id} />
- {/if}
- </div>
-{/snippet}
-
-<style>
- .downloads-empty {
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- min-height: calc(100vh - var(--padding) * 4);
- gap: calc(var(--padding) * 1.5);
- color: var(--gray);
- }
-
- .empty-text {
- font-size: var(--text-base);
- }
-
- .downloads-page {
- display: flex;
- flex-direction: column;
- gap: calc(var(--padding) * 1.5);
- padding: calc(var(--padding) * 1.5);
- max-width: 800px;
- margin: 0 auto;
- width: 100%;
- }
-
- .downloads-page h2 {
- margin-block: 0;
- }
-
- .downloads-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--padding);
- flex-wrap: wrap;
- }
-
- .downloads-stats {
- font-size: 12px;
- color: var(--tertiary);
- font-weight: 400;
- }
-
- .bulk-actions {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 3);
- flex-shrink: 0;
- }
-
- .clear-btn {
- font-size: var(--text-sm);
- font-weight: 500;
- padding: calc(var(--padding) / 3) calc(var(--padding) * 0.75);
- background: var(--button-elevated);
- color: var(--gray);
- border: none;
- border-radius: calc(var(--border-radius) / 2);
- cursor: pointer;
- flex-shrink: 0;
- }
-
- @media (hover: hover) {
- .clear-btn:hover {
- background: var(--button-elevated-hover);
- color: var(--secondary);
- }
- }
-
- .clear-btn:active {
- background: var(--button-elevated-press);
- }
-
- .clear-btn:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .section-label {
- color: var(--gray);
- text-transform: uppercase;
- letter-spacing: 0.5px;
- margin-block: 0;
- padding-top: calc(var(--padding) / 2);
- }
-
- .filter-pills {
- display: flex;
- flex-wrap: wrap;
- gap: 6px;
- margin-bottom: var(--padding);
- }
-
- .filter-pill {
- display: inline-flex;
- align-items: center;
- gap: var(--space-2);
- padding: var(--space-2) var(--space-3);
- font-size: var(--text-sm);
- font-weight: 500;
- border: 1px solid var(--border);
- border-radius: var(--radius-full);
- background: var(--surface);
- color: var(--text-dim);
- cursor: pointer;
- transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
- }
-
- @media (hover: hover) {
- .filter-pill:hover {
- background: var(--surface-hi);
- color: var(--text);
- }
- }
-
- .filter-pill.active {
- background: var(--accent-soft);
- color: var(--accent);
- border-color: transparent;
- }
-
- @media (prefers-reduced-motion: reduce) {
- .filter-pill {
- transition: none;
- }
- }
-
- .filter-pill:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .filter-count {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- min-width: 20px;
- padding: 0 5px;
- font-size: 10px;
- font-weight: 600;
- background: color-mix(in srgb, var(--surface) 70%, var(--bg-overlay));
- border-radius: 9999px;
- }
-
- .filter-pill.active .filter-count {
- background: color-mix(in srgb, var(--on-accent) 22%, transparent);
- }
-
- .download-list {
- display: flex;
- flex-direction: column;
- gap: var(--padding);
- }
-
- .download-item {
- background: var(--surface);
- border: 1px solid var(--border);
- border-radius: var(--radius-md);
- padding: var(--space-3) var(--space-4);
- display: flex;
- flex-direction: column;
- gap: var(--space-1);
- transition: background var(--duration-fast) var(--ease-out);
- }
-
- @media (hover: hover) {
- .download-item:hover {
- background: var(--surface-hi);
- }
- }
-
- .download-item[data-status="queued"] .item-name {
- color: var(--text-muted);
- }
-
- @media (prefers-reduced-motion: reduce) {
- .download-item {
- transition: none;
- }
- }
-
- .item-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: var(--padding);
- }
-
- .item-header-actions {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 2);
- flex-shrink: 0;
- }
-
- .item-header-left {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 2);
- min-width: 0;
- flex: 1;
- }
-
- .queue-thumb {
- width: 48px;
- height: 48px;
- border-radius: 6px;
- object-fit: cover;
- flex-shrink: 0;
- }
-
- .item-name {
- font-size: var(--text-base);
- font-weight: 500;
- color: var(--secondary);
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .action-icon-btn {
- width: 28px;
- height: 28px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: calc(var(--border-radius) / 2);
- background: transparent;
- color: var(--gray);
- border: none;
- cursor: pointer;
- padding: 0;
- }
-
- @media (hover: hover) {
- .action-icon-btn:hover {
- background: var(--button-elevated);
- color: var(--secondary);
- }
- }
-
- .action-icon-btn:active {
- background: var(--button-elevated);
- color: var(--secondary);
- }
-
- .action-icon-btn:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .action-icon-btn svg {
- pointer-events: none;
- }
-
- .action-icon-btn.confirm-remove {
- color: var(--red);
- background: color-mix(in srgb, var(--red) 12%, transparent);
- animation: confirm-pulse 1s ease-in-out infinite;
- }
-
- @keyframes confirm-pulse {
- 0%, 100% { opacity: 1; }
- 50% { opacity: 0.6; }
- }
-
- .item-status {
- font-size: var(--text-xs);
- font-weight: 500;
- height: 20px;
- display: inline-flex;
- align-items: center;
- padding: 0 var(--space-2);
- border-radius: var(--radius-full);
- flex-shrink: 0;
- }
-
- .item-status[data-status="downloading"] {
- background: var(--accent-soft);
- color: var(--accent);
- }
-
- .item-status[data-status="seeding"],
- .item-status[data-status="complete"] {
- background: color-mix(in srgb, var(--success) 16%, transparent);
- color: var(--success);
- }
-
- .item-status[data-status="error"] {
- background: color-mix(in srgb, var(--danger) 16%, transparent);
- color: var(--danger);
- }
-
- .item-status[data-status="queued"] {
- background: var(--surface-hi);
- color: var(--text-dim);
- }
-
- .item-status[data-status="paused"] {
- background: color-mix(in srgb, var(--warning) 16%, transparent);
- color: var(--warning);
- }
-
- .item-detail {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
-
- .item-stats {
- display: flex;
- align-items: center;
- gap: calc(var(--padding) / 3);
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- font-variant-numeric: tabular-nums;
- }
-
- .stats-sep {
- opacity: 0.5;
- }
-
- .item-error {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--red);
- }
-
- .progress-track {
- width: 100%;
- height: 4px;
- background: var(--fill-1);
- border-radius: var(--radius-full);
- overflow: hidden;
- }
-
- .download-item[data-status="complete"] .progress-track,
- .download-item[data-status="complete"] .item-percent {
- display: none;
- }
-
- .progress-fill {
- height: 100%;
- border-radius: var(--radius-full);
- transition: width var(--duration-slow) var(--ease-out);
- }
-
- .progress-fill[data-status="downloading"] {
- background: var(--blue);
- }
-
- .progress-fill[data-status="seeding"] {
- background: var(--green);
- }
-
- .progress-fill[data-status="complete"] {
- background: var(--green);
- }
-
- .progress-fill[data-status="error"] {
- background: var(--red);
- }
-
- .progress-fill[data-status="paused"] {
- background: var(--gray);
- }
-
- .item-percent {
- font-size: var(--text-sm);
- font-weight: 500;
- color: var(--gray);
- font-variant-numeric: tabular-nums;
- }
-
- .quality-chip {
- padding: 1px 7px;
- font-size: 10.5px;
- font-weight: 600;
- line-height: 1.4;
- color: var(--secondary);
- background: var(--button-elevated);
- border: 1px solid var(--button-stroke);
- border-radius: 999px;
- letter-spacing: 0.2px;
- flex-shrink: 0;
- font-variant-numeric: tabular-nums;
- }
-
- .show-more-btn {
- align-self: center;
- font-size: 13px;
- padding: calc(var(--padding) / 2) var(--padding);
- }
-
- .history-toggle {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 26px;
- height: 26px;
- background: transparent;
- border: 1px solid transparent;
- border-radius: calc(var(--border-radius) / 2);
- color: var(--tertiary);
- cursor: pointer;
- flex-shrink: 0;
- }
-
- @media (hover: hover) {
- .history-toggle:hover {
- color: var(--secondary);
- background: var(--button-elevated);
- }
- }
-
- .history-toggle.on {
- color: var(--accent);
- background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent));
- border-color: color-mix(in srgb, var(--accent) 25%, transparent);
- }
-
- .history-toggle:focus-visible {
- outline: var(--focus-ring);
- outline-offset: var(--focus-ring-offset);
- }
-
- .history-view {
- display: flex;
- flex-direction: column;
- gap: 6px;
- }
-
- .history-empty {
- color: var(--tertiary);
- font-size: 13px;
- padding: var(--padding) 0;
- }
-
- .history-empty-state {
- display: flex;
- flex-direction: column;
- align-items: center;
- gap: calc(var(--padding) / 2);
- padding: calc(var(--padding) * 3) var(--padding);
- color: var(--tertiary);
- }
-
- .history-empty-text {
- font-size: 13.5px;
- margin: 0;
- }
-
- .history-list {
- list-style: none;
- margin: 0;
- padding: 0;
- display: flex;
- flex-direction: column;
- gap: 4px;
- }
-
- .history-item {
- display: grid;
- grid-template-columns: 1fr auto;
- grid-template-areas:
- "head actions"
- "meta actions";
- column-gap: calc(var(--padding) / 2);
- align-items: center;
- padding: 8px 10px;
- border-radius: var(--border-radius);
- background: var(--button);
- }
-
- .history-item[data-success="false"] {
- background: color-mix(in srgb, var(--error, #c33) 6%, var(--button));
- }
-
- .history-item-head {
- grid-area: head;
- display: flex;
- align-items: center;
- gap: 8px;
- min-width: 0;
- }
-
- .history-title {
- font-size: 13.5px;
- color: var(--secondary);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- flex: 1;
- min-width: 0;
- }
-
- .history-time {
- font-size: 11.5px;
- color: var(--tertiary);
- flex-shrink: 0;
- }
-
- .history-item-meta {
- grid-area: meta;
- display: flex;
- gap: 6px;
- margin-top: 2px;
- padding-left: 24px;
- }
-
- .history-meta-chip {
- font-size: 11px;
- color: var(--tertiary);
- background: var(--button-elevated);
- padding: 2px 6px;
- border-radius: calc(var(--border-radius) / 2);
- }
-
- .history-meta-error {
- color: var(--error, #c33);
- background: color-mix(in srgb, var(--error, #c33) 12%, transparent);
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 320px;
- }
-
- .history-item-actions {
- grid-area: actions;
- display: flex;
- gap: 2px;
- align-items: center;
- }
-
- .empty-links {
- display: flex;
- gap: 12px;
- flex-wrap: wrap;
- justify-content: center;
- }
- .history-link {
- margin-top: calc(var(--padding) / 2);
- display: inline-flex;
- align-items: center;
- gap: 5px;
- font-size: var(--text-sm);
- color: var(--tertiary);
- background: transparent;
- border: none;
- cursor: pointer;
- padding: 4px 6px;
- border-radius: calc(var(--border-radius) / 2);
- }
-
- @media (hover: hover) {
- .history-link:hover {
- color: var(--secondary);
- background: var(--button);
- }
- }
-
- .queue-reorder-hint {
- font-size: 10.5px;
- font-weight: 400;
- color: var(--tertiary);
- text-transform: none;
- letter-spacing: 0;
- margin-left: 8px;
- }
-
- .queue-drop-zone {
- position: relative;
- cursor: grab;
- transition: opacity 0.12s;
- }
-
- .queue-drop-zone:active {
- cursor: grabbing;
- }
-
- .queue-drop-zone.dragging {
- opacity: 0.4;
- }
-
- .queue-drop-zone.drop-before::before,
- .queue-drop-zone.drop-after::after {
- content: "";
- position: absolute;
- left: 8px;
- right: 8px;
- height: 2px;
- background: var(--accent);
- border-radius: 1px;
- pointer-events: none;
- }
-
- .queue-drop-zone.drop-before::before {
- top: -2px;
- }
-
- .queue-drop-zone.drop-after::after {
- bottom: -2px;
- }
-</style>
+<script lang="ts">
+ import { onMount } from "svelte";
+ import { goto } from "$app/navigation";
+ import { invoke } from "@tauri-apps/api/core";
+ import { pluginInvoke } from "$lib/plugin-invoke";
+ import { t } from "$lib/i18n";
+ import { translateBackendError } from "$lib/error-translate";
+ import { showToast } from "$lib/stores/toast-store.svelte";
+ import {
+ getDownloads,
+ formatBytes,
+ formatSpeed,
+ formatEta,
+ getFinishedCount,
+ getSpeedHistory,
+ type CourseDownloadItem,
+ type GenericDownloadItem,
+ type QueueKind,
+ } from "$lib/stores/download-store.svelte";
+ import { getDownloadStats } from "$lib/stores/download-stats.svelte";
+ import PlatformIcon from "$components/icons/PlatformIcon.svelte";
+ import QueueKindBadge from "$lib/study-components/QueueKindBadge.svelte";
+ import Mascot from "$components/mascot/Mascot.svelte";
+ import ContextHint from "$components/hints/ContextHint.svelte";
+ import DownloadSpeedGraph from "$components/download/DownloadSpeedGraph.svelte";
+ import DownloadLog from "$components/download/DownloadLog.svelte";
+ import ReencodeDialog from "$components/dialog/ReencodeDialog.svelte";
+ import ToolsPanel from "$components/downloads/ToolsPanel.svelte";
+ import VideoOpsOverlay from "$components/downloads/VideoOpsOverlay.svelte";
+ import { locale as i18nLocale } from "$lib/i18n";
+ import { get } from "svelte/store";
+ import timeAgo from "$lib/time-ago";
+
+ let studyAvailable = $state(false);
+
+ onMount(async () => {
+ try {
+ const plugins = await invoke<{
+ id: string;
+ enabled: boolean;
+ loaded: boolean;
+ }[]>("list_plugins");
+ studyAvailable = plugins.some(
+ (p) => p.id === "study" && p.enabled && p.loaded,
+ );
+ } catch {
+ studyAvailable = false;
+ }
+ });
+
+ const VIDEO_EXTENSIONS = new Set([
+ "mp4", "mkv", "webm", "mov", "avi", "ts", "m4v", "flv", "wmv", "mpg", "mpeg", "3gp", "ogv", "m2ts", "mts",
+ ]);
+
+ function fileExtension(path: string): string | null {
+ const name = path.replace(/\\/g, "/").split("/").pop() ?? "";
+ const dot = name.lastIndexOf(".");
+ if (dot <= 0 || dot === name.length - 1) return null;
+ return name.slice(dot + 1).toLowerCase();
+ }
+
+ function isVideoItem(item: GenericDownloadItem): boolean {
+ if (item.filePath && (item.fileCount ?? 1) <= 1) {
+ const ext = fileExtension(item.filePath);
+ if (ext) return VIDEO_EXTENSIONS.has(ext);
+ }
+ if (item.downloadMode === "video") return true;
+ return item.queueKind === "video";
+ }
+
+ function qualityChip(item: GenericDownloadItem): string | null {
+ if (item.downloadMode === "audio") return $t('omnibox.quality_audio') as string;
+ if (!item.quality) return null;
+ const q = item.quality.toLowerCase();
+ if (q === "audio") return $t('omnibox.quality_audio') as string;
+ if (!isVideoItem(item)) return null;
+ if (q === "best" || q === "highest") return $t('omnibox.quality_best_short') as string;
+ return item.quality;
+ }
+
+ function canOpenInStudy(item: GenericDownloadItem): boolean {
+ return (
+ studyAvailable &&
+ item.status === "complete" &&
+ !!item.filePath &&
+ (item.queueKind === "video" || item.queueKind === "audio")
+ );
+ }
+
+ function openInStudy(filePath: string) {
+ const parts = filePath.replace(/\\/g, "/").split("/");
+ const name = parts[parts.length - 1] ?? "";
+ const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;
+ goto(url);
+ }
+
+ let downloads = $derived(getDownloads());
+ let courseList = $derived(
+ [...downloads.values()].filter((d): d is CourseDownloadItem => d.kind === "course")
+ );
+ let genericList = $derived(
+ [...downloads.values()].filter((d): d is GenericDownloadItem => d.kind === "generic")
+ );
+
+ let grouped = $derived.by(() => {
+ const active: GenericDownloadItem[] = [];
+ const paused: GenericDownloadItem[] = [];
+ const queued: GenericDownloadItem[] = [];
+ const finished: GenericDownloadItem[] = [];
+ const errored: GenericDownloadItem[] = [];
+ const completed: GenericDownloadItem[] = [];
+ for (const d of genericList) {
+ if (d.status === "downloading" || d.status === "seeding") active.push(d);
+ else if (d.status === "paused") paused.push(d);
+ else if (d.status === "queued") queued.push(d);
+ else {
+ finished.push(d);
+ if (d.status === "error") errored.push(d);
+ else if (d.status === "complete") completed.push(d);
+ }
+ }
+ return { active, paused, queued, finished, errored, completed };
+ });
+
+ type StatusFilter = "all" | "active" | "queued" | "completed" | "failed";
+ let statusFilter = $state<StatusFilter>("all");
+
+ let filterCounts = $derived({
+ all: genericList.length,
+ active: grouped.active.length + grouped.paused.length,
+ queued: grouped.queued.length,
+ completed: grouped.completed.length,
+ failed: grouped.errored.length,
+ });
+
+ let showSection = $derived({
+ active: statusFilter === "all" || statusFilter === "active",
+ queued: statusFilter === "all" || statusFilter === "queued",
+ completed: statusFilter === "all" || statusFilter === "completed",
+ failed: statusFilter === "all" || statusFilter === "failed",
+ });
+
+ let finishedFiltered = $derived.by(() => {
+ if (statusFilter === "completed") return grouped.completed;
+ if (statusFilter === "failed") return grouped.errored;
+ return grouped.finished;
+ });
+
+ const FINISHED_PAGE_SIZE = 20;
+ let finishedVisibleCount = $state(FINISHED_PAGE_SIZE);
+
+ let visibleFinished = $derived(
+ finishedFiltered.length <= finishedVisibleCount
+ ? finishedFiltered
+ : finishedFiltered.slice(0, finishedVisibleCount)
+ );
+
+ let hasDownloads = $derived(courseList.length > 0 || genericList.length > 0);
+ let finishedCount = $derived(getFinishedCount());
+ let dlStats = $derived(getDownloadStats());
+
+ async function cancelDownload(courseId: number) {
+ try {
+ await pluginInvoke("courses", "cancel_course_download", { courseId });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function cancelGenericDownload(id: number) {
+ try {
+ await invoke("cancel_generic_download", { downloadId: id });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function pauseDownload(id: number) {
+ try {
+ await invoke("pause_download", { downloadId: id });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function resumeDownload(id: number) {
+ try {
+ await invoke("resume_download", { downloadId: id });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function retryDownload(id: number) {
+ try {
+ await invoke("retry_download", { downloadId: id });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ let pendingRemove = $state<number | null>(null);
+ let pendingRemoveTimer = $state<ReturnType<typeof setTimeout> | null>(null);
+
+ function removeItem(id: number) {
+ if (pendingRemove === id) {
+ if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);
+ pendingRemove = null;
+ pendingRemoveTimer = null;
+ invoke("remove_download", { downloadId: id }).catch((e: any) => {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ });
+ } else {
+ if (pendingRemoveTimer) clearTimeout(pendingRemoveTimer);
+ pendingRemove = id;
+ pendingRemoveTimer = setTimeout(() => {
+ pendingRemove = null;
+ pendingRemoveTimer = null;
+ }, 3000);
+ }
+ }
+
+ async function removeItemWithFile(id: number) {
+ if (!confirm($t("downloads.delete_file_confirm"))) return;
+ try {
+ await invoke("remove_download", { downloadId: id, deleteFile: true });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function clearFinished() {
+ if (!confirm($t("downloads.clear_confirm"))) return;
+ try {
+ await invoke("clear_finished_downloads");
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function pauseAll() {
+ try {
+ await invoke("pause_all_downloads");
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function resumeAll() {
+ try {
+ await invoke("resume_all_downloads");
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ async function revealFile(path: string) {
+ try {
+ await invoke("reveal_file", { path });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ let reencodePath = $state<string | null>(null);
+
+ function openReencode(path: string) {
+ reencodePath = path;
+ }
+
+ let vopPath = $state<string | null>(null);
+
+ type HistoryEntry = {
+ id: number;
+ url: string;
+ platform: string;
+ title: string;
+ file_path: string | null;
+ file_size_bytes: number | null;
+ total_bytes: number | null;
+ success: boolean;
+ error: string | null;
+ completed_at: number;
+ thumbnail_url: string | null;
+ kind: QueueKind | null;
+ };
+
+ let viewMode = $state<"active" | "history" | "tools">("active");
+ let historyEntries = $state<HistoryEntry[]>([]);
+ let historyLoading = $state(false);
+
+ async function loadHistory() {
+ historyLoading = true;
+ try {
+ historyEntries = await invoke<HistoryEntry[]>("get_download_history");
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ } finally {
+ historyLoading = false;
+ }
+ }
+
+ async function clearHistory() {
+ if (!confirm($t("downloads.history_clear_confirm") as string)) return;
+ try {
+ await invoke("clear_download_history");
+ historyEntries = [];
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ function toggleHistoryView() {
+ if (viewMode === "history") {
+ viewMode = "active";
+ } else {
+ viewMode = "history";
+ loadHistory();
+ }
+ }
+
+ function toggleToolsView() {
+ viewMode = viewMode === "tools" ? "active" : "tools";
+ }
+
+ async function historyRetry(url: string, platform: string) {
+ try {
+ const settings = (await import("$lib/stores/settings-store.svelte")).getSettings();
+ const outputDir = settings?.download.default_output_dir ?? "";
+ if (!outputDir) {
+ showToast("error", $t("common.error") as string);
+ return;
+ }
+ await invoke("download_from_url", {
+ url,
+ outputDir,
+ downloadMode: null,
+ quality: settings?.download.video_quality ?? "best",
+ formatId: null,
+ referer: null,
+ });
+ viewMode = "active";
+ showToast("info", $t("downloads.history_requeued") as string);
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ function fmtHistoryTime(unixSec: number): string {
+ const ms = unixSec * 1000;
+ const loc = get(i18nLocale) || "en";
+ const lookup = loc.startsWith("pt") ? "pt" : "en";
+ return timeAgo(ms, lookup);
+ }
+
+ function canPlayInStudyHistory(entry: HistoryEntry): boolean {
+ return (
+ studyAvailable &&
+ entry.success &&
+ !!entry.file_path &&
+ (entry.kind === "video" || entry.kind === "audio")
+ );
+ }
+
+ function openHistoryInStudy(filePath: string) {
+ const parts = filePath.replace(/\\/g, "/").split("/");
+ const name = parts[parts.length - 1] ?? "";
+ const url = `/study/watch?path=${encodeURIComponent(filePath)}&name=${encodeURIComponent(name)}`;
+ goto(url);
+ }
+
+ let dragId = $state<number | null>(null);
+ let dropTargetId = $state<number | null>(null);
+ let dropPosition = $state<"before" | "after">("before");
+
+ function onDragStart(e: DragEvent, id: number) {
+ dragId = id;
+ if (e.dataTransfer) {
+ e.dataTransfer.effectAllowed = "move";
+ e.dataTransfer.setData("text/plain", String(id));
+ }
+ }
+
+ function onDragOver(e: DragEvent, id: number) {
+ if (dragId === null || dragId === id) return;
+ e.preventDefault();
+ if (e.dataTransfer) e.dataTransfer.dropEffect = "move";
+ const target = e.currentTarget as HTMLElement;
+ const rect = target.getBoundingClientRect();
+ const midpoint = rect.top + rect.height / 2;
+ dropPosition = e.clientY < midpoint ? "before" : "after";
+ dropTargetId = id;
+ }
+
+ function onDragLeave(e: DragEvent, id: number) {
+ if (dropTargetId === id) {
+ dropTargetId = null;
+ }
+ }
+
+ async function onDrop(e: DragEvent, targetId: number) {
+ e.preventDefault();
+ const movingId = dragId;
+ const position = dropPosition;
+ dragId = null;
+ dropTargetId = null;
+ if (movingId === null || movingId === targetId) return;
+
+ const order = grouped.queued.map((q) => q.id);
+ const fromIdx = order.indexOf(movingId);
+ if (fromIdx === -1) return;
+ order.splice(fromIdx, 1);
+ let targetIdx = order.indexOf(targetId);
+ if (targetIdx === -1) return;
+ if (position === "after") targetIdx += 1;
+ order.splice(targetIdx, 0, movingId);
+
+ try {
+ await invoke<boolean>("reorder_queue", { ids: order });
+ } catch (e: any) {
+ const msg = typeof e === "string" ? e : e.message ?? $t("common.error");
+ showToast("error", msg);
+ }
+ }
+
+ function onDragEnd() {
+ dragId = null;
+ dropTargetId = null;
+ }
+
+ function onKeydown(e: KeyboardEvent) {
+ const target = e.target as HTMLElement | null;
+ const tag = target?.tagName?.toLowerCase();
+ const isEditable =
+ tag === "input" ||
+ tag === "textarea" ||
+ tag === "select" ||
+ target?.isContentEditable;
+ if (isEditable) return;
+ if (e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey && (e.key === "h" || e.key === "H")) {
+ e.preventDefault();
+ toggleHistoryView();
+ }
+ }
+
+ onMount(() => {
+ window.addEventListener("keydown", onKeydown);
+ return () => window.removeEventListener("keydown", onKeydown);
+ });
+
+ // Relógio de 1s, ligado apenas enquanto algum item espera por rate limit.
+ // Sem isso a contagem regressiva ficaria parada até o próximo evento.
+ let nowTick = $state(Date.now());
+
+ let hasWaitingItem = $derived(
+ [...getDownloads().values()].some(
+ (d) => d.kind === "generic" && d.phase === "waiting_rate_limit" && (d.waitUntil ?? 0) > nowTick,
+ ),
+ );
+
+ $effect(() => {
+ if (!hasWaitingItem) return;
+ const timer = setInterval(() => (nowTick = Date.now()), 1000);
+ return () => clearInterval(timer);
+ });
+
+ function waitRemaining(waitUntil: number | null | undefined): number {
+ if (!waitUntil) return 0;
+ return Math.max(0, Math.ceil((waitUntil - nowTick) / 1000));
+ }
+</script>
+
+{#if hasDownloads || viewMode !== "active"}
+ <div class="downloads-page downloads-mac">
+ <div class="downloads-header">
+ {#if dlStats.totalDownloads > 0}
+ <span class="downloads-stats">{$t('downloads.stats_line', { count: String(dlStats.totalDownloads), size: formatBytes(dlStats.totalBytes) })}</span>
+ {/if}
+ <div class="bulk-actions">
+ {#if viewMode === "active"}
+ {#if grouped.active.length > 0}
+ <button class="clear-btn" onclick={pauseAll} title={$t('downloads.pause_all') as string}>
+ {$t('downloads.pause_all')}
+ </button>
+ {/if}
+ {#if grouped.paused.length > 0}
+ <button class="clear-btn" onclick={resumeAll} title={$t('downloads.resume_all') as string}>
+ {$t('downloads.resume_all')}
+ </button>
+ {/if}
+ {#if finishedCount > 0}
+ <button class="clear-btn" onclick={clearFinished}>
+ {$t('downloads.clear_finished')}
+ </button>
+ {/if}
+ {:else if historyEntries.length > 0}
+ <button class="clear-btn" onclick={clearHistory}>
+ {$t('downloads.history_clear')}
+ </button>
+ {/if}
+ <button
+ class="history-toggle"
+ class:on={viewMode === "history"}
+ onclick={toggleHistoryView}
+ aria-label={$t('downloads.history_toggle') as string}
+ title={$t('downloads.history_toggle_hint') as string}
+ >
+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="12" cy="12" r="9" />
+ <polyline points="12 7 12 12 15 14" />
+ </svg>
+ </button>
+ <button
+ class="history-toggle"
+ class:on={viewMode === "tools"}
+ onclick={toggleToolsView}
+ aria-label={$t('tools.tab') as string}
+ title={$t('tools.tab') as string}
+ >
+ <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />
+ </svg>
+ </button>
+ </div>
+ </div>
+
+ {#if viewMode === "active"}
+ <div class="filter-pills" role="tablist" aria-label={$t('downloads.filter_label')}>
+ {#each [
+ { value: 'all', labelKey: 'downloads.filter.all', count: filterCounts.all },
+ { value: 'active', labelKey: 'downloads.filter.active', count: filterCounts.active },
+ { value: 'queued', labelKey: 'downloads.filter.queued', count: filterCounts.queued },
+ { value: 'completed', labelKey: 'downloads.filter.completed', count: filterCounts.completed },
+ { value: 'failed', labelKey: 'downloads.filter.failed', count: filterCounts.failed },
+ ] as pill}
+ <button
+ type="button"
+ class="filter-pill"
+ class:active={statusFilter === pill.value}
+ role="tab"
+ aria-selected={statusFilter === pill.value}
+ onclick={() => { statusFilter = pill.value as StatusFilter; finishedVisibleCount = FINISHED_PAGE_SIZE; }}
+ >
+ <span>{$t(pill.labelKey)}</span>
+ <span class="filter-count">{pill.count}</span>
+ </button>
+ {/each}
+ </div>
+
+ <div class="download-list">
+ {#if showSection.active}
+ {#each grouped.active as item (item.id)}
+ {@render genericItem(item)}
+ {/each}
+
+ {#each grouped.paused as item (item.id)}
+ {@render genericItem(item)}
+ {/each}
+
+ {#each courseList as item (item.id)}
+ {@render courseItem(item)}
+ {/each}
+ {/if}
+
+ {#if showSection.queued && grouped.queued.length > 0}
+ <h5 class="section-label">
+ {$t('downloads.section_queued')}
+ {#if grouped.queued.length > 1}
+ <span class="queue-reorder-hint">{$t('downloads.reorder_hint')}</span>
+ {/if}
+ </h5>
+ {#each grouped.queued as item (item.id)}
+ <div
+ class="queue-drop-zone"
+ class:drop-before={dropTargetId === item.id && dropPosition === "before"}
+ class:drop-after={dropTargetId === item.id && dropPosition === "after"}
+ class:dragging={dragId === item.id}
+ draggable="true"
+ role="listitem"
+ ondragstart={(e) => onDragStart(e, item.id)}
+ ondragover={(e) => onDragOver(e, item.id)}
+ ondragleave={(e) => onDragLeave(e, item.id)}
+ ondrop={(e) => onDrop(e, item.id)}
+ ondragend={onDragEnd}
+ >
+ {@render genericItem(item)}
+ </div>
+ {/each}
+ {/if}
+
+ {#if (showSection.completed || showSection.failed) && finishedFiltered.length > 0}
+ <h5 class="section-label">{$t('downloads.section_finished')}</h5>
+ {#each visibleFinished as item (item.id)}
+ {@render genericItem(item)}
+ {/each}
+ {#if finishedFiltered.length > finishedVisibleCount}
+ <button
+ class="button show-more-btn"
+ onclick={() => { finishedVisibleCount += FINISHED_PAGE_SIZE; }}
+ >
+ {$t('downloads.show_more', { count: finishedFiltered.length - finishedVisibleCount })}
+ </button>
+ {/if}
+ {/if}
+ </div>
+ {:else if viewMode === "history"}
+ <div class="history-view">
+ {#if historyLoading}
+ <p class="history-empty">{$t('downloads.history_loading')}</p>
+ {:else if historyEntries.length === 0}
+ <div class="history-empty-state">
+ <svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="12" r="9" />
+ <polyline points="12 7 12 12 15 14" />
+ </svg>
+ <p class="history-empty-text">{$t('downloads.history_empty')}</p>
+ </div>
+ {:else}
+ <ul class="history-list">
+ {#each historyEntries as entry (entry.id)}
+ <li class="history-item" data-success={entry.success}>
+ <div class="history-item-head">
+ {#if entry.thumbnail_url}
+ <img
+ src={entry.thumbnail_url}
+ alt=""
+ class="queue-thumb"
+ loading="lazy"
+ onerror={(e) => { (e.target as HTMLImageElement).style.display = 'none'; }}
+ />
+ {/if}
+ <PlatformIcon platform={entry.platform} size={16} />
+ {#if entry.kind}
+ <QueueKindBadge kind={entry.kind} size={14} />
+ {/if}
+ <span class="history-title">{entry.title || entry.url}</span>
+ <span class="history-time">{fmtHistoryTime(entry.completed_at)}</span>
+ </div>
+ <div class="history-item-meta">
+ {#if entry.success && entry.file_size_bytes}
+ <span class="history-meta-chip">{formatBytes(entry.file_size_bytes)}</span>
+ {/if}
+ {#if !entry.success && entry.error}
+ <span class="history-meta-chip history-meta-error">{entry.error}</span>
+ {/if}
+ </div>
+ <div class="history-item-actions">
+ {#if canPlayInStudyHistory(entry) && entry.file_path}
+ <button
+ class="action-icon-btn"
+ onclick={() => openHistoryInStudy(entry.file_path!)}
+ aria-label={$t('downloads.open_in_study')}
+ title={$t('downloads.open_in_study')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="12" cy="12" r="10" />
+ <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />
+ </svg>
+ </button>
+ {/if}
+ {#if entry.success && entry.file_path}
+ <button
+ class="action-icon-btn"
+ onclick={() => revealFile(entry.file_path!)}
+ aria-label={$t('downloads.open_folder')}
+ title={$t('downloads.open_folder')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
+ </svg>
+ </button>
+ {/if}
+ {#if entry.success && entry.file_path && entry.kind === "video"}
+ <button
+ class="action-icon-btn"
+ onclick={() => openReencode(entry.file_path!)}
+ aria-label={$t('reencode.action_label')}
+ title={$t('reencode.action_label')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="4 14 10 14 10 20" />
+ <polyline points="20 10 14 10 14 4" />
+ <line x1="14" y1="10" x2="21" y2="3" />
+ <line x1="3" y1="21" x2="10" y2="14" />
+ </svg>
+ </button>
+ {/if}
+ <button
+ class="action-icon-btn"
+ onclick={() => historyRetry(entry.url, entry.platform)}
+ aria-label={$t('downloads.history_redownload')}
+ title={$t('downloads.history_redownload')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="23 4 23 10 17 10" />
+ <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />
+ </svg>
+ </button>
+ </div>
+ </li>
+ {/each}
+ </ul>
+ {/if}
+ </div>
+ {:else}
+ <ToolsPanel />
+ {/if}
+ </div>
+{:else}
+ <div class="downloads-empty downloads-mac-empty">
+ <Mascot emotion="idle" />
+ <p class="empty-text">{$t('downloads.empty')} <ContextHint text={$t('hints.downloads_empty')} dismissKey="downloads_empty" /></p>
+ <div class="empty-links">
+ <button class="history-link" onclick={toggleHistoryView}>
+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <circle cx="12" cy="12" r="9" />
+ <polyline points="12 7 12 12 15 14" />
+ </svg>
+ {$t('downloads.history_view_link')}
+ </button>
+ <button class="history-link" onclick={toggleToolsView}>
+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
+ <path d="M14.7 6.3a4 4 0 0 0-5.4 5.4L3 18l3 3 6.3-6.3a4 4 0 0 0 5.4-5.4l-2.6 2.6-2.4-2.4z" />
+ </svg>
+ {$t('tools.tab')}
+ </button>
+ </div>
+ </div>
+{/if}
+
+<ReencodeDialog bind:inputPath={reencodePath} />
+
+{#if vopPath}
+ <VideoOpsOverlay filePath={vopPath} onClose={() => (vopPath = null)} />
+{/if}
+
+{#snippet genericItem(item: GenericDownloadItem)}
+ <div class="download-item" data-status={item.status}>
+ <div class="item-header">
+ <div class="item-header-left">
+ {#if item.thumbnail_url}
+ <img
+ src={item.thumbnail_url}
+ alt=""
+ class="queue-thumb"
+ loading="lazy"
+ onerror={(e) => {
+ (e.target as HTMLImageElement).style.display = 'none';
+ }}
+ />
+ {/if}
+ <PlatformIcon platform={item.platform} size={16} />
+ <QueueKindBadge kind={item.queueKind} size={14} />
+ <span class="item-name">{item.name}</span>
+ {#if qualityChip(item)}
+ <span class="quality-chip" title={$t('downloads.quality_hint')}>{qualityChip(item)}</span>
+ {/if}
+ </div>
+ <div class="item-header-actions">
+ {#if item.status === "downloading"}
+ <button
+ class="action-icon-btn"
+ onclick={() => pauseDownload(item.id)}
+ aria-label={$t('downloads.pause')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="6" y="4" width="4" height="16" />
+ <rect x="14" y="4" width="4" height="16" />
+ </svg>
+ </button>
+ <button
+ class="action-icon-btn"
+ onclick={() => cancelGenericDownload(item.id)}
+ aria-label={$t('downloads.cancel')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ {:else if item.status === "seeding"}
+ {#if item.filePath}
+ <button
+ class="action-icon-btn"
+ onclick={() => revealFile(item.filePath!)}
+ aria-label={$t('downloads.open_folder')}
+ title={$t('downloads.open_folder')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
+ </svg>
+ </button>
+ {/if}
+ <button
+ class="action-icon-btn"
+ onclick={() => removeItem(item.id)}
+ aria-label={$t('downloads.stop')}
+ title={$t('downloads.stop')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="currentColor">
+ <rect x="6" y="6" width="12" height="12" />
+ </svg>
+ </button>
+ {:else if item.status === "paused"}
+ <button
+ class="action-icon-btn"
+ onclick={() => resumeDownload(item.id)}
+ aria-label={$t('downloads.resume')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polygon points="5 3 19 12 5 21 5 3" />
+ </svg>
+ </button>
+ <button
+ class="action-icon-btn"
+ onclick={() => cancelGenericDownload(item.id)}
+ aria-label={$t('downloads.cancel')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ {:else if item.status === "error"}
+ <button
+ class="action-icon-btn"
+ onclick={() => retryDownload(item.id)}
+ aria-label={$t('downloads.retry')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="23 4 23 10 17 10" />
+ <path d="M20.49 15a9 9 0 11-2.12-9.36L23 10" />
+ </svg>
+ </button>
+ <button
+ class="action-icon-btn"
+ class:confirm-remove={pendingRemove === item.id}
+ onclick={() => removeItem(item.id)}
+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
+ >
+ {#if pendingRemove === item.id}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M5 12l5 5L20 7" />
+ </svg>
+ {:else}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ {/if}
+ </button>
+ {:else if item.status === "complete" && item.filePath}
+ {#if canOpenInStudy(item)}
+ <button
+ class="action-icon-btn"
+ onclick={() => openInStudy(item.filePath!)}
+ aria-label={$t('downloads.open_in_study')}
+ title={$t('downloads.open_in_study')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <circle cx="12" cy="12" r="10" />
+ <polygon points="10 8 16 12 10 16 10 8" fill="currentColor" stroke="none" />
+ </svg>
+ </button>
+ {/if}
+ <button
+ class="action-icon-btn"
+ onclick={() => revealFile(item.filePath!)}
+ aria-label={$t('downloads.open_folder')}
+ title={$t('downloads.open_folder')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z" />
+ </svg>
+ </button>
+ {#if item.queueKind === "video"}
+ <button
+ class="action-icon-btn"
+ onclick={() => openReencode(item.filePath!)}
+ aria-label={$t('reencode.action_label')}
+ title={$t('reencode.action_label')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="4 14 10 14 10 20" />
+ <polyline points="20 10 14 10 14 4" />
+ <line x1="14" y1="10" x2="21" y2="3" />
+ <line x1="3" y1="21" x2="10" y2="14" />
+ </svg>
+ </button>
+ {/if}
+ <button
+ class="action-icon-btn"
+ class:confirm-remove={pendingRemove === item.id}
+ onclick={() => removeItem(item.id)}
+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
+ >
+ {#if pendingRemove === item.id}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M5 12l5 5L20 7" />
+ </svg>
+ {:else}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ {/if}
+ </button>
+ {:else if item.status === "complete"}
+ {#if item.filePath && item.queueKind === "video"}
+ <button
+ class="action-icon-btn"
+ onclick={() => (vopPath = item.filePath!)}
+ aria-label={$t('downloads.vop.action_label')}
+ title={$t('downloads.vop.action_label')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M12 2 2 7l10 5 10-5-10-5Z" />
+ <path d="m2 17 10 5 10-5M2 12l10 5 10-5" />
+ </svg>
+ </button>
+ {/if}
+ {#if item.filePath}
+ <button
+ class="action-icon-btn"
+ onclick={() => removeItemWithFile(item.id)}
+ aria-label={$t('downloads.delete_file')}
+ title={$t('downloads.delete_file')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <polyline points="3 6 5 6 21 6" />
+ <path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
+ <line x1="10" y1="11" x2="10" y2="17" />
+ <line x1="14" y1="11" x2="14" y2="17" />
+ </svg>
+ </button>
+ {/if}
+ <button
+ class="action-icon-btn"
+ class:confirm-remove={pendingRemove === item.id}
+ onclick={() => removeItem(item.id)}
+ aria-label={pendingRemove === item.id ? $t('downloads.confirm_remove') : $t('common.close')}
+ title={pendingRemove === item.id ? $t('downloads.confirm_remove') : undefined}
+ >
+ {#if pendingRemove === item.id}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M5 12l5 5L20 7" />
+ </svg>
+ {:else}
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ {/if}
+ </button>
+ {:else if item.status === "queued"}
+ <button
+ class="action-icon-btn"
+ onclick={() => cancelGenericDownload(item.id)}
+ aria-label={$t('downloads.cancel')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ {/if}
+ <span class="item-status" data-status={item.status}>
+ {$t(`downloads.status.${item.status}`)}
+ </span>
+ </div>
+ </div>
+
+ {#if item.status === "downloading"}
+ {#if item.phase === "preparing"}
+ <span class="item-detail">{$t('downloads.phase_preparing')}</span>
+ {:else if item.phase === "fetching_info"}
+ <span class="item-detail">{$t('downloads.phase_fetching_info')}</span>
+ {:else if item.phase === "starting"}
+ <span class="item-detail">{$t('downloads.phase_starting')}</span>
+ {:else if item.phase === "connecting"}
+ <span class="item-detail">{$t('downloads.phase_connecting')}</span>
+ {:else if item.phase === "waiting_rate_limit"}
+ <span class="item-detail">
+ {#if waitRemaining(item.waitUntil) > 0}
+ {$t('downloads.phase_waiting_rate_limit_countdown', { seconds: waitRemaining(item.waitUntil) })}
+ {:else}
+ {$t('downloads.phase_waiting_rate_limit')}
+ {/if}
+ </span>
+ {:else if item.phase === "merging"}
+ <span class="item-detail">{$t('downloads.phase_merging')}</span>
+ {:else if item.phase === "extracting_audio"}
+ <span class="item-detail">{$t('downloads.phase_extracting_audio')}</span>
+ {:else if item.phase === "embedding_subtitles"}
+ <span class="item-detail">{$t('downloads.phase_embedding_subtitles')}</span>
+ {:else}
+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
+ <div class="item-stats">
+ {#if item.downloadedBytes > 0}
+ <span>
+ {formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}
+ </span>
+ <span class="stats-sep">&middot;</span>
+ {/if}
+ {#if item.speed > 0}
+ <span>{formatSpeed(item.speed)}</span>
+ {#if formatEta(item.etaSeconds)}
+ <span class="stats-sep">&middot;</span>
+ <span>ETA {formatEta(item.etaSeconds)}</span>
+ {/if}
+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
+ {/if}
+ </div>
+ {/if}
+ {:else if item.status === "seeding"}
+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
+ <div class="item-stats">
+ {#if item.totalBytes}
+ <span>{formatBytes(item.totalBytes)}</span>
+ <span class="stats-sep">&middot;</span>
+ {/if}
+ {#if item.speed > 0}
+ <span>{formatSpeed(item.speed)}</span>
+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
+ {/if}
+ </div>
+ {:else if item.status === "paused"}
+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
+ {#if item.downloadedBytes > 0}
+ <div class="item-stats">
+ <span>{formatBytes(item.downloadedBytes)}{#if item.totalBytes} / {formatBytes(item.totalBytes)}{/if}</span>
+ </div>
+ {/if}
+ {:else if item.status === "queued"}
+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
+ {:else}
+ <span class="item-detail">{item.platform.charAt(0).toUpperCase() + item.platform.slice(1)}</span>
+ {/if}
+
+ {#if item.status === "complete" && item.totalBytes}
+ <span class="item-detail">{formatBytes(item.totalBytes)}</span>
+ {/if}
+
+ {#if item.status === "error" && item.error}
+ <span class="item-error">{translateBackendError(item.error, $t)}</span>
+ {/if}
+
+ {#if item.status !== "queued"}
+ <div class="progress-track">
+ <div
+ class="progress-fill"
+ data-status={item.status}
+ style="width: {Math.max(0, item.percent).toFixed(1)}%"
+ ></div>
+ </div>
+ <span class="item-percent">{Math.max(0, item.percent).toFixed(0)}%</span>
+ {/if}
+
+ {#if item.status !== "queued"}
+ <DownloadLog id={item.id} />
+ {/if}
+ </div>
+{/snippet}
+
+{#snippet courseItem(item: CourseDownloadItem)}
+ <div class="download-item" data-status={item.status}>
+ <div class="item-header">
+ <span class="item-name">{item.name}</span>
+ <div class="item-header-actions">
+ {#if item.status === "downloading"}
+ <button
+ class="action-icon-btn"
+ onclick={() => cancelDownload(item.id)}
+ aria-label={$t('downloads.cancel')}
+ >
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+ <path d="M18 6L6 18M6 6l12 12" />
+ </svg>
+ </button>
+ {/if}
+ <span class="item-status" data-status={item.status}>
+ {$t(`downloads.status.${item.status}`)}
+ </span>
+ </div>
+ </div>
+
+ {#if item.status === "downloading"}
+ {#if item.currentModule}
+ <span class="item-detail">
+ {item.currentModule} &middot; {item.currentPage}
+ </span>
+ {/if}
+
+ <div class="item-stats">
+ {#if item.totalPages > 0}
+ <span>{$t('downloads.page_progress', { current: item.completedPages, total: item.totalPages })}</span>
+ <span class="stats-sep">&middot;</span>
+ <span>{$t('downloads.module_progress', { current: item.currentModuleIndex, total: item.totalModules })}</span>
+ {/if}
+ {#if item.bytesDownloaded > 0}
+ <span class="stats-sep">&middot;</span>
+ <span>{formatBytes(item.bytesDownloaded)}</span>
+ {/if}
+ </div>
+
+ <div class="item-stats">
+ <span>{formatSpeed(item.speed)}</span>
+ {#if item.speed > 0}
+ <DownloadSpeedGraph points={getSpeedHistory(item.id)} />
+ {/if}
+ </div>
+ {/if}
+
+ {#if item.status === "complete" && item.bytesDownloaded > 0}
+ <span class="item-detail">{formatBytes(item.bytesDownloaded)}</span>
+ {/if}
+
+ {#if item.status === "error" && item.error}
+ <span class="item-error">{translateBackendError(item.error, $t)}</span>
+ {/if}
+
+ <div class="progress-track">
+ <div
+ class="progress-fill"
+ data-status={item.status}
+ style="width: {Math.max(0, item.percent).toFixed(1)}%"
+ ></div>
+ </div>
+
+ <span class="item-percent">{Math.max(0, item.percent).toFixed(1)}%</span>
+
+ {#if item.status !== "queued"}
+ <DownloadLog id={item.id} />
+ {/if}
+ </div>
+{/snippet}
+
+<style>
+ .downloads-empty {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ min-height: calc(100vh - var(--padding) * 4);
+ gap: calc(var(--padding) * 1.5);
+ color: var(--gray);
+ }
+
+ .empty-text {
+ font-size: var(--text-base);
+ }
+
+ .downloads-page {
+ display: flex;
+ flex-direction: column;
+ gap: calc(var(--padding) * 1.5);
+ padding: calc(var(--padding) * 1.5);
+ max-width: 800px;
+ margin: 0 auto;
+ width: 100%;
+ }
+
+ .downloads-page h2 {
+ margin-block: 0;
+ }
+
+ .downloads-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--padding);
+ flex-wrap: wrap;
+ }
+
+ .downloads-stats {
+ font-size: 12px;
+ color: var(--tertiary);
+ font-weight: 400;
+ }
+
+ .bulk-actions {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 3);
+ flex-shrink: 0;
+ }
+
+ .clear-btn {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ padding: calc(var(--padding) / 3) calc(var(--padding) * 0.75);
+ background: var(--button-elevated);
+ color: var(--gray);
+ border: none;
+ border-radius: calc(var(--border-radius) / 2);
+ cursor: pointer;
+ flex-shrink: 0;
+ }
+
+ @media (hover: hover) {
+ .clear-btn:hover {
+ background: var(--button-elevated-hover);
+ color: var(--secondary);
+ }
+ }
+
+ .clear-btn:active {
+ background: var(--button-elevated-press);
+ }
+
+ .clear-btn:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+ }
+
+ .section-label {
+ color: var(--gray);
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ margin-block: 0;
+ padding-top: calc(var(--padding) / 2);
+ }
+
+ .filter-pills {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+ margin-bottom: var(--padding);
+ }
+
+ .filter-pill {
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-2);
+ padding: var(--space-2) var(--space-3);
+ font-size: var(--text-sm);
+ font-weight: 500;
+ border: 1px solid var(--border);
+ border-radius: var(--radius-full);
+ background: var(--surface);
+ color: var(--text-dim);
+ cursor: pointer;
+ transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
+ }
+
+ @media (hover: hover) {
+ .filter-pill:hover {
+ background: var(--surface-hi);
+ color: var(--text);
+ }
+ }
+
+ .filter-pill.active {
+ background: var(--accent-soft);
+ color: var(--accent);
+ border-color: transparent;
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .filter-pill {
+ transition: none;
+ }
+ }
+
+ .filter-pill:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+ }
+
+ .filter-count {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ min-width: 20px;
+ padding: 0 5px;
+ font-size: 10px;
+ font-weight: 600;
+ background: color-mix(in srgb, var(--surface) 70%, var(--bg-overlay));
+ border-radius: 9999px;
+ }
+
+ .filter-pill.active .filter-count {
+ background: color-mix(in srgb, var(--on-accent) 22%, transparent);
+ }
+
+ .download-list {
+ display: flex;
+ flex-direction: column;
+ gap: var(--padding);
+ }
+
+ .download-item {
+ background: var(--surface);
+ border: 1px solid var(--border);
+ border-radius: var(--radius-md);
+ padding: var(--space-3) var(--space-4);
+ display: flex;
+ flex-direction: column;
+ gap: var(--space-1);
+ transition: background var(--duration-fast) var(--ease-out);
+ }
+
+ @media (hover: hover) {
+ .download-item:hover {
+ background: var(--surface-hi);
+ }
+ }
+
+ .download-item[data-status="queued"] .item-name {
+ color: var(--text-muted);
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ .download-item {
+ transition: none;
+ }
+ }
+
+ .item-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: var(--padding);
+ }
+
+ .item-header-actions {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 2);
+ flex-shrink: 0;
+ }
+
+ .item-header-left {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 2);
+ min-width: 0;
+ flex: 1;
+ }
+
+ .queue-thumb {
+ width: 48px;
+ height: 48px;
+ border-radius: 6px;
+ object-fit: cover;
+ flex-shrink: 0;
+ }
+
+ .item-name {
+ font-size: var(--text-base);
+ font-weight: 500;
+ color: var(--secondary);
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .action-icon-btn {
+ width: 28px;
+ height: 28px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border-radius: calc(var(--border-radius) / 2);
+ background: transparent;
+ color: var(--gray);
+ border: none;
+ cursor: pointer;
+ padding: 0;
+ }
+
+ @media (hover: hover) {
+ .action-icon-btn:hover {
+ background: var(--button-elevated);
+ color: var(--secondary);
+ }
+ }
+
+ .action-icon-btn:active {
+ background: var(--button-elevated);
+ color: var(--secondary);
+ }
+
+ .action-icon-btn:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+ }
+
+ .action-icon-btn svg {
+ pointer-events: none;
+ }
+
+ .action-icon-btn.confirm-remove {
+ color: var(--red);
+ background: color-mix(in srgb, var(--red) 12%, transparent);
+ animation: confirm-pulse 1s ease-in-out infinite;
+ }
+
+ @keyframes confirm-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.6; }
+ }
+
+ .item-status {
+ font-size: var(--text-xs);
+ font-weight: 500;
+ height: 20px;
+ display: inline-flex;
+ align-items: center;
+ padding: 0 var(--space-2);
+ border-radius: var(--radius-full);
+ flex-shrink: 0;
+ }
+
+ .item-status[data-status="downloading"] {
+ background: var(--accent-soft);
+ color: var(--accent);
+ }
+
+ .item-status[data-status="seeding"],
+ .item-status[data-status="complete"] {
+ background: color-mix(in srgb, var(--success) 16%, transparent);
+ color: var(--success);
+ }
+
+ .item-status[data-status="error"] {
+ background: color-mix(in srgb, var(--danger) 16%, transparent);
+ color: var(--danger);
+ }
+
+ .item-status[data-status="queued"] {
+ background: var(--surface-hi);
+ color: var(--text-dim);
+ }
+
+ .item-status[data-status="paused"] {
+ background: color-mix(in srgb, var(--warning) 16%, transparent);
+ color: var(--warning);
+ }
+
+ .item-detail {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+
+ .item-stats {
+ display: flex;
+ align-items: center;
+ gap: calc(var(--padding) / 3);
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ font-variant-numeric: tabular-nums;
+ }
+
+ .stats-sep {
+ opacity: 0.5;
+ }
+
+ .item-error {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--red);
+ }
+
+ .progress-track {
+ width: 100%;
+ height: 4px;
+ background: var(--fill-1);
+ border-radius: var(--radius-full);
+ overflow: hidden;
+ }
+
+ .download-item[data-status="complete"] .progress-track,
+ .download-item[data-status="complete"] .item-percent {
+ display: none;
+ }
+
+ .progress-fill {
+ height: 100%;
+ border-radius: var(--radius-full);
+ transition: width var(--duration-slow) var(--ease-out);
+ }
+
+ .progress-fill[data-status="downloading"] {
+ background: var(--blue);
+ }
+
+ .progress-fill[data-status="seeding"] {
+ background: var(--green);
+ }
+
+ .progress-fill[data-status="complete"] {
+ background: var(--green);
+ }
+
+ .progress-fill[data-status="error"] {
+ background: var(--red);
+ }
+
+ .progress-fill[data-status="paused"] {
+ background: var(--gray);
+ }
+
+ .item-percent {
+ font-size: var(--text-sm);
+ font-weight: 500;
+ color: var(--gray);
+ font-variant-numeric: tabular-nums;
+ }
+
+ .quality-chip {
+ padding: 1px 7px;
+ font-size: 10.5px;
+ font-weight: 600;
+ line-height: 1.4;
+ color: var(--secondary);
+ background: var(--button-elevated);
+ border: 1px solid var(--button-stroke);
+ border-radius: 999px;
+ letter-spacing: 0.2px;
+ flex-shrink: 0;
+ font-variant-numeric: tabular-nums;
+ }
+
+ .show-more-btn {
+ align-self: center;
+ font-size: 13px;
+ padding: calc(var(--padding) / 2) var(--padding);
+ }
+
+ .history-toggle {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 26px;
+ height: 26px;
+ background: transparent;
+ border: 1px solid transparent;
+ border-radius: calc(var(--border-radius) / 2);
+ color: var(--tertiary);
+ cursor: pointer;
+ flex-shrink: 0;
+ }
+
+ @media (hover: hover) {
+ .history-toggle:hover {
+ color: var(--secondary);
+ background: var(--button-elevated);
+ }
+ }
+
+ .history-toggle.on {
+ color: var(--accent);
+ background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent));
+ border-color: color-mix(in srgb, var(--accent) 25%, transparent);
+ }
+
+ .history-toggle:focus-visible {
+ outline: var(--focus-ring);
+ outline-offset: var(--focus-ring-offset);
+ }
+
+ .history-view {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ }
+
+ .history-empty {
+ color: var(--tertiary);
+ font-size: 13px;
+ padding: var(--padding) 0;
+ }
+
+ .history-empty-state {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: calc(var(--padding) / 2);
+ padding: calc(var(--padding) * 3) var(--padding);
+ color: var(--tertiary);
+ }
+
+ .history-empty-text {
+ font-size: 13.5px;
+ margin: 0;
+ }
+
+ .history-list {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ }
+
+ .history-item {
+ display: grid;
+ grid-template-columns: 1fr auto;
+ grid-template-areas:
+ "head actions"
+ "meta actions";
+ column-gap: calc(var(--padding) / 2);
+ align-items: center;
+ padding: 8px 10px;
+ border-radius: var(--border-radius);
+ background: var(--button);
+ }
+
+ .history-item[data-success="false"] {
+ background: color-mix(in srgb, var(--error, #c33) 6%, var(--button));
+ }
+
+ .history-item-head {
+ grid-area: head;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ min-width: 0;
+ }
+
+ .history-title {
+ font-size: 13.5px;
+ color: var(--secondary);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ flex: 1;
+ min-width: 0;
+ }
+
+ .history-time {
+ font-size: 11.5px;
+ color: var(--tertiary);
+ flex-shrink: 0;
+ }
+
+ .history-item-meta {
+ grid-area: meta;
+ display: flex;
+ gap: 6px;
+ margin-top: 2px;
+ padding-left: 24px;
+ }
+
+ .history-meta-chip {
+ font-size: 11px;
+ color: var(--tertiary);
+ background: var(--button-elevated);
+ padding: 2px 6px;
+ border-radius: calc(var(--border-radius) / 2);
+ }
+
+ .history-meta-error {
+ color: var(--error, #c33);
+ background: color-mix(in srgb, var(--error, #c33) 12%, transparent);
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ max-width: 320px;
+ }
+
+ .history-item-actions {
+ grid-area: actions;
+ display: flex;
+ gap: 2px;
+ align-items: center;
+ }
+
+ .empty-links {
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ justify-content: center;
+ }
+ .history-link {
+ margin-top: calc(var(--padding) / 2);
+ display: inline-flex;
+ align-items: center;
+ min-height: 24px;
+ gap: 5px;
+ font-size: var(--text-sm);
+ color: var(--tertiary);
+ background: transparent;
+ border: none;
+ cursor: pointer;
+ padding: 4px 6px;
+ border-radius: calc(var(--border-radius) / 2);
+ }
+
+ @media (hover: hover) {
+ .history-link:hover {
+ color: var(--secondary);
+ background: var(--button);
+ }
+ }
+
+ .queue-reorder-hint {
+ font-size: 10.5px;
+ font-weight: 400;
+ color: var(--tertiary);
+ text-transform: none;
+ letter-spacing: 0;
+ margin-left: 8px;
+ }
+
+ .queue-drop-zone {
+ position: relative;
+ cursor: grab;
+ transition: opacity 0.12s;
+ }
+
+ .queue-drop-zone:active {
+ cursor: grabbing;
+ }
+
+ .queue-drop-zone.dragging {
+ opacity: 0.4;
+ }
+
+ .queue-drop-zone.drop-before::before,
+ .queue-drop-zone.drop-after::after {
+ content: "";
+ position: absolute;
+ left: 8px;
+ right: 8px;
+ height: 2px;
+ background: var(--accent);
+ border-radius: 1px;
+ pointer-events: none;
+ }
+
+ .queue-drop-zone.drop-before::before {
+ top: -2px;
+ }
+
+ .queue-drop-zone.drop-after::after {
+ bottom: -2px;
+ }
+</style>
diff --git a/src/routes/marketplace/+page.svelte b/src/routes/marketplace/+page.svelte
index b0c0d138..ef68095b 100644
--- a/src/routes/marketplace/+page.svelte
+++ b/src/routes/marketplace/+page.svelte
@@ -910,4 +910,14 @@
color: var(--green);
pointer-events: none;
}
+ @media (prefers-reduced-motion: reduce) {
+ .loading :global(.spinner) {
+ animation: mp-soft-pulse calc(var(--duration-bounce) * 3) var(--ease-in-out) infinite;
+ }
+ }
+
+ @keyframes mp-soft-pulse {
+ 0%, 100% { opacity: 1; }
+ 50% { opacity: 0.45; }
+ }
</style>
diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
index ca8aa9c0..15188e52 100644
--- a/src/routes/settings/+page.svelte
+++ b/src/routes/settings/+page.svelte
@@ -1,609 +1,609 @@
-<script lang="ts">
- import { tick } from "svelte";
- import { invoke } from "@tauri-apps/api/core";
- import { open } from "@tauri-apps/plugin-dialog";
- import { t, locale, loadTranslations } from "$lib/i18n";
- import { getSettings, updateSettings, resetSettings } from "$lib/stores/settings-store.svelte";
- import { getUpdateInfo } from "$lib/stores/update-store.svelte";
- import { installUpdate } from "$lib/updater";
- import { showToast } from "$lib/stores/toast-store.svelte";
- import { refreshYtdlpStatus } from "$lib/stores/dependency-store.svelte";
- import { isDebugEnabled, setDebugEnabled, setDebugPanelOpen } from "$lib/stores/debug-store.svelte";
- import ContextHint from "$components/hints/ContextHint.svelte";
- import SettingsPlugins from "$components/settings/SettingsPlugins.svelte";
- import SettingsAdvanced from "$components/settings/SettingsAdvanced.svelte";
- import SettingsAppearance from "$components/settings/SettingsAppearance.svelte";
- import SettingsNetwork from "$components/settings/SettingsNetwork.svelte";
- import SettingsDownloads from "$components/settings/SettingsDownloads.svelte";
- import SettingsTypography from "$components/settings/SettingsTypography.svelte";
- import SettingsBrowserExtension from "$components/settings/SettingsBrowserExtension.svelte";
- import SettingsCookies from "$components/settings/SettingsCookies.svelte";
- import SettingsChannels from "$components/settings/SettingsChannels.svelte";
- import SettingsAI from "$components/settings/SettingsAI.svelte";
-
- type DependencyStatus = {
- name: string;
- installed: boolean;
- version: string | null;
- outdated: boolean;
- };
-
- let settings = $derived(getSettings());
- let updateInfo = $derived(getUpdateInfo());
- let isWindows = typeof navigator !== "undefined" && navigator.userAgent.includes("Windows");
- let resetting = $state(false);
- let updating = $state(false);
- let deps = $state<DependencyStatus[]>([]);
- let installingDep = $state<string | null>(null);
-
- async function loadDeps() {
- try {
- deps = await invoke<DependencyStatus[]>("check_dependencies");
- } catch {}
- }
-
- async function chooseCookieFile() {
- const selected = await open({
- title: "Select cookies.txt file",
- filters: [{ name: "Cookies", extensions: ["txt"] }],
- multiple: false,
- });
- if (selected && typeof selected === "string") {
- await updateSettings({ download: { cookie_file: selected } });
- }
- }
-
- async function handleInstallDep(name: string, variant: string | null = null) {
- const wasInstalled = deps.find((d) => d.name === name)?.installed ?? false;
- installingDep = name;
- try {
- const version = await invoke<string>("install_dependency", { name, variant, force: wasInstalled });
- await loadDeps();
- await refreshYtdlpStatus();
- showToast(
- "success",
- $t(
- wasInstalled ? "settings.dependencies.update_success" : "settings.dependencies.install_success",
- { name, version },
- ) as string,
- );
- } catch (e: any) {
- showToast("error", typeof e === "string" ? e : e.message ?? $t("common.error"));
- } finally {
- installingDep = null;
- }
- }
-
- $effect(() => {
- if (settings) {
- loadDeps();
- }
- });
-
- async function handleUpdate() {
- updating = true;
- try {
- await installUpdate();
- } catch {
- updating = false;
- }
- }
-
- async function changeTheme(value: string) {
- await updateSettings({ appearance: { theme: value } });
- }
-
- const CORE_THEMES = [
- { id: "system", labelKey: "settings.appearance.theme_system", colors: null as string[] | null },
- { id: "light", labelKey: null, label: "Light", colors: ["#fafafa", "#1a1a1a", "#E05500"] },
- { id: "dark", labelKey: null, label: "Dark", colors: ["#0a0a0a", "#e8e8e8", "#FF7D38"] },
- ];
- const MORE_THEMES = [
- { id: "catppuccin-latte", label: "Catppuccin Latte", colors: ["#eff1f5", "#4c4f69", "#1e66f5"] },
- { id: "catppuccin-frappe", label: "Catppuccin Frappé", colors: ["#303446", "#c6d0f5", "#8caaee"] },
- { id: "catppuccin-macchiato", label: "Catppuccin Macchiato", colors: ["#24273a", "#cad3f5", "#8aadf4"] },
- { id: "catppuccin-mocha", label: "Catppuccin Mocha", colors: ["#1e1e2e", "#cdd6f4", "#89b4fa"] },
- { id: "one-dark-pro", label: "One Dark Pro", colors: ["#282c34", "#abb2bf", "#61afef"] },
- { id: "dracula", label: "Dracula", colors: ["#22212C", "#F8F8F2", "#9580FF"] },
- { id: "nyxvamp-veil", label: "NyxVamp Veil", colors: ["#1E1E2E", "#D9E0EE", "#F28FAD"] },
- { id: "nyxvamp-obsidian", label: "NyxVamp Obsidian", colors: ["#000A0F", "#C0C0CE", "#F28FAD"] },
- { id: "nyxvamp-radiance", label: "NyxVamp Radiance", colors: ["#F7F7FF", "#1E1E2E", "#9655FF"] },
- { id: "eink-day", label: "E-ink Day", colors: ["#f5f2ea", "#1d1d1b", "#2b2b28"] },
- { id: "eink-sepia", label: "E-ink Sepia", colors: ["#f0e6d2", "#3f2e20", "#7a4a22"] },
- { id: "eink-night", label: "E-ink Night", colors: ["#0a0a0a", "#d4d4d0", "#b0b0ab"] },
- ];
- const MORE_THEME_IDS = new Set(MORE_THEMES.map((t) => t.id));
- let selectedInMore = $derived(MORE_THEME_IDS.has(settings?.appearance?.theme ?? ""));
-
- async function changeLanguage(e: Event) {
- const value = (e.target as HTMLSelectElement).value;
- await updateSettings({ appearance: { language: value } });
- await loadTranslations(value, "/settings");
- locale.set(value);
- }
-
- async function chooseFolder() {
- const selected = await open({ directory: true, title: $t("settings.download.default_output_dir") });
- if (selected) {
- await updateSettings({ download: { default_output_dir: selected } });
- }
- }
-
- async function toggleBool(section: string, key: string, current: boolean) {
- await updateSettings({ [section]: { [key]: !current } });
- }
-
- async function changeNumber(section: string, key: string, e: Event) {
- const value = parseInt((e.target as HTMLInputElement).value, 10);
- if (!isNaN(value) && value > 0) {
- await updateSettings({ [section]: { [key]: value } });
- if (key === "max_concurrent_downloads") {
- try {
- await invoke("update_max_concurrent", { max: value });
- } catch {}
- }
- }
- }
-
- async function changeQuality(e: Event) {
- const value = (e.target as HTMLSelectElement).value;
- await updateSettings({ download: { video_quality: value } });
- }
-
- type SettingsCategory = "downloads" | "appearance" | "typography" | "network" | "cookies" | "channels" | "ai" | "plugins" | "advanced";
-
- const SETTINGS_NAV_GROUPS: {
- labelKey: string;
- items: [SettingsCategory, string][];
- }[] = [
- {
- labelKey: "settings.group_general",
- items: [
- ["appearance", "settings.cat_appearance"],
- ["typography", "settings.cat_typography"],
- ],
- },
- {
- labelKey: "settings.group_media",
- items: [["downloads", "settings.cat_downloads"]],
- },
- {
- labelKey: "settings.group_integrations",
- items: [
- ["network", "settings.cat_network"],
- ["cookies", "settings.cat_cookies"],
- ["channels", "settings.cat_channels"],
- ["ai", "settings.cat_ai"],
- ["plugins", "settings.cat_plugins"],
- ],
- },
- {
- labelKey: "settings.group_advanced",
- items: [["advanced", "settings.cat_advanced"]],
- },
- ];
-
- let activeCategory = $state<SettingsCategory>("downloads");
-
- let tabApplied = false;
- $effect(() => {
- if (tabApplied || typeof window === "undefined") return;
- tabApplied = true;
- const tab = new URLSearchParams(window.location.search).get("tab");
- const valid = ["downloads", "appearance", "typography", "network", "cookies", "channels", "ai", "plugins", "advanced"];
- if (tab && valid.includes(tab)) {
- activeCategory = tab as SettingsCategory;
- }
- });
-
- let searchQuery = $state("");
- let normalizedQuery = $derived(searchQuery.trim().toLowerCase());
- let isSearching = $derived(normalizedQuery.length > 0);
- let categoryMatchCounts = $state<Partial<Record<SettingsCategory, number>>>({});
-
- const PANEL_MATCH_SELECTORS =
- ".setting-row, .preset-card, .settings-section-head, .section-title, .deps-table-row";
-
- function clearSearchHighlights(root: ParentNode) {
- root.querySelectorAll("mark.settings-search-hit").forEach((mark) => {
- const parent = mark.parentNode;
- if (!parent) return;
- parent.replaceChild(document.createTextNode(mark.textContent ?? ""), mark);
- parent.normalize();
- });
- }
-
- function highlightPlainText(el: HTMLElement, query: string) {
- if (el.children.length > 0) return;
- const text = el.textContent ?? "";
- const lower = text.toLowerCase();
- const idx = lower.indexOf(query);
- if (idx === -1) return;
- const before = text.slice(0, idx);
- const match = text.slice(idx, idx + query.length);
- const after = text.slice(idx + query.length);
- el.textContent = "";
- if (before) el.appendChild(document.createTextNode(before));
- const mark = document.createElement("mark");
- mark.className = "settings-search-hit";
- mark.textContent = match;
- el.appendChild(mark);
- if (after) el.appendChild(document.createTextNode(after));
- }
-
- function applySearchHighlights(container: HTMLElement, query: string) {
- clearSearchHighlights(container);
- if (!query) return;
- const highlightSelectors =
- ".setting-path, .settings-section-hint, .preset-desc, .preset-label";
- container.querySelectorAll<HTMLElement>(highlightSelectors).forEach((el) => {
- if (el.style.display === "none") return;
- highlightPlainText(el, query);
- });
- container.querySelectorAll<HTMLElement>(".setting-label").forEach((el) => {
- if (el.style.display === "none" || el.children.length > 0) return;
- highlightPlainText(el, query);
- });
- }
-
- function countPanelMatches(panel: HTMLElement, query: string): number {
- let count = 0;
- panel.querySelectorAll<HTMLElement>(PANEL_MATCH_SELECTORS).forEach((el) => {
- if ((el.textContent ?? "").toLowerCase().includes(query)) count += 1;
- });
- return count;
- }
-
- function resetSettingsSearchDisplay(content: HTMLElement) {
- content
- .querySelectorAll<HTMLElement>(
- ".setting-row, .section-title, .settings-section-head, .card, .preset-card, .section, .deps-table-row",
- )
- .forEach((el) => {
- el.style.display = "";
- });
- clearSearchHighlights(content);
- categoryMatchCounts = {};
- }
-
- function applySettingsPanelFilter(content: HTMLElement, query: string) {
- const rows = content.querySelectorAll<HTMLElement>(
- ".setting-row, .section-title, .settings-section-head, .deps-table-row",
- );
- rows.forEach((row) => {
- const text = (row.textContent ?? "").toLowerCase();
- row.style.display = text.includes(query) ? "" : "none";
- });
- content.querySelectorAll<HTMLElement>(".preset-card").forEach((card) => {
- const text = (card.textContent ?? "").toLowerCase();
- card.style.display = text.includes(query) ? "" : "none";
- });
- content.querySelectorAll<HTMLElement>(".card").forEach((card) => {
- const hasVisibleRow = Array.from(
- card.querySelectorAll<HTMLElement>(".setting-row"),
- ).some((r) => r.style.display !== "none");
- card.style.display = hasVisibleRow ? "" : "none";
- });
- content.querySelectorAll<HTMLElement>(".section").forEach((section) => {
- const titleEl = section.querySelector<HTMLElement>(
- ".section-title, .settings-section-head",
- );
- const hasVisibleRow = Array.from(
- section.querySelectorAll<HTMLElement>(".setting-row, .deps-table-row"),
- ).some((r) => r.style.display !== "none");
- const hasVisibleCard = Array.from(
- section.querySelectorAll<HTMLElement>(".card"),
- ).some((c) => c.style.display !== "none");
- const hasVisiblePreset = Array.from(
- section.querySelectorAll<HTMLElement>(".preset-card"),
- ).some((p) => p.style.display !== "none");
- const hasMatchingTitle = (titleEl?.textContent ?? "")
- .toLowerCase()
- .includes(query);
- section.style.display =
- hasVisibleRow || hasVisibleCard || hasVisiblePreset || hasMatchingTitle
- ? ""
- : "none";
- });
- }
-
- $effect(() => {
- const q = normalizedQuery;
- if (typeof document === "undefined") return;
- let cancelled = false;
-
- (async () => {
- await tick();
- if (cancelled) return;
- const content = document.querySelector<HTMLElement>(".settings-content");
- if (!content) return;
-
- if (!q) {
- resetSettingsSearchDisplay(content);
- return;
- }
-
- if (isSearching) await tick();
- if (cancelled) return;
-
- applySettingsPanelFilter(content, q);
-
- const counts: Partial<Record<SettingsCategory, number>> = {};
- content.querySelectorAll<HTMLElement>("[data-settings-cat]").forEach((panel) => {
- const cat = panel.dataset.settingsCat as SettingsCategory | undefined;
- if (!cat) return;
- counts[cat] = countPanelMatches(panel, q);
- });
- categoryMatchCounts = counts;
-
- applySearchHighlights(content, q);
- })();
-
- return () => {
- cancelled = true;
- };
- });
-
- function groupHasSearchMatch(group: (typeof SETTINGS_NAV_GROUPS)[number]): boolean {
- if (!isSearching) return true;
- return group.items.some(([cat]) => (categoryMatchCounts[cat] ?? 0) > 0);
- }
-
- let templateInput = $state("");
- let templateTimer = $state<ReturnType<typeof setTimeout> | null>(null);
- let hotkeyInput = $state("");
- let hotkeyTimer = $state<ReturnType<typeof setTimeout> | null>(null);
- let hotkeyMode = $state<"record" | "type">("record");
- let hotkeyRecording = $state(false);
- let proxyHost = $state("");
- let proxyUsername = $state("");
- let proxyPassword = $state("");
- let proxyTimer = $state<ReturnType<typeof setTimeout> | null>(null);
-
- $effect(() => {
- if (settings) {
- templateInput = settings.download.filename_template;
- hotkeyInput = settings.download.hotkey_binding;
- proxyHost = settings.proxy?.host ?? "";
- proxyUsername = settings.proxy?.username ?? "";
- proxyPassword = settings.proxy?.password ?? "";
- }
- });
-
- function previewTemplate(template: string): string {
- return template
- .replace("%(title).200s", "My Video Title")
- .replace("%(title)s", "My Video Title")
- .replace("%(id)s", "dQw4w9WgXcQ")
- .replace("%(ext)s", "mp4")
- .replace("%(uploader)s", "Channel Name")
- .replace("%(upload_date)s", "20260217")
- .replace("%(resolution)s", "1920x1080")
- .replace("%(fps)s", "30")
- .replace("%(duration)s", "212");
- }
-
- function handleTemplateInput(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- templateInput = value;
- if (templateTimer) clearTimeout(templateTimer);
- templateTimer = setTimeout(async () => {
- if (value.trim() && value.includes("%(ext)s")) {
- await updateSettings({ download: { filename_template: value } });
- }
- }, 800);
- }
-
- function handleHotkeyInput(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- hotkeyInput = value;
- if (hotkeyTimer) clearTimeout(hotkeyTimer);
- hotkeyTimer = setTimeout(async () => {
- if (value.trim()) {
- await updateSettings({ download: { hotkey_binding: value } });
- }
- }, 800);
- }
-
- function mapKeyName(key: string): string | null {
- if (key.length === 1 && /[a-zA-Z]/.test(key)) return key.toUpperCase();
- if (key.length === 1 && /[0-9]/.test(key)) return key;
- if (/^F([1-9]|1[0-2])$/.test(key)) return key;
- const map: Record<string, string> = {
- " ": "Space", ArrowUp: "Up", ArrowDown: "Down", ArrowLeft: "Left", ArrowRight: "Right",
- Enter: "Enter", Tab: "Tab", Escape: "Escape", Backspace: "Backspace", Delete: "Delete",
- Home: "Home", End: "End", PageUp: "PageUp", PageDown: "PageDown", Insert: "Insert",
- };
- return map[key] ?? null;
- }
-
- function handleHotkeyKeyDown(e: KeyboardEvent) {
- e.preventDefault();
- e.stopPropagation();
- if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
- const keyName = mapKeyName(e.key);
- if (!keyName) return;
- const parts: string[] = [];
- if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
- if (e.shiftKey) parts.push("Shift");
- if (e.altKey) parts.push("Alt");
- parts.push(keyName);
- const value = parts.join("+");
- hotkeyInput = value;
- hotkeyRecording = false;
- updateSettings({ download: { hotkey_binding: value } });
- }
-
- async function changeProxyType(e: Event) {
- const value = (e.target as HTMLSelectElement).value;
- await updateSettings({ proxy: { proxy_type: value } });
- }
-
- function handleProxyHost(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- proxyHost = value;
- if (proxyTimer) clearTimeout(proxyTimer);
- proxyTimer = setTimeout(async () => {
- await updateSettings({ proxy: { host: value } });
- }, 800);
- }
-
- function handleProxyUsername(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- proxyUsername = value;
- if (proxyTimer) clearTimeout(proxyTimer);
- proxyTimer = setTimeout(async () => {
- await updateSettings({ proxy: { username: value } });
- }, 800);
- }
-
- function handleProxyPassword(e: Event) {
- const value = (e.target as HTMLInputElement).value;
- proxyPassword = value;
- if (proxyTimer) clearTimeout(proxyTimer);
- proxyTimer = setTimeout(async () => {
- await updateSettings({ proxy: { password: value } });
- }, 800);
- }
-
- async function handleReset() {
- if (!confirm($t("settings.advanced.reset_confirm"))) return;
- resetting = true;
- try {
- await resetSettings();
- } catch (e: any) {
- showToast("error", typeof e === "string" ? e : e.message ?? $t("common.error"));
- } finally {
- resetting = false;
- }
- }
-</script>
-
-{#if settings}
- <div class="settings settings-mac">
- {#if updateInfo.available}
- <div class="update-banner">
- <span class="update-text">
- {#if updating}
- {$t('settings.update_downloading')}
- {:else}
- {$t('settings.update_available', { version: updateInfo.version })}
- {/if}
- </span>
- <button class="update-btn" onclick={handleUpdate} disabled={updating}>
- {#if updating}
- <span class="update-spinner"></span>
- {:else}
- {$t('settings.update_button')}
- {/if}
- </button>
- </div>
- {/if}
-
- <div class="settings-mac-body">
- <aside class="settings-mac-sidebar">
- <div class="settings-search-row">
- <input
- type="search"
- class="settings-search"
- placeholder={$t('settings.search_placeholder')}
- value={searchQuery}
- oninput={(e) => searchQuery = (e.target as HTMLInputElement).value}
- spellcheck="false"
- aria-label={$t('settings.search_placeholder')}
- />
- </div>
- {#each SETTINGS_NAV_GROUPS as group (group.labelKey)}
- {#if groupHasSearchMatch(group)}
- <div class="settings-mac-nav-group">
- <div class="mac-nav-section-header">{$t(group.labelKey)}</div>
- {#each group.items as [cat, key] (cat)}
- {#if !isSearching || (categoryMatchCounts[cat] ?? 0) > 0}
- <button
- class="settings-mac-cat"
- class:active={!isSearching && activeCategory === cat}
- class:search-match={isSearching && (categoryMatchCounts[cat] ?? 0) > 0}
- onclick={() => { activeCategory = cat; searchQuery = ""; }}
- >
- <span class="settings-mac-cat-label">{$t(key)}</span>
- {#if isSearching && (categoryMatchCounts[cat] ?? 0) > 0}
- <span class="settings-cat-match-count">{categoryMatchCounts[cat]}</span>
- {/if}
- </button>
- {/if}
- {/each}
- </div>
- {/if}
- {/each}
- </aside>
-
- <div class="settings-mac-content settings-content">
-
- {#if isSearching || activeCategory === "appearance"}
- <div class="settings-panel" data-settings-cat="appearance">
- <SettingsAppearance searchActive={isSearching} />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "typography"}
- <div class="settings-panel" data-settings-cat="typography">
- <SettingsTypography />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "downloads"}
- <div class="settings-panel" data-settings-cat="downloads">
- <SettingsDownloads searchActive={isSearching} />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "plugins"}
- <div class="settings-panel" data-settings-cat="plugins">
- <SettingsPlugins
- {deps}
- {installingDep}
- onInstallDep={handleInstallDep}
- onRefresh={loadDeps}
- />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "network"}
- <div class="settings-panel" data-settings-cat="network">
- <SettingsBrowserExtension />
- <SettingsNetwork />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "cookies"}
- <div class="settings-panel" data-settings-cat="cookies">
- <SettingsCookies />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "channels"}
- <div class="settings-panel" data-settings-cat="channels">
- <SettingsChannels />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "ai"}
- <div class="settings-panel" data-settings-cat="ai">
- <SettingsAI />
- </div>
- {/if}
-
- {#if isSearching || activeCategory === "advanced"}
- <div class="settings-panel" data-settings-cat="advanced">
- <SettingsAdvanced {resetting} onReset={handleReset} searchActive={isSearching} />
- </div>
- {/if}
- </div>
- </div>
- </div>
-{:else}
- <div class="settings-loading">
- <span class="spinner"></span>
- </div>
-{/if}
-
+<script lang="ts">
+ import { tick } from "svelte";
+ import { invoke } from "@tauri-apps/api/core";
+ import { open } from "@tauri-apps/plugin-dialog";
+ import { t, locale, loadTranslations } from "$lib/i18n";
+ import { getSettings, updateSettings, resetSettings } from "$lib/stores/settings-store.svelte";
+ import { getUpdateInfo } from "$lib/stores/update-store.svelte";
+ import { installUpdate } from "$lib/updater";
+ import { showToast } from "$lib/stores/toast-store.svelte";
+ import { refreshYtdlpStatus } from "$lib/stores/dependency-store.svelte";
+ import { isDebugEnabled, setDebugEnabled, setDebugPanelOpen } from "$lib/stores/debug-store.svelte";
+ import ContextHint from "$components/hints/ContextHint.svelte";
+ import SettingsPlugins from "$components/settings/SettingsPlugins.svelte";
+ import SettingsAdvanced from "$components/settings/SettingsAdvanced.svelte";
+ import SettingsAppearance from "$components/settings/SettingsAppearance.svelte";
+ import SettingsNetwork from "$components/settings/SettingsNetwork.svelte";
+ import SettingsDownloads from "$components/settings/SettingsDownloads.svelte";
+ import SettingsTypography from "$components/settings/SettingsTypography.svelte";
+ import SettingsBrowserExtension from "$components/settings/SettingsBrowserExtension.svelte";
+ import SettingsCookies from "$components/settings/SettingsCookies.svelte";
+ import SettingsChannels from "$components/settings/SettingsChannels.svelte";
+ import SettingsAI from "$components/settings/SettingsAI.svelte";
+
+ type DependencyStatus = {
+ name: string;
+ installed: boolean;
+ version: string | null;
+ outdated: boolean;
+ };
+
+ let settings = $derived(getSettings());
+ let updateInfo = $derived(getUpdateInfo());
+ let isWindows = typeof navigator !== "undefined" && navigator.userAgent.includes("Windows");
+ let resetting = $state(false);
+ let updating = $state(false);
+ let deps = $state<DependencyStatus[]>([]);
+ let installingDep = $state<string | null>(null);
+
+ async function loadDeps() {
+ try {
+ deps = await invoke<DependencyStatus[]>("check_dependencies");
+ } catch {}
+ }
+
+ async function chooseCookieFile() {
+ const selected = await open({
+ title: "Select cookies.txt file",
+ filters: [{ name: "Cookies", extensions: ["txt"] }],
+ multiple: false,
+ });
+ if (selected && typeof selected === "string") {
+ await updateSettings({ download: { cookie_file: selected } });
+ }
+ }
+
+ async function handleInstallDep(name: string, variant: string | null = null) {
+ const wasInstalled = deps.find((d) => d.name === name)?.installed ?? false;
+ installingDep = name;
+ try {
+ const version = await invoke<string>("install_dependency", { name, variant, force: wasInstalled });
+ await loadDeps();
+ await refreshYtdlpStatus();
+ showToast(
+ "success",
+ $t(
+ wasInstalled ? "settings.dependencies.update_success" : "settings.dependencies.install_success",
+ { name, version },
+ ) as string,
+ );
+ } catch (e: any) {
+ showToast("error", typeof e === "string" ? e : e.message ?? $t("common.error"));
+ } finally {
+ installingDep = null;
+ }
+ }
+
+ $effect(() => {
+ if (settings) {
+ loadDeps();
+ }
+ });
+
+ async function handleUpdate() {
+ updating = true;
+ try {
+ await installUpdate();
+ } catch {
+ updating = false;
+ }
+ }
+
+ async function changeTheme(value: string) {
+ await updateSettings({ appearance: { theme: value } });
+ }
+
+ const CORE_THEMES = [
+ { id: "system", labelKey: "settings.appearance.theme_system", colors: null as string[] | null },
+ { id: "light", labelKey: null, label: "Light", colors: ["#fafafa", "#1a1a1a", "#E05500"] },
+ { id: "dark", labelKey: null, label: "Dark", colors: ["#0a0a0a", "#e8e8e8", "#FF7D38"] },
+ ];
+ const MORE_THEMES = [
+ { id: "catppuccin-latte", label: "Catppuccin Latte", colors: ["#eff1f5", "#4c4f69", "#1e66f5"] },
+ { id: "catppuccin-frappe", label: "Catppuccin Frappé", colors: ["#303446", "#c6d0f5", "#8caaee"] },
+ { id: "catppuccin-macchiato", label: "Catppuccin Macchiato", colors: ["#24273a", "#cad3f5", "#8aadf4"] },
+ { id: "catppuccin-mocha", label: "Catppuccin Mocha", colors: ["#1e1e2e", "#cdd6f4", "#89b4fa"] },
+ { id: "one-dark-pro", label: "One Dark Pro", colors: ["#282c34", "#abb2bf", "#61afef"] },
+ { id: "dracula", label: "Dracula", colors: ["#22212C", "#F8F8F2", "#9580FF"] },
+ { id: "nyxvamp-veil", label: "NyxVamp Veil", colors: ["#1E1E2E", "#D9E0EE", "#F28FAD"] },
+ { id: "nyxvamp-obsidian", label: "NyxVamp Obsidian", colors: ["#000A0F", "#C0C0CE", "#F28FAD"] },
+ { id: "nyxvamp-radiance", label: "NyxVamp Radiance", colors: ["#F7F7FF", "#1E1E2E", "#9655FF"] },
+ { id: "eink-day", label: "E-ink Day", colors: ["#f5f2ea", "#1d1d1b", "#2b2b28"] },
+ { id: "eink-sepia", label: "E-ink Sepia", colors: ["#f0e6d2", "#3f2e20", "#7a4a22"] },
+ { id: "eink-night", label: "E-ink Night", colors: ["#0a0a0a", "#d4d4d0", "#b0b0ab"] },
+ ];
+ const MORE_THEME_IDS = new Set(MORE_THEMES.map((t) => t.id));
+ let selectedInMore = $derived(MORE_THEME_IDS.has(settings?.appearance?.theme ?? ""));
+
+ async function changeLanguage(e: Event) {
+ const value = (e.target as HTMLSelectElement).value;
+ await updateSettings({ appearance: { language: value } });
+ await loadTranslations(value, "/settings");
+ locale.set(value);
+ }
+
+ async function chooseFolder() {
+ const selected = await open({ directory: true, title: $t("settings.download.default_output_dir") });
+ if (selected) {
+ await updateSettings({ download: { default_output_dir: selected } });
+ }
+ }
+
+ async function toggleBool(section: string, key: string, current: boolean) {
+ await updateSettings({ [section]: { [key]: !current } });
+ }
+
+ async function changeNumber(section: string, key: string, e: Event) {
+ const value = parseInt((e.target as HTMLInputElement).value, 10);
+ if (!isNaN(value) && value > 0) {
+ await updateSettings({ [section]: { [key]: value } });
+ if (key === "max_concurrent_downloads") {
+ try {
+ await invoke("update_max_concurrent", { max: value });
+ } catch {}
+ }
+ }
+ }
+
+ async function changeQuality(e: Event) {
+ const value = (e.target as HTMLSelectElement).value;
+ await updateSettings({ download: { video_quality: value } });
+ }
+
+ type SettingsCategory = "downloads" | "appearance" | "typography" | "network" | "cookies" | "channels" | "ai" | "plugins" | "advanced";
+
+ const SETTINGS_NAV_GROUPS: {
+ labelKey: string;
+ items: [SettingsCategory, string][];
+ }[] = [
+ {
+ labelKey: "settings.group_general",
+ items: [
+ ["appearance", "settings.cat_appearance"],
+ ["typography", "settings.cat_typography"],
+ ],
+ },
+ {
+ labelKey: "settings.group_media",
+ items: [["downloads", "settings.cat_downloads"]],
+ },
+ {
+ labelKey: "settings.group_integrations",
+ items: [
+ ["network", "settings.cat_network"],
+ ["cookies", "settings.cat_cookies"],
+ ["channels", "settings.cat_channels"],
+ ["ai", "settings.cat_ai"],
+ ["plugins", "settings.cat_plugins"],
+ ],
+ },
+ {
+ labelKey: "settings.group_advanced",
+ items: [["advanced", "settings.cat_advanced"]],
+ },
+ ];
+
+ let activeCategory = $state<SettingsCategory>("downloads");
+
+ let tabApplied = false;
+ $effect(() => {
+ if (tabApplied || typeof window === "undefined") return;
+ tabApplied = true;
+ const tab = new URLSearchParams(window.location.search).get("tab");
+ const valid = ["downloads", "appearance", "typography", "network", "cookies", "channels", "ai", "plugins", "advanced"];
+ if (tab && valid.includes(tab)) {
+ activeCategory = tab as SettingsCategory;
+ }
+ });
+
+ let searchQuery = $state("");
+ let normalizedQuery = $derived(searchQuery.trim().toLowerCase());
+ let isSearching = $derived(normalizedQuery.length > 0);
+ let categoryMatchCounts = $state<Partial<Record<SettingsCategory, number>>>({});
+
+ const PANEL_MATCH_SELECTORS =
+ ".setting-row, .preset-card, .settings-section-head, .section-title, .deps-table-row";
+
+ function clearSearchHighlights(root: ParentNode) {
+ root.querySelectorAll("mark.settings-search-hit").forEach((mark) => {
+ const parent = mark.parentNode;
+ if (!parent) return;
+ parent.replaceChild(document.createTextNode(mark.textContent ?? ""), mark);
+ parent.normalize();
+ });
+ }
+
+ function highlightPlainText(el: HTMLElement, query: string) {
+ if (el.children.length > 0) return;
+ const text = el.textContent ?? "";
+ const lower = text.toLowerCase();
+ const idx = lower.indexOf(query);
+ if (idx === -1) return;
+ const before = text.slice(0, idx);
+ const match = text.slice(idx, idx + query.length);
+ const after = text.slice(idx + query.length);
+ el.textContent = "";
+ if (before) el.appendChild(document.createTextNode(before));
+ const mark = document.createElement("mark");
+ mark.className = "settings-search-hit";
+ mark.textContent = match;
+ el.appendChild(mark);
+ if (after) el.appendChild(document.createTextNode(after));
+ }
+
+ function applySearchHighlights(container: HTMLElement, query: string) {
+ clearSearchHighlights(container);
+ if (!query) return;
+ const highlightSelectors =
+ ".setting-path, .settings-section-hint, .preset-desc, .preset-label";
+ container.querySelectorAll<HTMLElement>(highlightSelectors).forEach((el) => {
+ if (el.style.display === "none") return;
+ highlightPlainText(el, query);
+ });
+ container.querySelectorAll<HTMLElement>(".setting-label").forEach((el) => {
+ if (el.style.display === "none" || el.children.length > 0) return;
+ highlightPlainText(el, query);
+ });
+ }
+
+ function countPanelMatches(panel: HTMLElement, query: string): number {
+ let count = 0;
+ panel.querySelectorAll<HTMLElement>(PANEL_MATCH_SELECTORS).forEach((el) => {
+ if ((el.textContent ?? "").toLowerCase().includes(query)) count += 1;
+ });
+ return count;
+ }
+
+ function resetSettingsSearchDisplay(content: HTMLElement) {
+ content
+ .querySelectorAll<HTMLElement>(
+ ".setting-row, .section-title, .settings-section-head, .card, .preset-card, .section, .deps-table-row",
+ )
+ .forEach((el) => {
+ el.style.display = "";
+ });
+ clearSearchHighlights(content);
+ categoryMatchCounts = {};
+ }
+
+ function applySettingsPanelFilter(content: HTMLElement, query: string) {
+ const rows = content.querySelectorAll<HTMLElement>(
+ ".setting-row, .section-title, .settings-section-head, .deps-table-row",
+ );
+ rows.forEach((row) => {
+ const text = (row.textContent ?? "").toLowerCase();
+ row.style.display = text.includes(query) ? "" : "none";
+ });
+ content.querySelectorAll<HTMLElement>(".preset-card").forEach((card) => {
+ const text = (card.textContent ?? "").toLowerCase();
+ card.style.display = text.includes(query) ? "" : "none";
+ });
+ content.querySelectorAll<HTMLElement>(".card").forEach((card) => {
+ const hasVisibleRow = Array.from(
+ card.querySelectorAll<HTMLElement>(".setting-row"),
+ ).some((r) => r.style.display !== "none");
+ card.style.display = hasVisibleRow ? "" : "none";
+ });
+ content.querySelectorAll<HTMLElement>(".section").forEach((section) => {
+ const titleEl = section.querySelector<HTMLElement>(
+ ".section-title, .settings-section-head",
+ );
+ const hasVisibleRow = Array.from(
+ section.querySelectorAll<HTMLElement>(".setting-row, .deps-table-row"),
+ ).some((r) => r.style.display !== "none");
+ const hasVisibleCard = Array.from(
+ section.querySelectorAll<HTMLElement>(".card"),
+ ).some((c) => c.style.display !== "none");
+ const hasVisiblePreset = Array.from(
+ section.querySelectorAll<HTMLElement>(".preset-card"),
+ ).some((p) => p.style.display !== "none");
+ const hasMatchingTitle = (titleEl?.textContent ?? "")
+ .toLowerCase()
+ .includes(query);
+ section.style.display =
+ hasVisibleRow || hasVisibleCard || hasVisiblePreset || hasMatchingTitle
+ ? ""
+ : "none";
+ });
+ }
+
+ $effect(() => {
+ const q = normalizedQuery;
+ if (typeof document === "undefined") return;
+ let cancelled = false;
+
+ (async () => {
+ await tick();
+ if (cancelled) return;
+ const content = document.querySelector<HTMLElement>(".settings-content");
+ if (!content) return;
+
+ if (!q) {
+ resetSettingsSearchDisplay(content);
+ return;
+ }
+
+ if (isSearching) await tick();
+ if (cancelled) return;
+
+ applySettingsPanelFilter(content, q);
+
+ const counts: Partial<Record<SettingsCategory, number>> = {};
+ content.querySelectorAll<HTMLElement>("[data-settings-cat]").forEach((panel) => {
+ const cat = panel.dataset.settingsCat as SettingsCategory | undefined;
+ if (!cat) return;
+ counts[cat] = countPanelMatches(panel, q);
+ });
+ categoryMatchCounts = counts;
+
+ applySearchHighlights(content, q);
+ })();
+
+ return () => {
+ cancelled = true;
+ };
+ });
+
+ function groupHasSearchMatch(group: (typeof SETTINGS_NAV_GROUPS)[number]): boolean {
+ if (!isSearching) return true;
+ return group.items.some(([cat]) => (categoryMatchCounts[cat] ?? 0) > 0);
+ }
+
+ let templateInput = $state("");
+ let templateTimer = $state<ReturnType<typeof setTimeout> | null>(null);
+ let hotkeyInput = $state("");
+ let hotkeyTimer = $state<ReturnType<typeof setTimeout> | null>(null);
+ let hotkeyMode = $state<"record" | "type">("record");
+ let hotkeyRecording = $state(false);
+ let proxyHost = $state("");
+ let proxyUsername = $state("");
+ let proxyPassword = $state("");
+ let proxyTimer = $state<ReturnType<typeof setTimeout> | null>(null);
+
+ $effect(() => {
+ if (settings) {
+ templateInput = settings.download.filename_template;
+ hotkeyInput = settings.download.hotkey_binding;
+ proxyHost = settings.proxy?.host ?? "";
+ proxyUsername = settings.proxy?.username ?? "";
+ proxyPassword = settings.proxy?.password ?? "";
+ }
+ });
+
+ function previewTemplate(template: string): string {
+ return template
+ .replace("%(title).200s", "My Video Title")
+ .replace("%(title)s", "My Video Title")
+ .replace("%(id)s", "dQw4w9WgXcQ")
+ .replace("%(ext)s", "mp4")
+ .replace("%(uploader)s", "Channel Name")
+ .replace("%(upload_date)s", "20260217")
+ .replace("%(resolution)s", "1920x1080")
+ .replace("%(fps)s", "30")
+ .replace("%(duration)s", "212");
+ }
+
+ function handleTemplateInput(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ templateInput = value;
+ if (templateTimer) clearTimeout(templateTimer);
+ templateTimer = setTimeout(async () => {
+ if (value.trim() && value.includes("%(ext)s")) {
+ await updateSettings({ download: { filename_template: value } });
+ }
+ }, 800);
+ }
+
+ function handleHotkeyInput(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ hotkeyInput = value;
+ if (hotkeyTimer) clearTimeout(hotkeyTimer);
+ hotkeyTimer = setTimeout(async () => {
+ if (value.trim()) {
+ await updateSettings({ download: { hotkey_binding: value } });
+ }
+ }, 800);
+ }
+
+ function mapKeyName(key: string): string | null {
+ if (key.length === 1 && /[a-zA-Z]/.test(key)) return key.toUpperCase();
+ if (key.length === 1 && /[0-9]/.test(key)) return key;
+ if (/^F([1-9]|1[0-2])$/.test(key)) return key;
+ const map: Record<string, string> = {
+ " ": "Space", ArrowUp: "Up", ArrowDown: "Down", ArrowLeft: "Left", ArrowRight: "Right",
+ Enter: "Enter", Tab: "Tab", Escape: "Escape", Backspace: "Backspace", Delete: "Delete",
+ Home: "Home", End: "End", PageUp: "PageUp", PageDown: "PageDown", Insert: "Insert",
+ };
+ return map[key] ?? null;
+ }
+
+ function handleHotkeyKeyDown(e: KeyboardEvent) {
+ e.preventDefault();
+ e.stopPropagation();
+ if (["Control", "Shift", "Alt", "Meta"].includes(e.key)) return;
+ const keyName = mapKeyName(e.key);
+ if (!keyName) return;
+ const parts: string[] = [];
+ if (e.ctrlKey || e.metaKey) parts.push("CmdOrCtrl");
+ if (e.shiftKey) parts.push("Shift");
+ if (e.altKey) parts.push("Alt");
+ parts.push(keyName);
+ const value = parts.join("+");
+ hotkeyInput = value;
+ hotkeyRecording = false;
+ updateSettings({ download: { hotkey_binding: value } });
+ }
+
+ async function changeProxyType(e: Event) {
+ const value = (e.target as HTMLSelectElement).value;
+ await updateSettings({ proxy: { proxy_type: value } });
+ }
+
+ function handleProxyHost(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ proxyHost = value;
+ if (proxyTimer) clearTimeout(proxyTimer);
+ proxyTimer = setTimeout(async () => {
+ await updateSettings({ proxy: { host: value } });
+ }, 800);
+ }
+
+ function handleProxyUsername(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ proxyUsername = value;
+ if (proxyTimer) clearTimeout(proxyTimer);
+ proxyTimer = setTimeout(async () => {
+ await updateSettings({ proxy: { username: value } });
+ }, 800);
+ }
+
+ function handleProxyPassword(e: Event) {
+ const value = (e.target as HTMLInputElement).value;
+ proxyPassword = value;
+ if (proxyTimer) clearTimeout(proxyTimer);
+ proxyTimer = setTimeout(async () => {
+ await updateSettings({ proxy: { password: value } });
+ }, 800);
+ }
+
+ async function handleReset() {
+ if (!confirm($t("settings.advanced.reset_confirm"))) return;
+ resetting = true;
+ try {
+ await resetSettings();
+ } catch (e: any) {
+ showToast("error", typeof e === "string" ? e : e.message ?? $t("common.error"));
+ } finally {
+ resetting = false;
+ }
+ }
+</script>
+
+{#if settings}
+ <div class="settings settings-mac">
+ {#if updateInfo.available}
+ <div class="update-banner">
+ <span class="update-text">
+ {#if updating}
+ {$t('settings.update_downloading')}
+ {:else}
+ {$t('settings.update_available', { version: updateInfo.version })}
+ {/if}
+ </span>
+ <button class="update-btn" onclick={handleUpdate} disabled={updating}>
+ {#if updating}
+ <span class="update-spinner"></span>
+ {:else}
+ {$t('settings.update_button')}
+ {/if}
+ </button>
+ </div>
+ {/if}
+
+ <div class="settings-mac-body">
+ <aside class="settings-mac-sidebar">
+ <div class="settings-search-row">
+ <input
+ type="search"
+ class="settings-search"
+ placeholder={$t('settings.search_placeholder')}
+ value={searchQuery}
+ oninput={(e) => searchQuery = (e.target as HTMLInputElement).value}
+ spellcheck="false"
+ aria-label={$t('settings.search_placeholder')}
+ />
+ </div>
+ {#each SETTINGS_NAV_GROUPS as group (group.labelKey)}
+ {#if groupHasSearchMatch(group)}
+ <div class="settings-mac-nav-group">
+ <div class="mac-nav-section-header">{$t(group.labelKey)}</div>
+ {#each group.items as [cat, key] (cat)}
+ {#if !isSearching || (categoryMatchCounts[cat] ?? 0) > 0}
+ <button
+ class="settings-mac-cat"
+ class:active={!isSearching && activeCategory === cat}
+ class:search-match={isSearching && (categoryMatchCounts[cat] ?? 0) > 0}
+ onclick={() => { activeCategory = cat; searchQuery = ""; }}
+ >
+ <span class="settings-mac-cat-label">{$t(key)}</span>
+ {#if isSearching && (categoryMatchCounts[cat] ?? 0) > 0}
+ <span class="settings-cat-match-count">{categoryMatchCounts[cat]}</span>
+ {/if}
+ </button>
+ {/if}
+ {/each}
+ </div>
+ {/if}
+ {/each}
+ </aside>
+
+ <div class="settings-mac-content settings-content">
+
+ {#if isSearching || activeCategory === "appearance"}
+ <div class="settings-panel" data-settings-cat="appearance">
+ <SettingsAppearance searchActive={isSearching} />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "typography"}
+ <div class="settings-panel" data-settings-cat="typography">
+ <SettingsTypography />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "downloads"}
+ <div class="settings-panel" data-settings-cat="downloads">
+ <SettingsDownloads searchActive={isSearching} />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "plugins"}
+ <div class="settings-panel" data-settings-cat="plugins">
+ <SettingsPlugins
+ {deps}
+ {installingDep}
+ onInstallDep={handleInstallDep}
+ onRefresh={loadDeps}
+ />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "network"}
+ <div class="settings-panel" data-settings-cat="network">
+ <SettingsBrowserExtension />
+ <SettingsNetwork />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "cookies"}
+ <div class="settings-panel" data-settings-cat="cookies">
+ <SettingsCookies />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "channels"}
+ <div class="settings-panel" data-settings-cat="channels">
+ <SettingsChannels />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "ai"}
+ <div class="settings-panel" data-settings-cat="ai">
+ <SettingsAI />
+ </div>
+ {/if}
+
+ {#if isSearching || activeCategory === "advanced"}
+ <div class="settings-panel" data-settings-cat="advanced">
+ <SettingsAdvanced {resetting} onReset={handleReset} searchActive={isSearching} />
+ </div>
+ {/if}
+ </div>
+ </div>
+ </div>
+{:else}
+ <div class="settings-loading">
+ <span class="spinner"></span>
+ </div>
+{/if}
+