From b8e496457ff65ab728cc91093c21d02463a95cf9 Mon Sep 17 00:00:00 2001 From: TheGeneralist <180094941+thegeneralist01@users.noreply.github.com> Date: Sun, 5 Jul 2026 20:42:41 +0200 Subject: [PATCH] feat: add video quality selection for yt-dlp captures (#17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ytdlp::download() accepts quality: Option<&str>; quality_format() maps best/1080p/720p/480p/360p to yt-dlp -f format strings - perform_capture() threads quality through to the downloader - CaptureBody gains optional quality field; capture_handler validates it against the allowlist (400 on unknown values) before spawning - CLI passes None (preserves existing best-quality behaviour) - Frontend: isVideoSource() mirrors determine_source() exactly — shows quality picker only for yt-dlp-backed sources, excludes playlist/channel shorthands and tweet/thread paths - submitCapture(archiveId, locator, quality) sends quality in POST body - CSS: .capture-quality styles the inline select to fit the capture row - Tests: quality_format unit tests in ytdlp.rs; two new route tests (valid quality accepted, invalid quality rejected with 400) - Docs: video quality section added under Supported Platforms --- crates/archivr-cli/src/main.rs | 2 +- crates/archivr-core/src/capture.rs | 45 ++-- crates/archivr-core/src/downloader/ytdlp.rs | 230 +++++++++++++++++- crates/archivr-server/src/routes.rs | 171 ++++++++++++- .../static/assets/index-BHg5-TAr.js | 40 +++ .../static/assets/index-BW0QKHXE.css | 1 + .../static/assets/index-BZfMx3eM.css | 1 - .../static/assets/index-CTwpNgei.js | 40 --- crates/archivr-server/static/index.html | 4 +- docs/README.md | 29 +++ frontend/src/api.js | 12 +- frontend/src/components/CaptureDialog.jsx | 170 ++++++++++++- frontend/src/styles.css | 33 +++ 13 files changed, 689 insertions(+), 89 deletions(-) create mode 100644 crates/archivr-server/static/assets/index-BHg5-TAr.js create mode 100644 crates/archivr-server/static/assets/index-BW0QKHXE.css delete mode 100644 crates/archivr-server/static/assets/index-BZfMx3eM.css delete mode 100644 crates/archivr-server/static/assets/index-CTwpNgei.js diff --git a/crates/archivr-cli/src/main.rs b/crates/archivr-cli/src/main.rs index 22606be..44451c8 100644 --- a/crates/archivr-cli/src/main.rs +++ b/crates/archivr-cli/src/main.rs @@ -63,7 +63,7 @@ fn main() -> Result<()> { } }; let archive_paths = archive::read_archive_paths(&archive_path)?; - let result = archivr_core::capture::perform_capture(&archive_paths, path, None)?; + let result = archivr_core::capture::perform_capture(&archive_paths, path, None, None)?; println!("Archived: run {}", result.run_uid); Ok(()) } diff --git a/crates/archivr-core/src/capture.rs b/crates/archivr-core/src/capture.rs index fc76efa..848906b 100644 --- a/crates/archivr-core/src/capture.rs +++ b/crates/archivr-core/src/capture.rs @@ -331,6 +331,26 @@ fn determine_source(path: &str) -> Source { Source::Other } +/// Resolves `locator` to the canonical URL that yt-dlp should receive, or +/// returns `None` if the locator does not map to a yt-dlp-downloadable source +/// (e.g. tweet/thread shorthands, web pages, local files, playlists/channels). +/// +/// Use this to gate the probe endpoint: only call `fetch_metadata` when this +/// returns `Some`. +pub fn locator_to_ytdlp_url(locator: &str) -> Option { + let source = determine_source(locator); + match source { + Source::YouTubeVideo + | Source::X + | Source::Instagram + | Source::Facebook + | Source::TikTok + | Source::Reddit + | Source::Snapchat => Some(expand_shorthand_to_url(locator, &source)), + _ => None, + } +} + fn hash_exists(hash: &str, file_extension: &str, store_path: &Path) -> Result { let path = store_path.join(raw_relative_path_from_hash(hash, file_extension)?); Ok(path.exists()) @@ -427,20 +447,6 @@ fn local_file_extension(path: &str) -> String { .map_or(String::new(), |ext| format!(".{}", ext.to_string_lossy())) } -fn media_file_extension(source: Source, path: &str) -> String { - match source { - Source::YouTubeVideo - | Source::X - | Source::Instagram - | Source::Facebook - | Source::TikTok - | Source::Reddit - | Source::Snapchat => ".mp4".to_string(), - Source::Local => local_file_extension(path), - _ => String::new(), - } -} - fn tweet_id_from_archive_path(path: &str) -> Option { path.split(':').next_back().and_then(parse_tweet_id) } @@ -677,6 +683,7 @@ pub fn perform_capture( archive_paths: &ArchivePaths, locator: &str, archive_id: Option<&str>, + quality: Option<&str>, ) -> Result { // Append a UUID so parallel captures starting in the same millisecond // never collide on the staging directory or file names. @@ -1015,7 +1022,7 @@ pub fn perform_capture( _ => None, }; - let hash = match source { + let (hash, file_extension) = match source { Source::YouTubeVideo | Source::X | Source::Instagram @@ -1023,8 +1030,8 @@ pub fn perform_capture( | Source::TikTok | Source::Reddit | Source::Snapchat => { - match downloader::ytdlp::download(path.clone(), store_path, ×tamp) { - Ok(h) => h, + match downloader::ytdlp::download(path.clone(), store_path, ×tamp, quality) { + Ok(result) => result, Err(e) => { return Err(fail_run( &conn, @@ -1037,7 +1044,7 @@ pub fn perform_capture( } Source::Local => { match downloader::local::save(path.clone(), store_path, ×tamp) { - Ok(h) => h, + Ok(h) => (h, local_file_extension(&path)), Err(e) => { return Err(fail_run( &conn, @@ -1058,8 +1065,6 @@ pub fn perform_capture( } _ => unreachable!(), }; - - let file_extension = media_file_extension(source, &path); let temp_file = store_path .join("temp") .join(×tamp) diff --git a/crates/archivr-core/src/downloader/ytdlp.rs b/crates/archivr-core/src/downloader/ytdlp.rs index 3cacb98..1b75843 100644 --- a/crates/archivr-core/src/downloader/ytdlp.rs +++ b/crates/archivr-core/src/downloader/ytdlp.rs @@ -1,26 +1,126 @@ -use anyhow::{Context, Result, bail}; -use std::{env, path::Path, process::Command}; +use anyhow::{bail, Context, Result}; +use std::{env, path::{Path, PathBuf}, process::Command}; use crate::hash::hash_file; -pub fn download(path: String, store_path: &Path, timestamp: &String) -> Result { +/// Returns the yt-dlp `-f` format selector for `quality`. +/// +/// - `"audio"` → prefers native Opus/WebM (most efficient), then native +/// AAC/M4A, then any best-audio fallback — no transcoding, smallest file +/// at equivalent perceptual quality. +/// - `"NNNp"` (e.g. `"1080p"`) → height-capped selector with `/best` fallback +/// - `None` / `"best"` / anything else → highest-quality video+audio +pub fn quality_format(quality: Option<&str>) -> String { + if quality == Some("audio") { + // Opus (WebM) is more efficient than AAC (M4A) at the same perceptual + // quality, so prefer it first. Both are taken natively — no transcode. + return "bestaudio[ext=webm]/bestaudio[ext=m4a]/bestaudio/best".to_string(); + } + if let Some(q) = quality { + if let Some(h) = q.strip_suffix('p').and_then(|n| n.parse::().ok()) { + return format!("bestvideo[height<={h}]+bestaudio/best[height<={h}]/best"); + } + } + "bestvideo+bestaudio/best".to_string() +} + + +/// Combined result of a yt-dlp metadata probe. +pub struct ProbeResult { + /// Distinct video heights available, sorted highest-first (e.g. `[1080, 720, 480]`). + pub video_heights: Vec, + /// True when at least one format with a real audio codec exists. + pub has_audio: bool, +} + +/// Parses a yt-dlp `--dump-json` response into a `ProbeResult`. +pub fn probe_result(json: &str) -> ProbeResult { + ProbeResult { + video_heights: available_video_heights(json), + has_audio: has_audio_track(json), + } +} + +/// Distinct video heights from a yt-dlp `--dump-json` response, sorted highest-first. +/// Audio-only formats (`vcodec == "none"`) and zero-height entries are excluded. +pub fn available_video_heights(json: &str) -> Vec { + let v: serde_json::Value = match serde_json::from_str(json) { + Ok(v) => v, + Err(_) => return vec![], + }; + let Some(formats) = v.get("formats").and_then(|f| f.as_array()) else { + return vec![]; + }; + let mut heights: Vec = formats + .iter() + .filter_map(|f| { + let vcodec = f.get("vcodec")?.as_str()?; + if vcodec == "none" { + return None; + } + let h = f.get("height")?.as_u64()?; + if h == 0 { None } else { Some(h as u32) } + }) + .collect(); + heights.sort_unstable_by(|a, b| b.cmp(a)); + heights.dedup(); + heights +} + +/// Returns true when the yt-dlp `--dump-json` response contains at least one +/// format with a real audio codec (i.e. `acodec != "none"`). +pub fn has_audio_track(json: &str) -> bool { + let Ok(v) = serde_json::from_str::(json) else { + return false; + }; + let Some(formats) = v.get("formats").and_then(|f| f.as_array()) else { + return false; + }; + formats.iter().any(|f| { + f.get("acodec") + .and_then(|a| a.as_str()) + .is_some_and(|a| a != "none") + }) +} + +/// Downloads `path` via yt-dlp and returns `(hash, file_extension_with_dot)`. +/// +/// For video the extension is always `.mp4` (forced via `--merge-output-format`). +/// For audio (`quality == Some("audio")`) `-x` is passed to guarantee audio-only +/// output even when only combined A/V formats exist (yt-dlp strips the video +/// track). `--audio-format` is intentionally omitted so the audio stream is +/// remuxed into its native container without re-encoding — no lossy transcode, +/// no size inflation. The actual output extension is discovered by globbing. +pub fn download( + path: String, + store_path: &Path, + timestamp: &String, + quality: Option<&str>, +) -> Result<(String, String)> { println!("Downloading with yt-dlp: {path}"); let ytdlp = env::var("ARCHIVR_YT_DLP").unwrap_or_else(|_| "yt-dlp".to_string()); + let is_audio = quality == Some("audio"); let temp_dir = store_path.join("temp").join(timestamp); std::fs::create_dir_all(&temp_dir)?; - let out_file = temp_dir.join(format!("{timestamp}.mp4")); + // %(ext)s lets yt-dlp write the correct extension for the chosen format. + let out_template = temp_dir.join(format!("{timestamp}.%(ext)s")); - let out = Command::new(&ytdlp) - .arg(&path) - .arg("-f") - .arg("bestvideo+bestaudio/best") - .arg("--merge-output-format") - .arg("mp4") + let mut cmd = Command::new(&ytdlp); + cmd.arg(&path).arg("-f").arg(quality_format(quality)); + if is_audio { + // -x guarantees audio-only even when /best falls back to a combined + // A/V format. No --audio-format → native remux only, no re-encode. + cmd.arg("-x"); + } else { + // Force the video container to mp4 so we always have a known extension. + cmd.arg("--merge-output-format").arg("mp4"); + } + let out = cmd .arg("-o") - .arg(&out_file) + .arg(&out_template) .output() .with_context(|| format!("failed to spawn {ytdlp} process"))?; @@ -29,7 +129,31 @@ pub fn download(path: String, store_path: &Path, timestamp: &String) -> Result Result { + let entries = std::fs::read_dir(temp_dir) + .with_context(|| format!("failed to read temp dir {}", temp_dir.display()))?; + for entry in entries.flatten() { + let name = entry.file_name(); + let name_str = name.to_string_lossy(); + if name_str.starts_with(timestamp) && !name_str.ends_with(".part") { + return Ok(entry.path()); + } + } + bail!( + "yt-dlp output file not found in {}", + temp_dir.display() + ) } /// Fetches metadata JSON for `path` via `yt-dlp --dump-json`. @@ -48,10 +172,90 @@ pub fn fetch_metadata(path: &str) -> Option { if !out.status.success() { let stderr = String::from_utf8_lossy(&out.stderr); - eprintln!("yt-dlp --dump-json failed for {path} (status {:?}): {stderr}", out.status); + eprintln!( + "yt-dlp --dump-json failed for {path} (status {:?}): {stderr}", + out.status + ); return None; } let json = String::from_utf8(out.stdout).ok()?; if json.trim().is_empty() { None } else { Some(json) } } + +#[cfg(test)] +mod tests { + use super::{available_video_heights, has_audio_track, quality_format}; + + #[test] + fn quality_format_audio() { + assert_eq!(quality_format(Some("audio")), "bestaudio[ext=webm]/bestaudio[ext=m4a]/bestaudio/best"); + } + + #[test] + fn quality_format_known_heights() { + assert_eq!( + quality_format(Some("1080p")), + "bestvideo[height<=1080]+bestaudio/best[height<=1080]/best" + ); + assert_eq!( + quality_format(Some("720p")), + "bestvideo[height<=720]+bestaudio/best[height<=720]/best" + ); + assert_eq!( + quality_format(Some("2160p")), + "bestvideo[height<=2160]+bestaudio/best[height<=2160]/best" + ); + } + + #[test] + fn quality_format_defaults_to_best() { + assert_eq!(quality_format(None), "bestvideo+bestaudio/best"); + assert_eq!(quality_format(Some("best")), "bestvideo+bestaudio/best"); + assert_eq!(quality_format(Some("bogus")), "bestvideo+bestaudio/best"); + } + + + #[test] + fn available_video_heights_parses_formats() { + let json = r#"{ + "formats": [ + {"height": 1080, "vcodec": "avc1.640028", "acodec": "none"}, + {"height": 720, "vcodec": "avc1.4d401f", "acodec": "none"}, + {"height": 1080, "vcodec": "avc1.640028", "acodec": "mp4a.40.2"}, + {"height": null, "vcodec": "none", "acodec": "mp4a.40.2"}, + {"height": 360, "vcodec": "none", "acodec": "mp4a.40.2"} + ] + }"#; + assert_eq!(available_video_heights(json), vec![1080, 720]); + } + + #[test] + fn available_video_heights_empty_on_audio_only() { + let json = r#"{"formats": [{"height": null, "vcodec": "none", "acodec": "mp4a.40.2"}]}"#; + assert_eq!(available_video_heights(json), vec![0u32; 0]); + } + + #[test] + fn available_video_heights_empty_on_bad_json() { + assert_eq!(available_video_heights("not json"), vec![0u32; 0]); + assert_eq!(available_video_heights("{}"), vec![0u32; 0]); + } + + #[test] + fn has_audio_track_detects_audio() { + let with_audio = r#"{"formats": [ + {"vcodec": "avc1", "acodec": "mp4a.40.2"}, + {"vcodec": "none", "acodec": "mp4a.40.2"} + ]}"#; + assert!(has_audio_track(with_audio)); + + let video_only = r#"{"formats": [ + {"vcodec": "avc1", "acodec": "none"} + ]}"#; + assert!(!has_audio_track(video_only)); + + assert!(!has_audio_track("not json")); + assert!(!has_audio_track("{}")); + } +} diff --git a/crates/archivr-server/src/routes.rs b/crates/archivr-server/src/routes.rs index ff99a6e..d0575c4 100644 --- a/crates/archivr-server/src/routes.rs +++ b/crates/archivr-server/src/routes.rs @@ -29,7 +29,7 @@ use std::{ }; use parking_lot::Mutex; -use archivr_core::{archive, capture, database}; +use archivr_core::{archive, capture, database, downloader}; use axum::{ Json, Router, extract::{ConnectInfo, Path, Query, Request, State}, @@ -231,6 +231,7 @@ pub fn app_with_state(state: AppState) -> Router { ) .route("/api/archives/:archive_id/runs", get(list_runs)) .route("/api/archives/:archive_id/captures", post(capture_handler)) + .route("/api/archives/:archive_id/captures/probe", get(probe_handler)) .route( "/api/archives/:archive_id/capture_jobs/:job_uid", get(get_capture_job_handler), @@ -637,6 +638,14 @@ async fn delete_entry_handler( #[derive(Debug, serde::Deserialize)] struct CaptureBody { locator: String, + /// Optional quality cap for yt-dlp sources: `"best"` or any `"NNNp"` string + /// (e.g. `"1080p"`, `"720p"`, `"2160p"`). Absent or `"best"` → highest available. + quality: Option, +} + +#[derive(Debug, serde::Deserialize)] +struct ProbeQuery { + locator: String, } #[derive(Debug, serde::Deserialize)] @@ -676,6 +685,18 @@ async fn capture_handler( if body.locator.trim().is_empty() { return Err(ApiError::bad_request("locator must not be empty")); } + if let Some(q) = &body.quality { + let valid = q == "best" + || q == "audio" + || q.strip_suffix('p') + .and_then(|n| n.parse::().ok()) + .is_some(); + if !valid { + return Err(ApiError::bad_request( + "invalid quality: must be \"best\", \"audio\", or a height string like \"1080p\"", + )); + } + } let mounted = mounted_archive(&state, &archive_id)?; let archive_paths = archive::read_archive_paths(&mounted.archive_path) .map_err(ApiError::from)?; @@ -687,6 +708,7 @@ async fn capture_handler( // Spawn background capture. let locator = body.locator.trim().to_string(); + let quality = body.quality.clone(); let archive_path = mounted.archive_path.clone(); let job_uid_bg = job_uid.clone(); let archive_id_bg = archive_id.clone(); @@ -699,7 +721,7 @@ async fn capture_handler( } }; database::update_capture_job_status(&conn, &job_uid_bg, "running", None, None).ok(); - match capture::perform_capture(&archive_paths, &locator, Some(&archive_id_bg)) { + match capture::perform_capture(&archive_paths, &locator, Some(&archive_id_bg), quality.as_deref()) { Ok(result) => { database::update_capture_job_status( &conn, @@ -742,6 +764,64 @@ async fn get_capture_job_handler( .ok_or_else(|| ApiError::not_found("capture job not found")) } +/// `GET /api/archives/:id/captures/probe?locator=` +/// +/// Runs `yt-dlp --dump-json` (behind `spawn_blocking`) and returns the video +/// heights actually available at the given locator. +/// +/// Response shapes: +/// - Locator is not a yt-dlp source (tweet, webpage, local, …): +/// `{ "has_video": false, "qualities": [] }` — 200 +/// - yt-dlp ran and found no video tracks (e.g. tweet URL with no media): +/// `{ "has_video": false, "qualities": [] }` — 200 +/// - yt-dlp ran and found video tracks: +/// `{ "has_video": true, "qualities": ["1080p", "720p", …] }` — 200 +/// - yt-dlp itself failed (non-zero exit, network error, rate-limit, …): +/// 502 — caller should treat this as "probe inconclusive", not "no video" +async fn probe_handler( + State(state): State, + auth_user: AuthUser, + Path(archive_id): Path, + Query(params): Query, +) -> Result, ApiError> { + auth_user.require_role(ROLE_USER)?; + let locator = params.locator.trim().to_string(); + if locator.is_empty() { + return Err(ApiError::bad_request("locator must not be empty")); + } + // Verify the archive exists but don't need the paths for probing. + let _ = mounted_archive(&state, &archive_id)?; + + // Resolve to a yt-dlp URL; return empty result immediately for non-video sources. + let Some(ytdlp_url) = capture::locator_to_ytdlp_url(&locator) else { + return Ok(Json(serde_json::json!({ "has_video": false, "has_audio": false, "qualities": [] }))); + }; + + // fetch_metadata shells out and can take several seconds — keep the async runtime free. + // Returns None when yt-dlp exits non-zero (transient error, rate-limit, unsupported + // extractor, etc.). That is distinct from "yt-dlp ran fine but found no video": we + // return 502 so the frontend treats it as inconclusive rather than showing + // "No video detected" for a URL that may well be downloadable. + let maybe_result = tokio::task::spawn_blocking(move || { + downloader::ytdlp::fetch_metadata(&ytdlp_url) + .map(|json| downloader::ytdlp::probe_result(&json)) + }) + .await + .map_err(|_| ApiError::internal("probe task panicked"))?; + + let result = maybe_result.ok_or_else(|| ApiError { + status: StatusCode::BAD_GATEWAY, + message: "yt-dlp metadata fetch failed".to_string(), + })?; + + let qualities: Vec = result.video_heights.iter().map(|h| format!("{h}p")).collect(); + Ok(Json(serde_json::json!({ + "has_video": !qualities.is_empty(), + "qualities": qualities, + "has_audio": result.has_audio, + }))) +} + async fn auth_setup_status( State(state): State, ) -> Result, ApiError> { @@ -2206,6 +2286,93 @@ mod tests { assert_eq!(json["status"], "pending"); } + #[tokio::test] + async fn capture_with_valid_quality_is_accepted() { + let dir = tempfile::tempdir().unwrap(); + let (registry, _, auth_path) = make_test_registry(&dir); + let session_cookie = make_test_session(&auth_path); + let response = app(registry, auth_path) + .oneshot( + Request::builder() + .method("POST") + .uri("/api/archives/test/captures") + .header("content-type", "application/json") + .header("cookie", &session_cookie) + .body(Body::from(r#"{"locator":"local:/nonexistent","quality":"720p"}"#)) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::ACCEPTED); + let body = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); + let json: serde_json::Value = serde_json::from_slice(&body).unwrap(); + assert!(json["job_uid"].as_str().is_some(), "response must have job_uid"); + assert_eq!(json["status"], "pending"); + } + + #[tokio::test] + async fn capture_with_invalid_quality_is_rejected() { + let dir = tempfile::tempdir().unwrap(); + let (registry, _, auth_path) = make_test_registry(&dir); + let session_cookie = make_test_session(&auth_path); + let response = app(registry, auth_path) + .oneshot( + Request::builder() + .method("POST") + .uri("/api/archives/test/captures") + .header("content-type", "application/json") + .header("cookie", &session_cookie) + .body(Body::from(r#"{"locator":"local:/nonexistent","quality":"4K"}"#)) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::BAD_REQUEST); + let body = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); + let json: serde_json::Value = serde_json::from_slice(&body).unwrap(); + assert!(json["error"].as_str().is_some_and(|e| e.contains("invalid quality"))); + } + + #[tokio::test] + async fn probe_requires_auth() { + let (test_app, _dir) = make_test_app(); + let response = test_app + .oneshot( + Request::builder() + .uri("/api/archives/test/captures/probe?locator=local%3A%2Fnonexistent") + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::UNAUTHORIZED); + } + + #[tokio::test] + async fn probe_non_video_locator_returns_has_video_false() { + // local:/nonexistent is not a yt-dlp source — the handler returns + // immediately without spawning yt-dlp, so this is fast and deterministic. + let dir = tempfile::tempdir().unwrap(); + let (registry, _, auth_path) = make_test_registry(&dir); + let session_cookie = make_test_session(&auth_path); + let response = app(registry, auth_path) + .oneshot( + Request::builder() + .uri("/api/archives/test/captures/probe?locator=local%3A%2Fnonexistent") + .header("cookie", &session_cookie) + .body(Body::empty()) + .unwrap(), + ) + .await + .unwrap(); + assert_eq!(response.status(), StatusCode::OK); + let body = axum::body::to_bytes(response.into_body(), usize::MAX).await.unwrap(); + let json: serde_json::Value = serde_json::from_slice(&body).unwrap(); + assert_eq!(json["has_video"], false); + assert_eq!(json["qualities"], serde_json::json!([])); + assert_eq!(json["has_audio"], false); + } + #[tokio::test] async fn admin_users_requires_admin_role() { let (test_app, _dir) = make_test_app(); diff --git a/crates/archivr-server/static/assets/index-BHg5-TAr.js b/crates/archivr-server/static/assets/index-BHg5-TAr.js new file mode 100644 index 0000000..62970ca --- /dev/null +++ b/crates/archivr-server/static/assets/index-BHg5-TAr.js @@ -0,0 +1,40 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var va={exports:{}},vl={},ga={exports:{}},B={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var fr=Symbol.for("react.element"),Oc=Symbol.for("react.portal"),$c=Symbol.for("react.fragment"),Mc=Symbol.for("react.strict_mode"),Fc=Symbol.for("react.profiler"),Ic=Symbol.for("react.provider"),Ac=Symbol.for("react.context"),Uc=Symbol.for("react.forward_ref"),Bc=Symbol.for("react.suspense"),Vc=Symbol.for("react.memo"),Wc=Symbol.for("react.lazy"),to=Symbol.iterator;function Hc(e){return e===null||typeof e!="object"?null:(e=to&&e[to]||e["@@iterator"],typeof e=="function"?e:null)}var ya={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},wa=Object.assign,xa={};function jn(e,t,n){this.props=e,this.context=t,this.refs=xa,this.updater=n||ya}jn.prototype.isReactComponent={};jn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Sa(){}Sa.prototype=jn.prototype;function os(e,t,n){this.props=e,this.context=t,this.refs=xa,this.updater=n||ya}var as=os.prototype=new Sa;as.constructor=os;wa(as,jn.prototype);as.isPureReactComponent=!0;var no=Array.isArray,ka=Object.prototype.hasOwnProperty,us={current:null},ja={key:!0,ref:!0,__self:!0,__source:!0};function Na(e,t,n){var r,l={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)ka.call(t,r)&&!ja.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,I=L[Q];if(0>>1;Ql(Qe,M))Fel(lt,Qe)?(L[Q]=lt,L[Fe]=M,Q=Fe):(L[Q]=Qe,L[ue]=M,Q=ue);else if(Fel(lt,M))L[Q]=lt,L[Fe]=M,Q=Fe;else break e}}return N}function l(L,N){var M=L.sortIndex-N.sortIndex;return M!==0?M:L.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var u=[],c=[],g=1,m=null,h=3,x=!1,S=!1,j=!1,O=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(L){for(var N=n(c);N!==null;){if(N.callback===null)r(c);else if(N.startTime<=L)r(c),N.sortIndex=N.expirationTime,t(u,N);else break;N=n(c)}}function w(L){if(j=!1,p(L),!S)if(n(u)!==null)S=!0,Z(k);else{var N=n(c);N!==null&&Me(w,N.startTime-L)}}function k(L,N){S=!1,j&&(j=!1,f(y),y=-1),x=!0;var M=h;try{for(p(N),m=n(u);m!==null&&(!(m.expirationTime>N)||L&&!A());){var Q=m.callback;if(typeof Q=="function"){m.callback=null,h=m.priorityLevel;var I=Q(m.expirationTime<=N);N=e.unstable_now(),typeof I=="function"?m.callback=I:m===n(u)&&r(u),p(N)}else r(u);m=n(u)}if(m!==null)var we=!0;else{var ue=n(c);ue!==null&&Me(w,ue.startTime-N),we=!1}return we}finally{m=null,h=M,x=!1}}var _=!1,P=null,y=-1,T=5,R=-1;function A(){return!(e.unstable_now()-RL||125Q?(L.sortIndex=M,t(c,L),n(u)===null&&L===n(c)&&(j?(f(y),y=-1):j=!0,Me(w,M-Q))):(L.sortIndex=I,t(u,L),S||x||(S=!0,Z(k))),L},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(L){var N=h;return function(){var M=h;h=N;try{return L.apply(this,arguments)}finally{h=M}}}})(Pa);Ta.exports=Pa;var td=Ta.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var nd=v,De=td;function C(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pi=Object.prototype.hasOwnProperty,rd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lo={},io={};function ld(e){return pi.call(io,e)?!0:pi.call(lo,e)?!1:rd.test(e)?io[e]=!0:(lo[e]=!0,!1)}function id(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function sd(e,t,n,r){if(t===null||typeof t>"u"||id(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function je(e,t,n,r,l,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var pe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){pe[e]=new je(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];pe[t]=new je(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){pe[e]=new je(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){pe[e]=new je(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){pe[e]=new je(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){pe[e]=new je(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){pe[e]=new je(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){pe[e]=new je(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){pe[e]=new je(e,5,!1,e.toLowerCase(),null,!1,!1)});var ds=/[\-:]([a-z])/g;function fs(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ds,fs);pe[t]=new je(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ds,fs);pe[t]=new je(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ds,fs);pe[t]=new je(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){pe[e]=new je(e,1,!1,e.toLowerCase(),null,!1,!1)});pe.xlinkHref=new je("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){pe[e]=new je(e,1,!1,e.toLowerCase(),null,!0,!0)});function ps(e,t,n,r){var l=pe.hasOwnProperty(t)?pe[t]:null;(l!==null?l.type!==0:r||!(2a||l[s]!==i[a]){var u=` +`+l[s].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=s&&0<=a);break}}}finally{Ul=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?$n(e):""}function od(e){switch(e.tag){case 5:return $n(e.type);case 16:return $n("Lazy");case 13:return $n("Suspense");case 19:return $n("SuspenseList");case 0:case 2:case 15:return e=Bl(e.type,!1),e;case 11:return e=Bl(e.type.render,!1),e;case 1:return e=Bl(e.type,!0),e;default:return""}}function gi(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case qt:return"Fragment";case Zt:return"Portal";case hi:return"Profiler";case hs:return"StrictMode";case mi:return"Suspense";case vi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ra:return(e.displayName||"Context")+".Consumer";case za:return(e._context.displayName||"Context")+".Provider";case ms:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vs:return t=e.displayName||null,t!==null?t:gi(e.type)||"Memo";case vt:t=e._payload,e=e._init;try{return gi(e(t))}catch{}}return null}function ad(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return gi(t);case 8:return t===hs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Lt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Oa(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ud(e){var t=Oa(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=ud(e))}function $a(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Oa(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Kr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function yi(e,t){var n=t.checked;return te({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function oo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Lt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ma(e,t){t=t.checked,t!=null&&ps(e,"checked",t,!1)}function wi(e,t){Ma(e,t);var n=Lt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?xi(e,t.type,n):t.hasOwnProperty("defaultValue")&&xi(e,t.type,Lt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ao(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function xi(e,t,n){(t!=="number"||Kr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Mn=Array.isArray;function cn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=xr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Gn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Un={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},cd=["Webkit","ms","Moz","O"];Object.keys(Un).forEach(function(e){cd.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Un[t]=Un[e]})});function Ua(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Un.hasOwnProperty(e)&&Un[e]?(""+t).trim():t+"px"}function Ba(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Ua(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var dd=te({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ji(e,t){if(t){if(dd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(C(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(C(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(C(61))}if(t.style!=null&&typeof t.style!="object")throw Error(C(62))}}function Ni(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ci=null;function gs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var _i=null,dn=null,fn=null;function fo(e){if(e=mr(e)){if(typeof _i!="function")throw Error(C(280));var t=e.stateNode;t&&(t=Sl(t),_i(e.stateNode,e.type,t))}}function Va(e){dn?fn?fn.push(e):fn=[e]:dn=e}function Wa(){if(dn){var e=dn,t=fn;if(fn=dn=null,fo(e),t)for(e=0;e>>=0,e===0?32:31-(kd(e)/jd|0)|0}var Sr=64,kr=4194304;function Fn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Gr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~l;a!==0?r=Fn(a):(i&=s,i!==0&&(r=Fn(i)))}else s=n&~l,s!==0?r=Fn(s):i!==0&&(r=Fn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function pr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ge(t),e[t]=n}function Ed(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Vn),So=" ",ko=!1;function uu(e,t){switch(e){case"keyup":return tf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bt=!1;function rf(e,t){switch(e){case"compositionend":return cu(t);case"keypress":return t.which!==32?null:(ko=!0,So);case"textInput":return e=t.data,e===So&&ko?null:e;default:return null}}function lf(e,t){if(bt)return e==="compositionend"||!Cs&&uu(e,t)?(e=ou(),Fr=ks=xt=null,bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_o(n)}}function hu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function mu(){for(var e=window,t=Kr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kr(e.document)}return t}function _s(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function hf(e){var t=mu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hu(n.ownerDocument.documentElement,n)){if(r!==null&&_s(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=Eo(n,i);var s=Eo(n,r);l&&s&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,en=null,Ri=null,Hn=null,Di=!1;function To(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Di||en==null||en!==Kr(r)||(r=en,"selectionStart"in r&&_s(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Hn&&nr(Hn,r)||(Hn=r,r=br(Ri,"onSelect"),0rn||(e.current=Ai[rn],Ai[rn]=null,rn--)}function J(e,t){rn++,Ai[rn]=e.current,e.current=t}var zt={},ge=Dt(zt),_e=Dt(!1),Wt=zt;function gn(e,t){var n=e.type.contextTypes;if(!n)return zt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Ee(e){return e=e.childContextTypes,e!=null}function tl(){G(_e),G(ge)}function $o(e,t,n){if(ge.current!==zt)throw Error(C(168));J(ge,t),J(_e,n)}function Nu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(C(108,ad(e)||"Unknown",l));return te({},n,r)}function nl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zt,Wt=ge.current,J(ge,e),J(_e,_e.current),!0}function Mo(e,t,n){var r=e.stateNode;if(!r)throw Error(C(169));n?(e=Nu(e,t,Wt),r.__reactInternalMemoizedMergedChildContext=e,G(_e),G(ge),J(ge,e)):G(_e),J(_e,n)}var st=null,kl=!1,ti=!1;function Cu(e){st===null?st=[e]:st.push(e)}function _f(e){kl=!0,Cu(e)}function Ot(){if(!ti&&st!==null){ti=!0;var e=0,t=Y;try{var n=st;for(Y=1;e>=s,l-=s,ot=1<<32-Ge(t)+l|n<y?(T=P,P=null):T=P.sibling;var R=h(f,P,p[y],w);if(R===null){P===null&&(P=T);break}e&&P&&R.alternate===null&&t(f,P),d=i(R,d,y),_===null?k=R:_.sibling=R,_=R,P=T}if(y===p.length)return n(f,P),q&&$t(f,y),k;if(P===null){for(;yy?(T=P,P=null):T=P.sibling;var A=h(f,P,R.value,w);if(A===null){P===null&&(P=T);break}e&&P&&A.alternate===null&&t(f,P),d=i(A,d,y),_===null?k=A:_.sibling=A,_=A,P=T}if(R.done)return n(f,P),q&&$t(f,y),k;if(P===null){for(;!R.done;y++,R=p.next())R=m(f,R.value,w),R!==null&&(d=i(R,d,y),_===null?k=R:_.sibling=R,_=R);return q&&$t(f,y),k}for(P=r(f,P);!R.done;y++,R=p.next())R=x(P,f,y,R.value,w),R!==null&&(e&&R.alternate!==null&&P.delete(R.key===null?y:R.key),d=i(R,d,y),_===null?k=R:_.sibling=R,_=R);return e&&P.forEach(function(U){return t(f,U)}),q&&$t(f,y),k}function O(f,d,p,w){if(typeof p=="object"&&p!==null&&p.type===qt&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case yr:e:{for(var k=p.key,_=d;_!==null;){if(_.key===k){if(k=p.type,k===qt){if(_.tag===7){n(f,_.sibling),d=l(_,p.props.children),d.return=f,f=d;break e}}else if(_.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===vt&&Ao(k)===_.type){n(f,_.sibling),d=l(_,p.props),d.ref=zn(f,_,p),d.return=f,f=d;break e}n(f,_);break}else t(f,_);_=_.sibling}p.type===qt?(d=Vt(p.props.children,f.mode,w,p.key),d.return=f,f=d):(w=Qr(p.type,p.key,p.props,null,f.mode,w),w.ref=zn(f,d,p),w.return=f,f=w)}return s(f);case Zt:e:{for(_=p.key;d!==null;){if(d.key===_)if(d.tag===4&&d.stateNode.containerInfo===p.containerInfo&&d.stateNode.implementation===p.implementation){n(f,d.sibling),d=l(d,p.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ui(p,f.mode,w),d.return=f,f=d}return s(f);case vt:return _=p._init,O(f,d,_(p._payload),w)}if(Mn(p))return S(f,d,p,w);if(_n(p))return j(f,d,p,w);Pr(f,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,p),d.return=f,f=d):(n(f,d),d=ai(p,f.mode,w),d.return=f,f=d),s(f)):n(f,d)}return O}var wn=Pu(!0),Lu=Pu(!1),il=Dt(null),sl=null,on=null,Ls=null;function zs(){Ls=on=sl=null}function Rs(e){var t=il.current;G(il),e._currentValue=t}function Vi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function hn(e,t){sl=e,Ls=on=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ce=!0),e.firstContext=null)}function We(e){var t=e._currentValue;if(Ls!==e)if(e={context:e,memoizedValue:t,next:null},on===null){if(sl===null)throw Error(C(308));on=e,sl.dependencies={lanes:0,firstContext:e}}else on=on.next=e;return t}var It=null;function Ds(e){It===null?It=[e]:It.push(e)}function zu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ds(t)):(n.next=l.next,l.next=n),t.interleaved=n,ft(e,r)}function ft(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var gt=!1;function Os(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ru(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function _t(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,ft(e,n)}return l=r.interleaved,l===null?(t.next=t,Ds(r)):(t.next=l.next,l.next=t),r.interleaved=t,ft(e,n)}function Ar(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}function Uo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ol(e,t,n,r){var l=e.updateQueue;gt=!1;var i=l.firstBaseUpdate,s=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,s===null?i=c:s.next=c,s=u;var g=e.alternate;g!==null&&(g=g.updateQueue,a=g.lastBaseUpdate,a!==s&&(a===null?g.firstBaseUpdate=c:a.next=c,g.lastBaseUpdate=u))}if(i!==null){var m=l.baseState;s=0,g=c=u=null,a=i;do{var h=a.lane,x=a.eventTime;if((r&h)===h){g!==null&&(g=g.next={eventTime:x,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var S=e,j=a;switch(h=t,x=n,j.tag){case 1:if(S=j.payload,typeof S=="function"){m=S.call(x,m,h);break e}m=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=j.payload,h=typeof S=="function"?S.call(x,m,h):S,h==null)break e;m=te({},m,h);break e;case 2:gt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,h=l.effects,h===null?l.effects=[a]:h.push(a))}else x={eventTime:x,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},g===null?(c=g=x,u=m):g=g.next=x,s|=h;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;h=a,a=h.next,h.next=null,l.lastBaseUpdate=h,l.shared.pending=null}}while(!0);if(g===null&&(u=m),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do s|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Kt|=s,e.lanes=s,e.memoizedState=m}}function Bo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ri.transition;ri.transition={};try{e(!1),t()}finally{Y=n,ri.transition=r}}function Xu(){return He().memoizedState}function Lf(e,t,n){var r=Tt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Gu(e))Zu(t,n);else if(n=zu(e,t,n,r),n!==null){var l=Se();Ze(n,e,r,l),qu(n,t,r)}}function zf(e,t,n){var r=Tt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Gu(e))Zu(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,a=i(s,n);if(l.hasEagerState=!0,l.eagerState=a,qe(a,s)){var u=t.interleaved;u===null?(l.next=l,Ds(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=zu(e,t,l,r),n!==null&&(l=Se(),Ze(n,e,r,l),qu(n,t,r))}}function Gu(e){var t=e.alternate;return e===ee||t!==null&&t===ee}function Zu(e,t){Qn=ul=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}var cl={readContext:We,useCallback:he,useContext:he,useEffect:he,useImperativeHandle:he,useInsertionEffect:he,useLayoutEffect:he,useMemo:he,useReducer:he,useRef:he,useState:he,useDebugValue:he,useDeferredValue:he,useTransition:he,useMutableSource:he,useSyncExternalStore:he,useId:he,unstable_isNewReconciler:!1},Rf={readContext:We,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:We,useEffect:Wo,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Br(4194308,4,Hu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Br(4194308,4,e,t)},useInsertionEffect:function(e,t){return Br(4,2,e,t)},useMemo:function(e,t){var n=et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Lf.bind(null,ee,e),[r.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:Vo,useDebugValue:Vs,useDeferredValue:function(e){return et().memoizedState=e},useTransition:function(){var e=Vo(!1),t=e[0];return e=Pf.bind(null,e[1]),et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ee,l=et();if(q){if(n===void 0)throw Error(C(407));n=n()}else{if(n=t(),ae===null)throw Error(C(349));Qt&30||Mu(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Wo(Iu.bind(null,r,i,e),[e]),r.flags|=2048,cr(9,Fu.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=et(),t=ae.identifierPrefix;if(q){var n=at,r=ot;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ar++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[tt]=t,e[ir]=r,ac(e,t,!1,!1),t.stateNode=e;e:{switch(s=Ni(n,r),n){case"dialog":X("cancel",e),X("close",e),l=r;break;case"iframe":case"object":case"embed":X("load",e),l=r;break;case"video":case"audio":for(l=0;lkn&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304)}else{if(!r)if(e=al(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Rn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!q)return me(t),null}else 2*re()-i.renderingStartTime>kn&&n!==1073741824&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=re(),t.sibling=null,n=b.current,J(b,r?n&1|2:n&1),t):(me(t),null);case 22:case 23:return Js(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Le&1073741824&&(me(t),t.subtreeFlags&6&&(t.flags|=8192)):me(t),null;case 24:return null;case 25:return null}throw Error(C(156,t.tag))}function Uf(e,t){switch(Ts(t),t.tag){case 1:return Ee(t.type)&&tl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xn(),G(_e),G(ge),Fs(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ms(t),null;case 13:if(G(b),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(C(340));yn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return G(b),null;case 4:return xn(),null;case 10:return Rs(t.type._context),null;case 22:case 23:return Js(),null;case 24:return null;default:return null}}var zr=!1,ve=!1,Bf=typeof WeakSet=="function"?WeakSet:Set,D=null;function an(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ne(e,t,r)}else n.current=null}function Zi(e,t,n){try{n()}catch(r){ne(e,t,r)}}var ea=!1;function Vf(e,t){if(Oi=Zr,e=mu(),_s(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,a=-1,u=-1,c=0,g=0,m=e,h=null;t:for(;;){for(var x;m!==n||l!==0&&m.nodeType!==3||(a=s+l),m!==i||r!==0&&m.nodeType!==3||(u=s+r),m.nodeType===3&&(s+=m.nodeValue.length),(x=m.firstChild)!==null;)h=m,m=x;for(;;){if(m===e)break t;if(h===n&&++c===l&&(a=s),h===i&&++g===r&&(u=s),(x=m.nextSibling)!==null)break;m=h,h=m.parentNode}m=x}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for($i={focusedElem:e,selectionRange:n},Zr=!1,D=t;D!==null;)if(t=D,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,D=e;else for(;D!==null;){t=D;try{var S=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var j=S.memoizedProps,O=S.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?j:Ye(t.type,j),O);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var p=t.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(C(163))}}catch(w){ne(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,D=e;break}D=t.return}return S=ea,ea=!1,S}function Kn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Zi(t,n,i)}l=l.next}while(l!==r)}}function Cl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function qi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function dc(e){var t=e.alternate;t!==null&&(e.alternate=null,dc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[tt],delete t[ir],delete t[Ii],delete t[Nf],delete t[Cf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function fc(e){return e.tag===5||e.tag===3||e.tag===4}function ta(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function bi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=el));else if(r!==4&&(e=e.child,e!==null))for(bi(e,t,n),e=e.sibling;e!==null;)bi(e,t,n),e=e.sibling}function es(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(es(e,t,n),e=e.sibling;e!==null;)es(e,t,n),e=e.sibling}var de=null,Je=!1;function mt(e,t,n){for(n=n.child;n!==null;)pc(e,t,n),n=n.sibling}function pc(e,t,n){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(gl,n)}catch{}switch(n.tag){case 5:ve||an(n,t);case 6:var r=de,l=Je;de=null,mt(e,t,n),de=r,Je=l,de!==null&&(Je?(e=de,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):de.removeChild(n.stateNode));break;case 18:de!==null&&(Je?(e=de,n=n.stateNode,e.nodeType===8?ei(e.parentNode,n):e.nodeType===1&&ei(e,n),er(e)):ei(de,n.stateNode));break;case 4:r=de,l=Je,de=n.stateNode.containerInfo,Je=!0,mt(e,t,n),de=r,Je=l;break;case 0:case 11:case 14:case 15:if(!ve&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Zi(n,t,s),l=l.next}while(l!==r)}mt(e,t,n);break;case 1:if(!ve&&(an(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){ne(n,t,a)}mt(e,t,n);break;case 21:mt(e,t,n);break;case 22:n.mode&1?(ve=(r=ve)||n.memoizedState!==null,mt(e,t,n),ve=r):mt(e,t,n);break;default:mt(e,t,n)}}function na(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Bf),t.forEach(function(r){var l=Zf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ke(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=s),r&=~i}if(r=l,r=re()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Hf(r/1960))-r,10e?16:e,St===null)var r=!1;else{if(e=St,St=null,pl=0,W&6)throw Error(C(331));var l=W;for(W|=4,D=e.current;D!==null;){var i=D,s=i.child;if(D.flags&16){var a=i.deletions;if(a!==null){for(var u=0;ure()-Ks?Bt(e,0):Qs|=n),Te(e,t)}function Sc(e,t){t===0&&(e.mode&1?(t=kr,kr<<=1,!(kr&130023424)&&(kr=4194304)):t=1);var n=Se();e=ft(e,t),e!==null&&(pr(e,t,n),Te(e,n))}function Gf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Sc(e,n)}function Zf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(C(314))}r!==null&&r.delete(t),Sc(e,n)}var kc;kc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||_e.current)Ce=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ce=!1,If(e,t,n);Ce=!!(e.flags&131072)}else Ce=!1,q&&t.flags&1048576&&_u(t,ll,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vr(e,t),e=t.pendingProps;var l=gn(t,ge.current);hn(t,n),l=As(null,t,r,e,l,n);var i=Us();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ee(r)?(i=!0,nl(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Os(t),l.updater=Nl,t.stateNode=l,l._reactInternals=t,Hi(t,r,e,n),t=Yi(null,t,r,!0,i,n)):(t.tag=0,q&&i&&Es(t),xe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=bf(r),e=Ye(r,e),l){case 0:t=Ki(null,t,r,e,n);break e;case 1:t=Zo(null,t,r,e,n);break e;case 11:t=Xo(null,t,r,e,n);break e;case 14:t=Go(null,t,r,Ye(r.type,e),n);break e}throw Error(C(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Ki(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Zo(e,t,r,l,n);case 3:e:{if(ic(t),e===null)throw Error(C(387));r=t.pendingProps,i=t.memoizedState,l=i.element,Ru(e,t),ol(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=Sn(Error(C(423)),t),t=qo(e,t,r,n,l);break e}else if(r!==l){l=Sn(Error(C(424)),t),t=qo(e,t,r,n,l);break e}else for(ze=Ct(t.stateNode.containerInfo.firstChild),Re=t,q=!0,Xe=null,n=Lu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yn(),r===l){t=pt(e,t,n);break e}xe(e,t,r,n)}t=t.child}return t;case 5:return Du(t),e===null&&Bi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,s=l.children,Mi(r,l)?s=null:i!==null&&Mi(r,i)&&(t.flags|=32),lc(e,t),xe(e,t,s,n),t.child;case 6:return e===null&&Bi(t),null;case 13:return sc(e,t,n);case 4:return $s(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wn(t,null,r,n):xe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Xo(e,t,r,l,n);case 7:return xe(e,t,t.pendingProps,n),t.child;case 8:return xe(e,t,t.pendingProps.children,n),t.child;case 12:return xe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,s=l.value,J(il,r._currentValue),r._currentValue=s,i!==null)if(qe(i.value,s)){if(i.children===l.children&&!_e.current){t=pt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){s=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=ut(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?u.next=u:(u.next=g.next,g.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Vi(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(C(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Vi(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}xe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,hn(t,n),l=We(l),r=r(l),t.flags|=1,xe(e,t,r,n),t.child;case 14:return r=t.type,l=Ye(r,t.pendingProps),l=Ye(r.type,l),Go(e,t,r,l,n);case 15:return nc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Vr(e,t),t.tag=1,Ee(r)?(e=!0,nl(t)):e=!1,hn(t,n),bu(t,r,l),Hi(t,r,l,n),Yi(null,t,r,!0,e,n);case 19:return oc(e,t,n);case 22:return rc(e,t,n)}throw Error(C(156,t.tag))};function jc(e,t){return Ga(e,t)}function qf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Be(e,t,n,r){return new qf(e,t,n,r)}function Gs(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bf(e){if(typeof e=="function")return Gs(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ms)return 11;if(e===vs)return 14}return 2}function Pt(e,t){var n=e.alternate;return n===null?(n=Be(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Qr(e,t,n,r,l,i){var s=2;if(r=e,typeof e=="function")Gs(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case qt:return Vt(n.children,l,i,t);case hs:s=8,l|=8;break;case hi:return e=Be(12,n,t,l|2),e.elementType=hi,e.lanes=i,e;case mi:return e=Be(13,n,t,l),e.elementType=mi,e.lanes=i,e;case vi:return e=Be(19,n,t,l),e.elementType=vi,e.lanes=i,e;case Da:return El(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case za:s=10;break e;case Ra:s=9;break e;case ms:s=11;break e;case vs:s=14;break e;case vt:s=16,r=null;break e}throw Error(C(130,e==null?e:typeof e,""))}return t=Be(s,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Vt(e,t,n,r){return e=Be(7,e,r,t),e.lanes=n,e}function El(e,t,n,r){return e=Be(22,e,r,t),e.elementType=Da,e.lanes=n,e.stateNode={isHidden:!1},e}function ai(e,t,n){return e=Be(6,e,null,t),e.lanes=n,e}function ui(e,t,n){return t=Be(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ep(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Wl(0),this.expirationTimes=Wl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Zs(e,t,n,r,l,i,s,a,u){return e=new ep(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Be(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Os(i),e}function tp(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ec)}catch(e){console.error(e)}}Ec(),Ea.exports=Oe;var sp=Ea.exports,Tc,ca=sp;Tc=ca.createRoot,ca.hydrateRoot;async function ye(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function op(){return ye("/api/archives")}async function ap(e){return ye(`/api/archives/${e}/entries`)}async function up(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),ye(`/api/archives/${e}/entries/search?${r}`)}async function cp(e,t){return ye(`/api/archives/${e}/entries/${t}`)}async function dp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function ci(e,t){return ye(`/api/archives/${e}/entries/${t}/tags`)}async function fp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag_path:n})});if(!r.ok)throw new Error(`Failed to add tag (${r.status})`)}async function pp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function hp(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function mp(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function vp(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function da(e){return ye(`/api/archives/${e}/runs`)}async function di(e){return ye(`/api/archives/${e}/tags`)}async function gp(e,t,n=null){const r={locator:t};n&&n!=="best"&&(r.quality=n);const l=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(i.error||`HTTP ${l.status}`)}return l.json()}async function yp(e,t){return ye(`/api/archives/${e}/captures/probe?locator=${encodeURIComponent(t)}`)}async function wp(e,t){return ye(`/api/archives/${e}/capture_jobs/${t}`)}async function xp(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function Sp(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function kp(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function jp(){await fetch("/api/auth/logout",{method:"POST"})}async function Np(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function Cp(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function _p(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function Ep(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function Tp(){return ye("/api/auth/tokens")}async function Pp(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function Lp(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function zp(){return ye("/api/admin/instance-settings")}async function Rp(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function Dp(){return ye("/api/admin/users")}async function Op(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function $p(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Mp(){return ye("/api/admin/roles")}async function Fp(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Ip(e){return ye(`/api/archives/${e}/collections`)}async function Ap(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}return l.json()}async function Up(e,t){return ye(`/api/archives/${e}/collections/${t}`)}async function Bp(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Vp(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function Wp(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Hp(e,t){return ye(`/api/archives/${e}/entries/${t}/collections`)}async function fa(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Qp(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}const Kp=window.fetch;window.fetch=async(...e)=>{var n;const t=await Kp(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function Yp({onLogin:e}){const[t,n]=v.useState(""),[r,l]=v.useState(""),[i,s]=v.useState(null),[a,u]=v.useState(!1);async function c(g){g.preventDefault(),s(null),u(!0);try{const m=await kp(t,r);e(m)}catch(m){s(m.message)}finally{u(!1)}}return o.jsx("div",{className:"login-page",children:o.jsxs("div",{className:"login-card",children:[o.jsx("h1",{className:"login-brand",children:"Archivr"}),o.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),o.jsxs("form",{onSubmit:c,children:[o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),o.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:g=>n(g.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),o.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:g=>l(g.target.value),required:!0,autoComplete:"current-password"})]}),i&&o.jsx("p",{className:"login-error",children:i}),o.jsx("button",{className:"login-submit",type:"submit",disabled:a,children:a?"Signing in…":"Sign in"})]})]})})}function Jp({onComplete:e}){const[t,n]=v.useState(""),[r,l]=v.useState(""),[i,s]=v.useState(""),[a,u]=v.useState(null),[c,g]=v.useState(!1);async function m(h){if(h.preventDefault(),r!==i){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),g(!0);try{await Sp(t,r),e()}catch(x){u(x.message)}finally{g(!1)}}return o.jsx("div",{className:"setup-page",children:o.jsxs("div",{className:"setup-card",children:[o.jsx("h1",{className:"setup-brand",children:"Archivr"}),o.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),o.jsxs("form",{onSubmit:m,children:[o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),o.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:h=>n(h.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),o.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:h=>l(h.target.value),required:!0,autoComplete:"new-password"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),o.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:h=>s(h.target.value),required:!0,autoComplete:"new-password"})]}),a&&o.jsx("p",{className:"setup-error",children:a}),o.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Xp({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){const{currentUser:s,setCurrentUser:a}=v.useContext(Rl)??{},[u,c]=v.useState(!1);async function g(){c(!0),await jp(),a(null),window.location.reload()}return o.jsxs("header",{className:"topbar",children:[o.jsx("div",{className:"brand",children:"Archivr"}),o.jsx("div",{className:"switcher",children:o.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:m=>n(m.target.value),children:e.map(m=>o.jsx("option",{value:m.id,children:m.label},m.id))})}),o.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(m=>o.jsx("button",{className:`nav-link${r===m?" is-active":""}`,onClick:()=>l(m),children:m.charAt(0).toUpperCase()+m.slice(1)},m))}),o.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),s&&o.jsxs("div",{className:"user-menu",children:[o.jsx("span",{className:"user-name",children:s.display_name||s.username}),o.jsx("button",{className:"logout-btn",onClick:g,disabled:u,children:u?"Logging out…":"Log out"})]})]})}let is=1;function Pc(e){const t=e.trim(),n=t.toLowerCase();for(const r of["yt:","youtube:"])if(n.startsWith(r)){const l=n.slice(r.length);return l.startsWith("video/")||l.startsWith("short/")||l.startsWith("shorts/")}for(const r of["x:","twitter:","tweet:"])if(n.startsWith(r))return n.slice(r.length).startsWith("media:");return!!(n.startsWith("instagram:")||n.startsWith("facebook:")||n.startsWith("tiktok:")||n.startsWith("reddit:")||n.startsWith("snapchat:")||(n.startsWith("http://")||n.startsWith("https://"))&&(/^https?:\/\/(?:www\.)?(?:youtu\.be\/[0-9A-Za-z_-]+|youtube\.com\/watch\?v=[0-9A-Za-z_-]+|youtube\.com\/shorts\/[0-9A-Za-z_-]+)/.test(t)||n.startsWith("https://x.com/")||n.startsWith("http://x.com/")||/^https?:\/\/(?:www\.)?instagram\.com\//.test(n)||/^https?:\/\/(?:www\.)?facebook\.com\//.test(n)||n.startsWith("https://fb.watch/")||n.startsWith("http://fb.watch/")||/^https?:\/\/(?:www\.)?tiktok\.com\//.test(n)||/^https?:\/\/(?:www\.)?reddit\.com\//.test(n)||n.startsWith("https://redd.it/")||n.startsWith("http://redd.it/")||/^https?:\/\/(?:www\.)?snapchat\.com\//.test(n)))}function On(e=""){return{id:is++,locator:e,quality:"best",probeState:"idle",probeQualities:null,probeHasAudio:!1,status:"idle",error:null,jobUid:null,archiveId:null}}function pa(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function Gp({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const i=v.useRef(null),s=v.useRef(!0),a=v.useRef(new Map),u=v.useRef(new Map),c=v.useRef(t);v.useEffect(()=>{c.current=t},[t]);const g=v.useRef(r),m=v.useRef(l);v.useEffect(()=>{g.current=r},[r]),v.useEffect(()=>{m.current=l},[l]);const[h,x]=v.useState(()=>{try{const y=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(y)&&y.length>0)return y.forEach(T=>{T.id>=is&&(is=T.id+1)}),y}catch{}return[On()]});v.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(h))},[h]),v.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(y=>sessionStorage.removeItem(y)),x(y=>y.map(T=>T.status==="submitting"?{...T,status:"idle",error:null}:T)),h.forEach(y=>{y.status==="running"&&y.jobUid&&y.archiveId&&!a.current.has(y.jobUid)&&S(y.id,y.jobUid,y.locator,y.archiveId)})},[]),v.useEffect(()=>{const y=i.current;if(!y)return;const T=()=>{u.current.forEach(R=>clearTimeout(R)),u.current.clear(),n()};return y.addEventListener("close",T),()=>y.removeEventListener("close",T)},[n]),v.useEffect(()=>{const y=i.current;y&&(e?(!s.current&&!pa(h)&&x([On()]),s.current=!1,y.open||y.showModal()):(u.current.forEach(T=>clearTimeout(T)),u.current.clear(),y.open&&y.close()))},[e]),v.useEffect(()=>()=>{a.current.forEach(y=>clearInterval(y)),u.current.forEach(y=>clearTimeout(y))},[]);function S(y,T,R,A){if(a.current.has(T))return;const U=setInterval(async()=>{try{const E=await wp(A,T);if(E.status==="completed")clearInterval(a.current.get(T)),a.current.delete(T),x(F=>F.map(H=>H.id===y?{...H,status:"completed"}:H)),setTimeout(()=>{x(F=>{const H=F.filter(Z=>Z.id!==y);return H.length===0?[On()]:H})},1400),g.current();else if(E.status==="failed"){clearInterval(a.current.get(T)),a.current.delete(T);const F=E.error_text||"Capture failed.";x(H=>H.map(Z=>Z.id===y?{...Z,status:"failed",error:F}:Z)),m.current(F,R)}}catch(E){clearInterval(a.current.get(T)),a.current.delete(T);const F=E.message||"Network error";x(H=>H.map(Z=>Z.id===y?{...Z,status:"failed",error:F}:Z)),m.current(F,R)}},500);a.current.set(T,U)}async function j(y){if(!y.locator.trim())return;const T=t,R=y.locator.trim(),A=y.quality||"best";x(U=>U.map(E=>E.id===y.id?{...E,status:"submitting",error:null}:E));try{const U=await gp(T,R,A);x(E=>E.map(F=>F.id===y.id?{...F,status:"running",jobUid:U.job_uid,archiveId:T}:F)),S(y.id,U.job_uid,R,T)}catch(U){const E=U.message||"Submission failed.";x(F=>F.map(H=>H.id===y.id?{...H,status:"failed",error:E}:H)),m.current(E,R)}}function O(){h.filter(T=>T.status==="idle"&&T.locator.trim()).forEach(T=>j(T))}function f(){x(y=>[...y,On()])}function d(y){clearTimeout(u.current.get(y)),u.current.delete(y),x(T=>{const R=T.filter(A=>A.id!==y);return R.length===0?[On()]:R})}function p(y){x(T=>T.map(R=>R.id===y?{...R,status:"idle",error:null}:R))}function w(y,T){if(clearTimeout(u.current.get(y)),x(A=>A.map(U=>U.id===y?{...U,locator:T,probeState:"idle",probeQualities:null,probeHasAudio:!1,quality:"best"}:U)),!Pc(T))return;const R=setTimeout(async()=>{u.current.delete(y),x(A=>A.map(U=>U.id===y?{...U,probeState:"probing"}:U));try{const A=await yp(c.current,T.trim());x(U=>U.map(E=>{if(E.id!==y||E.locator!==T)return E;const F=A.qualities??[],H=A.has_audio??!1,Z=F.length===0&&H?"audio":"best";return{...E,probeState:"done",probeQualities:F,probeHasAudio:H,quality:Z}}))}catch{x(A=>A.map(U=>U.id===y?{...U,probeState:"idle",probeQualities:null}:U))}},600);u.current.set(y,R)}function k(y,T){x(R=>R.map(A=>A.id===y?{...A,quality:T}:A))}const _=h.filter(y=>y.status==="idle"&&y.locator.trim()).length,P=pa(h);return o.jsx("dialog",{ref:i,className:"capture-dialog",children:o.jsxs("div",{className:"capture-dialog-inner",children:[o.jsxs("div",{className:"capture-dialog-header",children:[o.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),o.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var y;return(y=i.current)==null?void 0:y.close()},"aria-label":"Close",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),o.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),o.jsx("div",{className:"capture-rows",children:h.map((y,T)=>o.jsx(Zp,{item:y,autoFocus:T===h.length-1&&y.status==="idle",onLocatorChange:R=>w(y.id,R),onQualityChange:R=>k(y.id,R),onRemove:()=>d(y.id),onReset:()=>p(y.id),onSubmit:O},y.id))}),o.jsxs("button",{type:"button",className:"capture-add-row",onClick:f,children:[o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),o.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),o.jsxs("div",{className:"capture-actions",children:[o.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var y;return(y=i.current)==null?void 0:y.close()},children:P?"Close":"Cancel"}),o.jsx("button",{type:"button",className:"capture-submit",onClick:O,disabled:_===0,children:_>1?`Archive ${_}`:"Archive"})]})]})})}function Zp({item:e,autoFocus:t,onLocatorChange:n,onQualityChange:r,onRemove:l,onReset:i,onSubmit:s}){const a=v.useRef(null),u=e.status==="submitting"||e.status==="running";v.useEffect(()=>{var g;t&&e.status==="idle"&&((g=a.current)==null||g.focus())},[t]);const c=(()=>{if(e.status==="completed"||u||!Pc(e.locator))return null;if(e.probeState==="probing")return o.jsx("span",{className:"capture-quality-probing","aria-label":"Checking available qualities",children:"…"});if(e.probeState==="done"){const g=e.probeQualities??[],m=e.probeHasAudio??!1;return g.length===0&&!m?o.jsx("span",{className:"capture-quality-hint",children:"No media detected"}):g.length===0&&m?o.jsx("select",{className:"capture-quality",value:"audio",onChange:h=>r(h.target.value),"aria-label":"Video quality",children:o.jsx("option",{value:"audio",children:"Audio only"})}):o.jsxs("select",{className:"capture-quality",value:e.quality||"best",onChange:h=>r(h.target.value),"aria-label":"Video quality",children:[o.jsx("option",{value:"best",children:"Best quality"}),g.map(h=>o.jsx("option",{value:h,children:h},h)),m&&o.jsx("option",{value:"audio",children:"Audio only"})]})}return null})();return o.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[o.jsxs("div",{className:"capture-row-main",children:[o.jsx(qp,{status:e.status}),o.jsx("input",{ref:a,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · tweet:ID · x:ID",value:e.locator,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&s()},disabled:u||e.status==="completed",autoComplete:"off",spellCheck:!1}),c,e.status==="failed"&&o.jsx("button",{type:"button",className:"capture-row-action",onClick:i,title:"Retry",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),o.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!u&&e.status!=="completed"&&e.status!=="failed"&&o.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:l,"aria-label":"Remove",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),o.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&o.jsx("p",{className:"capture-row-error",children:e.error})]})}function qp({status:e}){return e==="submitting"||e==="running"?o.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:o.jsx("span",{className:"cap-spinner"})}):e==="completed"?o.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?o.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):o.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function ss(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Ut(e){return bp(e)??""}function Lc(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const ha={youtube:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function zc(e){return ha[e]??ha.other}function Rc(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function eh({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,i]=v.useState(!1),a=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?o.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>i(!0),style:{objectFit:"contain"}}):o.jsx("span",{dangerouslySetInnerHTML:{__html:zc(e.source_kind)}});return o.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[o.jsx("div",{className:"col-added",children:Lc(e.archived_at)}),o.jsxs("div",{className:"col-title",children:[o.jsx("span",{className:"source-icon",children:a}),o.jsx("span",{className:"entry-title",children:Ut(e.title)||Ut(e.entry_uid)})]}),o.jsx("div",{className:"col-type",children:o.jsx("span",{className:"type-pill",children:Ut(e.entity_kind)})}),o.jsxs("div",{className:"col-size",children:[o.jsx("span",{className:"size-total",children:ss(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&o.jsxs("span",{className:"size-cached-pct",title:`${ss(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),o.jsx("div",{className:"url-cell col-url",children:Ut(e.original_url)})]})}function th({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return o.jsx("section",{id:"archive-view",className:"view is-active",children:o.jsxs("div",{className:"entry-table",children:[o.jsxs("div",{className:"entry-header-row",children:[o.jsx("div",{className:"col-added",children:"Added"}),o.jsx("div",{className:"col-title",children:"Title"}),o.jsx("div",{className:"col-type",children:"Type"}),o.jsx("div",{className:"col-size",children:"Size"}),o.jsx("div",{className:"col-url",children:"Original URL"})]}),o.jsx("div",{id:"entries-body",children:e.map(l=>o.jsx(eh,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function nh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function rh({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return o.jsx("span",{className:`run-status ${t}`,children:n})}function lh({runs:e}){const[t,n]=v.useState(null);function r(l){n(i=>i===l?null:l)}return o.jsx("section",{id:"runs-view",className:"view is-active",children:o.jsxs("table",{className:"entry-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Started"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Requested"}),o.jsx("th",{children:"Completed"}),o.jsx("th",{children:"Failed"})]})}),o.jsx("tbody",{children:e.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const i=l.status==="failed"&&l.error_summary,s=t===l.run_uid;return[o.jsxs("tr",{className:i?"run-row run-row--failed":"run-row",onClick:i?()=>r(l.run_uid):void 0,title:i?s?"Click to hide error":"Click to view error":void 0,children:[o.jsx("td",{children:nh(l.started_at)}),o.jsxs("td",{children:[o.jsx(rh,{status:l.status}),i&&o.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:s?"▴":"▾"})]}),o.jsx("td",{children:l.requested_count??"—"}),o.jsx("td",{children:l.completed_count??"—"}),o.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),i&&s&&o.jsx("tr",{className:"run-error-row",children:o.jsx("td",{colSpan:5,children:o.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const ih=4;function sh({archives:e}){const{currentUser:t}=v.useContext(Rl)??{},n=t&&(t.role_bits&ih)!==0,[r,l]=v.useState("users"),[i,s]=v.useState([]),[a,u]=v.useState([]),[c,g]=v.useState(!1),[m,h]=v.useState(null),[x,S]=v.useState(""),[j,O]=v.useState(""),[f,d]=v.useState(""),[p,w]=v.useState(null),[k,_]=v.useState(!1),[P,y]=v.useState(""),[T,R]=v.useState(""),[A,U]=v.useState(null),[E,F]=v.useState(!1),H=v.useCallback(async()=>{if(n){g(!0),h(null);try{const[N,M]=await Promise.all([Dp(),Mp()]);s(N),u(M)}catch(N){h(N.message)}finally{g(!1)}}},[n]);v.useEffect(()=>{H()},[H]);async function Z(N){const M=N.status==="active"?"disabled":"active";try{await $p(N.user_uid,M),s(Q=>Q.map(I=>I.user_uid===N.user_uid?{...I,status:M}:I))}catch(Q){h(Q.message)}}async function Me(N){if(N.preventDefault(),!x.trim()||!j){w("Username and password required");return}_(!0),w(null);try{await Op(x.trim(),j,f.trim()||void 0),S(""),O(""),d(""),await H()}catch(M){w(M.message)}finally{_(!1)}}async function L(N){if(N.preventDefault(),!P.trim()||!T.trim()){U("Slug and name required");return}F(!0),U(null);try{await Fp(P.trim(),T.trim()),y(""),R(""),await H()}catch(M){U(M.message)}finally{F(!1)}}return n?o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsxs("div",{className:"view-tabs",children:[o.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),o.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),o.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),m&&o.jsx("div",{className:"form-msg form-msg--err",children:m}),r==="users"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Users"}),c?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Username"}),o.jsx("th",{children:"Email"}),o.jsx("th",{children:"Roles"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Actions"})]})}),o.jsx("tbody",{children:i.map(N=>o.jsxs("tr",{className:N.status==="disabled"?"admin-row-disabled":"",children:[o.jsx("td",{children:N.username}),o.jsx("td",{className:"muted",children:N.email||"—"}),o.jsx("td",{children:N.role_slugs.join(", ")||"—"}),o.jsx("td",{children:o.jsx("span",{className:`status-badge status-${N.status}`,children:N.status})}),o.jsx("td",{children:o.jsx("button",{className:"admin-action-btn",onClick:()=>Z(N),children:N.status==="active"?"Ban":"Unban"})})]},N.user_uid))})]}),o.jsx("h3",{children:"Create User"}),o.jsxs("form",{className:"admin-form",onSubmit:Me,children:[o.jsx("input",{className:"admin-input",placeholder:"Username",value:x,onChange:N=>S(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:j,onChange:N=>O(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:f,onChange:N=>d(N.target.value)}),p&&o.jsx("div",{className:"form-msg form-msg--err",children:p}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:k,children:k?"Creating…":"Create User"})]})]}),r==="roles"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Roles"}),c?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Slug"}),o.jsx("th",{children:"Name"}),o.jsx("th",{children:"Level"}),o.jsx("th",{children:"Bit"}),o.jsx("th",{children:"Built-in"})]})}),o.jsx("tbody",{children:a.map(N=>o.jsxs("tr",{children:[o.jsx("td",{children:o.jsx("code",{children:N.slug})}),o.jsx("td",{children:N.name}),o.jsx("td",{children:N.level}),o.jsx("td",{children:N.bit_position}),o.jsx("td",{children:N.is_builtin?"✓":""})]},N.role_uid))})]}),o.jsx("h3",{children:"Create Custom Role"}),o.jsxs("form",{className:"admin-form",onSubmit:L,children:[o.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:P,onChange:N=>y(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:T,onChange:N=>R(N.target.value),required:!0}),A&&o.jsx("div",{className:"form-msg form-msg--err",children:A}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:E,children:E?"Creating…":"Create Role"})]})]}),r==="archives"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})]}):o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})}function Dc({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u}){var w;const c=n===e.tag.full_path,[g,m]=v.useState(!1),[h,x]=v.useState(""),S=v.useRef(!1);function j(){if(g)return;const k=c?null:e.tag.full_path;r(k),l("archive")}function O(k){k.stopPropagation(),x(e.tag.slug),m(!0)}async function f(){const k=h.trim();if(!k||k===e.tag.slug){m(!1);return}try{const _=await mp(t,e.tag.tag_uid,k);i(e.tag.full_path,_.full_path),a()}catch{}finally{m(!1)}}async function d(k){var P;k.stopPropagation();const _=((P=e.children)==null?void 0:P.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(_))try{await vp(t,e.tag.tag_uid),s(e.tag.full_path),a()}catch{}}const p={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u};return o.jsxs("li",{children:[o.jsxs("div",{className:"tag-node-row",children:[g?o.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:h,onChange:k=>x(k.target.value),onKeyDown:k=>{k.key==="Enter"&&k.currentTarget.blur(),k.key==="Escape"&&(S.current=!0,k.currentTarget.blur())},onBlur:()=>{S.current?(S.current=!1,m(!1)):f()}}):o.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:j,onDoubleClick:O,children:[u?e.tag.name:e.tag.slug,o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:k=>{k.stopPropagation(),O(k)},children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),o.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:d,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((w=e.children)==null?void 0:w.length)>0&&o.jsx("div",{className:"tag-children",children:o.jsx("ul",{className:"tag-tree-list",children:e.children.map(k=>o.jsx(Dc,{node:k,...p},k.tag.tag_uid))})})]})}function oh({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u}){return o.jsx("section",{id:"tags-view",className:"view is-active",children:o.jsxs("div",{className:"tag-tree",children:[o.jsxs("div",{className:"tag-tree-header",children:[o.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&o.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?o.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):o.jsx("ul",{className:"tag-tree-list",children:t.map(c=>o.jsx(Dc,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u},c.tag.tag_uid))})]})})}const An=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],ah=e=>{var t;return((t=An.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function uh({archiveId:e}){const[t,n]=v.useState([]),[r,l]=v.useState(!1),[i,s]=v.useState(null),[a,u]=v.useState(null),[c,g]=v.useState(null),[m,h]=v.useState(!1),[x,S]=v.useState(null),[j,O]=v.useState(""),[f,d]=v.useState(""),[p,w]=v.useState(2),[k,_]=v.useState(!1),[P,y]=v.useState(null),[T,R]=v.useState(""),[A,U]=v.useState(2),[E,F]=v.useState(!1),[H,Z]=v.useState(null),[Me,L]=v.useState(!1),[N,M]=v.useState(""),Q=v.useRef(null),I=t.find(z=>z.collection_uid===a)??null,we=(I==null?void 0:I.slug)==="_default_",ue=v.useCallback(async()=>{if(e){l(!0),s(null);try{const z=await Ip(e);n(z)}catch(z){s(z.message)}finally{l(!1)}}},[e]),Qe=v.useCallback(async z=>{if(!z){g(null);return}h(!0),S(null);try{const V=await Up(e,z);g(V)}catch(V){S(V.message)}finally{h(!1)}},[e]);v.useEffect(()=>{ue()},[ue]),v.useEffect(()=>{Qe(a)},[a,Qe]),v.useEffect(()=>{Me&&Q.current&&Q.current.focus()},[Me]);async function Fe(z){z.preventDefault();const V=j.trim(),Pe=f.trim();if(!(!V||!Pe)){_(!0),y(null);try{const $=await Ap(e,V,Pe,p);O(""),d(""),w(2),await ue(),u($.collection_uid)}catch($){y($.message)}finally{_(!1)}}}async function lt(){const z=N.trim();if(!z||!I){L(!1);return}try{await fa(e,I.collection_uid,{name:z}),await ue(),g(V=>V&&{...V,name:z})}catch(V){s(V.message)}finally{L(!1)}}async function Dl(z){if(I)try{await fa(e,I.collection_uid,{default_visibility_bits:z}),await ue(),g(V=>V&&{...V,default_visibility_bits:z})}catch(V){s(V.message)}}async function Ol(){if(I&&window.confirm(`Delete collection "${I.name}"? Entries will not be deleted.`))try{await Qp(e,I.collection_uid),u(null),g(null),await ue()}catch(z){s(z.message)}}async function $l(z){z.preventDefault();const V=T.trim();if(!(!V||!I)){F(!0),Z(null);try{await Bp(e,I.collection_uid,V,A),R(""),await Qe(I.collection_uid)}catch(Pe){Z(Pe.message)}finally{F(!1)}}}async function Ml(z){if(I)try{await Vp(e,I.collection_uid,z),await Qe(I.collection_uid)}catch(V){S(V.message)}}async function Fl(z,V){if(I)try{await Wp(e,I.collection_uid,z,V),g(Pe=>Pe&&{...Pe,entries:Pe.entries.map($=>$.entry_uid===z?{...$,collection_visibility_bits:V}:$)})}catch(Pe){S(Pe.message)}}return e?o.jsxs("div",{className:"collections-view",children:[o.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&o.jsx("div",{className:"muted",children:"Loading…"}),i&&o.jsxs("div",{className:"collections-error",children:[i," ",o.jsx("button",{onClick:()=>s(null),className:"coll-dismiss",children:"×"})]}),o.jsxs("div",{className:"collections-layout",children:[o.jsxs("div",{className:"collections-sidebar",children:[t.map(z=>o.jsxs("button",{className:`coll-sidebar-row${a===z.collection_uid?" is-active":""}`,onClick:()=>u(z.collection_uid),children:[o.jsx("span",{className:"coll-row-name",children:z.name}),o.jsx("span",{className:"coll-row-meta",children:ah(z.default_visibility_bits)})]},z.collection_uid)),t.length===0&&!r&&o.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),I?o.jsxs("div",{className:"coll-detail",children:[o.jsxs("div",{className:"coll-detail-header",children:[Me?o.jsx("input",{ref:Q,className:"coll-rename-input",value:N,onChange:z=>M(z.target.value),onBlur:lt,onKeyDown:z=>{z.key==="Enter"&<(),z.key==="Escape"&&L(!1)}}):o.jsxs("h3",{className:`coll-detail-name${we?"":" coll-detail-name--editable"}`,title:we?void 0:"Click to rename",onClick:()=>{we||(M(I.name),L(!0))},children:[(c==null?void 0:c.name)??I.name,!we&&o.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!we&&o.jsx("button",{className:"coll-delete-btn",onClick:Ol,title:"Delete collection",children:"Delete"})]}),o.jsxs("div",{className:"coll-detail-vis",children:[o.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),o.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??I.default_visibility_bits,onChange:z=>Dl(Number(z.target.value)),disabled:we,children:An.map(z=>o.jsx("option",{value:z.value,children:z.label},z.value))})]}),o.jsxs("div",{className:"coll-entries-section",children:[o.jsx("div",{className:"coll-section-heading",children:"Entries"}),m&&o.jsx("div",{className:"muted",children:"Loading…"}),x&&o.jsx("div",{className:"collections-error",children:x}),!m&&c&&(c.entries.length===0?o.jsx("div",{className:"muted",children:"No entries in this collection."}):o.jsx("ul",{className:"coll-entries-list",children:c.entries.map(z=>o.jsxs("li",{className:"coll-entry-row",children:[o.jsxs("div",{className:"coll-entry-info",children:[o.jsx("span",{className:"coll-entry-title",children:z.title||z.entry_uid}),o.jsx("span",{className:"coll-entry-kind muted",children:z.source_kind})]}),o.jsxs("div",{className:"coll-entry-actions",children:[o.jsx("select",{className:"coll-entry-vis-select",value:z.collection_visibility_bits,onChange:V=>Fl(z.entry_uid,Number(V.target.value)),children:An.map(V=>o.jsx("option",{value:V.value,children:V.label},V.value))}),!we&&o.jsx("button",{className:"coll-entry-remove",onClick:()=>Ml(z.entry_uid),title:"Remove from collection",children:"×"})]})]},z.entry_uid))}))]}),!we&&o.jsxs("form",{className:"coll-add-entry-form",onSubmit:$l,children:[o.jsx("div",{className:"coll-section-heading",children:"Add entry"}),o.jsxs("div",{className:"coll-add-entry-row",children:[o.jsx("input",{className:"coll-add-entry-input",type:"text",value:T,onChange:z=>R(z.target.value),placeholder:"entry_uid",required:!0}),o.jsx("select",{className:"coll-vis-select",value:A,onChange:z=>U(Number(z.target.value)),children:An.map(z=>o.jsx("option",{value:z.value,children:z.label},z.value))}),o.jsx("button",{className:"coll-add-btn",type:"submit",disabled:E,children:E?"…":"Add"})]}),H&&o.jsx("div",{className:"collections-error",style:{marginTop:4},children:H})]})]}):o.jsx("div",{className:"coll-detail coll-detail--empty",children:o.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),o.jsxs("details",{className:"coll-create-details",children:[o.jsx("summary",{children:"+ Create collection"}),o.jsxs("form",{className:"coll-create-form",onSubmit:Fe,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),o.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:j,onChange:z=>{O(z.target.value),f||d(z.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),o.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:f,onChange:z=>d(z.target.value),placeholder:"my-collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),o.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:p,onChange:z=>w(Number(z.target.value)),children:An.map(z=>o.jsx("option",{value:z.value,children:z.label},z.value))})]}),P&&o.jsx("div",{className:"collections-error",children:P}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:k,children:k?"Creating…":"Create collection"})]})]})]}):o.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const ch=4;function dh({tab:e,onTabChange:t}){const{currentUser:n,setCurrentUser:r}=v.useContext(Rl)??{},l=n&&(n.role_bits&ch)!==0,i=["profile","tokens",...l?["instance"]:[]],s={profile:"Profile",tokens:"API Tokens",instance:"Instance"};return o.jsxs("section",{className:"admin-view",children:[o.jsx("h1",{children:"Settings"}),o.jsx("div",{className:"view-tabs",children:i.map(a=>o.jsx("button",{className:`view-tab${e===a?" is-active":""}`,onClick:()=>t(a),children:s[a]},a))}),e==="profile"&&o.jsx(fh,{currentUser:n,setCurrentUser:r}),e==="tokens"&&o.jsx(ph,{}),e==="instance"&&l&&o.jsx(hh,{})]})}function fh({currentUser:e,setCurrentUser:t}){const[n,r]=v.useState((e==null?void 0:e.display_name)??""),[l,i]=v.useState(!1),[s,a]=v.useState(null),[u,c]=v.useState(""),[g,m]=v.useState(""),[h,x]=v.useState(""),[S,j]=v.useState(!1),[O,f]=v.useState(null);async function d(w){w.preventDefault(),i(!0),a(null);try{await Cp(n),t(k=>({...k,display_name:n||null})),a({ok:!0,text:"Saved."})}catch(k){a({ok:!1,text:k.message})}finally{i(!1)}}async function p(w){if(w.preventDefault(),g!==h){f({ok:!1,text:"Passwords do not match."});return}j(!0),f(null);try{await Ep(u,g),c(""),m(""),x(""),f({ok:!0,text:"Password changed."})}catch(k){f({ok:!1,text:k.message})}finally{j(!1)}}return o.jsxs("div",{style:{maxWidth:440},children:[o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Name"}),o.jsxs("form",{onSubmit:d,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),o.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:w=>r(w.target.value)})]}),s&&o.jsx("div",{className:`form-msg form-msg--${s.ok?"ok":"err"}`,children:s.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Preferences"}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async w=>{const k=w.target.checked;try{await _p({humanize_slugs:k}),t(_=>({..._,humanize_slugs:k}))}catch{}}}),o.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),o.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Change Password"}),o.jsxs("form",{onSubmit:p,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),o.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:w=>c(w.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),o.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:g,onChange:w=>m(w.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),o.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:h,onChange:w=>x(w.target.value),required:!0})]}),O&&o.jsx("div",{className:`form-msg form-msg--${O.ok?"ok":"err"}`,children:O.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:S,children:S?"Changing…":"Change Password"})]})]})]})}function ph(){const[e,t]=v.useState([]),[n,r]=v.useState(!0),[l,i]=v.useState(null),[s,a]=v.useState(""),[u,c]=v.useState(!1),[g,m]=v.useState(null),h=v.useCallback(async()=>{r(!0),i(null);try{t(await Tp())}catch(j){i(j.message)}finally{r(!1)}},[]);v.useEffect(()=>{h()},[h]);async function x(j){if(j.preventDefault(),!!s.trim()){c(!0);try{const O=await Pp(s.trim());m(O),a(""),h()}catch(O){i(O.message)}finally{c(!1)}}}async function S(j){try{await Lp(j),t(O=>O.filter(f=>f.token_uid!==j))}catch(O){i(O.message)}}return o.jsx("div",{style:{maxWidth:600},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"API Tokens"}),g&&o.jsxs("div",{className:"token-banner",children:[o.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",o.jsx("code",{children:g.raw_token}),o.jsx("button",{className:"token-dismiss",onClick:()=>m(null),children:"Dismiss"})]}),o.jsxs("form",{className:"token-create-row",onSubmit:x,children:[o.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:s,onChange:j=>a(j.target.value),required:!0}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&o.jsx("div",{className:"form-msg form-msg--err",children:l}),n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):o.jsxs("div",{children:[e.length===0&&o.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(j=>o.jsxs("div",{className:"token-row",children:[o.jsxs("div",{className:"token-row-info",children:[o.jsx("strong",{children:j.name}),o.jsxs("div",{className:"muted",children:["Created ",j.created_at.slice(0,10),j.last_used_at&&` · Last used ${j.last_used_at.slice(0,10)}`]})]}),o.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>S(j.token_uid),children:"Revoke"})]},j.token_uid))]})]})})}function hh(){const[e,t]=v.useState(null),[n,r]=v.useState(!0),[l,i]=v.useState(null),[s,a]=v.useState(!1),[u,c]=v.useState(null);v.useEffect(()=>{(async()=>{try{t(await zp())}catch(m){i(m.message)}finally{r(!1)}})()},[]);async function g(m){m.preventDefault(),a(!0),c(null);try{await Rp(e),c({ok:!0,text:"Saved."})}catch(h){c({ok:!1,text:h.message})}finally{a(!1)}}return n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):l?o.jsx("div",{className:"form-msg form-msg--err",children:l}):e?o.jsx("div",{style:{maxWidth:440},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Instance Settings"}),o.jsxs("form",{onSubmit:g,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([m,h])=>o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:!!e[m],onChange:x=>t(S=>({...S,[m]:x.target.checked}))}),h]},m)),o.jsxs("div",{className:"form-field",style:{marginTop:4},children:[o.jsx("label",{className:"form-label",children:"Default entry visibility"}),o.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:m=>t(h=>({...h,default_entry_visibility:Number(m.target.value)})),children:[o.jsx("option",{value:0,children:"Private"}),o.jsx("option",{value:2,children:"Unlisted"}),o.jsx("option",{value:3,children:"Public"})]})]}),u&&o.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:s,children:s?"Saving…":"Save Settings"})]})]})}):null}const ma={0:"Private",1:"Public",2:"Users only",3:"Public"},mh=()=>o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function vh({archiveId:e,selectedEntry:t,onTagFilterSet:n,tagNodes:r,onTagsRefresh:l,onEntryTitleChange:i,onEntryDeleted:s,humanizeTags:a}){const[u,c]=v.useState(null),[g,m]=v.useState([]),[h,x]=v.useState(""),[S,j]=v.useState([]),[O,f]=v.useState(""),d=v.useRef(0),p=v.useRef(!1),[w,k]=v.useState(!1),[_,P]=v.useState("");v.useEffect(()=>{if(!t||!e){c(null),m([]),j([]);return}k(!1),P(""),p.current=!1;const E=++d.current;c(null),m([]),Promise.all([cp(e,t.entry_uid),ci(e,t.entry_uid),Hp(e,t.entry_uid)]).then(([F,H,Z])=>{E===d.current&&(c(F),m(H),j(Z))}).catch(()=>{})},[t,e]);async function y(){const E=_.trim()||null;try{await dp(e,t.entry_uid,E),c(F=>F&&{...F,summary:{...F.summary,title:E}}),i==null||i(t.entry_uid,E)}catch{}finally{k(!1)}}async function T(){const E=h.trim();if(!(!E||!t))try{await fp(e,t.entry_uid,E),x(""),f("");const F=await ci(e,t.entry_uid);m(F),l()}catch(F){f(F.message)}}async function R(E){try{await pp(e,t.entry_uid,E);const F=await ci(e,t.entry_uid);m(F),l()}catch{}}async function A(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await hp(e,t.entry_uid),s==null||s(t.entry_uid)}catch{}}const U=u?[["Added",Lc(u.summary.archived_at)],["Source",u.summary.source_kind],["Type",u.summary.entity_kind],["Visibility",ma[u.summary.visibility]??u.summary.visibility],["Root",u.structured_root_relpath]]:[];return o.jsxs("aside",{className:"context-rail",children:[o.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?u?o.jsxs(o.Fragment,{children:[w?o.jsx("input",{className:"rail-title-input",autoFocus:!0,value:_,onChange:E=>P(E.target.value),onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur(),E.key==="Escape"&&(p.current=!0,E.currentTarget.blur())},onBlur:()=>{p.current?k(!1):y(),p.current=!1}}):o.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{P(u.summary.title??""),k(!0)},children:[Ut(u.summary.title)||Ut(u.summary.entry_uid),o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),u.summary.original_url&&o.jsxs("a",{className:"url-tile",href:u.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[o.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:zc(u.summary.source_kind)}}),o.jsx("span",{className:"u-text",children:u.summary.original_url}),o.jsx("span",{className:"ext",children:o.jsx(mh,{})})]}),o.jsx("div",{className:"meta-list",children:U.filter(([,E])=>E!=null&&E!=="").map(([E,F])=>o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-k",children:E}),o.jsx("span",{className:`meta-v${E==="Root"?" mono":""}`,children:Ut(F)})]},E))}),u.artifacts.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",o.jsx("span",{className:"num",children:u.artifacts.length})]}),o.jsx("ul",{className:"artifact-list",children:u.artifacts.map((E,F)=>o.jsx("li",{children:o.jsxs("a",{href:`/api/archives/${e}/entries/${u.summary.entry_uid}/artifacts/${F}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[o.jsx("span",{className:"artifact-name",children:E.artifact_role.replace(/_/g," ")}),o.jsx("span",{className:"artifact-size",children:E.byte_size!=null?ss(E.byte_size):"—"})]})},F))})]})]}):o.jsx("p",{className:"tags-empty",children:"Loading…"}):o.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Tags"}),g.length===0?o.jsx("p",{className:"tags-empty",children:"No tags yet."}):o.jsx("div",{className:"tags-wrap",children:g.map(E=>o.jsxs("span",{className:"tag-pill",title:E.full_path,children:[a?Rc(E.full_path):E.full_path,o.jsx("button",{className:"remove",title:`Remove tag ${E.full_path}`,onClick:()=>R(E.tag_uid),children:"×"})]},E.tag_uid))}),O&&o.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:O}),o.jsxs("div",{className:"tag-input-wrap",children:[o.jsx("span",{className:"hash",children:"/"}),o.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:h,onChange:E=>x(E.target.value),onKeyDown:E=>{E.key==="Enter"&&T()}}),o.jsx("button",{className:"tag-add-btn",onClick:T,children:"Add"})]})]}),S.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Collections"}),S.map(E=>o.jsxs("div",{className:"coll-row",children:[o.jsx("span",{className:"coll-name",children:E.collection_uid}),o.jsx("span",{className:"vis-badge",children:ma[E.visibility_bits]??`bits:${E.visibility_bits}`})]},E.collection_uid))]}),o.jsx("div",{className:"rail-delete-zone",children:o.jsx("button",{className:"rail-delete-btn",onClick:A,children:"Delete entry"})})]})]})}const gh=7e3;function yh({toasts:e,onDismiss:t}){return e.length?o.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(n=>o.jsx(wh,{toast:n,onDismiss:t},n.id))}):null}function wh({toast:e,onDismiss:t}){const[n,r]=v.useState(!1);v.useEffect(()=>{if(n)return;const i=setTimeout(()=>t(e.id),gh);return()=>clearTimeout(i)},[n,e.id,t]);const l=e.locator?e.locator.length>48?e.locator.slice(0,45)+"…":e.locator:null;return o.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[o.jsxs("div",{className:"toast-top",children:[o.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),o.jsxs("div",{className:"toast-body",children:[o.jsx("span",{className:"toast-headline",children:"Capture failed"}),l&&o.jsx("span",{className:"toast-locator",children:l})]}),o.jsxs("div",{className:"toast-btns",children:[e.errorText&&o.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>r(i=>!i),children:n?"Hide":"View error"}),o.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),n&&e.errorText&&o.jsx("pre",{className:"toast-error-detail",children:e.errorText})]})}const Rl=v.createContext(null),xh=["archive","tags","collections","runs","admin","settings"],Sh=["profile","tokens","instance"];function fi(){const e=window.location.pathname.split("/").filter(Boolean),t=xh.includes(e[0])?e[0]:"archive",n=t==="settings"&&Sh.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function kh(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function jh(){const[e,t]=v.useState("loading"),[n,r]=v.useState(null);v.useEffect(()=>{(async()=>{if(await xp()){t("setup");return}const K=await Np();if(!K){t("login");return}r(K),t("authenticated")})()},[]),v.useEffect(()=>{const $=()=>{r(null),t("login")};return window.addEventListener("auth:expired",$),()=>window.removeEventListener("auth:expired",$)},[]),v.useEffect(()=>{const $=()=>{const{view:K,settingsTab:ce}=fi();f(K),p(ce)};return window.addEventListener("popstate",$),()=>window.removeEventListener("popstate",$)},[]);const[l,i]=v.useState([]),[s,a]=v.useState(null),[u,c]=v.useState([]),[g,m]=v.useState(null),[h,x]=v.useState(null),[S,j]=v.useState(null),[O,f]=v.useState(()=>fi().view),[d,p]=v.useState(()=>fi().settingsTab),[w,k]=v.useState(""),[_,P]=v.useState(""),[y,T]=v.useState(!1),[R,A]=v.useState([]),[U,E]=v.useState([]),[F,H]=v.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[Z,Me]=v.useState([]),L=v.useRef(0),N=(n==null?void 0:n.humanize_slugs)??!1;v.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",F)},[F]);const M=v.useCallback(async($,K,ce)=>{if($){T(!0);try{let Ie;K||ce?Ie=await up($,K,ce):Ie=await ap($),c(Ie),P(Ie.length===0?"No results":`${Ie.length} result${Ie.length===1?"":"s"}`)}catch{c([]),P("Search failed. Try again.")}finally{T(!1)}}},[]);v.useEffect(()=>{e==="authenticated"&&op().then($=>{if(i($),$.length>0){const K=$[0].id;a(K)}})},[e]),v.useEffect(()=>{s&&(j(null),x(null),m(null),Promise.all([M(s,"",null),da(s).then(A),di(s).then(E)]))},[s]),v.useEffect(()=>{if(s===null)return;const $=setTimeout(()=>{M(s,w,S)},300);return()=>clearTimeout($)},[w,s]),v.useEffect(()=>{s!==null&&(S!==null&&f("archive"),M(s,w,S))},[S,s]);const Q=v.useCallback($=>{a($)},[]),I=v.useCallback($=>{f($),$==="tags"&&s&&di(s).then(E)},[s]);v.useEffect(()=>{const $=kh(O,d);window.location.pathname!==$&&history.pushState(null,"",$)},[O,d]);const we=v.useCallback($=>{m($?$.entry_uid:null),x($)},[]),ue=v.useCallback($=>{j($)},[]),Qe=v.useCallback(()=>{j(null)},[]),Fe=v.useCallback(()=>{s&&di(s).then(E)},[s]),lt=v.useCallback(($,K)=>{S===$?j(K):S!=null&&S.startsWith($+"/")&&j(K+S.slice($.length))},[S]),Dl=v.useCallback($=>{(S===$||S!=null&&S.startsWith($+"/"))&&j(null)},[S]),Ol=v.useCallback(($,K)=>{c(ce=>ce.map(Ie=>Ie.entry_uid===$?{...Ie,title:K}:Ie)),x(ce=>ce&&ce.entry_uid===$?{...ce,title:K}:ce)},[]),$l=v.useCallback($=>{c(K=>K.filter(ce=>ce.entry_uid!==$)),x(K=>(K==null?void 0:K.entry_uid)===$?null:K),m(K=>K===$?null:K)},[]),Ml=v.useCallback(()=>{H(!0)},[]),Fl=v.useCallback(()=>{H(!1)},[]),z=v.useCallback(()=>{s&&Promise.all([M(s,w,S),da(s).then(A)])},[s,w,S,M]),V=v.useCallback(($,K)=>{const ce=++L.current;Me(Ie=>[...Ie,{id:ce,errorText:$,locator:K}])},[]),Pe=v.useCallback($=>{Me(K=>K.filter(ce=>ce.id!==$))},[]);return e==="loading"?o.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?o.jsx(Jp,{onComplete:()=>t("login")}):e==="login"?o.jsx(Yp,{onLogin:$=>{r($),t("authenticated")}}):o.jsx(Rl.Provider,{value:{currentUser:n,setCurrentUser:r},children:o.jsxs(o.Fragment,{children:[o.jsx(Xp,{archives:l,archiveId:s,onArchiveChange:Q,view:O,onViewChange:I,onCaptureClick:Ml}),o.jsxs("main",{className:"app-shell",children:[o.jsxs("div",{className:"workspace",children:[O==="archive"&&o.jsxs("div",{className:"toolbar",children:[o.jsxs("div",{className:"search-field",children:[o.jsx("span",{className:"ico","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"7"}),o.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),o.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":y,placeholder:"Search titles, URLs, types, tags…",value:w,onChange:$=>k($.target.value)}),o.jsx("span",{className:"kbd",children:"⌘K"})]}),o.jsxs("span",{className:"result-count",children:[_&&o.jsxs(o.Fragment,{children:[o.jsx("b",{children:_.split(" ")[0]})," ",_.split(" ").slice(1).join(" ")]}),S&&o.jsxs("button",{className:"tag-filter-badge",onClick:Qe,children:["× ",N?Rc(S):S]})]})]}),O==="archive"&&o.jsx(th,{entries:u,selectedEntryUid:g,onSelectEntry:we,archiveId:s,tagFilter:S,onClearTagFilter:Qe,searchQuery:w,onSearchChange:k,resultCount:_,searchBusy:y}),O==="runs"&&o.jsx(lh,{runs:R}),O==="admin"&&o.jsx(sh,{archives:l}),O==="tags"&&o.jsx(oh,{archiveId:s,tagNodes:U,tagFilter:S,onTagFilterSet:ue,onViewChange:I,onTagRenamed:lt,onTagDeleted:Dl,onTagsRefresh:Fe,humanizeTags:N}),O==="collections"&&o.jsx(uh,{archiveId:s}),O==="settings"&&o.jsx(dh,{tab:d,onTabChange:p})]}),o.jsx(vh,{archiveId:s,selectedEntry:h,onTagFilterSet:ue,tagNodes:U,onTagsRefresh:Fe,onEntryTitleChange:Ol,onEntryDeleted:$l,humanizeTags:N})]}),o.jsx(Gp,{open:F,archiveId:s,onClose:Fl,onCaptured:z,onToast:V}),o.jsx(yh,{toasts:Z,onDismiss:Pe})]})})}Tc(document.getElementById("root")).render(o.jsx(v.StrictMode,{children:o.jsx(jh,{})})); diff --git a/crates/archivr-server/static/assets/index-BW0QKHXE.css b/crates/archivr-server/static/assets/index-BW0QKHXE.css new file mode 100644 index 0000000..5f2d0db --- /dev/null +++ b/crates/archivr-server/static/assets/index-BW0QKHXE.css @@ -0,0 +1 @@ +@import"https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Spectral:wght@500;600&display=swap";:root{color-scheme:light;--ink: #20251f;--muted: #6b6f66;--muted-2: #8a8d83;--paper: #f5f0e7;--paper-2: #e9e1d2;--paper-3: #fffaf0;--line: #d2c6b5;--line-soft: #e5dccd;--accent: #8d3f30;--accent-2: #b78342;--link: #245f72;--top: #141d18;--field: #fffdf7;--r: 3px;--r2: 6px;--r3: 10px;--sans: "Helvetica Neue", Helvetica, Arial, sans-serif;--serif: "Spectral", Georgia, "Times New Roman", serif;--display: "Cormorant Garamond", Georgia, serif}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:14px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select{font:inherit}.workspace,.context-rail{scrollbar-width:thin;scrollbar-color:var(--line) transparent}.workspace::-webkit-scrollbar,.context-rail::-webkit-scrollbar{width:11px;height:11px}.workspace::-webkit-scrollbar-track,.context-rail::-webkit-scrollbar-track{background:transparent}.workspace::-webkit-scrollbar-thumb,.context-rail::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:3px solid transparent;background-clip:padding-box}.workspace::-webkit-scrollbar-thumb:hover,.context-rail::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:3px solid transparent}.topbar{height:58px;display:grid;grid-template-columns:auto auto 1fr auto auto;align-items:center;gap:26px;padding:0 22px;background:var(--top);color:#efe6d6;border-bottom:3px solid var(--accent)}.brand{font-family:var(--display);font-weight:600;font-size:30px;line-height:1;letter-spacing:.01em;color:#f4ead8}.switcher{position:relative;display:inline-flex;align-items:center}.switcher select{-moz-appearance:none;appearance:none;-webkit-appearance:none;border:1px solid rgba(247,238,223,.2);background:#f7eedf0f;color:#f1e8d8;font-family:var(--sans);font-weight:550;font-size:13.5px;letter-spacing:.04em;padding:8px 32px 8px 15px;cursor:pointer;border-radius:6px;transition:background .15s ease,border-color .15s ease}.switcher select:hover{background:#f7eedf1c;border-color:#f7eedf57}.switcher:after{content:"";position:absolute;right:15px;top:50%;width:6px;height:6px;margin-top:-5px;border-right:1.2px solid #b6ab98;border-bottom:1.2px solid #b6ab98;transform:rotate(45deg);pointer-events:none}.nav{display:flex;gap:22px;justify-content:flex-end;min-width:0}.nav-link{border:0;background:transparent;color:#cdc1ad;cursor:pointer;padding:6px 0;font-size:12.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;position:relative}.nav-link:hover,.nav-link.is-active{color:#f4ead8}.nav-link.is-active:after{content:"";position:absolute;left:0;right:0;bottom:-2px;height:1px;background:var(--accent-2)}.capture-button{display:inline-flex;align-items:center;gap:8px;position:relative;overflow:hidden;border:0;background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 88%,#fff) 0%,var(--accent) 55%);color:#f7eddd;padding:10px 18px;cursor:pointer;font-size:12px;font-weight:600;letter-spacing:.15em;text-transform:uppercase;border-radius:var(--r);box-shadow:inset 0 1px #fff5e629,0 1px 2px #141d184d;transition:filter .18s ease,box-shadow .18s ease}.capture-button:hover{filter:brightness(.93);box-shadow:inset 0 1px #fff5e61f,0 2px 6px #141d1857}.capture-button:before{content:"";position:absolute;top:0;bottom:0;left:0;width:45%;background:linear-gradient(100deg,transparent 0%,rgba(255,246,232,.45) 50%,transparent 100%);transform:translate(-180%) skew(-18deg);pointer-events:none}@media (prefers-reduced-motion: no-preference){.capture-button:hover:before{animation:cap-sheen .7s ease}}@keyframes cap-sheen{0%{transform:translate(-180%) skew(-18deg)}to{transform:translate(340%) skew(-18deg)}}.app-shell{height:calc(100vh - 58px);display:grid;grid-template-columns:minmax(0,1fr) 340px}.workspace{min-width:0;overflow:auto;display:flex;flex-direction:column}.view{display:none}.view.is-active{display:block}.toolbar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:16px;padding:12px 22px;background:color-mix(in srgb,var(--paper) 88%,white);border-bottom:1px solid var(--line-soft)}.search-field{position:relative;flex:1 1 auto;min-width:0;display:flex;align-items:center;height:42px;background:var(--field);border:1px solid var(--line);border-radius:20px;transition:border-color .15s ease,box-shadow .15s ease}.search-field:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.search-field .ico{display:grid;place-items:center;width:46px;height:100%;color:var(--muted-2);flex-shrink:0}.search-field .ico svg{width:16px;height:16px}.search-input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);padding:0 6px 0 0;font-size:14px;letter-spacing:.01em;outline:none}.search-input::placeholder{color:var(--muted-2)}.search-field .kbd{margin-right:12px;display:inline-flex;align-items:center;padding:3px 7px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:var(--r);flex-shrink:0}.result-count{flex-shrink:0;font-size:13px;color:var(--muted);letter-spacing:.02em;white-space:nowrap}.result-count b{color:var(--ink);font-weight:600;font-variant-numeric:tabular-nums}.tag-filter-badge{display:inline-flex;align-items:center;gap:4px;background:var(--accent);color:#fff;border:0;border-radius:var(--r);font-size:12px;padding:2px 8px;cursor:pointer;margin-left:8px}.tag-filter-badge:hover{opacity:.85}.entry-table{width:100%;font-size:12.5px}.entry-header-row{display:flex;align-items:stretch;position:sticky;top:67px;z-index:2;background:color-mix(in srgb,var(--paper) 92%,white);border-bottom:1px solid var(--line-soft);color:var(--muted);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600;display:flex;align-items:center}#entries-body>div{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft)}#entries-body>div>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>div:nth-child(2n){background:#f2ede5}#entries-body>div:nth-child(odd){background:var(--paper-3)}#entries-body>div.is-selected{background:#eee2d2;outline:2px solid var(--accent);outline-offset:-2px}.col-added{width:162px;color:var(--muted)}.col-title{flex:1 1 0;min-width:0;overflow:hidden;display:flex;align-items:center;gap:.42em}.col-type{width:116px}.col-size{width:100px;display:flex;flex-direction:column;justify-content:center;gap:1px}.size-total{font-variant-numeric:tabular-nums}.size-cached-pct{font-size:10px;color:var(--muted);opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.col-url{flex:0 0 30%;min-width:0;overflow:hidden}.entry-header-row>div:first-child,#entries-body>div>div:first-child{padding-left:22px}.entry-header-row>div:last-child,#entries-body>div>div:last-child{padding-right:22px}.entry-title{color:var(--link);font-weight:700;min-width:0}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600}.source-icon{display:flex;align-items:center;justify-content:center;width:1.05em;height:1.05em;flex-shrink:0}.source-icon>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.source-icon svg{width:100%;height:100%}.url-cell{color:#555b55;white-space:nowrap;text-overflow:ellipsis;word-break:break-all}#entries-body .url-cell:hover,#entries-body .is-selected .url-cell{overflow:visible;white-space:normal}.type-pill{display:inline-block;padding:2px 6px;background:#d8e3df;color:#275a5f;border:1px solid #bfd0ca;border-radius:var(--r)}#runs-view .entry-table{border-collapse:collapse;table-layout:auto}#runs-view .entry-table th{position:sticky;top:0;z-index:1;text-align:left;padding:10px;background:color-mix(in srgb,var(--paper) 92%,white);color:var(--muted);border-bottom:1px solid var(--line-soft);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}#runs-view .entry-table td{padding:10px;border-bottom:1px solid var(--line-soft);vertical-align:top}#runs-view .entry-table tr:nth-child(2n) td{background:#f2ede5}#runs-view .entry-table tr:nth-child(odd) td{background:var(--paper-3)}.context-rail{border-left:1px solid var(--line);background:var(--paper);padding:20px 20px 32px;overflow:auto}.rail-eyebrow{font-size:10.5px;font-weight:600;letter-spacing:.16em;text-transform:uppercase;color:var(--muted-2);margin-bottom:16px}.rail-title{display:block;font-family:var(--sans);font-weight:700;font-size:15.5px;line-height:1.4;color:var(--ink);margin:0 0 16px;word-break:break-word}.url-tile{display:flex;align-items:center;gap:9px;padding:10px 12px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);margin-bottom:20px;text-decoration:none}.url-tile:hover{background:var(--field);border-color:var(--accent)}.url-tile .ico{color:var(--ink);flex-shrink:0;display:grid;place-items:center}.url-tile .ico svg{width:15px;height:15px}.url-tile .u-text{min-width:0;flex:1;font-size:12.5px;color:var(--link);font-family:ui-monospace,SF Mono,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.url-tile .ext{color:var(--muted-2);flex-shrink:0}.url-tile .ext svg{width:13px;height:13px;display:block}.meta-list{margin-bottom:24px;border-top:1px solid var(--line-soft)}.meta-item{display:grid;grid-template-columns:92px 1fr;gap:14px;align-items:baseline;padding:9px 0;border-bottom:1px solid var(--line-soft)}.meta-k{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2)}.meta-v{font-size:13.5px;color:var(--ink);word-break:break-word;line-height:1.4}.meta-v.mono{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:12px;color:var(--muted)}.rail-section{margin-bottom:24px}.rail-section-heading{display:flex;align-items:baseline;gap:8px;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--muted-2);margin-bottom:9px;padding-bottom:8px;border-bottom:1px solid var(--line)}.rail-section-heading .num{color:var(--muted-2);font-weight:600}.artifact-list{list-style:none;margin:0;padding:0}.artifact-link{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:7px 2px;border-bottom:1px solid var(--line-soft);text-decoration:none}.artifact-link:last-child{border-bottom:0}.artifact-name{font-size:13px;color:var(--link);min-width:0;word-break:break-word}.artifact-link:hover .artifact-name{text-decoration:underline}.artifact-size{font-size:11.5px;color:var(--muted-2);flex-shrink:0;font-variant-numeric:tabular-nums}.tags-wrap{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 12px}.tag-pill{display:inline-flex;align-items:center;gap:7px;background:var(--paper-2);border:1px solid var(--line);border-radius:var(--r);font-size:12px;padding:4px 7px 4px 10px;color:var(--ink)}.tag-pill .remove{border:0;background:transparent;cursor:pointer;color:var(--muted-2);width:15px;height:15px;display:grid;place-items:center;font-size:13px;line-height:1}.tag-pill .remove:hover{color:var(--accent)}.tags-empty{font-size:13px;color:var(--muted);margin:0 0 11px}.tag-input-wrap{display:flex;align-items:center;gap:8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);padding:2px 2px 2px 11px;transition:border-color .15s ease,box-shadow .15s ease}.tag-input-wrap:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent)}.tag-input-wrap .hash{color:var(--muted-2);font-size:13px}.tag-input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font-size:13px;padding:6px 0;outline:none;font-family:ui-monospace,SF Mono,Menlo,monospace}.tag-add-btn{border:0;background:var(--ink);color:var(--paper-3);padding:6px 13px;font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;border-radius:var(--r);cursor:pointer;white-space:nowrap}.tag-add-btn:hover{background:#2c332b}.coll-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 13px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);margin-bottom:6px;transition:border-color .15s ease}.coll-row:hover{border-color:var(--accent)}.coll-name{font-size:13px;color:var(--ink);font-weight:500}.vis-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:999px;padding:3px 10px}.vis-badge:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent-2)}.rail-delete-zone{margin-top:24px;padding-top:20px;border-top:1px solid var(--line-soft)}.rail-delete-btn{width:100%;padding:8px 14px;background:none;border:1px solid color-mix(in srgb,var(--accent) 45%,transparent);color:var(--accent);border-radius:var(--r);cursor:pointer;font-size:12.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;transition:background .15s ease,border-color .15s ease}.rail-delete-btn:hover{background:color-mix(in srgb,var(--accent) 8%,transparent);border-color:var(--accent)}.capture-dialog{border:1px solid var(--line);background:var(--paper);padding:0;width:min(540px,calc(100vw - 32px));border-radius:var(--r3);box-shadow:0 20px 60px #141d1847}.capture-dialog::backdrop{background:#141d1873}.capture-dialog-inner{padding:28px}.capture-dialog-title{margin:0;font-size:22px;font-family:var(--display);font-weight:600}.capture-label{display:block;font-size:11px;font-weight:600;margin-bottom:6px;color:var(--muted-2);text-transform:uppercase;letter-spacing:.06em}.capture-input{width:100%;height:44px;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:0 14px;font-size:15px;margin-bottom:10px;border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease}.capture-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.form-field .capture-input{margin-bottom:0}.capture-error{color:var(--accent);font-size:13px;margin-bottom:10px;min-height:18px}.capture-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}.capture-cancel{border:1px solid var(--line);background:none;color:var(--ink);padding:8px 18px;border-radius:var(--r);cursor:pointer}.capture-cancel:hover{background:var(--paper-2)}.capture-submit{border:0;background:var(--ink);color:var(--paper);padding:8px 20px;border-radius:var(--r);cursor:pointer;font-weight:600}.capture-submit:hover{opacity:.85}.capture-submit:disabled{opacity:.45;cursor:default}.capture-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.capture-dialog-close{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-dialog-close svg{width:14px;height:14px}.capture-dialog-close:hover{background:var(--paper-2);color:var(--ink)}.capture-rows{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}.capture-row{display:flex;flex-direction:column;gap:3px}.capture-row-main{display:flex;align-items:center;gap:8px}.capture-row-main .capture-input{margin-bottom:0}.capture-quality{flex-shrink:0;height:32px;padding:0 6px;border:1px solid var(--line);border-radius:var(--r);background:var(--paper);color:var(--ink);font-size:12px;cursor:pointer;outline:none;transition:border-color .15s}.capture-quality:hover{border-color:var(--accent-2)}.capture-quality:focus{border-color:var(--accent)}.capture-quality:disabled{opacity:.5;cursor:default}.capture-quality-probing{flex-shrink:0;font-size:12px;color:var(--muted);padding:0 4px;letter-spacing:.05em}.capture-quality-hint{flex-shrink:0;font-size:12px;color:var(--muted);font-style:italic}.cap-dot{flex-shrink:0;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;line-height:1}.cap-dot--idle{background:var(--paper-2)}.cap-dot--running{background:#fdefd8;color:#8a4f10}.cap-dot--ok{background:#d8eddf;color:#235c35}.cap-dot--err{background:#f5ddd8;color:#8d3f30}.cap-spinner{display:block;width:10px;height:10px;border:2px solid currentColor;border-top-color:transparent;border-radius:50%;animation:cap-spin .7s linear infinite}@keyframes cap-spin{to{transform:rotate(360deg)}}.capture-row-action{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-row-action svg{width:12px;height:12px}.capture-row-action:hover{color:var(--accent);background:var(--paper-2)}.capture-row-remove:hover{color:var(--accent)}.capture-row-error{margin:0;padding-left:28px;font-size:12px;color:var(--accent);line-height:1.45}.capture-add-row{display:flex;align-items:center;gap:7px;width:100%;background:none;border:1px dashed var(--line);border-radius:var(--r);color:var(--muted);font-size:13px;cursor:pointer;padding:7px 12px;margin-top:4px;margin-bottom:18px;transition:border-color .15s,color .15s,background .15s}.capture-add-row svg{width:13px;height:13px;flex-shrink:0}.capture-add-row:hover{border-color:var(--accent-2);color:var(--ink);background:var(--paper-2)}.toast-stack{position:fixed;bottom:24px;right:24px;z-index:9000;display:flex;flex-direction:column;gap:10px;width:340px;max-width:calc(100vw - 32px);pointer-events:none}.toast{pointer-events:auto;background:var(--paper);border:1px solid var(--line);border-radius:var(--r2);box-shadow:0 6px 24px #141d182e,0 1px 4px #141d181a;overflow:hidden;animation:toast-slide-in .22s cubic-bezier(.22,.68,0,1.2)}@keyframes toast-slide-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.toast--error{border-left:3px solid var(--accent)}.toast-top{display:flex;align-items:flex-start;gap:10px;padding:12px 12px 12px 14px}.toast-icon{flex-shrink:0;font-size:13px;font-weight:700;color:var(--accent);margin-top:2px}.toast-body{flex:1;min-width:0}.toast-headline{display:block;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.3}.toast-locator{display:block;font-size:12px;color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-btns{display:flex;align-items:center;gap:6px;flex-shrink:0}.toast-view-btn{background:none;border:1px solid var(--line);color:var(--link);font-size:12px;cursor:pointer;padding:3px 9px;border-radius:var(--r);white-space:nowrap}.toast-view-btn:hover{background:var(--paper-2);border-color:var(--link)}.toast-dismiss{background:none;border:0;cursor:pointer;color:var(--muted);font-size:20px;line-height:1;width:24px;height:24px;display:grid;place-items:center;border-radius:var(--r);padding:0}.toast-dismiss:hover{color:var(--ink);background:var(--paper-2)}.toast-error-detail{margin:0;padding:10px 14px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word;max-height:200px;overflow-y:auto}.muted{color:var(--muted)}.admin-view{padding:22px}.admin-list{display:grid;gap:10px;max-width:780px}.admin-archive{border:1px solid var(--line);background:var(--paper-3);padding:12px;border-radius:var(--r2)}.tag-tree{padding:20px 22px;max-width:320px}.tag-tree-header{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;border-bottom:1px solid var(--line-soft);padding-bottom:10px}.tag-tree-title{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}.tag-tree-active{font-size:12px;color:var(--muted-2);font-style:italic}.tag-tree-list{list-style:none;margin:0;padding:0}.tag-children{padding-left:16px}.tag-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 0;text-align:left;font-size:13px;display:block;width:100%}.tag-node-btn:hover{text-decoration:underline}.tag-node-btn.is-active{font-weight:600;color:var(--ink)}.tag-node-row{display:flex;align-items:center;gap:4px}.tag-node-row .tag-node-btn{flex:1 1 0;min-width:0;display:flex;align-items:center;gap:4px;width:auto}.tag-node-btn .edit-icon{width:.75em;height:.75em;flex-shrink:0;vertical-align:-.1em;opacity:.35}.tag-node-btn:hover .edit-icon{opacity:.65}.tag-node-delete{flex-shrink:0;border:0;background:transparent;color:var(--muted-2);cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:0}.tag-node-row:hover .tag-node-delete{opacity:1}.tag-node-delete:hover{color:var(--accent)}.tag-rename-input{font-size:13px;flex:1 1 0;min-width:0;padding:2px 5px;border:1px solid var(--accent);border-radius:var(--r);background:var(--field);color:var(--ink);outline:none}.collections-view{padding:24px}.collections-heading{margin:0 0 16px;font-size:22px;font-family:var(--display);font-weight:600}.collections-error{color:var(--accent);font-size:13px;margin-bottom:8px}.coll-dismiss{background:none;border:none;cursor:pointer;color:var(--accent);font-size:16px;line-height:1;padding:0 4px}.collections-layout{display:grid;grid-template-columns:220px 1fr;gap:0;border:1px solid var(--line);border-radius:var(--r2);min-height:340px}.collections-sidebar{border-right:1px solid var(--line);overflow-y:auto}.coll-sidebar-row{display:flex;flex-direction:column;width:100%;padding:10px 14px;border:none;border-bottom:1px solid var(--line-soft);background:none;cursor:pointer;text-align:left;gap:2px}.coll-sidebar-row:hover{background:var(--paper-2)}.coll-sidebar-row.is-active{background:var(--paper-2);border-left:3px solid var(--accent)}.coll-row-name{font-size:14px;font-weight:600;color:var(--ink)}.coll-row-meta{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.coll-detail{padding:20px 24px;display:flex;flex-direction:column;gap:16px}.coll-detail--empty{justify-content:center;align-items:center}.coll-detail-header{display:flex;align-items:center;gap:12px}.coll-detail-name{margin:0;font-size:18px;font-family:var(--display);font-weight:600;flex:1}.coll-detail-name--editable{cursor:pointer}.coll-detail-name--editable:hover{color:var(--link)}.coll-edit-hint{font-size:14px;opacity:.5;margin-left:4px}.coll-rename-input{flex:1;font-size:16px;font-family:var(--display);border:1px solid var(--line);padding:4px 8px;background:var(--field);color:var(--ink);border-radius:var(--r)}.coll-delete-btn{border:1px solid var(--accent);background:none;color:var(--accent);padding:5px 12px;font-size:13px;cursor:pointer;border-radius:var(--r)}.coll-delete-btn:hover{background:var(--accent);color:var(--paper)}.coll-detail-vis{display:flex;align-items:center;gap:10px}.coll-vis-label{font-size:13px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}.coll-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:4px 8px;font-size:13px;border-radius:var(--r)}.coll-section-heading{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px}.coll-entries-section{flex:1}.coll-entries-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}.coll-entry-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid var(--line-soft)}.coll-entry-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.coll-entry-title{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.coll-entry-kind{font-size:11px;text-transform:uppercase;letter-spacing:.04em}.coll-entry-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}.coll-entry-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:3px 6px;font-size:12px;border-radius:var(--r)}.coll-entry-remove{border:none;background:none;cursor:pointer;color:var(--muted);font-size:18px;line-height:1;padding:0 4px}.coll-entry-remove:hover{color:var(--accent)}.coll-add-entry-form{border-top:1px solid var(--line-soft);padding-top:12px}.coll-add-entry-row{display:flex;gap:8px;align-items:center}.coll-add-entry-input{flex:1;border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:6px 10px;font-size:13px;min-width:0;border-radius:var(--r)}.coll-add-btn{border:none;background:var(--ink);color:var(--paper);padding:6px 14px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;border-radius:var(--r)}.coll-add-btn:hover{opacity:.85}.coll-add-btn:disabled{opacity:.45;cursor:default}.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:15px;background:var(--paper)}.user-menu{display:flex;align-items:center;gap:14px;padding-left:6px;flex-shrink:0}.user-name{font-size:12.5px;color:var(--muted-2);letter-spacing:.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:140px}.logout-btn{border:1px solid rgba(255,255,255,.18);background:transparent;color:#c8bfb0;font-size:12px;padding:4px 11px;border-radius:var(--r);cursor:pointer;white-space:nowrap;transition:background .15s,color .15s}.logout-btn:hover{background:#ffffff1a;color:var(--paper)}.logout-btn:disabled{opacity:.5;cursor:default}.login-page,.setup-page{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--paper)}.login-card,.setup-card{width:100%;max-width:360px;padding:40px 36px 44px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);box-shadow:0 2px 20px #141d1812}.login-brand,.setup-brand{font-family:var(--display);font-size:32px;font-weight:600;color:var(--ink);letter-spacing:-.01em;margin:0 0 6px}.login-tagline,.setup-tagline{font-size:13px;color:var(--muted);margin:0 0 28px}.login-field,.setup-field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px}.login-label,.setup-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.login-input,.setup-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:9px 11px;font-size:14px;border-radius:var(--r2);outline:none;transition:border-color .15s}.login-input:focus,.setup-input:focus{border-color:var(--accent)}.login-error,.setup-error{font-size:13px;color:var(--accent);margin:4px 0 8px}.login-submit,.setup-submit{width:100%;margin-top:8px;border:none;background:var(--top);color:var(--paper);font-size:14px;font-weight:600;padding:11px 16px;border-radius:var(--r2);cursor:pointer;letter-spacing:.02em;transition:opacity .15s}.login-submit:hover,.setup-submit:hover{opacity:.85}.login-submit:disabled,.setup-submit:disabled{opacity:.45;cursor:default}.view-tabs{display:flex;gap:2px;margin-bottom:22px;border-bottom:1px solid var(--line-soft);padding-bottom:0}.view-tab{border:none;background:none;color:var(--muted);font-size:13px;font-weight:600;padding:7px 14px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;letter-spacing:.02em;transition:color .12s;text-transform:uppercase;letter-spacing:.06em;font-size:11.5px}.view-tab:hover{color:var(--ink)}.view-tab.is-active{color:var(--ink);border-bottom-color:var(--accent)}.form-section{margin-bottom:32px}.form-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.form-row{display:flex;gap:8px;margin-bottom:10px}.form-field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}.form-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}.field-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s;min-width:0}.field-input:focus{border-color:var(--accent)}.field-input--flex{flex:1}.form-msg{font-size:13px;margin:6px 0}.form-msg--ok{color:var(--link)}.form-msg--err{color:var(--accent)}.btn-primary{border:none;background:var(--top);color:var(--paper);font-size:13px;font-weight:600;padding:8px 16px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.btn-primary:hover{opacity:.85}.btn-primary:disabled{opacity:.45;cursor:default}.btn-ghost{border:1px solid var(--line);background:none;color:var(--ink);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-ghost:hover{background:var(--paper-2)}.btn-danger{border:1px solid var(--accent);background:none;color:var(--accent);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-danger:hover{background:var(--accent);color:var(--paper)}.admin-view h1{font-family:var(--display);font-weight:600;font-size:26px;margin:0 0 20px}.admin-table{width:100%;border-collapse:collapse;font-size:13px;margin-bottom:28px}.admin-table th{text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding:8px 10px;border-bottom:1px solid var(--line);background:var(--paper-2)}.admin-table th:first-child{padding-left:16px}.admin-table td{padding:9px 10px;border-bottom:1px solid var(--line-soft);color:var(--ink);vertical-align:middle}.admin-table td:first-child{padding-left:16px}.admin-table tr:hover td{background:var(--paper-2)}.admin-row-disabled td{opacity:.45}.admin-section{margin-bottom:36px;max-width:860px}.admin-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.admin-section h3{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:22px 0 10px}.admin-form{display:flex;flex-direction:column;gap:8px;max-width:480px}.admin-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s}.admin-input:focus{border-color:var(--accent)}.admin-action-btn{border:1px solid var(--line);background:none;color:var(--ink);font-size:12px;padding:4px 10px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.admin-action-btn:hover{border-color:var(--accent);color:var(--accent)}.status-badge{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.status-active{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.status-disabled{background:#ede8e0;color:var(--muted);border:1px solid var(--line)}.run-status{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.run-status--completed{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.run-status--failed{background:#f5ddd8;color:#8d3f30;border:1px solid #e0b8b0}.run-status--in-progress{background:#fdefd8;color:#8a4f10;border:1px solid #f0cfa0}.run-row--failed{cursor:pointer}.run-row--failed:hover td{background:#fdf0ed!important}.run-expand-hint{margin-left:6px;font-size:10px;color:var(--accent);vertical-align:middle}.run-error-row td{padding:0!important;background:var(--paper-2)!important}.run-error-detail{margin:0;padding:10px 16px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);white-space:pre-wrap;word-break:break-word;max-height:220px;overflow-y:auto}.token-banner{background:#d8eddf;border:1px solid #b4d9be;padding:12px 14px;margin-bottom:16px;font-size:13px;border-radius:var(--r2)}.token-banner code{word-break:break-all;display:block;margin-top:6px;padding:6px 8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r);font-size:12px;font-family:ui-monospace,SF Mono,Menlo,monospace}.token-dismiss{margin-top:8px;font-size:12px;border:1px solid var(--line);background:none;cursor:pointer;padding:3px 8px;border-radius:var(--r);color:var(--muted)}.token-dismiss:hover{background:var(--paper-2)}.token-row{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--line);background:var(--paper-3);padding:10px 12px;border-radius:var(--r);margin-bottom:6px}.token-row-info strong{font-size:14px;display:block}.token-row-info .muted{font-size:12px;margin-top:2px}.token-create-row{display:flex;gap:8px;margin-bottom:16px}.checkbox-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;cursor:pointer;font-size:14px}.checkbox-row input[type=checkbox]{width:15px;height:15px;accent-color:var(--accent)}.coll-create-details{margin-top:16px}.coll-create-details summary{font-weight:600;cursor:pointer;font-size:13px;color:var(--link);list-style:none;display:flex;align-items:center;gap:6px;padding:8px 12px;border:1px solid var(--line-soft);border-radius:var(--r2);background:var(--paper-3);width:fit-content}.coll-create-details summary:hover{background:var(--paper-2)}.coll-create-details[open] summary{border-bottom-left-radius:0;border-bottom-right-radius:0}.coll-create-form{border:1px solid var(--line-soft);border-top:none;padding:14px;border-radius:0 0 var(--r2) var(--r2);background:var(--paper-3);display:flex;flex-direction:column;gap:10px;max-width:440px}@media (max-width: 900px){.topbar{grid-template-columns:1fr auto;height:auto;min-height:58px;padding:12px}.switcher,.nav{grid-column:1 / -1}.nav{justify-content:flex-start;overflow-x:auto}.app-shell{height:auto;grid-template-columns:1fr}.context-rail{border-left:0;border-top:1px solid var(--line)}.entry-table{min-width:860px}}.rail-title--editable{cursor:pointer}.rail-title--editable:hover{opacity:.75}.rail-title--editable .edit-icon{display:inline-block;width:.75em;height:.75em;margin-left:.35em;vertical-align:middle;opacity:0;transition:opacity .1s;flex-shrink:0}.rail-title--editable:hover .edit-icon{opacity:.5}.rail-title-input{width:100%;font:inherit;font-size:inherit;font-weight:600;background:transparent;border:none;border-bottom:1px solid currentColor;color:inherit;padding:0;margin:0 0 8px;outline:none} diff --git a/crates/archivr-server/static/assets/index-BZfMx3eM.css b/crates/archivr-server/static/assets/index-BZfMx3eM.css deleted file mode 100644 index 63c40a8..0000000 --- a/crates/archivr-server/static/assets/index-BZfMx3eM.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@500;600&family=Spectral:wght@500;600&display=swap";:root{color-scheme:light;--ink: #20251f;--muted: #6b6f66;--muted-2: #8a8d83;--paper: #f5f0e7;--paper-2: #e9e1d2;--paper-3: #fffaf0;--line: #d2c6b5;--line-soft: #e5dccd;--accent: #8d3f30;--accent-2: #b78342;--link: #245f72;--top: #141d18;--field: #fffdf7;--r: 3px;--r2: 6px;--r3: 10px;--sans: "Helvetica Neue", Helvetica, Arial, sans-serif;--serif: "Spectral", Georgia, "Times New Roman", serif;--display: "Cormorant Garamond", Georgia, serif}*{box-sizing:border-box}body{margin:0;min-height:100vh;background:var(--paper);color:var(--ink);font-family:var(--sans);font-size:14px;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}button,input,select{font:inherit}.workspace,.context-rail{scrollbar-width:thin;scrollbar-color:var(--line) transparent}.workspace::-webkit-scrollbar,.context-rail::-webkit-scrollbar{width:11px;height:11px}.workspace::-webkit-scrollbar-track,.context-rail::-webkit-scrollbar-track{background:transparent}.workspace::-webkit-scrollbar-thumb,.context-rail::-webkit-scrollbar-thumb{background:var(--line);border-radius:999px;border:3px solid transparent;background-clip:padding-box}.workspace::-webkit-scrollbar-thumb:hover,.context-rail::-webkit-scrollbar-thumb:hover{background:var(--muted-2);background-clip:padding-box;border:3px solid transparent}.topbar{height:58px;display:grid;grid-template-columns:auto auto 1fr auto auto;align-items:center;gap:26px;padding:0 22px;background:var(--top);color:#efe6d6;border-bottom:3px solid var(--accent)}.brand{font-family:var(--display);font-weight:600;font-size:30px;line-height:1;letter-spacing:.01em;color:#f4ead8}.switcher{position:relative;display:inline-flex;align-items:center}.switcher select{-moz-appearance:none;appearance:none;-webkit-appearance:none;border:1px solid rgba(247,238,223,.2);background:#f7eedf0f;color:#f1e8d8;font-family:var(--sans);font-weight:550;font-size:13.5px;letter-spacing:.04em;padding:8px 32px 8px 15px;cursor:pointer;border-radius:6px;transition:background .15s ease,border-color .15s ease}.switcher select:hover{background:#f7eedf1c;border-color:#f7eedf57}.switcher:after{content:"";position:absolute;right:15px;top:50%;width:6px;height:6px;margin-top:-5px;border-right:1.2px solid #b6ab98;border-bottom:1.2px solid #b6ab98;transform:rotate(45deg);pointer-events:none}.nav{display:flex;gap:22px;justify-content:flex-end;min-width:0}.nav-link{border:0;background:transparent;color:#cdc1ad;cursor:pointer;padding:6px 0;font-size:12.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;position:relative}.nav-link:hover,.nav-link.is-active{color:#f4ead8}.nav-link.is-active:after{content:"";position:absolute;left:0;right:0;bottom:-2px;height:1px;background:var(--accent-2)}.capture-button{display:inline-flex;align-items:center;gap:8px;position:relative;overflow:hidden;border:0;background:linear-gradient(180deg,color-mix(in srgb,var(--accent) 88%,#fff) 0%,var(--accent) 55%);color:#f7eddd;padding:10px 18px;cursor:pointer;font-size:12px;font-weight:600;letter-spacing:.15em;text-transform:uppercase;border-radius:var(--r);box-shadow:inset 0 1px #fff5e629,0 1px 2px #141d184d;transition:filter .18s ease,box-shadow .18s ease}.capture-button:hover{filter:brightness(.93);box-shadow:inset 0 1px #fff5e61f,0 2px 6px #141d1857}.capture-button:before{content:"";position:absolute;top:0;bottom:0;left:0;width:45%;background:linear-gradient(100deg,transparent 0%,rgba(255,246,232,.45) 50%,transparent 100%);transform:translate(-180%) skew(-18deg);pointer-events:none}@media (prefers-reduced-motion: no-preference){.capture-button:hover:before{animation:cap-sheen .7s ease}}@keyframes cap-sheen{0%{transform:translate(-180%) skew(-18deg)}to{transform:translate(340%) skew(-18deg)}}.app-shell{height:calc(100vh - 58px);display:grid;grid-template-columns:minmax(0,1fr) 340px}.workspace{min-width:0;overflow:auto;display:flex;flex-direction:column}.view{display:none}.view.is-active{display:block}.toolbar{position:sticky;top:0;z-index:3;display:flex;align-items:center;gap:16px;padding:12px 22px;background:color-mix(in srgb,var(--paper) 88%,white);border-bottom:1px solid var(--line-soft)}.search-field{position:relative;flex:1 1 auto;min-width:0;display:flex;align-items:center;height:42px;background:var(--field);border:1px solid var(--line);border-radius:20px;transition:border-color .15s ease,box-shadow .15s ease}.search-field:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.search-field .ico{display:grid;place-items:center;width:46px;height:100%;color:var(--muted-2);flex-shrink:0}.search-field .ico svg{width:16px;height:16px}.search-input{flex:1;min-width:0;height:100%;border:0;background:transparent;color:var(--ink);padding:0 6px 0 0;font-size:14px;letter-spacing:.01em;outline:none}.search-input::placeholder{color:var(--muted-2)}.search-field .kbd{margin-right:12px;display:inline-flex;align-items:center;padding:3px 7px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:var(--r);flex-shrink:0}.result-count{flex-shrink:0;font-size:13px;color:var(--muted);letter-spacing:.02em;white-space:nowrap}.result-count b{color:var(--ink);font-weight:600;font-variant-numeric:tabular-nums}.tag-filter-badge{display:inline-flex;align-items:center;gap:4px;background:var(--accent);color:#fff;border:0;border-radius:var(--r);font-size:12px;padding:2px 8px;cursor:pointer;margin-left:8px}.tag-filter-badge:hover{opacity:.85}.entry-table{width:100%;font-size:12.5px}.entry-header-row{display:flex;align-items:stretch;position:sticky;top:67px;z-index:2;background:color-mix(in srgb,var(--paper) 92%,white);border-bottom:1px solid var(--line-soft);color:var(--muted);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600;display:flex;align-items:center}#entries-body>div{display:flex;align-items:center;cursor:default;border-bottom:1px solid var(--line-soft)}#entries-body>div>div{padding:7px 10px;flex-shrink:0;overflow:hidden}#entries-body>div:nth-child(2n){background:#f2ede5}#entries-body>div:nth-child(odd){background:var(--paper-3)}#entries-body>div.is-selected{background:#eee2d2;outline:2px solid var(--accent);outline-offset:-2px}.col-added{width:162px;color:var(--muted)}.col-title{flex:1 1 0;min-width:0;overflow:hidden;display:flex;align-items:center;gap:.42em}.col-type{width:116px}.col-size{width:100px;display:flex;flex-direction:column;justify-content:center;gap:1px}.size-total{font-variant-numeric:tabular-nums}.size-cached-pct{font-size:10px;color:var(--muted);opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.col-url{flex:0 0 30%;min-width:0;overflow:hidden}.entry-header-row>div:first-child,#entries-body>div>div:first-child{padding-left:22px}.entry-header-row>div:last-child,#entries-body>div>div:last-child{padding-right:22px}.entry-title{color:var(--link);font-weight:700;min-width:0}.entry-header-row>div{padding:9px 10px;flex-shrink:0;font-weight:600}.source-icon{display:flex;align-items:center;justify-content:center;width:1.05em;height:1.05em;flex-shrink:0}.source-icon>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.source-icon svg{width:100%;height:100%}.url-cell{color:#555b55;white-space:nowrap;text-overflow:ellipsis;word-break:break-all}#entries-body .url-cell:hover,#entries-body .is-selected .url-cell{overflow:visible;white-space:normal}.type-pill{display:inline-block;padding:2px 6px;background:#d8e3df;color:#275a5f;border:1px solid #bfd0ca;border-radius:var(--r)}#runs-view .entry-table{border-collapse:collapse;table-layout:auto}#runs-view .entry-table th{position:sticky;top:0;z-index:1;text-align:left;padding:10px;background:color-mix(in srgb,var(--paper) 92%,white);color:var(--muted);border-bottom:1px solid var(--line-soft);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em}#runs-view .entry-table td{padding:10px;border-bottom:1px solid var(--line-soft);vertical-align:top}#runs-view .entry-table tr:nth-child(2n) td{background:#f2ede5}#runs-view .entry-table tr:nth-child(odd) td{background:var(--paper-3)}.context-rail{border-left:1px solid var(--line);background:var(--paper);padding:20px 20px 32px;overflow:auto}.rail-eyebrow{font-size:10.5px;font-weight:600;letter-spacing:.16em;text-transform:uppercase;color:var(--muted-2);margin-bottom:16px}.rail-title{display:block;font-family:var(--sans);font-weight:700;font-size:15.5px;line-height:1.4;color:var(--ink);margin:0 0 16px;word-break:break-word}.url-tile{display:flex;align-items:center;gap:9px;padding:10px 12px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);margin-bottom:20px;text-decoration:none}.url-tile:hover{background:var(--field);border-color:var(--accent)}.url-tile .ico{color:var(--ink);flex-shrink:0;display:grid;place-items:center}.url-tile .ico svg{width:15px;height:15px}.url-tile .u-text{min-width:0;flex:1;font-size:12.5px;color:var(--link);font-family:ui-monospace,SF Mono,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.url-tile .ext{color:var(--muted-2);flex-shrink:0}.url-tile .ext svg{width:13px;height:13px;display:block}.meta-list{margin-bottom:24px;border-top:1px solid var(--line-soft)}.meta-item{display:grid;grid-template-columns:92px 1fr;gap:14px;align-items:baseline;padding:9px 0;border-bottom:1px solid var(--line-soft)}.meta-k{font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.06em;color:var(--muted-2)}.meta-v{font-size:13.5px;color:var(--ink);word-break:break-word;line-height:1.4}.meta-v.mono{font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:12px;color:var(--muted)}.rail-section{margin-bottom:24px}.rail-section-heading{display:flex;align-items:baseline;gap:8px;font-size:10.5px;font-weight:600;text-transform:uppercase;letter-spacing:.12em;color:var(--muted-2);margin-bottom:9px;padding-bottom:8px;border-bottom:1px solid var(--line)}.rail-section-heading .num{color:var(--muted-2);font-weight:600}.artifact-list{list-style:none;margin:0;padding:0}.artifact-link{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:7px 2px;border-bottom:1px solid var(--line-soft);text-decoration:none}.artifact-link:last-child{border-bottom:0}.artifact-name{font-size:13px;color:var(--link);min-width:0;word-break:break-word}.artifact-link:hover .artifact-name{text-decoration:underline}.artifact-size{font-size:11.5px;color:var(--muted-2);flex-shrink:0;font-variant-numeric:tabular-nums}.tags-wrap{display:flex;flex-wrap:wrap;gap:7px;margin:0 0 12px}.tag-pill{display:inline-flex;align-items:center;gap:7px;background:var(--paper-2);border:1px solid var(--line);border-radius:var(--r);font-size:12px;padding:4px 7px 4px 10px;color:var(--ink)}.tag-pill .remove{border:0;background:transparent;cursor:pointer;color:var(--muted-2);width:15px;height:15px;display:grid;place-items:center;font-size:13px;line-height:1}.tag-pill .remove:hover{color:var(--accent)}.tags-empty{font-size:13px;color:var(--muted);margin:0 0 11px}.tag-input-wrap{display:flex;align-items:center;gap:8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);padding:2px 2px 2px 11px;transition:border-color .15s ease,box-shadow .15s ease}.tag-input-wrap:focus-within{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 12%,transparent)}.tag-input-wrap .hash{color:var(--muted-2);font-size:13px}.tag-input{flex:1;min-width:0;border:0;background:transparent;color:var(--ink);font-size:13px;padding:6px 0;outline:none;font-family:ui-monospace,SF Mono,Menlo,monospace}.tag-add-btn{border:0;background:var(--ink);color:var(--paper-3);padding:6px 13px;font-size:11.5px;letter-spacing:.06em;text-transform:uppercase;border-radius:var(--r);cursor:pointer;white-space:nowrap}.tag-add-btn:hover{background:#2c332b}.coll-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 13px;background:var(--field);border:1px solid var(--line);border-radius:var(--r2);margin-bottom:6px;transition:border-color .15s ease}.coll-row:hover{border-color:var(--accent)}.coll-name{font-size:13px;color:var(--ink);font-weight:500}.vis-badge{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--muted);background:var(--paper-2);border:1px solid var(--line-soft);border-radius:999px;padding:3px 10px}.vis-badge:before{content:"";width:6px;height:6px;border-radius:50%;background:var(--accent-2)}.rail-delete-zone{margin-top:24px;padding-top:20px;border-top:1px solid var(--line-soft)}.rail-delete-btn{width:100%;padding:8px 14px;background:none;border:1px solid color-mix(in srgb,var(--accent) 45%,transparent);color:var(--accent);border-radius:var(--r);cursor:pointer;font-size:12.5px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;transition:background .15s ease,border-color .15s ease}.rail-delete-btn:hover{background:color-mix(in srgb,var(--accent) 8%,transparent);border-color:var(--accent)}.capture-dialog{border:1px solid var(--line);background:var(--paper);padding:0;width:min(540px,calc(100vw - 32px));border-radius:var(--r3);box-shadow:0 20px 60px #141d1847}.capture-dialog::backdrop{background:#141d1873}.capture-dialog-inner{padding:28px}.capture-dialog-title{margin:0;font-size:22px;font-family:var(--display);font-weight:600}.capture-label{display:block;font-size:11px;font-weight:600;margin-bottom:6px;color:var(--muted-2);text-transform:uppercase;letter-spacing:.06em}.capture-input{width:100%;height:44px;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:0 14px;font-size:15px;margin-bottom:10px;border-radius:var(--r2);outline:none;transition:border-color .15s ease,box-shadow .15s ease}.capture-input:focus{border-color:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 14%,transparent)}.form-field .capture-input{margin-bottom:0}.capture-error{color:var(--accent);font-size:13px;margin-bottom:10px;min-height:18px}.capture-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:16px}.capture-cancel{border:1px solid var(--line);background:none;color:var(--ink);padding:8px 18px;border-radius:var(--r);cursor:pointer}.capture-cancel:hover{background:var(--paper-2)}.capture-submit{border:0;background:var(--ink);color:var(--paper);padding:8px 20px;border-radius:var(--r);cursor:pointer;font-weight:600}.capture-submit:hover{opacity:.85}.capture-submit:disabled{opacity:.45;cursor:default}.capture-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.capture-dialog-close{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-dialog-close svg{width:14px;height:14px}.capture-dialog-close:hover{background:var(--paper-2);color:var(--ink)}.capture-rows{display:flex;flex-direction:column;gap:8px;margin-bottom:8px}.capture-row{display:flex;flex-direction:column;gap:3px}.capture-row-main{display:flex;align-items:center;gap:8px}.capture-row-main .capture-input{margin-bottom:0}.cap-dot{flex-shrink:0;width:20px;height:20px;border-radius:50%;display:grid;place-items:center;font-size:10px;font-weight:700;line-height:1}.cap-dot--idle{background:var(--paper-2)}.cap-dot--running{background:#fdefd8;color:#8a4f10}.cap-dot--ok{background:#d8eddf;color:#235c35}.cap-dot--err{background:#f5ddd8;color:#8d3f30}.cap-spinner{display:block;width:10px;height:10px;border:2px solid currentColor;border-top-color:transparent;border-radius:50%;animation:cap-spin .7s linear infinite}@keyframes cap-spin{to{transform:rotate(360deg)}}.capture-row-action{flex-shrink:0;background:none;border:0;cursor:pointer;color:var(--muted);width:28px;height:28px;display:grid;place-items:center;border-radius:var(--r);padding:0}.capture-row-action svg{width:12px;height:12px}.capture-row-action:hover{color:var(--accent);background:var(--paper-2)}.capture-row-remove:hover{color:var(--accent)}.capture-row-error{margin:0;padding-left:28px;font-size:12px;color:var(--accent);line-height:1.45}.capture-add-row{display:flex;align-items:center;gap:7px;width:100%;background:none;border:1px dashed var(--line);border-radius:var(--r);color:var(--muted);font-size:13px;cursor:pointer;padding:7px 12px;margin-top:4px;margin-bottom:18px;transition:border-color .15s,color .15s,background .15s}.capture-add-row svg{width:13px;height:13px;flex-shrink:0}.capture-add-row:hover{border-color:var(--accent-2);color:var(--ink);background:var(--paper-2)}.toast-stack{position:fixed;bottom:24px;right:24px;z-index:9000;display:flex;flex-direction:column;gap:10px;width:340px;max-width:calc(100vw - 32px);pointer-events:none}.toast{pointer-events:auto;background:var(--paper);border:1px solid var(--line);border-radius:var(--r2);box-shadow:0 6px 24px #141d182e,0 1px 4px #141d181a;overflow:hidden;animation:toast-slide-in .22s cubic-bezier(.22,.68,0,1.2)}@keyframes toast-slide-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}.toast--error{border-left:3px solid var(--accent)}.toast-top{display:flex;align-items:flex-start;gap:10px;padding:12px 12px 12px 14px}.toast-icon{flex-shrink:0;font-size:13px;font-weight:700;color:var(--accent);margin-top:2px}.toast-body{flex:1;min-width:0}.toast-headline{display:block;font-size:13.5px;font-weight:600;color:var(--ink);line-height:1.3}.toast-locator{display:block;font-size:12px;color:var(--muted);margin-top:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.toast-btns{display:flex;align-items:center;gap:6px;flex-shrink:0}.toast-view-btn{background:none;border:1px solid var(--line);color:var(--link);font-size:12px;cursor:pointer;padding:3px 9px;border-radius:var(--r);white-space:nowrap}.toast-view-btn:hover{background:var(--paper-2);border-color:var(--link)}.toast-dismiss{background:none;border:0;cursor:pointer;color:var(--muted);font-size:20px;line-height:1;width:24px;height:24px;display:grid;place-items:center;border-radius:var(--r);padding:0}.toast-dismiss:hover{color:var(--ink);background:var(--paper-2)}.toast-error-detail{margin:0;padding:10px 14px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);background:var(--paper-2);border-top:1px solid var(--line);white-space:pre-wrap;word-break:break-word;max-height:200px;overflow-y:auto}.muted{color:var(--muted)}.admin-view{padding:22px}.admin-list{display:grid;gap:10px;max-width:780px}.admin-archive{border:1px solid var(--line);background:var(--paper-3);padding:12px;border-radius:var(--r2)}.tag-tree{padding:20px 22px;max-width:320px}.tag-tree-header{display:flex;align-items:baseline;gap:10px;margin-bottom:14px;border-bottom:1px solid var(--line-soft);padding-bottom:10px}.tag-tree-title{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.07em}.tag-tree-active{font-size:12px;color:var(--muted-2);font-style:italic}.tag-tree-list{list-style:none;margin:0;padding:0}.tag-children{padding-left:16px}.tag-node-btn{border:0;background:transparent;color:var(--link);cursor:pointer;padding:3px 0;text-align:left;font-size:13px;display:block;width:100%}.tag-node-btn:hover{text-decoration:underline}.tag-node-btn.is-active{font-weight:600;color:var(--ink)}.tag-node-row{display:flex;align-items:center;gap:4px}.tag-node-row .tag-node-btn{flex:1 1 0;min-width:0;display:flex;align-items:center;gap:4px;width:auto}.tag-node-btn .edit-icon{width:.75em;height:.75em;flex-shrink:0;vertical-align:-.1em;opacity:.35}.tag-node-btn:hover .edit-icon{opacity:.65}.tag-node-delete{flex-shrink:0;border:0;background:transparent;color:var(--muted-2);cursor:pointer;padding:0 3px;font-size:14px;line-height:1;opacity:0}.tag-node-row:hover .tag-node-delete{opacity:1}.tag-node-delete:hover{color:var(--accent)}.tag-rename-input{font-size:13px;flex:1 1 0;min-width:0;padding:2px 5px;border:1px solid var(--accent);border-radius:var(--r);background:var(--field);color:var(--ink);outline:none}.collections-view{padding:24px}.collections-heading{margin:0 0 16px;font-size:22px;font-family:var(--display);font-weight:600}.collections-error{color:var(--accent);font-size:13px;margin-bottom:8px}.coll-dismiss{background:none;border:none;cursor:pointer;color:var(--accent);font-size:16px;line-height:1;padding:0 4px}.collections-layout{display:grid;grid-template-columns:220px 1fr;gap:0;border:1px solid var(--line);border-radius:var(--r2);min-height:340px}.collections-sidebar{border-right:1px solid var(--line);overflow-y:auto}.coll-sidebar-row{display:flex;flex-direction:column;width:100%;padding:10px 14px;border:none;border-bottom:1px solid var(--line-soft);background:none;cursor:pointer;text-align:left;gap:2px}.coll-sidebar-row:hover{background:var(--paper-2)}.coll-sidebar-row.is-active{background:var(--paper-2);border-left:3px solid var(--accent)}.coll-row-name{font-size:14px;font-weight:600;color:var(--ink)}.coll-row-meta{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.04em}.coll-detail{padding:20px 24px;display:flex;flex-direction:column;gap:16px}.coll-detail--empty{justify-content:center;align-items:center}.coll-detail-header{display:flex;align-items:center;gap:12px}.coll-detail-name{margin:0;font-size:18px;font-family:var(--display);font-weight:600;flex:1}.coll-detail-name--editable{cursor:pointer}.coll-detail-name--editable:hover{color:var(--link)}.coll-edit-hint{font-size:14px;opacity:.5;margin-left:4px}.coll-rename-input{flex:1;font-size:16px;font-family:var(--display);border:1px solid var(--line);padding:4px 8px;background:var(--field);color:var(--ink);border-radius:var(--r)}.coll-delete-btn{border:1px solid var(--accent);background:none;color:var(--accent);padding:5px 12px;font-size:13px;cursor:pointer;border-radius:var(--r)}.coll-delete-btn:hover{background:var(--accent);color:var(--paper)}.coll-detail-vis{display:flex;align-items:center;gap:10px}.coll-vis-label{font-size:13px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;white-space:nowrap}.coll-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:4px 8px;font-size:13px;border-radius:var(--r)}.coll-section-heading{font-size:11px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:8px}.coll-entries-section{flex:1}.coll-entries-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px}.coll-entry-row{display:flex;align-items:center;gap:10px;padding:7px 0;border-bottom:1px solid var(--line-soft)}.coll-entry-info{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.coll-entry-title{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.coll-entry-kind{font-size:11px;text-transform:uppercase;letter-spacing:.04em}.coll-entry-actions{display:flex;align-items:center;gap:6px;flex-shrink:0}.coll-entry-vis-select{border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:3px 6px;font-size:12px;border-radius:var(--r)}.coll-entry-remove{border:none;background:none;cursor:pointer;color:var(--muted);font-size:18px;line-height:1;padding:0 4px}.coll-entry-remove:hover{color:var(--accent)}.coll-add-entry-form{border-top:1px solid var(--line-soft);padding-top:12px}.coll-add-entry-row{display:flex;gap:8px;align-items:center}.coll-add-entry-input{flex:1;border:1px solid var(--line);background:var(--paper-3);color:var(--ink);padding:6px 10px;font-size:13px;min-width:0;border-radius:var(--r)}.coll-add-btn{border:none;background:var(--ink);color:var(--paper);padding:6px 14px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;border-radius:var(--r)}.coll-add-btn:hover{opacity:.85}.coll-add-btn:disabled{opacity:.45;cursor:default}.auth-loading{min-height:100vh;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:15px;background:var(--paper)}.user-menu{display:flex;align-items:center;gap:14px;padding-left:6px;flex-shrink:0}.user-name{font-size:12.5px;color:var(--muted-2);letter-spacing:.01em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:140px}.logout-btn{border:1px solid rgba(255,255,255,.18);background:transparent;color:#c8bfb0;font-size:12px;padding:4px 11px;border-radius:var(--r);cursor:pointer;white-space:nowrap;transition:background .15s,color .15s}.logout-btn:hover{background:#ffffff1a;color:var(--paper)}.logout-btn:disabled{opacity:.5;cursor:default}.login-page,.setup-page{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:center;background:var(--paper)}.login-card,.setup-card{width:100%;max-width:360px;padding:40px 36px 44px;background:var(--paper-3);border:1px solid var(--line);border-radius:var(--r3);box-shadow:0 2px 20px #141d1812}.login-brand,.setup-brand{font-family:var(--display);font-size:32px;font-weight:600;color:var(--ink);letter-spacing:-.01em;margin:0 0 6px}.login-tagline,.setup-tagline{font-size:13px;color:var(--muted);margin:0 0 28px}.login-field,.setup-field{display:flex;flex-direction:column;gap:5px;margin-bottom:14px}.login-label,.setup-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}.login-input,.setup-input{width:100%;border:1px solid var(--line);background:var(--field);color:var(--ink);padding:9px 11px;font-size:14px;border-radius:var(--r2);outline:none;transition:border-color .15s}.login-input:focus,.setup-input:focus{border-color:var(--accent)}.login-error,.setup-error{font-size:13px;color:var(--accent);margin:4px 0 8px}.login-submit,.setup-submit{width:100%;margin-top:8px;border:none;background:var(--top);color:var(--paper);font-size:14px;font-weight:600;padding:11px 16px;border-radius:var(--r2);cursor:pointer;letter-spacing:.02em;transition:opacity .15s}.login-submit:hover,.setup-submit:hover{opacity:.85}.login-submit:disabled,.setup-submit:disabled{opacity:.45;cursor:default}.view-tabs{display:flex;gap:2px;margin-bottom:22px;border-bottom:1px solid var(--line-soft);padding-bottom:0}.view-tab{border:none;background:none;color:var(--muted);font-size:13px;font-weight:600;padding:7px 14px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;letter-spacing:.02em;transition:color .12s;text-transform:uppercase;letter-spacing:.06em;font-size:11.5px}.view-tab:hover{color:var(--ink)}.view-tab.is-active{color:var(--ink);border-bottom-color:var(--accent)}.form-section{margin-bottom:32px}.form-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.form-row{display:flex;gap:8px;margin-bottom:10px}.form-field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px}.form-label{font-size:11.5px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.05em}.field-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s;min-width:0}.field-input:focus{border-color:var(--accent)}.field-input--flex{flex:1}.form-msg{font-size:13px;margin:6px 0}.form-msg--ok{color:var(--link)}.form-msg--err{color:var(--accent)}.btn-primary{border:none;background:var(--top);color:var(--paper);font-size:13px;font-weight:600;padding:8px 16px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.btn-primary:hover{opacity:.85}.btn-primary:disabled{opacity:.45;cursor:default}.btn-ghost{border:1px solid var(--line);background:none;color:var(--ink);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-ghost:hover{background:var(--paper-2)}.btn-danger{border:1px solid var(--accent);background:none;color:var(--accent);font-size:13px;padding:7px 14px;border-radius:var(--r);cursor:pointer}.btn-danger:hover{background:var(--accent);color:var(--paper)}.admin-view h1{font-family:var(--display);font-weight:600;font-size:26px;margin:0 0 20px}.admin-table{width:100%;border-collapse:collapse;font-size:13px;margin-bottom:28px}.admin-table th{text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--muted);padding:8px 10px;border-bottom:1px solid var(--line);background:var(--paper-2)}.admin-table th:first-child{padding-left:16px}.admin-table td{padding:9px 10px;border-bottom:1px solid var(--line-soft);color:var(--ink);vertical-align:middle}.admin-table td:first-child{padding-left:16px}.admin-table tr:hover td{background:var(--paper-2)}.admin-row-disabled td{opacity:.45}.admin-section{margin-bottom:36px;max-width:860px}.admin-section h2{font-size:14px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:0 0 14px}.admin-section h3{font-size:13px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:.05em;margin:22px 0 10px}.admin-form{display:flex;flex-direction:column;gap:8px;max-width:480px}.admin-input{border:1px solid var(--line);background:var(--field);color:var(--ink);padding:8px 10px;font-size:13.5px;border-radius:var(--r);outline:none;transition:border-color .15s}.admin-input:focus{border-color:var(--accent)}.admin-action-btn{border:1px solid var(--line);background:none;color:var(--ink);font-size:12px;padding:4px 10px;border-radius:var(--r);cursor:pointer;white-space:nowrap}.admin-action-btn:hover{border-color:var(--accent);color:var(--accent)}.status-badge{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.status-active{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.status-disabled{background:#ede8e0;color:var(--muted);border:1px solid var(--line)}.run-status{display:inline-block;padding:2px 8px;border-radius:var(--r);font-size:11.5px;font-weight:600;text-transform:uppercase;letter-spacing:.04em}.run-status--completed{background:#d8eddf;color:#235c35;border:1px solid #b4d9be}.run-status--failed{background:#f5ddd8;color:#8d3f30;border:1px solid #e0b8b0}.run-status--in-progress{background:#fdefd8;color:#8a4f10;border:1px solid #f0cfa0}.run-row--failed{cursor:pointer}.run-row--failed:hover td{background:#fdf0ed!important}.run-expand-hint{margin-left:6px;font-size:10px;color:var(--accent);vertical-align:middle}.run-error-row td{padding:0!important;background:var(--paper-2)!important}.run-error-detail{margin:0;padding:10px 16px 12px;font-family:ui-monospace,SF Mono,Menlo,monospace;font-size:11.5px;line-height:1.55;color:var(--muted);white-space:pre-wrap;word-break:break-word;max-height:220px;overflow-y:auto}.token-banner{background:#d8eddf;border:1px solid #b4d9be;padding:12px 14px;margin-bottom:16px;font-size:13px;border-radius:var(--r2)}.token-banner code{word-break:break-all;display:block;margin-top:6px;padding:6px 8px;background:var(--field);border:1px solid var(--line);border-radius:var(--r);font-size:12px;font-family:ui-monospace,SF Mono,Menlo,monospace}.token-dismiss{margin-top:8px;font-size:12px;border:1px solid var(--line);background:none;cursor:pointer;padding:3px 8px;border-radius:var(--r);color:var(--muted)}.token-dismiss:hover{background:var(--paper-2)}.token-row{display:flex;align-items:center;justify-content:space-between;border:1px solid var(--line);background:var(--paper-3);padding:10px 12px;border-radius:var(--r);margin-bottom:6px}.token-row-info strong{font-size:14px;display:block}.token-row-info .muted{font-size:12px;margin-top:2px}.token-create-row{display:flex;gap:8px;margin-bottom:16px}.checkbox-row{display:flex;align-items:center;gap:10px;margin-bottom:12px;cursor:pointer;font-size:14px}.checkbox-row input[type=checkbox]{width:15px;height:15px;accent-color:var(--accent)}.coll-create-details{margin-top:16px}.coll-create-details summary{font-weight:600;cursor:pointer;font-size:13px;color:var(--link);list-style:none;display:flex;align-items:center;gap:6px;padding:8px 12px;border:1px solid var(--line-soft);border-radius:var(--r2);background:var(--paper-3);width:fit-content}.coll-create-details summary:hover{background:var(--paper-2)}.coll-create-details[open] summary{border-bottom-left-radius:0;border-bottom-right-radius:0}.coll-create-form{border:1px solid var(--line-soft);border-top:none;padding:14px;border-radius:0 0 var(--r2) var(--r2);background:var(--paper-3);display:flex;flex-direction:column;gap:10px;max-width:440px}@media (max-width: 900px){.topbar{grid-template-columns:1fr auto;height:auto;min-height:58px;padding:12px}.switcher,.nav{grid-column:1 / -1}.nav{justify-content:flex-start;overflow-x:auto}.app-shell{height:auto;grid-template-columns:1fr}.context-rail{border-left:0;border-top:1px solid var(--line)}.entry-table{min-width:860px}}.rail-title--editable{cursor:pointer}.rail-title--editable:hover{opacity:.75}.rail-title--editable .edit-icon{display:inline-block;width:.75em;height:.75em;margin-left:.35em;vertical-align:middle;opacity:0;transition:opacity .1s;flex-shrink:0}.rail-title--editable:hover .edit-icon{opacity:.5}.rail-title-input{width:100%;font:inherit;font-size:inherit;font-weight:600;background:transparent;border:none;border-bottom:1px solid currentColor;color:inherit;padding:0;margin:0 0 8px;outline:none} diff --git a/crates/archivr-server/static/assets/index-CTwpNgei.js b/crates/archivr-server/static/assets/index-CTwpNgei.js deleted file mode 100644 index b28e965..0000000 --- a/crates/archivr-server/static/assets/index-CTwpNgei.js +++ /dev/null @@ -1,40 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(l){if(l.ep)return;l.ep=!0;const i=n(l);fetch(l.href,i)}})();var va={exports:{}},vl={},ga={exports:{}},I={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var fr=Symbol.for("react.element"),Dc=Symbol.for("react.portal"),Oc=Symbol.for("react.fragment"),$c=Symbol.for("react.strict_mode"),Mc=Symbol.for("react.profiler"),Fc=Symbol.for("react.provider"),Ic=Symbol.for("react.context"),Ac=Symbol.for("react.forward_ref"),Uc=Symbol.for("react.suspense"),Bc=Symbol.for("react.memo"),Vc=Symbol.for("react.lazy"),to=Symbol.iterator;function Hc(e){return e===null||typeof e!="object"?null:(e=to&&e[to]||e["@@iterator"],typeof e=="function"?e:null)}var ya={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},wa=Object.assign,xa={};function jn(e,t,n){this.props=e,this.context=t,this.refs=xa,this.updater=n||ya}jn.prototype.isReactComponent={};jn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Sa(){}Sa.prototype=jn.prototype;function os(e,t,n){this.props=e,this.context=t,this.refs=xa,this.updater=n||ya}var as=os.prototype=new Sa;as.constructor=os;wa(as,jn.prototype);as.isPureReactComponent=!0;var no=Array.isArray,ka=Object.prototype.hasOwnProperty,us={current:null},ja={key:!0,ref:!0,__self:!0,__source:!0};function Na(e,t,n){var r,l={},i=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)ka.call(t,r)&&!ja.hasOwnProperty(r)&&(l[r]=t[r]);var a=arguments.length-2;if(a===1)l.children=n;else if(1>>1,M=T[V];if(0>>1;Vl(Qe,$))Fel(lt,Qe)?(T[V]=lt,T[Fe]=$,V=Fe):(T[V]=Qe,T[oe]=$,V=oe);else if(Fel(lt,$))T[V]=lt,T[Fe]=$,V=Fe;else break e}}return N}function l(T,N){var $=T.sortIndex-N.sortIndex;return $!==0?$:T.id-N.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var s=Date,a=s.now();e.unstable_now=function(){return s.now()-a}}var u=[],c=[],y=1,h=null,v=3,j=!1,x=!1,k=!1,R=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function p(T){for(var N=n(c);N!==null;){if(N.callback===null)r(c);else if(N.startTime<=T)r(c),N.sortIndex=N.expirationTime,t(u,N);else break;N=n(c)}}function w(T){if(k=!1,p(T),!x)if(n(u)!==null)x=!0,$e(m);else{var N=n(c);N!==null&&Me(w,N.startTime-T)}}function m(T,N){x=!1,k&&(k=!1,f(E),E=-1),j=!0;var $=v;try{for(p(N),h=n(u);h!==null&&(!(h.expirationTime>N)||T&&!A());){var V=h.callback;if(typeof V=="function"){h.callback=null,v=h.priorityLevel;var M=V(h.expirationTime<=N);N=e.unstable_now(),typeof M=="function"?h.callback=M:h===n(u)&&r(u),p(N)}else r(u);h=n(u)}if(h!==null)var ve=!0;else{var oe=n(c);oe!==null&&Me(w,oe.startTime-N),ve=!1}return ve}finally{h=null,v=$,j=!1}}var S=!1,_=null,E=-1,F=5,O=-1;function A(){return!(e.unstable_now()-OT||125V?(T.sortIndex=$,t(c,T),n(u)===null&&T===n(c)&&(k?(f(E),E=-1):k=!0,Me(w,$-V))):(T.sortIndex=M,t(u,T),x||j||(x=!0,$e(m))),T},e.unstable_shouldYield=A,e.unstable_wrapCallback=function(T){var N=v;return function(){var $=v;v=N;try{return T.apply(this,arguments)}finally{v=$}}}})(Pa);Ta.exports=Pa;var ed=Ta.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var td=g,Re=ed;function C(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pi=Object.prototype.hasOwnProperty,nd=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lo={},io={};function rd(e){return pi.call(io,e)?!0:pi.call(lo,e)?!1:nd.test(e)?io[e]=!0:(lo[e]=!0,!1)}function ld(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function id(e,t,n,r){if(t===null||typeof t>"u"||ld(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function xe(e,t,n,r,l,i,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var de={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){de[e]=new xe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];de[t]=new xe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){de[e]=new xe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){de[e]=new xe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){de[e]=new xe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){de[e]=new xe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){de[e]=new xe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){de[e]=new xe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){de[e]=new xe(e,5,!1,e.toLowerCase(),null,!1,!1)});var ds=/[\-:]([a-z])/g;function fs(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ds,fs);de[t]=new xe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ds,fs);de[t]=new xe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ds,fs);de[t]=new xe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){de[e]=new xe(e,1,!1,e.toLowerCase(),null,!1,!1)});de.xlinkHref=new xe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){de[e]=new xe(e,1,!1,e.toLowerCase(),null,!0,!0)});function ps(e,t,n,r){var l=de.hasOwnProperty(t)?de[t]:null;(l!==null?l.type!==0:r||!(2a||l[s]!==i[a]){var u=` -`+l[s].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=s&&0<=a);break}}}finally{Ul=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?$n(e):""}function sd(e){switch(e.tag){case 5:return $n(e.type);case 16:return $n("Lazy");case 13:return $n("Suspense");case 19:return $n("SuspenseList");case 0:case 2:case 15:return e=Bl(e.type,!1),e;case 11:return e=Bl(e.type.render,!1),e;case 1:return e=Bl(e.type,!0),e;default:return""}}function gi(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case qt:return"Fragment";case Zt:return"Portal";case hi:return"Profiler";case hs:return"StrictMode";case mi:return"Suspense";case vi:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ra:return(e.displayName||"Context")+".Consumer";case za:return(e._context.displayName||"Context")+".Provider";case ms:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case vs:return t=e.displayName||null,t!==null?t:gi(e.type)||"Memo";case vt:t=e._payload,e=e._init;try{return gi(e(t))}catch{}}return null}function od(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return gi(t);case 8:return t===hs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Lt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Oa(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ad(e){var t=Oa(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(s){r=""+s,i.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function wr(e){e._valueTracker||(e._valueTracker=ad(e))}function $a(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Oa(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Kr(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function yi(e,t){var n=t.checked;return b({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function oo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Lt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Ma(e,t){t=t.checked,t!=null&&ps(e,"checked",t,!1)}function wi(e,t){Ma(e,t);var n=Lt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?xi(e,t.type,n):t.hasOwnProperty("defaultValue")&&xi(e,t.type,Lt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ao(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function xi(e,t,n){(t!=="number"||Kr(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Mn=Array.isArray;function cn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=xr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Gn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Un={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ud=["Webkit","ms","Moz","O"];Object.keys(Un).forEach(function(e){ud.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Un[t]=Un[e]})});function Ua(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Un.hasOwnProperty(e)&&Un[e]?(""+t).trim():t+"px"}function Ba(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Ua(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var cd=b({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ji(e,t){if(t){if(cd[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(C(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(C(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(C(61))}if(t.style!=null&&typeof t.style!="object")throw Error(C(62))}}function Ni(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ci=null;function gs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var _i=null,dn=null,fn=null;function fo(e){if(e=mr(e)){if(typeof _i!="function")throw Error(C(280));var t=e.stateNode;t&&(t=Sl(t),_i(e.stateNode,e.type,t))}}function Va(e){dn?fn?fn.push(e):fn=[e]:dn=e}function Ha(){if(dn){var e=dn,t=fn;if(fn=dn=null,fo(e),t)for(e=0;e>>=0,e===0?32:31-(Sd(e)/kd|0)|0}var Sr=64,kr=4194304;function Fn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Gr(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,i=e.pingedLanes,s=n&268435455;if(s!==0){var a=s&~l;a!==0?r=Fn(a):(i&=s,i!==0&&(r=Fn(i)))}else s=n&~l,s!==0?r=Fn(s):i!==0&&(r=Fn(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,i=t&-t,l>=i||l===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function pr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ge(t),e[t]=n}function _d(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Vn),So=" ",ko=!1;function uu(e,t){switch(e){case"keyup":return ef.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var bt=!1;function nf(e,t){switch(e){case"compositionend":return cu(t);case"keypress":return t.which!==32?null:(ko=!0,So);case"textInput":return e=t.data,e===So&&ko?null:e;default:return null}}function rf(e,t){if(bt)return e==="compositionend"||!Cs&&uu(e,t)?(e=ou(),Fr=ks=xt=null,bt=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_o(n)}}function hu(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hu(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function mu(){for(var e=window,t=Kr();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Kr(e.document)}return t}function _s(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function pf(e){var t=mu(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&hu(n.ownerDocument.documentElement,n)){if(r!==null&&_s(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,i=Math.min(r.start,l);r=r.end===void 0?i:Math.min(r.end,l),!e.extend&&i>r&&(l=r,r=i,i=l),l=Eo(n,i);var s=Eo(n,r);l&&s&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,en=null,Ri=null,Wn=null,Di=!1;function To(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Di||en==null||en!==Kr(r)||(r=en,"selectionStart"in r&&_s(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Wn&&nr(Wn,r)||(Wn=r,r=br(Ri,"onSelect"),0rn||(e.current=Ai[rn],Ai[rn]=null,rn--)}function Y(e,t){rn++,Ai[rn]=e.current,e.current=t}var zt={},me=Dt(zt),Ce=Dt(!1),Ht=zt;function gn(e,t){var n=e.type.contextTypes;if(!n)return zt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},i;for(i in n)l[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function _e(e){return e=e.childContextTypes,e!=null}function tl(){X(Ce),X(me)}function $o(e,t,n){if(me.current!==zt)throw Error(C(168));Y(me,t),Y(Ce,n)}function Nu(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(C(108,od(e)||"Unknown",l));return b({},n,r)}function nl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zt,Ht=me.current,Y(me,e),Y(Ce,Ce.current),!0}function Mo(e,t,n){var r=e.stateNode;if(!r)throw Error(C(169));n?(e=Nu(e,t,Ht),r.__reactInternalMemoizedMergedChildContext=e,X(Ce),X(me),Y(me,e)):X(Ce),Y(Ce,n)}var st=null,kl=!1,ti=!1;function Cu(e){st===null?st=[e]:st.push(e)}function Cf(e){kl=!0,Cu(e)}function Ot(){if(!ti&&st!==null){ti=!0;var e=0,t=Q;try{var n=st;for(Q=1;e>=s,l-=s,ot=1<<32-Ge(t)+l|n<E?(F=_,_=null):F=_.sibling;var O=v(f,_,p[E],w);if(O===null){_===null&&(_=F);break}e&&_&&O.alternate===null&&t(f,_),d=i(O,d,E),S===null?m=O:S.sibling=O,S=O,_=F}if(E===p.length)return n(f,_),G&&$t(f,E),m;if(_===null){for(;EE?(F=_,_=null):F=_.sibling;var A=v(f,_,O.value,w);if(A===null){_===null&&(_=F);break}e&&_&&A.alternate===null&&t(f,_),d=i(A,d,E),S===null?m=A:S.sibling=A,S=A,_=F}if(O.done)return n(f,_),G&&$t(f,E),m;if(_===null){for(;!O.done;E++,O=p.next())O=h(f,O.value,w),O!==null&&(d=i(O,d,E),S===null?m=O:S.sibling=O,S=O);return G&&$t(f,E),m}for(_=r(f,_);!O.done;E++,O=p.next())O=j(_,f,E,O.value,w),O!==null&&(e&&O.alternate!==null&&_.delete(O.key===null?E:O.key),d=i(O,d,E),S===null?m=O:S.sibling=O,S=O);return e&&_.forEach(function(K){return t(f,K)}),G&&$t(f,E),m}function R(f,d,p,w){if(typeof p=="object"&&p!==null&&p.type===qt&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case yr:e:{for(var m=p.key,S=d;S!==null;){if(S.key===m){if(m=p.type,m===qt){if(S.tag===7){n(f,S.sibling),d=l(S,p.props.children),d.return=f,f=d;break e}}else if(S.elementType===m||typeof m=="object"&&m!==null&&m.$$typeof===vt&&Ao(m)===S.type){n(f,S.sibling),d=l(S,p.props),d.ref=zn(f,S,p),d.return=f,f=d;break e}n(f,S);break}else t(f,S);S=S.sibling}p.type===qt?(d=Vt(p.props.children,f.mode,w,p.key),d.return=f,f=d):(w=Qr(p.type,p.key,p.props,null,f.mode,w),w.ref=zn(f,d,p),w.return=f,f=w)}return s(f);case Zt:e:{for(S=p.key;d!==null;){if(d.key===S)if(d.tag===4&&d.stateNode.containerInfo===p.containerInfo&&d.stateNode.implementation===p.implementation){n(f,d.sibling),d=l(d,p.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=ui(p,f.mode,w),d.return=f,f=d}return s(f);case vt:return S=p._init,R(f,d,S(p._payload),w)}if(Mn(p))return x(f,d,p,w);if(_n(p))return k(f,d,p,w);Pr(f,p)}return typeof p=="string"&&p!==""||typeof p=="number"?(p=""+p,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,p),d.return=f,f=d):(n(f,d),d=ai(p,f.mode,w),d.return=f,f=d),s(f)):n(f,d)}return R}var wn=Pu(!0),Lu=Pu(!1),il=Dt(null),sl=null,on=null,Ls=null;function zs(){Ls=on=sl=null}function Rs(e){var t=il.current;X(il),e._currentValue=t}function Vi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function hn(e,t){sl=e,Ls=on=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ne=!0),e.firstContext=null)}function He(e){var t=e._currentValue;if(Ls!==e)if(e={context:e,memoizedValue:t,next:null},on===null){if(sl===null)throw Error(C(308));on=e,sl.dependencies={lanes:0,firstContext:e}}else on=on.next=e;return t}var It=null;function Ds(e){It===null?It=[e]:It.push(e)}function zu(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Ds(t)):(n.next=l.next,l.next=n),t.interleaved=n,ft(e,r)}function ft(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var gt=!1;function Os(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ru(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function _t(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,B&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,ft(e,n)}return l=r.interleaved,l===null?(t.next=t,Ds(r)):(t.next=l.next,l.next=t),r.interleaved=t,ft(e,n)}function Ar(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}function Uo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?l=i=s:i=i.next=s,n=n.next}while(n!==null);i===null?l=i=t:i=i.next=t}else l=i=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ol(e,t,n,r){var l=e.updateQueue;gt=!1;var i=l.firstBaseUpdate,s=l.lastBaseUpdate,a=l.shared.pending;if(a!==null){l.shared.pending=null;var u=a,c=u.next;u.next=null,s===null?i=c:s.next=c,s=u;var y=e.alternate;y!==null&&(y=y.updateQueue,a=y.lastBaseUpdate,a!==s&&(a===null?y.firstBaseUpdate=c:a.next=c,y.lastBaseUpdate=u))}if(i!==null){var h=l.baseState;s=0,y=c=u=null,a=i;do{var v=a.lane,j=a.eventTime;if((r&v)===v){y!==null&&(y=y.next={eventTime:j,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var x=e,k=a;switch(v=t,j=n,k.tag){case 1:if(x=k.payload,typeof x=="function"){h=x.call(j,h,v);break e}h=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=k.payload,v=typeof x=="function"?x.call(j,h,v):x,v==null)break e;h=b({},h,v);break e;case 2:gt=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,v=l.effects,v===null?l.effects=[a]:v.push(a))}else j={eventTime:j,lane:v,tag:a.tag,payload:a.payload,callback:a.callback,next:null},y===null?(c=y=j,u=h):y=y.next=j,s|=v;if(a=a.next,a===null){if(a=l.shared.pending,a===null)break;v=a,a=v.next,v.next=null,l.lastBaseUpdate=v,l.shared.pending=null}}while(!0);if(y===null&&(u=h),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=y,t=l.shared.interleaved,t!==null){l=t;do s|=l.lane,l=l.next;while(l!==t)}else i===null&&(l.shared.lanes=0);Kt|=s,e.lanes=s,e.memoizedState=h}}function Bo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ri.transition;ri.transition={};try{e(!1),t()}finally{Q=n,ri.transition=r}}function Xu(){return We().memoizedState}function Pf(e,t,n){var r=Tt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Gu(e))Zu(t,n);else if(n=zu(e,t,n,r),n!==null){var l=ye();Ze(n,e,r,l),qu(n,t,r)}}function Lf(e,t,n){var r=Tt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Gu(e))Zu(t,l);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var s=t.lastRenderedState,a=i(s,n);if(l.hasEagerState=!0,l.eagerState=a,qe(a,s)){var u=t.interleaved;u===null?(l.next=l,Ds(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=zu(e,t,l,r),n!==null&&(l=ye(),Ze(n,e,r,l),qu(n,t,r))}}function Gu(e){var t=e.alternate;return e===q||t!==null&&t===q}function Zu(e,t){Qn=ul=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qu(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ws(e,n)}}var cl={readContext:He,useCallback:fe,useContext:fe,useEffect:fe,useImperativeHandle:fe,useInsertionEffect:fe,useLayoutEffect:fe,useMemo:fe,useReducer:fe,useRef:fe,useState:fe,useDebugValue:fe,useDeferredValue:fe,useTransition:fe,useMutableSource:fe,useSyncExternalStore:fe,useId:fe,unstable_isNewReconciler:!1},zf={readContext:He,useCallback:function(e,t){return et().memoizedState=[e,t===void 0?null:t],e},useContext:He,useEffect:Ho,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Br(4194308,4,Wu.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Br(4194308,4,e,t)},useInsertionEffect:function(e,t){return Br(4,2,e,t)},useMemo:function(e,t){var n=et();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=et();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Pf.bind(null,q,e),[r.memoizedState,e]},useRef:function(e){var t=et();return e={current:e},t.memoizedState=e},useState:Vo,useDebugValue:Vs,useDeferredValue:function(e){return et().memoizedState=e},useTransition:function(){var e=Vo(!1),t=e[0];return e=Tf.bind(null,e[1]),et().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=q,l=et();if(G){if(n===void 0)throw Error(C(407));n=n()}else{if(n=t(),se===null)throw Error(C(349));Qt&30||Mu(r,t,n)}l.memoizedState=n;var i={value:n,getSnapshot:t};return l.queue=i,Ho(Iu.bind(null,r,i,e),[e]),r.flags|=2048,cr(9,Fu.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=et(),t=se.identifierPrefix;if(G){var n=at,r=ot;n=(r&~(1<<32-Ge(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ar++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[tt]=t,e[ir]=r,ac(e,t,!1,!1),t.stateNode=e;e:{switch(s=Ni(n,r),n){case"dialog":J("cancel",e),J("close",e),l=r;break;case"iframe":case"object":case"embed":J("load",e),l=r;break;case"video":case"audio":for(l=0;lkn&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304)}else{if(!r)if(e=al(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Rn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!s.alternate&&!G)return pe(t),null}else 2*te()-i.renderingStartTime>kn&&n!==1073741824&&(t.flags|=128,r=!0,Rn(i,!1),t.lanes=4194304);i.isBackwards?(s.sibling=t.child,t.child=s):(n=i.last,n!==null?n.sibling=s:t.child=s,i.last=s)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=te(),t.sibling=null,n=Z.current,Y(Z,r?n&1|2:n&1),t):(pe(t),null);case 22:case 23:return Js(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Pe&1073741824&&(pe(t),t.subtreeFlags&6&&(t.flags|=8192)):pe(t),null;case 24:return null;case 25:return null}throw Error(C(156,t.tag))}function Af(e,t){switch(Ts(t),t.tag){case 1:return _e(t.type)&&tl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return xn(),X(Ce),X(me),Fs(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ms(t),null;case 13:if(X(Z),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(C(340));yn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return X(Z),null;case 4:return xn(),null;case 10:return Rs(t.type._context),null;case 22:case 23:return Js(),null;case 24:return null;default:return null}}var zr=!1,he=!1,Uf=typeof WeakSet=="function"?WeakSet:Set,z=null;function an(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ee(e,t,r)}else n.current=null}function Zi(e,t,n){try{n()}catch(r){ee(e,t,r)}}var ea=!1;function Bf(e,t){if(Oi=Zr,e=mu(),_s(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var s=0,a=-1,u=-1,c=0,y=0,h=e,v=null;t:for(;;){for(var j;h!==n||l!==0&&h.nodeType!==3||(a=s+l),h!==i||r!==0&&h.nodeType!==3||(u=s+r),h.nodeType===3&&(s+=h.nodeValue.length),(j=h.firstChild)!==null;)v=h,h=j;for(;;){if(h===e)break t;if(v===n&&++c===l&&(a=s),v===i&&++y===r&&(u=s),(j=h.nextSibling)!==null)break;h=v,v=h.parentNode}h=j}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for($i={focusedElem:e,selectionRange:n},Zr=!1,z=t;z!==null;)if(t=z,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,z=e;else for(;z!==null;){t=z;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var k=x.memoizedProps,R=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?k:Ye(t.type,k),R);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var p=t.stateNode.containerInfo;p.nodeType===1?p.textContent="":p.nodeType===9&&p.documentElement&&p.removeChild(p.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(C(163))}}catch(w){ee(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,z=e;break}z=t.return}return x=ea,ea=!1,x}function Kn(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var i=l.destroy;l.destroy=void 0,i!==void 0&&Zi(t,n,i)}l=l.next}while(l!==r)}}function Cl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function qi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function dc(e){var t=e.alternate;t!==null&&(e.alternate=null,dc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[tt],delete t[ir],delete t[Ii],delete t[jf],delete t[Nf])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function fc(e){return e.tag===5||e.tag===3||e.tag===4}function ta(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||fc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function bi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=el));else if(r!==4&&(e=e.child,e!==null))for(bi(e,t,n),e=e.sibling;e!==null;)bi(e,t,n),e=e.sibling}function es(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(es(e,t,n),e=e.sibling;e!==null;)es(e,t,n),e=e.sibling}var ue=null,Je=!1;function mt(e,t,n){for(n=n.child;n!==null;)pc(e,t,n),n=n.sibling}function pc(e,t,n){if(nt&&typeof nt.onCommitFiberUnmount=="function")try{nt.onCommitFiberUnmount(gl,n)}catch{}switch(n.tag){case 5:he||an(n,t);case 6:var r=ue,l=Je;ue=null,mt(e,t,n),ue=r,Je=l,ue!==null&&(Je?(e=ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ue.removeChild(n.stateNode));break;case 18:ue!==null&&(Je?(e=ue,n=n.stateNode,e.nodeType===8?ei(e.parentNode,n):e.nodeType===1&&ei(e,n),er(e)):ei(ue,n.stateNode));break;case 4:r=ue,l=Je,ue=n.stateNode.containerInfo,Je=!0,mt(e,t,n),ue=r,Je=l;break;case 0:case 11:case 14:case 15:if(!he&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var i=l,s=i.destroy;i=i.tag,s!==void 0&&(i&2||i&4)&&Zi(n,t,s),l=l.next}while(l!==r)}mt(e,t,n);break;case 1:if(!he&&(an(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){ee(n,t,a)}mt(e,t,n);break;case 21:mt(e,t,n);break;case 22:n.mode&1?(he=(r=he)||n.memoizedState!==null,mt(e,t,n),he=r):mt(e,t,n);break;default:mt(e,t,n)}}function na(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Uf),t.forEach(function(r){var l=Gf.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ke(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=s),r&=~i}if(r=l,r=te()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Hf(r/1960))-r,10e?16:e,St===null)var r=!1;else{if(e=St,St=null,pl=0,B&6)throw Error(C(331));var l=B;for(B|=4,z=e.current;z!==null;){var i=z,s=i.child;if(z.flags&16){var a=i.deletions;if(a!==null){for(var u=0;ute()-Ks?Bt(e,0):Qs|=n),Ee(e,t)}function Sc(e,t){t===0&&(e.mode&1?(t=kr,kr<<=1,!(kr&130023424)&&(kr=4194304)):t=1);var n=ye();e=ft(e,t),e!==null&&(pr(e,t,n),Ee(e,n))}function Xf(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Sc(e,n)}function Gf(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(C(314))}r!==null&&r.delete(t),Sc(e,n)}var kc;kc=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ce.current)Ne=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ne=!1,Ff(e,t,n);Ne=!!(e.flags&131072)}else Ne=!1,G&&t.flags&1048576&&_u(t,ll,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Vr(e,t),e=t.pendingProps;var l=gn(t,me.current);hn(t,n),l=As(null,t,r,e,l,n);var i=Us();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,_e(r)?(i=!0,nl(t)):i=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Os(t),l.updater=Nl,t.stateNode=l,l._reactInternals=t,Wi(t,r,e,n),t=Yi(null,t,r,!0,i,n)):(t.tag=0,G&&i&&Es(t),ge(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Vr(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=qf(r),e=Ye(r,e),l){case 0:t=Ki(null,t,r,e,n);break e;case 1:t=Zo(null,t,r,e,n);break e;case 11:t=Xo(null,t,r,e,n);break e;case 14:t=Go(null,t,r,Ye(r.type,e),n);break e}throw Error(C(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Ki(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Zo(e,t,r,l,n);case 3:e:{if(ic(t),e===null)throw Error(C(387));r=t.pendingProps,i=t.memoizedState,l=i.element,Ru(e,t),ol(t,r,null,n);var s=t.memoizedState;if(r=s.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){l=Sn(Error(C(423)),t),t=qo(e,t,r,n,l);break e}else if(r!==l){l=Sn(Error(C(424)),t),t=qo(e,t,r,n,l);break e}else for(Le=Ct(t.stateNode.containerInfo.firstChild),ze=t,G=!0,Xe=null,n=Lu(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(yn(),r===l){t=pt(e,t,n);break e}ge(e,t,r,n)}t=t.child}return t;case 5:return Du(t),e===null&&Bi(t),r=t.type,l=t.pendingProps,i=e!==null?e.memoizedProps:null,s=l.children,Mi(r,l)?s=null:i!==null&&Mi(r,i)&&(t.flags|=32),lc(e,t),ge(e,t,s,n),t.child;case 6:return e===null&&Bi(t),null;case 13:return sc(e,t,n);case 4:return $s(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=wn(t,null,r,n):ge(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Xo(e,t,r,l,n);case 7:return ge(e,t,t.pendingProps,n),t.child;case 8:return ge(e,t,t.pendingProps.children,n),t.child;case 12:return ge(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,i=t.memoizedProps,s=l.value,Y(il,r._currentValue),r._currentValue=s,i!==null)if(qe(i.value,s)){if(i.children===l.children&&!Ce.current){t=pt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){s=i.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=ut(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var y=c.pending;y===null?u.next=u:(u.next=y.next,y.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Vi(i.return,n,t),a.lanes|=n;break}u=u.next}}else if(i.tag===10)s=i.type===t.type?null:i.child;else if(i.tag===18){if(s=i.return,s===null)throw Error(C(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Vi(s,n,t),s=i.sibling}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===t){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}ge(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,hn(t,n),l=He(l),r=r(l),t.flags|=1,ge(e,t,r,n),t.child;case 14:return r=t.type,l=Ye(r,t.pendingProps),l=Ye(r.type,l),Go(e,t,r,l,n);case 15:return nc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ye(r,l),Vr(e,t),t.tag=1,_e(r)?(e=!0,nl(t)):e=!1,hn(t,n),bu(t,r,l),Wi(t,r,l,n),Yi(null,t,r,!0,e,n);case 19:return oc(e,t,n);case 22:return rc(e,t,n)}throw Error(C(156,t.tag))};function jc(e,t){return Ga(e,t)}function Zf(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Be(e,t,n,r){return new Zf(e,t,n,r)}function Gs(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qf(e){if(typeof e=="function")return Gs(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ms)return 11;if(e===vs)return 14}return 2}function Pt(e,t){var n=e.alternate;return n===null?(n=Be(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Qr(e,t,n,r,l,i){var s=2;if(r=e,typeof e=="function")Gs(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case qt:return Vt(n.children,l,i,t);case hs:s=8,l|=8;break;case hi:return e=Be(12,n,t,l|2),e.elementType=hi,e.lanes=i,e;case mi:return e=Be(13,n,t,l),e.elementType=mi,e.lanes=i,e;case vi:return e=Be(19,n,t,l),e.elementType=vi,e.lanes=i,e;case Da:return El(n,l,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case za:s=10;break e;case Ra:s=9;break e;case ms:s=11;break e;case vs:s=14;break e;case vt:s=16,r=null;break e}throw Error(C(130,e==null?e:typeof e,""))}return t=Be(s,n,t,l),t.elementType=e,t.type=r,t.lanes=i,t}function Vt(e,t,n,r){return e=Be(7,e,r,t),e.lanes=n,e}function El(e,t,n,r){return e=Be(22,e,r,t),e.elementType=Da,e.lanes=n,e.stateNode={isHidden:!1},e}function ai(e,t,n){return e=Be(6,e,null,t),e.lanes=n,e}function ui(e,t,n){return t=Be(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function bf(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Hl(0),this.expirationTimes=Hl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Hl(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Zs(e,t,n,r,l,i,s,a,u){return e=new bf(e,t,n,a,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Be(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Os(i),e}function ep(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ec)}catch(e){console.error(e)}}Ec(),Ea.exports=De;var ip=Ea.exports,Tc,ca=ip;Tc=ca.createRoot,ca.hydrateRoot;async function Se(e){const t=await fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()}async function sp(){return Se("/api/archives")}async function op(e){return Se(`/api/archives/${e}/entries`)}async function ap(e,t,n){const r=new URLSearchParams;return t&&r.set("q",t),n&&r.set("tag",n),Se(`/api/archives/${e}/entries/search?${r}`)}async function up(e,t){return Se(`/api/archives/${e}/entries/${t}`)}async function cp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n??null})});if(!r.ok)throw new Error(await r.text())}async function ci(e,t){return Se(`/api/archives/${e}/entries/${t}/tags`)}async function dp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag_path:n})});if(!r.ok)throw new Error(`Failed to add tag (${r.status})`)}async function fp(e,t,n){const r=await fetch(`/api/archives/${e}/entries/${t}/tags/${n}`,{method:"DELETE"});if(!r.ok)throw new Error(`Remove failed (${r.status})`)}async function pp(e,t){const n=await fetch(`/api/archives/${e}/entries/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(`Delete failed (${n.status})`)}async function hp(e,t,n){const r=await fetch(`/api/archives/${e}/tags/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(!r.ok)throw new Error(await r.text());return r.json()}async function mp(e,t){const n=await fetch(`/api/archives/${e}/tags/${t}`,{method:"DELETE"});if(!n.ok)throw new Error(await n.text())}async function da(e){return Se(`/api/archives/${e}/runs`)}async function di(e){return Se(`/api/archives/${e}/tags`)}async function vp(e,t){const n=await fetch(`/api/archives/${e}/captures`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({locator:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function gp(e,t){return Se(`/api/archives/${e}/capture_jobs/${t}`)}async function yp(){return(await(await fetch("/api/auth/setup")).json()).setup_required===!0}async function wp(e,t){const n=await fetch("/api/auth/setup",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Setup failed");return n.json()}async function xp(e,t){const n=await fetch("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})});if(!n.ok)throw new Error((await n.json()).error||"Login failed");return n.json()}async function Sp(){await fetch("/api/auth/logout",{method:"POST"})}async function kp(){const e=await fetch("/api/auth/me");return e.status===401?null:e.json()}async function jp(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({display_name:e})});if(!t.ok)throw new Error(await t.text())}async function Np(e){const t=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function Cp(e,t){const n=await fetch("/api/auth/me",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({current_password:e,new_password:t})});if(!n.ok){let r=await n.text();try{r=JSON.parse(r).error??r}catch{}throw new Error(r)}}async function _p(){return Se("/api/auth/tokens")}async function Ep(e){const t=await fetch("/api/auth/tokens",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});if(!t.ok)throw new Error(await t.text());return t.json()}async function Tp(e){const t=await fetch(`/api/auth/tokens/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(await t.text())}async function Pp(){return Se("/api/admin/instance-settings")}async function Lp(e){const t=await fetch("/api/admin/instance-settings",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await t.text())}async function zp(){return Se("/api/admin/users")}async function Rp(e,t,n){const r=await fetch("/api/admin/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:n||void 0})});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error||`HTTP ${r.status}`)}return r.json()}async function Dp(e,t){const n=await fetch(`/api/admin/users/${e}/status`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Op(){return Se("/api/admin/roles")}async function $p(e,t){const n=await fetch("/api/admin/roles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:e,name:t})});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error||`HTTP ${n.status}`)}return n.json()}async function Mp(e){return Se(`/api/archives/${e}/collections`)}async function Fp(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({name:t,slug:n,default_visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}return l.json()}async function Ip(e,t){return Se(`/api/archives/${e}/collections/${t}`)}async function Ap(e,t,n,r=2){const l=await fetch(`/api/archives/${e}/collections/${t}/entries`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({entry_uid:n,visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Up(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"DELETE"});if(!r.ok){const l=await r.json().catch(()=>({error:r.statusText}));throw new Error(l.error||r.statusText)}}async function Bp(e,t,n,r){const l=await fetch(`/api/archives/${e}/collections/${t}/entries/${n}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({visibility_bits:r})});if(!l.ok){const i=await l.json().catch(()=>({error:l.statusText}));throw new Error(i.error||l.statusText)}}async function Vp(e,t){return Se(`/api/archives/${e}/entries/${t}/collections`)}async function fa(e,t,n){const r=await fetch(`/api/archives/${e}/collections/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.error??r.statusText)}}async function Hp(e,t){const n=await fetch(`/api/archives/${e}/collections/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.json().catch(()=>({}));throw new Error(r.error??n.statusText)}}const Wp=window.fetch;window.fetch=async(...e)=>{var n;const t=await Wp(...e);return t.status===401&&((typeof e[0]=="string"?e[0]:((n=e[0])==null?void 0:n.url)??"").includes("/api/auth/")||window.dispatchEvent(new CustomEvent("auth:expired"))),t};function Qp({onLogin:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(null),[a,u]=g.useState(!1);async function c(y){y.preventDefault(),s(null),u(!0);try{const h=await xp(t,r);e(h)}catch(h){s(h.message)}finally{u(!1)}}return o.jsx("div",{className:"login-page",children:o.jsxs("div",{className:"login-card",children:[o.jsx("h1",{className:"login-brand",children:"Archivr"}),o.jsx("p",{className:"login-tagline",children:"Sign in to your archive"}),o.jsxs("form",{onSubmit:c,children:[o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-username",children:"Username"}),o.jsx("input",{className:"login-input",id:"login-username",type:"text",value:t,onChange:y=>n(y.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"login-field",children:[o.jsx("label",{className:"login-label",htmlFor:"login-password",children:"Password"}),o.jsx("input",{className:"login-input",id:"login-password",type:"password",value:r,onChange:y=>l(y.target.value),required:!0,autoComplete:"current-password"})]}),i&&o.jsx("p",{className:"login-error",children:i}),o.jsx("button",{className:"login-submit",type:"submit",disabled:a,children:a?"Signing in…":"Sign in"})]})]})})}function Kp({onComplete:e}){const[t,n]=g.useState(""),[r,l]=g.useState(""),[i,s]=g.useState(""),[a,u]=g.useState(null),[c,y]=g.useState(!1);async function h(v){if(v.preventDefault(),r!==i){u("Passwords do not match");return}if(r.length<8){u("Password must be at least 8 characters");return}u(null),y(!0);try{await wp(t,r),e()}catch(j){u(j.message)}finally{y(!1)}}return o.jsx("div",{className:"setup-page",children:o.jsxs("div",{className:"setup-card",children:[o.jsx("h1",{className:"setup-brand",children:"Archivr"}),o.jsx("p",{className:"setup-tagline",children:"Create your owner account to get started."}),o.jsxs("form",{onSubmit:h,children:[o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-username",children:"Username"}),o.jsx("input",{className:"setup-input",id:"setup-username",type:"text",value:t,onChange:v=>n(v.target.value),autoFocus:!0,required:!0,autoComplete:"username"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-password",children:"Password"}),o.jsx("input",{className:"setup-input",id:"setup-password",type:"password",value:r,onChange:v=>l(v.target.value),required:!0,autoComplete:"new-password"})]}),o.jsxs("div",{className:"setup-field",children:[o.jsx("label",{className:"setup-label",htmlFor:"setup-confirm",children:"Confirm password"}),o.jsx("input",{className:"setup-input",id:"setup-confirm",type:"password",value:i,onChange:v=>s(v.target.value),required:!0,autoComplete:"new-password"})]}),a&&o.jsx("p",{className:"setup-error",children:a}),o.jsx("button",{className:"setup-submit",type:"submit",disabled:c,children:c?"Creating account…":"Create account"})]})]})})}function Yp({archives:e,archiveId:t,onArchiveChange:n,view:r,onViewChange:l,onCaptureClick:i}){const{currentUser:s,setCurrentUser:a}=g.useContext(Rl)??{},[u,c]=g.useState(!1);async function y(){c(!0),await Sp(),a(null),window.location.reload()}return o.jsxs("header",{className:"topbar",children:[o.jsx("div",{className:"brand",children:"Archivr"}),o.jsx("div",{className:"switcher",children:o.jsx("select",{"aria-label":"Select archive",value:t??"",onChange:h=>n(h.target.value),children:e.map(h=>o.jsx("option",{value:h.id,children:h.label},h.id))})}),o.jsx("nav",{className:"nav","aria-label":"Primary",children:["archive","tags","collections","runs","admin","settings"].map(h=>o.jsx("button",{className:`nav-link${r===h?" is-active":""}`,onClick:()=>l(h),children:h.charAt(0).toUpperCase()+h.slice(1)},h))}),o.jsx("button",{className:"capture-button",onClick:i,children:"Capture"}),s&&o.jsxs("div",{className:"user-menu",children:[o.jsx("span",{className:"user-name",children:s.display_name||s.username}),o.jsx("button",{className:"logout-btn",onClick:y,disabled:u,children:u?"Logging out…":"Log out"})]})]})}let is=1;function On(e=""){return{id:is++,locator:e,status:"idle",error:null,jobUid:null,archiveId:null}}function pa(e){return e.some(t=>t.status==="submitting"||t.status==="running")}function Jp({open:e,archiveId:t,onClose:n,onCaptured:r,onToast:l}){const i=g.useRef(null),s=g.useRef(!0),a=g.useRef(new Map),u=g.useRef(r),c=g.useRef(l);g.useEffect(()=>{u.current=r},[r]),g.useEffect(()=>{c.current=l},[l]);const[y,h]=g.useState(()=>{try{const m=JSON.parse(sessionStorage.getItem("captureItems")||"null");if(Array.isArray(m)&&m.length>0)return m.forEach(S=>{S.id>=is&&(is=S.id+1)}),m}catch{}return[On()]});g.useEffect(()=>{sessionStorage.setItem("captureItems",JSON.stringify(y))},[y]),g.useEffect(()=>{["captureDialogLocator","captureDialogError","captureDialogBusy","captureDialogJobStatus","captureDialogJobUid"].forEach(m=>sessionStorage.removeItem(m)),h(m=>m.map(S=>S.status==="submitting"?{...S,status:"idle",error:null}:S)),y.forEach(m=>{m.status==="running"&&m.jobUid&&m.archiveId&&!a.current.has(m.jobUid)&&v(m.id,m.jobUid,m.locator,m.archiveId)})},[]),g.useEffect(()=>{const m=i.current;if(!m)return;const S=()=>n();return m.addEventListener("close",S),()=>m.removeEventListener("close",S)},[n]),g.useEffect(()=>{const m=i.current;m&&(e?(!s.current&&!pa(y)&&h([On()]),s.current=!1,m.open||m.showModal()):m.open&&m.close())},[e]),g.useEffect(()=>()=>a.current.forEach(m=>clearInterval(m)),[]);function v(m,S,_,E){if(a.current.has(S))return;const F=setInterval(async()=>{try{const O=await gp(E,S);if(O.status==="completed")clearInterval(a.current.get(S)),a.current.delete(S),h(A=>A.map(K=>K.id===m?{...K,status:"completed"}:K)),setTimeout(()=>{h(A=>{const K=A.filter(L=>L.id!==m);return K.length===0?[On()]:K})},1400),u.current();else if(O.status==="failed"){clearInterval(a.current.get(S)),a.current.delete(S);const A=O.error_text||"Capture failed.";h(K=>K.map(L=>L.id===m?{...L,status:"failed",error:A}:L)),c.current(A,_)}}catch(O){clearInterval(a.current.get(S)),a.current.delete(S);const A=O.message||"Network error";h(K=>K.map(L=>L.id===m?{...L,status:"failed",error:A}:L)),c.current(A,_)}},500);a.current.set(S,F)}async function j(m){if(!m.locator.trim())return;const S=t,_=m.locator.trim();h(E=>E.map(F=>F.id===m.id?{...F,status:"submitting",error:null}:F));try{const E=await vp(S,_);h(F=>F.map(O=>O.id===m.id?{...O,status:"running",jobUid:E.job_uid,archiveId:S}:O)),v(m.id,E.job_uid,_,S)}catch(E){const F=E.message||"Submission failed.";h(O=>O.map(A=>A.id===m.id?{...A,status:"failed",error:F}:A)),c.current(F,_)}}function x(){y.filter(S=>S.status==="idle"&&S.locator.trim()).forEach(S=>j(S))}function k(){h(m=>[...m,On()])}function R(m){h(S=>{const _=S.filter(E=>E.id!==m);return _.length===0?[On()]:_})}function f(m){h(S=>S.map(_=>_.id===m?{..._,status:"idle",error:null}:_))}function d(m,S){h(_=>_.map(E=>E.id===m?{...E,locator:S}:E))}const p=y.filter(m=>m.status==="idle"&&m.locator.trim()).length,w=pa(y);return o.jsx("dialog",{ref:i,className:"capture-dialog",children:o.jsxs("div",{className:"capture-dialog-inner",children:[o.jsxs("div",{className:"capture-dialog-header",children:[o.jsx("h2",{className:"capture-dialog-title",children:"Capture"}),o.jsx("button",{type:"button",className:"capture-dialog-close",onClick:()=>{var m;return(m=i.current)==null?void 0:m.close()},"aria-label":"Close",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),o.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),o.jsx("div",{className:"capture-rows",children:y.map((m,S)=>o.jsx(Xp,{item:m,autoFocus:S===y.length-1&&m.status==="idle",onLocatorChange:_=>d(m.id,_),onRemove:()=>R(m.id),onReset:()=>f(m.id),onSubmit:x},m.id))}),o.jsxs("button",{type:"button",className:"capture-add-row",onClick:k,children:[o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"8",y1:"2",x2:"8",y2:"14"}),o.jsx("line",{x1:"2",y1:"8",x2:"14",y2:"8"})]}),"Add another"]}),o.jsxs("div",{className:"capture-actions",children:[o.jsx("button",{type:"button",className:"capture-cancel",onClick:()=>{var m;return(m=i.current)==null?void 0:m.close()},children:w?"Close":"Cancel"}),o.jsx("button",{type:"button",className:"capture-submit",onClick:x,disabled:p===0,children:p>1?`Archive ${p}`:"Archive"})]})]})})}function Xp({item:e,autoFocus:t,onLocatorChange:n,onRemove:r,onReset:l,onSubmit:i}){const s=g.useRef(null),a=e.status==="submitting"||e.status==="running";return g.useEffect(()=>{var u;t&&e.status==="idle"&&((u=s.current)==null||u.focus())},[t]),o.jsxs("div",{className:`capture-row capture-row--${e.status}`,children:[o.jsxs("div",{className:"capture-row-main",children:[o.jsx(Gp,{status:e.status}),o.jsx("input",{ref:s,className:"capture-input",type:"text",placeholder:"https://… · yt:ID · tweet:ID · x:ID",value:e.locator,onChange:u=>n(u.target.value),onKeyDown:u=>{u.key==="Enter"&&i()},disabled:a||e.status==="completed",autoComplete:"off",spellCheck:!1}),e.status==="failed"&&o.jsx("button",{type:"button",className:"capture-row-action",onClick:l,title:"Retry",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M13 2.5A7 7 0 1 1 6.5 1"}),o.jsx("polyline",{points:"6.5 1 4 3.5 6.5 6"})]})}),!a&&e.status!=="completed"&&e.status!=="failed"&&o.jsx("button",{type:"button",className:"capture-row-action capture-row-remove",onClick:r,"aria-label":"Remove",children:o.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("line",{x1:"3",y1:"3",x2:"13",y2:"13"}),o.jsx("line",{x1:"13",y1:"3",x2:"3",y2:"13"})]})})]}),e.error&&o.jsx("p",{className:"capture-row-error",children:e.error})]})}function Gp({status:e}){return e==="submitting"||e==="running"?o.jsx("span",{className:"cap-dot cap-dot--running","aria-label":"Running",children:o.jsx("span",{className:"cap-spinner"})}):e==="completed"?o.jsx("span",{className:"cap-dot cap-dot--ok","aria-label":"Done",children:"✓"}):e==="failed"?o.jsx("span",{className:"cap-dot cap-dot--err","aria-label":"Failed",children:"✕"}):o.jsx("span",{className:"cap-dot cap-dot--idle","aria-hidden":"true"})}function ss(e){if(!e)return"0 B";const t=["B","KB","MB","GB"];let n=e,r=0;for(;n>=1024&&r").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'")}function Ut(e){return Zp(e)??""}function Pc(e){if(!e)return"";const t=new Date(e);if(isNaN(t))return e;const n=r=>String(r).padStart(2,"0");return`${t.getUTCFullYear()}-${n(t.getUTCMonth()+1)}-${n(t.getUTCDate())} ${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}const ha={youtube:'',x:'',instagram:'',facebook:'',tiktok:'',reddit:'',snapchat:'',local:'',web:'',other:'?'};function Lc(e){return ha[e]??ha.other}function zc(e){return e.split("/").map(t=>t?t.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" "):"").join("/")}function qp({entry:e,archiveId:t,isSelected:n,onSelect:r}){const[l,i]=g.useState(!1),a=e.source_kind==="web"&&e.entity_kind==="page"&&e.has_favicon&&t&&!l?o.jsx("img",{src:`/api/archives/${t}/entries/${e.entry_uid}/favicon`,width:"16",height:"16",alt:"",onError:()=>i(!0),style:{objectFit:"contain"}}):o.jsx("span",{dangerouslySetInnerHTML:{__html:Lc(e.source_kind)}});return o.jsxs("div",{className:n?"is-selected":void 0,tabIndex:0,"data-entry-uid":e.entry_uid,onClick:r,onKeyDown:u=>{u.key==="Enter"&&r()},children:[o.jsx("div",{className:"col-added",children:Pc(e.archived_at)}),o.jsxs("div",{className:"col-title",children:[o.jsx("span",{className:"source-icon",children:a}),o.jsx("span",{className:"entry-title",children:Ut(e.title)||Ut(e.entry_uid)})]}),o.jsx("div",{className:"col-type",children:o.jsx("span",{className:"type-pill",children:Ut(e.entity_kind)})}),o.jsxs("div",{className:"col-size",children:[o.jsx("span",{className:"size-total",children:ss(e.total_artifact_bytes)}),e.cached_bytes>0&&e.total_artifact_bytes>0&&o.jsxs("span",{className:"size-cached-pct",title:`${ss(e.cached_bytes)} already on disk from an earlier entry`,children:[Math.round(e.cached_bytes/e.total_artifact_bytes*100),"% cached"]})]}),o.jsx("div",{className:"url-cell col-url",children:Ut(e.original_url)})]})}function bp({entries:e,selectedEntryUid:t,onSelectEntry:n,archiveId:r}){return o.jsx("section",{id:"archive-view",className:"view is-active",children:o.jsxs("div",{className:"entry-table",children:[o.jsxs("div",{className:"entry-header-row",children:[o.jsx("div",{className:"col-added",children:"Added"}),o.jsx("div",{className:"col-title",children:"Title"}),o.jsx("div",{className:"col-type",children:"Type"}),o.jsx("div",{className:"col-size",children:"Size"}),o.jsx("div",{className:"col-url",children:"Original URL"})]}),o.jsx("div",{id:"entries-body",children:e.map(l=>o.jsx(qp,{entry:l,archiveId:r,isSelected:l.entry_uid===t,onSelect:()=>n(l)},l.entry_uid))})]})})}function eh(e){if(!e)return"—";try{return new Date(e).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return e}}function th({status:e}){const t=e==="completed"?"run-status--completed":e==="failed"?"run-status--failed":e==="in_progress"?"run-status--in-progress":"",n=e?e.replace(/_/g," "):"—";return o.jsx("span",{className:`run-status ${t}`,children:n})}function nh({runs:e}){const[t,n]=g.useState(null);function r(l){n(i=>i===l?null:l)}return o.jsx("section",{id:"runs-view",className:"view is-active",children:o.jsxs("table",{className:"entry-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Started"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Requested"}),o.jsx("th",{children:"Completed"}),o.jsx("th",{children:"Failed"})]})}),o.jsx("tbody",{children:e.length===0?o.jsx("tr",{children:o.jsx("td",{colSpan:5,style:{color:"var(--muted)",padding:"24px 16px",textAlign:"center"},children:"No runs yet."})}):e.map(l=>{const i=l.status==="failed"&&l.error_summary,s=t===l.run_uid;return[o.jsxs("tr",{className:i?"run-row run-row--failed":"run-row",onClick:i?()=>r(l.run_uid):void 0,title:i?s?"Click to hide error":"Click to view error":void 0,children:[o.jsx("td",{children:eh(l.started_at)}),o.jsxs("td",{children:[o.jsx(th,{status:l.status}),i&&o.jsx("span",{className:"run-expand-hint","aria-hidden":"true",children:s?"▴":"▾"})]}),o.jsx("td",{children:l.requested_count??"—"}),o.jsx("td",{children:l.completed_count??"—"}),o.jsx("td",{children:l.failed_count??"—"})]},l.run_uid),i&&s&&o.jsx("tr",{className:"run-error-row",children:o.jsx("td",{colSpan:5,children:o.jsx("pre",{className:"run-error-detail",children:l.error_summary})})},`${l.run_uid}-detail`)]})})]})})}const rh=4;function lh({archives:e}){const{currentUser:t}=g.useContext(Rl)??{},n=t&&(t.role_bits&rh)!==0,[r,l]=g.useState("users"),[i,s]=g.useState([]),[a,u]=g.useState([]),[c,y]=g.useState(!1),[h,v]=g.useState(null),[j,x]=g.useState(""),[k,R]=g.useState(""),[f,d]=g.useState(""),[p,w]=g.useState(null),[m,S]=g.useState(!1),[_,E]=g.useState(""),[F,O]=g.useState(""),[A,K]=g.useState(null),[L,H]=g.useState(!1),ke=g.useCallback(async()=>{if(n){y(!0),v(null);try{const[N,$]=await Promise.all([zp(),Op()]);s(N),u($)}catch(N){v(N.message)}finally{y(!1)}}},[n]);g.useEffect(()=>{ke()},[ke]);async function $e(N){const $=N.status==="active"?"disabled":"active";try{await Dp(N.user_uid,$),s(V=>V.map(M=>M.user_uid===N.user_uid?{...M,status:$}:M))}catch(V){v(V.message)}}async function Me(N){if(N.preventDefault(),!j.trim()||!k){w("Username and password required");return}S(!0),w(null);try{await Rp(j.trim(),k,f.trim()||void 0),x(""),R(""),d(""),await ke()}catch($){w($.message)}finally{S(!1)}}async function T(N){if(N.preventDefault(),!_.trim()||!F.trim()){K("Slug and name required");return}H(!0),K(null);try{await $p(_.trim(),F.trim()),E(""),O(""),await ke()}catch($){K($.message)}finally{H(!1)}}return n?o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsxs("div",{className:"view-tabs",children:[o.jsx("button",{className:`view-tab${r==="users"?" is-active":""}`,onClick:()=>l("users"),children:"Users"}),o.jsx("button",{className:`view-tab${r==="roles"?" is-active":""}`,onClick:()=>l("roles"),children:"Roles"}),o.jsx("button",{className:`view-tab${r==="archives"?" is-active":""}`,onClick:()=>l("archives"),children:"Archives"})]}),h&&o.jsx("div",{className:"form-msg form-msg--err",children:h}),r==="users"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Users"}),c?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Username"}),o.jsx("th",{children:"Email"}),o.jsx("th",{children:"Roles"}),o.jsx("th",{children:"Status"}),o.jsx("th",{children:"Actions"})]})}),o.jsx("tbody",{children:i.map(N=>o.jsxs("tr",{className:N.status==="disabled"?"admin-row-disabled":"",children:[o.jsx("td",{children:N.username}),o.jsx("td",{className:"muted",children:N.email||"—"}),o.jsx("td",{children:N.role_slugs.join(", ")||"—"}),o.jsx("td",{children:o.jsx("span",{className:`status-badge status-${N.status}`,children:N.status})}),o.jsx("td",{children:o.jsx("button",{className:"admin-action-btn",onClick:()=>$e(N),children:N.status==="active"?"Ban":"Unban"})})]},N.user_uid))})]}),o.jsx("h3",{children:"Create User"}),o.jsxs("form",{className:"admin-form",onSubmit:Me,children:[o.jsx("input",{className:"admin-input",placeholder:"Username",value:j,onChange:N=>x(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"password",placeholder:"Password (min 8 chars)",value:k,onChange:N=>R(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",type:"email",placeholder:"Email (optional)",value:f,onChange:N=>d(N.target.value)}),p&&o.jsx("div",{className:"form-msg form-msg--err",children:p}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:m,children:m?"Creating…":"Create User"})]})]}),r==="roles"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Roles"}),c?o.jsx("p",{className:"muted",children:"Loading…"}):o.jsxs("table",{className:"admin-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Slug"}),o.jsx("th",{children:"Name"}),o.jsx("th",{children:"Level"}),o.jsx("th",{children:"Bit"}),o.jsx("th",{children:"Built-in"})]})}),o.jsx("tbody",{children:a.map(N=>o.jsxs("tr",{children:[o.jsx("td",{children:o.jsx("code",{children:N.slug})}),o.jsx("td",{children:N.name}),o.jsx("td",{children:N.level}),o.jsx("td",{children:N.bit_position}),o.jsx("td",{children:N.is_builtin?"✓":""})]},N.role_uid))})]}),o.jsx("h3",{children:"Create Custom Role"}),o.jsxs("form",{className:"admin-form",onSubmit:T,children:[o.jsx("input",{className:"admin-input",placeholder:"Slug (e.g. moderator)",value:_,onChange:N=>E(N.target.value),required:!0}),o.jsx("input",{className:"admin-input",placeholder:"Display Name (e.g. Moderator)",value:F,onChange:N=>O(N.target.value),required:!0}),A&&o.jsx("div",{className:"form-msg form-msg--err",children:A}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:L,children:L?"Creating…":"Create Role"})]})]}),r==="archives"&&o.jsxs("div",{className:"admin-section",children:[o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})]}):o.jsxs("section",{id:"admin-view",className:"view admin-view is-active",children:[o.jsx("h1",{children:"Admin"}),o.jsx("p",{className:"muted",children:"You need admin privileges to access this panel."}),o.jsx("h2",{children:"Mounted Archives"}),o.jsx("div",{className:"admin-list",children:e.map(N=>o.jsxs("div",{className:"admin-archive",children:[o.jsx("strong",{children:N.label}),o.jsx("div",{className:"muted",children:N.archive_path})]},N.id))})]})}function Rc({node:e,archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u}){var w;const c=n===e.tag.full_path,[y,h]=g.useState(!1),[v,j]=g.useState(""),x=g.useRef(!1);function k(){if(y)return;const m=c?null:e.tag.full_path;r(m),l("archive")}function R(m){m.stopPropagation(),j(e.tag.slug),h(!0)}async function f(){const m=v.trim();if(!m||m===e.tag.slug){h(!1);return}try{const S=await hp(t,e.tag.tag_uid,m);i(e.tag.full_path,S.full_path),a()}catch{}finally{h(!1)}}async function d(m){var _;m.stopPropagation();const S=((_=e.children)==null?void 0:_.length)>0?`Delete tag "${e.tag.full_path}" and all its child tags? This cannot be undone.`:`Delete tag "${e.tag.full_path}"? This cannot be undone.`;if(window.confirm(S))try{await mp(t,e.tag.tag_uid),s(e.tag.full_path),a()}catch{}}const p={archiveId:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u};return o.jsxs("li",{children:[o.jsxs("div",{className:"tag-node-row",children:[y?o.jsx("input",{className:"tag-rename-input",autoFocus:!0,value:v,onChange:m=>j(m.target.value),onKeyDown:m=>{m.key==="Enter"&&m.currentTarget.blur(),m.key==="Escape"&&(x.current=!0,m.currentTarget.blur())},onBlur:()=>{x.current?(x.current=!1,h(!1)):f()}}):o.jsxs("button",{className:`tag-node-btn${c?" is-active":""}`,title:e.tag.full_path,onClick:k,onDoubleClick:R,children:[u?e.tag.name:e.tag.slug,o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",onClick:m=>{m.stopPropagation(),R(m)},children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),o.jsx("button",{className:"remove tag-node-delete",title:`Delete tag ${e.tag.full_path}`,onClick:d,"aria-label":`Delete tag ${e.tag.full_path}`,children:"×"})]}),((w=e.children)==null?void 0:w.length)>0&&o.jsx("div",{className:"tag-children",children:o.jsx("ul",{className:"tag-tree-list",children:e.children.map(m=>o.jsx(Rc,{node:m,...p},m.tag.tag_uid))})})]})}function ih({archiveId:e,tagNodes:t,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u}){return o.jsx("section",{id:"tags-view",className:"view is-active",children:o.jsxs("div",{className:"tag-tree",children:[o.jsxs("div",{className:"tag-tree-header",children:[o.jsx("span",{className:"tag-tree-title",children:"Tags"}),n&&o.jsxs("span",{className:"tag-tree-active",children:["Filtering: ",n]})]}),t.length===0?o.jsx("p",{className:"muted",style:{padding:"8px 0"},children:"No tags yet."}):o.jsx("ul",{className:"tag-tree-list",children:t.map(c=>o.jsx(Rc,{node:c,archiveId:e,tagFilter:n,onTagFilterSet:r,onViewChange:l,onTagRenamed:i,onTagDeleted:s,onTagsRefresh:a,humanizeTags:u},c.tag.tag_uid))})]})})}const An=[{value:0,label:"Private"},{value:2,label:"Users only"},{value:3,label:"Public"}],sh=e=>{var t;return((t=An.find(n=>n.value===e))==null?void 0:t.label)??String(e)};function oh({archiveId:e}){const[t,n]=g.useState([]),[r,l]=g.useState(!1),[i,s]=g.useState(null),[a,u]=g.useState(null),[c,y]=g.useState(null),[h,v]=g.useState(!1),[j,x]=g.useState(null),[k,R]=g.useState(""),[f,d]=g.useState(""),[p,w]=g.useState(2),[m,S]=g.useState(!1),[_,E]=g.useState(null),[F,O]=g.useState(""),[A,K]=g.useState(2),[L,H]=g.useState(!1),[ke,$e]=g.useState(null),[Me,T]=g.useState(!1),[N,$]=g.useState(""),V=g.useRef(null),M=t.find(P=>P.collection_uid===a)??null,ve=(M==null?void 0:M.slug)==="_default_",oe=g.useCallback(async()=>{if(e){l(!0),s(null);try{const P=await Mp(e);n(P)}catch(P){s(P.message)}finally{l(!1)}}},[e]),Qe=g.useCallback(async P=>{if(!P){y(null);return}v(!0),x(null);try{const U=await Ip(e,P);y(U)}catch(U){x(U.message)}finally{v(!1)}},[e]);g.useEffect(()=>{oe()},[oe]),g.useEffect(()=>{Qe(a)},[a,Qe]),g.useEffect(()=>{Me&&V.current&&V.current.focus()},[Me]);async function Fe(P){P.preventDefault();const U=k.trim(),Te=f.trim();if(!(!U||!Te)){S(!0),E(null);try{const D=await Fp(e,U,Te,p);R(""),d(""),w(2),await oe(),u(D.collection_uid)}catch(D){E(D.message)}finally{S(!1)}}}async function lt(){const P=N.trim();if(!P||!M){T(!1);return}try{await fa(e,M.collection_uid,{name:P}),await oe(),y(U=>U&&{...U,name:P})}catch(U){s(U.message)}finally{T(!1)}}async function Dl(P){if(M)try{await fa(e,M.collection_uid,{default_visibility_bits:P}),await oe(),y(U=>U&&{...U,default_visibility_bits:P})}catch(U){s(U.message)}}async function Ol(){if(M&&window.confirm(`Delete collection "${M.name}"? Entries will not be deleted.`))try{await Hp(e,M.collection_uid),u(null),y(null),await oe()}catch(P){s(P.message)}}async function $l(P){P.preventDefault();const U=F.trim();if(!(!U||!M)){H(!0),$e(null);try{await Ap(e,M.collection_uid,U,A),O(""),await Qe(M.collection_uid)}catch(Te){$e(Te.message)}finally{H(!1)}}}async function Ml(P){if(M)try{await Up(e,M.collection_uid,P),await Qe(M.collection_uid)}catch(U){x(U.message)}}async function Fl(P,U){if(M)try{await Bp(e,M.collection_uid,P,U),y(Te=>Te&&{...Te,entries:Te.entries.map(D=>D.entry_uid===P?{...D,collection_visibility_bits:U}:D)})}catch(Te){x(Te.message)}}return e?o.jsxs("div",{className:"collections-view",children:[o.jsx("h2",{className:"collections-heading",children:"Collections"}),r&&o.jsx("div",{className:"muted",children:"Loading…"}),i&&o.jsxs("div",{className:"collections-error",children:[i," ",o.jsx("button",{onClick:()=>s(null),className:"coll-dismiss",children:"×"})]}),o.jsxs("div",{className:"collections-layout",children:[o.jsxs("div",{className:"collections-sidebar",children:[t.map(P=>o.jsxs("button",{className:`coll-sidebar-row${a===P.collection_uid?" is-active":""}`,onClick:()=>u(P.collection_uid),children:[o.jsx("span",{className:"coll-row-name",children:P.name}),o.jsx("span",{className:"coll-row-meta",children:sh(P.default_visibility_bits)})]},P.collection_uid)),t.length===0&&!r&&o.jsx("div",{className:"muted",style:{padding:"8px 12px"},children:"No collections yet."})]}),M?o.jsxs("div",{className:"coll-detail",children:[o.jsxs("div",{className:"coll-detail-header",children:[Me?o.jsx("input",{ref:V,className:"coll-rename-input",value:N,onChange:P=>$(P.target.value),onBlur:lt,onKeyDown:P=>{P.key==="Enter"&<(),P.key==="Escape"&&T(!1)}}):o.jsxs("h3",{className:`coll-detail-name${ve?"":" coll-detail-name--editable"}`,title:ve?void 0:"Click to rename",onClick:()=>{ve||($(M.name),T(!0))},children:[(c==null?void 0:c.name)??M.name,!ve&&o.jsx("span",{className:"coll-edit-hint",children:" ✎"})]}),!ve&&o.jsx("button",{className:"coll-delete-btn",onClick:Ol,title:"Delete collection",children:"Delete"})]}),o.jsxs("div",{className:"coll-detail-vis",children:[o.jsx("span",{className:"coll-vis-label",children:"Default visibility"}),o.jsx("select",{className:"coll-vis-select",value:(c==null?void 0:c.default_visibility_bits)??M.default_visibility_bits,onChange:P=>Dl(Number(P.target.value)),disabled:ve,children:An.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))})]}),o.jsxs("div",{className:"coll-entries-section",children:[o.jsx("div",{className:"coll-section-heading",children:"Entries"}),h&&o.jsx("div",{className:"muted",children:"Loading…"}),j&&o.jsx("div",{className:"collections-error",children:j}),!h&&c&&(c.entries.length===0?o.jsx("div",{className:"muted",children:"No entries in this collection."}):o.jsx("ul",{className:"coll-entries-list",children:c.entries.map(P=>o.jsxs("li",{className:"coll-entry-row",children:[o.jsxs("div",{className:"coll-entry-info",children:[o.jsx("span",{className:"coll-entry-title",children:P.title||P.entry_uid}),o.jsx("span",{className:"coll-entry-kind muted",children:P.source_kind})]}),o.jsxs("div",{className:"coll-entry-actions",children:[o.jsx("select",{className:"coll-entry-vis-select",value:P.collection_visibility_bits,onChange:U=>Fl(P.entry_uid,Number(U.target.value)),children:An.map(U=>o.jsx("option",{value:U.value,children:U.label},U.value))}),!ve&&o.jsx("button",{className:"coll-entry-remove",onClick:()=>Ml(P.entry_uid),title:"Remove from collection",children:"×"})]})]},P.entry_uid))}))]}),!ve&&o.jsxs("form",{className:"coll-add-entry-form",onSubmit:$l,children:[o.jsx("div",{className:"coll-section-heading",children:"Add entry"}),o.jsxs("div",{className:"coll-add-entry-row",children:[o.jsx("input",{className:"coll-add-entry-input",type:"text",value:F,onChange:P=>O(P.target.value),placeholder:"entry_uid",required:!0}),o.jsx("select",{className:"coll-vis-select",value:A,onChange:P=>K(Number(P.target.value)),children:An.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))}),o.jsx("button",{className:"coll-add-btn",type:"submit",disabled:L,children:L?"…":"Add"})]}),ke&&o.jsx("div",{className:"collections-error",style:{marginTop:4},children:ke})]})]}):o.jsx("div",{className:"coll-detail coll-detail--empty",children:o.jsx("div",{className:"muted",children:"Select a collection to view details."})})]}),o.jsxs("details",{className:"coll-create-details",children:[o.jsx("summary",{children:"+ Create collection"}),o.jsxs("form",{className:"coll-create-form",onSubmit:Fe,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-name",children:"Name"}),o.jsx("input",{className:"capture-input",id:"coll-name",type:"text",value:k,onChange:P=>{R(P.target.value),f||d(P.target.value.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},placeholder:"My Collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-slug",children:"Slug"}),o.jsx("input",{className:"capture-input",id:"coll-slug",type:"text",value:f,onChange:P=>d(P.target.value),placeholder:"my-collection",required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"coll-vis",children:"Default visibility"}),o.jsx("select",{className:"capture-input",id:"coll-vis",style:{height:42},value:p,onChange:P=>w(Number(P.target.value)),children:An.map(P=>o.jsx("option",{value:P.value,children:P.label},P.value))})]}),_&&o.jsx("div",{className:"collections-error",children:_}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:m,children:m?"Creating…":"Create collection"})]})]})]}):o.jsx("div",{className:"view-placeholder",children:"Select an archive."})}const ah=4;function uh({tab:e,onTabChange:t}){const{currentUser:n,setCurrentUser:r}=g.useContext(Rl)??{},l=n&&(n.role_bits&ah)!==0,i=["profile","tokens",...l?["instance"]:[]],s={profile:"Profile",tokens:"API Tokens",instance:"Instance"};return o.jsxs("section",{className:"admin-view",children:[o.jsx("h1",{children:"Settings"}),o.jsx("div",{className:"view-tabs",children:i.map(a=>o.jsx("button",{className:`view-tab${e===a?" is-active":""}`,onClick:()=>t(a),children:s[a]},a))}),e==="profile"&&o.jsx(ch,{currentUser:n,setCurrentUser:r}),e==="tokens"&&o.jsx(dh,{}),e==="instance"&&l&&o.jsx(fh,{})]})}function ch({currentUser:e,setCurrentUser:t}){const[n,r]=g.useState((e==null?void 0:e.display_name)??""),[l,i]=g.useState(!1),[s,a]=g.useState(null),[u,c]=g.useState(""),[y,h]=g.useState(""),[v,j]=g.useState(""),[x,k]=g.useState(!1),[R,f]=g.useState(null);async function d(w){w.preventDefault(),i(!0),a(null);try{await jp(n),t(m=>({...m,display_name:n||null})),a({ok:!0,text:"Saved."})}catch(m){a({ok:!1,text:m.message})}finally{i(!1)}}async function p(w){if(w.preventDefault(),y!==v){f({ok:!1,text:"Passwords do not match."});return}k(!0),f(null);try{await Cp(u,y),c(""),h(""),j(""),f({ok:!0,text:"Password changed."})}catch(m){f({ok:!1,text:m.message})}finally{k(!1)}}return o.jsxs("div",{style:{maxWidth:440},children:[o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Name"}),o.jsxs("form",{onSubmit:d,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"display-name",children:"Name shown in the UI"}),o.jsx("input",{className:"field-input",id:"display-name",placeholder:(e==null?void 0:e.username)??"",value:n,onChange:w=>r(w.target.value)})]}),s&&o.jsx("div",{className:`form-msg form-msg--${s.ok?"ok":"err"}`,children:s.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:l,children:l?"Saving…":"Save"})]})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Display Preferences"}),o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:(e==null?void 0:e.humanize_slugs)??!1,onChange:async w=>{const m=w.target.checked;try{await Np({humanize_slugs:m}),t(S=>({...S,humanize_slugs:m}))}catch{}}}),o.jsx("span",{className:"form-label",style:{margin:0},children:"Humanize tag display"})]}),o.jsx("p",{className:"muted",style:{fontSize:13,margin:"4px 0 0"},children:'When on, tag paths show as "X / Articles" instead of "x/articles".'})]}),o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Change Password"}),o.jsxs("form",{onSubmit:p,children:[o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"cur-pw",children:"Current password"}),o.jsx("input",{className:"field-input",id:"cur-pw",type:"password",value:u,onChange:w=>c(w.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"new-pw",children:"New password"}),o.jsx("input",{className:"field-input",id:"new-pw",type:"password",value:y,onChange:w=>h(w.target.value),required:!0})]}),o.jsxs("div",{className:"form-field",children:[o.jsx("label",{className:"form-label",htmlFor:"confirm-pw",children:"Confirm new password"}),o.jsx("input",{className:"field-input",id:"confirm-pw",type:"password",value:v,onChange:w=>j(w.target.value),required:!0})]}),R&&o.jsx("div",{className:`form-msg form-msg--${R.ok?"ok":"err"}`,children:R.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:x,children:x?"Changing…":"Change Password"})]})]})]})}function dh(){const[e,t]=g.useState([]),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,a]=g.useState(""),[u,c]=g.useState(!1),[y,h]=g.useState(null),v=g.useCallback(async()=>{r(!0),i(null);try{t(await _p())}catch(k){i(k.message)}finally{r(!1)}},[]);g.useEffect(()=>{v()},[v]);async function j(k){if(k.preventDefault(),!!s.trim()){c(!0);try{const R=await Ep(s.trim());h(R),a(""),v()}catch(R){i(R.message)}finally{c(!1)}}}async function x(k){try{await Tp(k),t(R=>R.filter(f=>f.token_uid!==k))}catch(R){i(R.message)}}return o.jsx("div",{style:{maxWidth:600},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"API Tokens"}),y&&o.jsxs("div",{className:"token-banner",children:[o.jsx("strong",{children:"Token created."})," Copy it now — it won't be shown again.",o.jsx("code",{children:y.raw_token}),o.jsx("button",{className:"token-dismiss",onClick:()=>h(null),children:"Dismiss"})]}),o.jsxs("form",{className:"token-create-row",onSubmit:j,children:[o.jsx("input",{className:"field-input field-input--flex",placeholder:"Token name",value:s,onChange:k=>a(k.target.value),required:!0}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:u,children:u?"Creating…":"Create token"})]}),l&&o.jsx("div",{className:"form-msg form-msg--err",children:l}),n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):o.jsxs("div",{children:[e.length===0&&o.jsx("div",{className:"muted",children:"No tokens yet."}),e.map(k=>o.jsxs("div",{className:"token-row",children:[o.jsxs("div",{className:"token-row-info",children:[o.jsx("strong",{children:k.name}),o.jsxs("div",{className:"muted",children:["Created ",k.created_at.slice(0,10),k.last_used_at&&` · Last used ${k.last_used_at.slice(0,10)}`]})]}),o.jsx("button",{className:"btn-danger",style:{fontSize:12,padding:"4px 10px"},onClick:()=>x(k.token_uid),children:"Revoke"})]},k.token_uid))]})]})})}function fh(){const[e,t]=g.useState(null),[n,r]=g.useState(!0),[l,i]=g.useState(null),[s,a]=g.useState(!1),[u,c]=g.useState(null);g.useEffect(()=>{(async()=>{try{t(await Pp())}catch(h){i(h.message)}finally{r(!1)}})()},[]);async function y(h){h.preventDefault(),a(!0),c(null);try{await Lp(e),c({ok:!0,text:"Saved."})}catch(v){c({ok:!1,text:v.message})}finally{a(!1)}}return n?o.jsx("div",{className:"muted",children:"Loading\\u2026"}):l?o.jsx("div",{className:"form-msg form-msg--err",children:l}):e?o.jsx("div",{style:{maxWidth:440},children:o.jsxs("div",{className:"form-section",children:[o.jsx("h2",{children:"Instance Settings"}),o.jsxs("form",{onSubmit:y,children:[[["public_index_enabled","Public index (unauthenticated browsing)"],["public_entry_content_enabled","Public entry content"],["open_registration_enabled","Open registration"]].map(([h,v])=>o.jsxs("label",{className:"checkbox-row",children:[o.jsx("input",{type:"checkbox",checked:!!e[h],onChange:j=>t(x=>({...x,[h]:j.target.checked}))}),v]},h)),o.jsxs("div",{className:"form-field",style:{marginTop:4},children:[o.jsx("label",{className:"form-label",children:"Default entry visibility"}),o.jsxs("select",{className:"field-input",value:e.default_entry_visibility,onChange:h=>t(v=>({...v,default_entry_visibility:Number(h.target.value)})),children:[o.jsx("option",{value:0,children:"Private"}),o.jsx("option",{value:2,children:"Unlisted"}),o.jsx("option",{value:3,children:"Public"})]})]}),u&&o.jsx("div",{className:`form-msg form-msg--${u.ok?"ok":"err"}`,children:u.text}),o.jsx("button",{className:"btn-primary",type:"submit",disabled:s,children:s?"Saving…":"Save Settings"})]})]})}):null}const ma={0:"Private",1:"Public",2:"Users only",3:"Public"},ph=()=>o.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:o.jsx("path",{d:"M7 17 17 7M9 7h8v8"})});function hh({archiveId:e,selectedEntry:t,onTagFilterSet:n,tagNodes:r,onTagsRefresh:l,onEntryTitleChange:i,onEntryDeleted:s,humanizeTags:a}){const[u,c]=g.useState(null),[y,h]=g.useState([]),[v,j]=g.useState(""),[x,k]=g.useState([]),[R,f]=g.useState(""),d=g.useRef(0),p=g.useRef(!1),[w,m]=g.useState(!1),[S,_]=g.useState("");g.useEffect(()=>{if(!t||!e){c(null),h([]),k([]);return}m(!1),_(""),p.current=!1;const L=++d.current;c(null),h([]),Promise.all([up(e,t.entry_uid),ci(e,t.entry_uid),Vp(e,t.entry_uid)]).then(([H,ke,$e])=>{L===d.current&&(c(H),h(ke),k($e))}).catch(()=>{})},[t,e]);async function E(){const L=S.trim()||null;try{await cp(e,t.entry_uid,L),c(H=>H&&{...H,summary:{...H.summary,title:L}}),i==null||i(t.entry_uid,L)}catch{}finally{m(!1)}}async function F(){const L=v.trim();if(!(!L||!t))try{await dp(e,t.entry_uid,L),j(""),f("");const H=await ci(e,t.entry_uid);h(H),l()}catch(H){f(H.message)}}async function O(L){try{await fp(e,t.entry_uid,L);const H=await ci(e,t.entry_uid);h(H),l()}catch{}}async function A(){if(!(!t||!e)&&window.confirm("Delete this entry? This cannot be undone."))try{await pp(e,t.entry_uid),s==null||s(t.entry_uid)}catch{}}const K=u?[["Added",Pc(u.summary.archived_at)],["Source",u.summary.source_kind],["Type",u.summary.entity_kind],["Visibility",ma[u.summary.visibility]??u.summary.visibility],["Root",u.structured_root_relpath]]:[];return o.jsxs("aside",{className:"context-rail",children:[o.jsx("div",{className:"rail-eyebrow",children:"Context"}),t?u?o.jsxs(o.Fragment,{children:[w?o.jsx("input",{className:"rail-title-input",autoFocus:!0,value:S,onChange:L=>_(L.target.value),onKeyDown:L=>{L.key==="Enter"&&L.currentTarget.blur(),L.key==="Escape"&&(p.current=!0,L.currentTarget.blur())},onBlur:()=>{p.current?m(!1):E(),p.current=!1}}):o.jsxs("h2",{className:"rail-title rail-title--editable",title:"Click to rename",onClick:()=>{_(u.summary.title??""),m(!0)},children:[Ut(u.summary.title)||Ut(u.summary.entry_uid),o.jsx("svg",{className:"edit-icon",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:o.jsx("path",{d:"M11.5 2.5a1.5 1.5 0 0 1 2 2L5 13l-3 1 1-3 8.5-8.5z"})})]}),u.summary.original_url&&o.jsxs("a",{className:"url-tile",href:u.summary.original_url,target:"_blank",rel:"noopener noreferrer",children:[o.jsx("span",{className:"ico",dangerouslySetInnerHTML:{__html:Lc(u.summary.source_kind)}}),o.jsx("span",{className:"u-text",children:u.summary.original_url}),o.jsx("span",{className:"ext",children:o.jsx(ph,{})})]}),o.jsx("div",{className:"meta-list",children:K.filter(([,L])=>L!=null&&L!=="").map(([L,H])=>o.jsxs("div",{className:"meta-item",children:[o.jsx("span",{className:"meta-k",children:L}),o.jsx("span",{className:`meta-v${L==="Root"?" mono":""}`,children:Ut(H)})]},L))}),u.artifacts.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsxs("div",{className:"rail-section-heading",children:["Artifacts ",o.jsx("span",{className:"num",children:u.artifacts.length})]}),o.jsx("ul",{className:"artifact-list",children:u.artifacts.map((L,H)=>o.jsx("li",{children:o.jsxs("a",{href:`/api/archives/${e}/entries/${u.summary.entry_uid}/artifacts/${H}`,target:"_blank",rel:"noopener noreferrer",className:"artifact-link",children:[o.jsx("span",{className:"artifact-name",children:L.artifact_role.replace(/_/g," ")}),o.jsx("span",{className:"artifact-size",children:L.byte_size!=null?ss(L.byte_size):"—"})]})},H))})]})]}):o.jsx("p",{className:"tags-empty",children:"Loading…"}):o.jsx("p",{className:"tags-empty",children:"Select an entry."}),t&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Tags"}),y.length===0?o.jsx("p",{className:"tags-empty",children:"No tags yet."}):o.jsx("div",{className:"tags-wrap",children:y.map(L=>o.jsxs("span",{className:"tag-pill",title:L.full_path,children:[a?zc(L.full_path):L.full_path,o.jsx("button",{className:"remove",title:`Remove tag ${L.full_path}`,onClick:()=>O(L.tag_uid),children:"×"})]},L.tag_uid))}),R&&o.jsx("p",{className:"form-msg form-msg--err",style:{margin:"0 0 8px"},children:R}),o.jsxs("div",{className:"tag-input-wrap",children:[o.jsx("span",{className:"hash",children:"/"}),o.jsx("input",{className:"tag-input",type:"text",placeholder:"science/cs",autoComplete:"off",value:v,onChange:L=>j(L.target.value),onKeyDown:L=>{L.key==="Enter"&&F()}}),o.jsx("button",{className:"tag-add-btn",onClick:F,children:"Add"})]})]}),x.length>0&&o.jsxs("div",{className:"rail-section",children:[o.jsx("div",{className:"rail-section-heading",children:"Collections"}),x.map(L=>o.jsxs("div",{className:"coll-row",children:[o.jsx("span",{className:"coll-name",children:L.collection_uid}),o.jsx("span",{className:"vis-badge",children:ma[L.visibility_bits]??`bits:${L.visibility_bits}`})]},L.collection_uid))]}),o.jsx("div",{className:"rail-delete-zone",children:o.jsx("button",{className:"rail-delete-btn",onClick:A,children:"Delete entry"})})]})]})}const mh=7e3;function vh({toasts:e,onDismiss:t}){return e.length?o.jsx("div",{className:"toast-stack",role:"log","aria-live":"polite","aria-label":"Notifications",children:e.map(n=>o.jsx(gh,{toast:n,onDismiss:t},n.id))}):null}function gh({toast:e,onDismiss:t}){const[n,r]=g.useState(!1);g.useEffect(()=>{if(n)return;const i=setTimeout(()=>t(e.id),mh);return()=>clearTimeout(i)},[n,e.id,t]);const l=e.locator?e.locator.length>48?e.locator.slice(0,45)+"…":e.locator:null;return o.jsxs("div",{className:"toast toast--error",role:"alert","aria-atomic":"true",children:[o.jsxs("div",{className:"toast-top",children:[o.jsx("span",{className:"toast-icon","aria-hidden":"true",children:"✕"}),o.jsxs("div",{className:"toast-body",children:[o.jsx("span",{className:"toast-headline",children:"Capture failed"}),l&&o.jsx("span",{className:"toast-locator",children:l})]}),o.jsxs("div",{className:"toast-btns",children:[e.errorText&&o.jsx("button",{type:"button",className:"toast-view-btn",onClick:()=>r(i=>!i),children:n?"Hide":"View error"}),o.jsx("button",{type:"button",className:"toast-dismiss",onClick:()=>t(e.id),"aria-label":"Dismiss",children:"×"})]})]}),n&&e.errorText&&o.jsx("pre",{className:"toast-error-detail",children:e.errorText})]})}const Rl=g.createContext(null),yh=["archive","tags","collections","runs","admin","settings"],wh=["profile","tokens","instance"];function fi(){const e=window.location.pathname.split("/").filter(Boolean),t=yh.includes(e[0])?e[0]:"archive",n=t==="settings"&&wh.includes(e[1])?e[1]:"profile";return{view:t,settingsTab:n}}function xh(e,t){return e==="archive"?"/":e==="settings"?`/settings/${t}`:`/${e}`}function Sh(){const[e,t]=g.useState("loading"),[n,r]=g.useState(null);g.useEffect(()=>{(async()=>{if(await yp()){t("setup");return}const W=await kp();if(!W){t("login");return}r(W),t("authenticated")})()},[]),g.useEffect(()=>{const D=()=>{r(null),t("login")};return window.addEventListener("auth:expired",D),()=>window.removeEventListener("auth:expired",D)},[]),g.useEffect(()=>{const D=()=>{const{view:W,settingsTab:ae}=fi();f(W),p(ae)};return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]);const[l,i]=g.useState([]),[s,a]=g.useState(null),[u,c]=g.useState([]),[y,h]=g.useState(null),[v,j]=g.useState(null),[x,k]=g.useState(null),[R,f]=g.useState(()=>fi().view),[d,p]=g.useState(()=>fi().settingsTab),[w,m]=g.useState(""),[S,_]=g.useState(""),[E,F]=g.useState(!1),[O,A]=g.useState([]),[K,L]=g.useState([]),[H,ke]=g.useState(()=>sessionStorage.getItem("captureDialogOpen")==="true"),[$e,Me]=g.useState([]),T=g.useRef(0),N=(n==null?void 0:n.humanize_slugs)??!1;g.useEffect(()=>{sessionStorage.setItem("captureDialogOpen",H)},[H]);const $=g.useCallback(async(D,W,ae)=>{if(D){F(!0);try{let Ie;W||ae?Ie=await ap(D,W,ae):Ie=await op(D),c(Ie),_(Ie.length===0?"No results":`${Ie.length} result${Ie.length===1?"":"s"}`)}catch{c([]),_("Search failed. Try again.")}finally{F(!1)}}},[]);g.useEffect(()=>{e==="authenticated"&&sp().then(D=>{if(i(D),D.length>0){const W=D[0].id;a(W)}})},[e]),g.useEffect(()=>{s&&(k(null),j(null),h(null),Promise.all([$(s,"",null),da(s).then(A),di(s).then(L)]))},[s]),g.useEffect(()=>{if(s===null)return;const D=setTimeout(()=>{$(s,w,x)},300);return()=>clearTimeout(D)},[w,s]),g.useEffect(()=>{s!==null&&(x!==null&&f("archive"),$(s,w,x))},[x,s]);const V=g.useCallback(D=>{a(D)},[]),M=g.useCallback(D=>{f(D),D==="tags"&&s&&di(s).then(L)},[s]);g.useEffect(()=>{const D=xh(R,d);window.location.pathname!==D&&history.pushState(null,"",D)},[R,d]);const ve=g.useCallback(D=>{h(D?D.entry_uid:null),j(D)},[]),oe=g.useCallback(D=>{k(D)},[]),Qe=g.useCallback(()=>{k(null)},[]),Fe=g.useCallback(()=>{s&&di(s).then(L)},[s]),lt=g.useCallback((D,W)=>{x===D?k(W):x!=null&&x.startsWith(D+"/")&&k(W+x.slice(D.length))},[x]),Dl=g.useCallback(D=>{(x===D||x!=null&&x.startsWith(D+"/"))&&k(null)},[x]),Ol=g.useCallback((D,W)=>{c(ae=>ae.map(Ie=>Ie.entry_uid===D?{...Ie,title:W}:Ie)),j(ae=>ae&&ae.entry_uid===D?{...ae,title:W}:ae)},[]),$l=g.useCallback(D=>{c(W=>W.filter(ae=>ae.entry_uid!==D)),j(W=>(W==null?void 0:W.entry_uid)===D?null:W),h(W=>W===D?null:W)},[]),Ml=g.useCallback(()=>{ke(!0)},[]),Fl=g.useCallback(()=>{ke(!1)},[]),P=g.useCallback(()=>{s&&Promise.all([$(s,w,x),da(s).then(A)])},[s,w,x,$]),U=g.useCallback((D,W)=>{const ae=++T.current;Me(Ie=>[...Ie,{id:ae,errorText:D,locator:W}])},[]),Te=g.useCallback(D=>{Me(W=>W.filter(ae=>ae.id!==D))},[]);return e==="loading"?o.jsx("div",{className:"auth-loading",children:"Loading\\u2026"}):e==="setup"?o.jsx(Kp,{onComplete:()=>t("login")}):e==="login"?o.jsx(Qp,{onLogin:D=>{r(D),t("authenticated")}}):o.jsx(Rl.Provider,{value:{currentUser:n,setCurrentUser:r},children:o.jsxs(o.Fragment,{children:[o.jsx(Yp,{archives:l,archiveId:s,onArchiveChange:V,view:R,onViewChange:M,onCaptureClick:Ml}),o.jsxs("main",{className:"app-shell",children:[o.jsxs("div",{className:"workspace",children:[R==="archive"&&o.jsxs("div",{className:"toolbar",children:[o.jsxs("div",{className:"search-field",children:[o.jsx("span",{className:"ico","aria-hidden":"true",children:o.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"11",cy:"11",r:"7"}),o.jsx("line",{x1:"16.5",y1:"16.5",x2:"21",y2:"21"})]})}),o.jsx("input",{className:"search-input",type:"search","aria-label":"Search archive","aria-busy":E,placeholder:"Search titles, URLs, types, tags…",value:w,onChange:D=>m(D.target.value)}),o.jsx("span",{className:"kbd",children:"⌘K"})]}),o.jsxs("span",{className:"result-count",children:[S&&o.jsxs(o.Fragment,{children:[o.jsx("b",{children:S.split(" ")[0]})," ",S.split(" ").slice(1).join(" ")]}),x&&o.jsxs("button",{className:"tag-filter-badge",onClick:Qe,children:["× ",N?zc(x):x]})]})]}),R==="archive"&&o.jsx(bp,{entries:u,selectedEntryUid:y,onSelectEntry:ve,archiveId:s,tagFilter:x,onClearTagFilter:Qe,searchQuery:w,onSearchChange:m,resultCount:S,searchBusy:E}),R==="runs"&&o.jsx(nh,{runs:O}),R==="admin"&&o.jsx(lh,{archives:l}),R==="tags"&&o.jsx(ih,{archiveId:s,tagNodes:K,tagFilter:x,onTagFilterSet:oe,onViewChange:M,onTagRenamed:lt,onTagDeleted:Dl,onTagsRefresh:Fe,humanizeTags:N}),R==="collections"&&o.jsx(oh,{archiveId:s}),R==="settings"&&o.jsx(uh,{tab:d,onTabChange:p})]}),o.jsx(hh,{archiveId:s,selectedEntry:v,onTagFilterSet:oe,tagNodes:K,onTagsRefresh:Fe,onEntryTitleChange:Ol,onEntryDeleted:$l,humanizeTags:N})]}),o.jsx(Jp,{open:H,archiveId:s,onClose:Fl,onCaptured:P,onToast:U}),o.jsx(vh,{toasts:$e,onDismiss:Te})]})})}Tc(document.getElementById("root")).render(o.jsx(g.StrictMode,{children:o.jsx(Sh,{})})); diff --git a/crates/archivr-server/static/index.html b/crates/archivr-server/static/index.html index 20fd1e9..cb78f40 100644 --- a/crates/archivr-server/static/index.html +++ b/crates/archivr-server/static/index.html @@ -4,8 +4,8 @@ Archivr - - + +
diff --git a/docs/README.md b/docs/README.md index 0f69323..b421947 100644 --- a/docs/README.md +++ b/docs/README.md @@ -146,6 +146,35 @@ Auth and session handling will be designed when remote or public hosting becomes - X/Twitter Tweet content scrape: [Tweet and Thread shorthands](#supported-shorthand-inputs). (These are saved as JSON files in `raw_tweets/`) - Instagram, Facebook, TikTok, Reddit, Snapchat: direct URLs or platform-prefixed shorthand passed through to `yt-dlp` +#### Video quality and audio-only downloads + +When capturing via the web UI, entering a URL for a yt-dlp-backed source (YouTube, Instagram, TikTok, Facebook, Reddit, Snapchat, X media) triggers a metadata probe via `GET /api/archives/:id/captures/probe`. The quality selector then shows only the heights actually available in that video plus **Best quality** (default). An **Audio only** option is appended whenever the probe confirms an audio track exists. UI behaviour by probe outcome: + +| `qualities` | `has_audio` | UI shows | +|---|---|---| +| `["1080p", "720p", …]` | `true` | Best / heights / Audio only | +| `["1080p", …]` | `false` | Best / heights | +| `[]` | `true` | Audio only (pre-selected, no Best option) | +| `[]` | `false` | "No media detected" | +| probe fails (502) | — | picker hidden, capture still submittable | + +The `POST /api/archives/:id/captures` endpoint accepts an optional `quality` field: `"best"`, `"audio"`, or any `"NNNp"` height string: + +```json +{ "locator": "https://www.youtube.com/watch?v=...", "quality": "720p" } +{ "locator": "https://www.youtube.com/watch?v=...", "quality": "audio" } +``` + +`"audio"` selects the most efficient native audio track without transcoding: Opus/WebM is preferred (smallest at equivalent quality), then AAC/M4A, then whatever yt-dlp considers best. The saved file's extension matches the native format (`.webm` for Opus, `.m4a` for AAC, etc.) — no ffmpeg re-encode, no size inflation. Any `"NNNp"` height is accepted; the server builds the yt-dlp format selector with an unconditional `/best` fallback so the download succeeds even if the exact height is unavailable. Omitting `quality` or passing `"best"` downloads at the highest available quality. Anything else is rejected with HTTP 400. + +The probe endpoint (`GET /api/archives/:id/captures/probe?locator=…`) requires auth and returns 200 with: +```json +{ "has_video": true, "has_audio": true, "qualities": ["1080p", "720p", "480p"] } +{ "has_video": false, "has_audio": true, "qualities": [] } +{ "has_video": false, "has_audio": false, "qualities": [] } +``` +`has_video: false, has_audio: false` means yt-dlp found no downloadable tracks (e.g. a tweet with no media). A 502 means yt-dlp itself failed (transient network error, rate-limit, unsupported extractor) — treat as inconclusive, not "no media." + ### Hosting on NixOS The flake exposes a `nixosModules.default` output. Add it to your system flake and diff --git a/frontend/src/api.js b/frontend/src/api.js index fba607f..a031601 100644 --- a/frontend/src/api.js +++ b/frontend/src/api.js @@ -95,11 +95,13 @@ export async function fetchTags(archiveId) { return getJson(`/api/archives/${archiveId}/tags`); } -export async function submitCapture(archiveId, locator) { +export async function submitCapture(archiveId, locator, quality = null) { + const payload = { locator } + if (quality && quality !== 'best') payload.quality = quality const res = await fetch(`/api/archives/${archiveId}/captures`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ locator }), + body: JSON.stringify(payload), }); if (!res.ok) { const body = await res.json().catch(() => ({})); @@ -108,6 +110,12 @@ export async function submitCapture(archiveId, locator) { return res.json(); // { job_uid, status: "pending" } } +// Returns { has_video: bool, qualities: string[] } e.g. { has_video: true, qualities: ["1080p","720p","480p"] } +// Throws on network error; returns { has_video: false, qualities: [] } on non-video locators. +export async function probeCapture(archiveId, locator) { + return getJson(`/api/archives/${archiveId}/captures/probe?locator=${encodeURIComponent(locator)}`); +} + export async function pollCaptureJob(archiveId, jobUid) { return getJson(`/api/archives/${archiveId}/capture_jobs/${jobUid}`); } diff --git a/frontend/src/components/CaptureDialog.jsx b/frontend/src/components/CaptureDialog.jsx index b8cd68b..5b2d9e0 100644 --- a/frontend/src/components/CaptureDialog.jsx +++ b/frontend/src/components/CaptureDialog.jsx @@ -1,10 +1,65 @@ import { useRef, useEffect, useState } from 'react' -import { submitCapture, pollCaptureJob } from '../api' +import { submitCapture, pollCaptureJob, probeCapture } from '../api' let nextItemId = 1 +// Returns true only for locators that determine_source() routes to yt-dlp download. +// Mirrors the exact conditions in capture.rs — playlist/channel shorthands are excluded +// (they return an "not yet implemented" error), as are tweet/thread shorthands. +function isVideoSource(locator) { + const l = locator.trim() + const ll = l.toLowerCase() + + // yt: / youtube: shorthands — video/short/shorts only; playlist and channel are unsupported + for (const scheme of ['yt:', 'youtube:']) { + if (ll.startsWith(scheme)) { + const after = ll.slice(scheme.length) + return after.startsWith('video/') || after.startsWith('short/') || after.startsWith('shorts/') + } + } + + // x: / twitter: / tweet: shorthands — only x:media:ID routes to yt-dlp (Source::X) + for (const scheme of ['x:', 'twitter:', 'tweet:']) { + if (ll.startsWith(scheme)) { + return ll.slice(scheme.length).startsWith('media:') + } + } + + // Other platform shorthands — all go to yt-dlp + if (ll.startsWith('instagram:') || ll.startsWith('facebook:') || + ll.startsWith('tiktok:') || ll.startsWith('reddit:') || + ll.startsWith('snapchat:')) return true + + // HTTP/HTTPS URLs — match the same regexes and prefix checks as determine_source + if (ll.startsWith('http://') || ll.startsWith('https://')) { + // YouTube video (watch, youtu.be, shorts) — not playlist or channel + if (/^https?:\/\/(?:www\.)?(?:youtu\.be\/[0-9A-Za-z_-]+|youtube\.com\/watch\?v=[0-9A-Za-z_-]+|youtube\.com\/shorts\/[0-9A-Za-z_-]+)/.test(l)) return true + // x.com → Source::X → yt-dlp (note: twitter.com URLs fall through to Source::Url, not yt-dlp) + if (ll.startsWith('https://x.com/') || ll.startsWith('http://x.com/')) return true + // Instagram + if (/^https?:\/\/(?:www\.)?instagram\.com\//.test(ll)) return true + // Facebook + fb.watch + if (/^https?:\/\/(?:www\.)?facebook\.com\//.test(ll) || ll.startsWith('https://fb.watch/') || ll.startsWith('http://fb.watch/')) return true + // TikTok + if (/^https?:\/\/(?:www\.)?tiktok\.com\//.test(ll)) return true + // Reddit + redd.it + if (/^https?:\/\/(?:www\.)?reddit\.com\//.test(ll) || ll.startsWith('https://redd.it/') || ll.startsWith('http://redd.it/')) return true + // Snapchat + if (/^https?:\/\/(?:www\.)?snapchat\.com\//.test(ll)) return true + } + + return false +} + function makeItem(locator = '') { - return { id: nextItemId++, locator, status: 'idle', error: null, jobUid: null, archiveId: null } + return { + id: nextItemId++, locator, quality: 'best', + // probe: tracks yt-dlp metadata fetch for the locator + probeState: 'idle', // 'idle' | 'probing' | 'done' + probeQualities: null, // null | string[] when done, e.g. ["1080p","720p","480p"] + probeHasAudio: false, // true when probe confirms at least one audio track + status: 'idle', error: null, jobUid: null, archiveId: null, + } } function hasActiveJobs(items) { @@ -16,6 +71,11 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on const isFirstRenderRef = useRef(true) // jobUid → intervalId; survives dialog close since component stays mounted const pollIntervals = useRef(new Map()) + // itemId → debounce timeoutId for probe calls + const probeTimers = useRef(new Map()) + // stable ref so probe callbacks always see the current archiveId + const archiveIdRef = useRef(archiveId) + useEffect(() => { archiveIdRef.current = archiveId }, [archiveId]) // Stable refs so polling callbacks always use the latest prop values const onCapturedRef = useRef(onCaptured) @@ -63,7 +123,11 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on useEffect(() => { const dialog = dialogRef.current if (!dialog) return - const handler = () => onClose() + const handler = () => { + probeTimers.current.forEach(id => clearTimeout(id)) + probeTimers.current.clear() + onClose() + } dialog.addEventListener('close', handler) return () => dialog.removeEventListener('close', handler) }, [onClose]) @@ -79,13 +143,18 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on isFirstRenderRef.current = false if (!dialog.open) dialog.showModal() } else { + probeTimers.current.forEach(id => clearTimeout(id)) + probeTimers.current.clear() if (dialog.open) dialog.close() } }, [open]) // eslint-disable-line react-hooks/exhaustive-deps - // Clear all intervals on unmount (component teardown) + // Clear all intervals and probe timers on unmount (component teardown) useEffect(() => { - return () => pollIntervals.current.forEach(id => clearInterval(id)) + return () => { + pollIntervals.current.forEach(id => clearInterval(id)) + probeTimers.current.forEach(id => clearTimeout(id)) + } }, []) function startPolling(itemId, jobUid, locator, aid) { @@ -132,9 +201,10 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on if (!item.locator.trim()) return const aid = archiveId // capture at submit time const loc = item.locator.trim() + const qual = item.quality || 'best' setItems(prev => prev.map(it => it.id === item.id ? { ...it, status: 'submitting', error: null } : it)) try { - const job = await submitCapture(aid, loc) + const job = await submitCapture(aid, loc, qual) setItems(prev => prev.map(it => it.id === item.id ? { ...it, status: 'running', jobUid: job.job_uid, archiveId: aid } : it )) @@ -156,6 +226,8 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on } function removeRow(id) { + clearTimeout(probeTimers.current.get(id)) + probeTimers.current.delete(id) setItems(prev => { const next = prev.filter(it => it.id !== id) return next.length === 0 ? [makeItem()] : next @@ -169,7 +241,44 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on } function updateLocator(id, val) { - setItems(prev => prev.map(it => it.id === id ? { ...it, locator: val } : it)) + // Cancel any in-flight debounce and immediately clear stale probe results. + // This prevents old qualities from being visible (and submittable) while + // the 600ms debounce is pending for the new URL. + clearTimeout(probeTimers.current.get(id)) + setItems(prev => prev.map(it => + it.id === id + ? { ...it, locator: val, probeState: 'idle', probeQualities: null, probeHasAudio: false, quality: 'best' } + : it + )) + + if (!isVideoSource(val)) return + + // Schedule a fresh probe after the user stops typing + const timer = setTimeout(async () => { + probeTimers.current.delete(id) + setItems(prev => prev.map(it => it.id === id ? { ...it, probeState: 'probing' } : it)) + try { + const result = await probeCapture(archiveIdRef.current, val.trim()) + setItems(prev => prev.map(it => { + if (it.id !== id || it.locator !== val) return it // stale — locator changed again + const qualities = result.qualities ?? [] + const hasAudio = result.has_audio ?? false + // Audio-only source: no video heights but audio confirmed — force audio mode + const quality = (qualities.length === 0 && hasAudio) ? 'audio' : 'best' + return { ...it, probeState: 'done', probeQualities: qualities, probeHasAudio: hasAudio, quality } + })) + } catch { + // Probe failed (network error, etc.) — clear silently; user can still submit + setItems(prev => prev.map(it => + it.id === id ? { ...it, probeState: 'idle', probeQualities: null } : it + )) + } + }, 600) + probeTimers.current.set(id, timer) + } + + function updateQuality(id, val) { + setItems(prev => prev.map(it => it.id === id ? { ...it, quality: val } : it)) } const pendingCount = items.filter(it => it.status === 'idle' && it.locator.trim()).length @@ -199,6 +308,7 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on item={item} autoFocus={idx === items.length - 1 && item.status === 'idle'} onLocatorChange={val => updateLocator(item.id, val)} + onQualityChange={val => updateQuality(item.id, val)} onRemove={() => removeRow(item.id)} onReset={() => resetRow(item.id)} onSubmit={handleArchive} @@ -231,7 +341,7 @@ export default function CaptureDialog({ open, archiveId, onClose, onCaptured, on ) } -function CaptureRow({ item, autoFocus, onLocatorChange, onRemove, onReset, onSubmit }) { +function CaptureRow({ item, autoFocus, onLocatorChange, onQualityChange, onRemove, onReset, onSubmit }) { const inputRef = useRef(null) const isActive = item.status === 'submitting' || item.status === 'running' @@ -241,6 +351,49 @@ function CaptureRow({ item, autoFocus, onLocatorChange, onRemove, onReset, onSub } }, [autoFocus]) // eslint-disable-line react-hooks/exhaustive-deps + // Quality control shown right of the input (hidden when active or completed) + const qualityEl = (() => { + if (item.status === 'completed' || isActive) return null + if (!isVideoSource(item.locator)) return null + if (item.probeState === 'probing') { + return + } + if (item.probeState === 'done') { + const qualities = item.probeQualities ?? [] + const hasAudio = item.probeHasAudio ?? false + if (qualities.length === 0 && !hasAudio) { + return No media detected + } + if (qualities.length === 0 && hasAudio) { + // Audio-only source: no video tracks, only audio available. + // Don't offer "Best quality" — it would request a video format and fail. + return ( + + ) + } + return ( + + ) + } + return null // probeState === 'idle', debounce not yet fired + })() + return (
@@ -257,6 +410,7 @@ function CaptureRow({ item, autoFocus, onLocatorChange, onRemove, onReset, onSub autoComplete="off" spellCheck={false} /> + {qualityEl} {item.status === 'failed' && (