diff --git a/Cargo.lock b/Cargo.lock index 1b88261c..eef876be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1253,7 +1253,7 @@ dependencies = [ [[package]] name = "librqbit" -version = "5.0.0-beta.0" +version = "5.0.0-beta.1" dependencies = [ "anyhow", "axum 0.7.1", @@ -1290,6 +1290,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-test", + "tokio-util", "tower-http", "tracing", "tracing-subscriber", @@ -1336,6 +1337,7 @@ dependencies = [ "serde", "serde_json", "tokio", + "tokio-util", "tracing", "url", "uuid", @@ -1343,7 +1345,7 @@ dependencies = [ [[package]] name = "librqbit-dht" -version = "4.1.0" +version = "5.0.0-beta.1" dependencies = [ "anyhow", "backoff", @@ -1362,6 +1364,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", + "tokio-util", "tracing", "tracing-subscriber", ] @@ -2002,7 +2005,7 @@ dependencies = [ [[package]] name = "rqbit" -version = "5.0.0-beta.0" +version = "5.0.0-beta.1" dependencies = [ "anyhow", "clap", diff --git a/crates/dht/Cargo.toml b/crates/dht/Cargo.toml index e3a55b39..b3eb4075 100644 --- a/crates/dht/Cargo.toml +++ b/crates/dht/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librqbit-dht" -version = "4.1.0" +version = "5.0.0-beta.1" edition = "2021" description = "DHT implementation, used in rqbit torrent client." license = "Apache-2.0" @@ -32,10 +32,10 @@ futures = "0.3" rand = "0.8" indexmap = "2" dashmap = {version = "5.5.3", features = ["serde"]} - clone_to_owned = {path="../clone_to_owned", package="librqbit-clone-to-owned", version = "2.2.1"} librqbit-core = {path="../librqbit_core", version = "3.3.0"} chrono = {version = "0.4.31", features = ["serde"]} +tokio-util = "0.7.10" [dev-dependencies] tracing-subscriber = "0.3" diff --git a/crates/dht/examples/dht.rs b/crates/dht/examples/dht.rs index 11c289c4..ec436ad3 100644 --- a/crates/dht/examples/dht.rs +++ b/crates/dht/examples/dht.rs @@ -17,6 +17,7 @@ async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt::init(); let dht = DhtBuilder::new().await.context("error initializing DHT")?; + let mut stream = dht.get_peers(info_hash, None)?; let stats_printer = async { diff --git a/crates/dht/src/dht.rs b/crates/dht/src/dht.rs index b55a54cd..e97762ec 100644 --- a/crates/dht/src/dht.rs +++ b/crates/dht/src/dht.rs @@ -26,7 +26,11 @@ use dashmap::DashMap; use futures::{stream::FuturesUnordered, Stream, StreamExt, TryFutureExt}; use leaky_bucket::RateLimiter; -use librqbit_core::{id20::Id20, peer_id::generate_peer_id, spawn_utils::spawn}; +use librqbit_core::{ + id20::Id20, + peer_id::generate_peer_id, + spawn_utils::{spawn, spawn_with_cancel}, +}; use parking_lot::RwLock; use serde::Serialize; @@ -35,6 +39,7 @@ use tokio::{ sync::mpsc::{channel, unbounded_channel, Sender, UnboundedReceiver, UnboundedSender}, }; +use tokio_util::sync::CancellationToken; use tracing::{debug, debug_span, error, error_span, info, trace, warn, Instrument}; #[derive(Debug, Serialize)] @@ -535,6 +540,8 @@ pub struct DhtState { // This is to send raw messages worker_sender: UnboundedSender, + cancellation_token: CancellationToken, + pub(crate) peer_store: PeerStore, } @@ -545,6 +552,7 @@ impl DhtState { routing_table: Option, listen_addr: SocketAddr, peer_store: PeerStore, + cancellation_token: CancellationToken, ) -> Self { let routing_table = routing_table.unwrap_or_else(|| RoutingTable::new(id, None)); Self { @@ -556,6 +564,7 @@ impl DhtState { listen_addr, rate_limiter: make_rate_limiter(), peer_store, + cancellation_token, } } @@ -1124,13 +1133,18 @@ pub struct DhtConfig { pub routing_table: Option, pub listen_addr: Option, pub peer_store: Option, + pub cancellation_token: Option, } impl DhtState { pub async fn new() -> anyhow::Result> { Self::with_config(DhtConfig::default()).await } - pub async fn with_config(config: DhtConfig) -> anyhow::Result> { + pub fn cancellation_token(&self) -> &CancellationToken { + &self.cancellation_token + } + + pub async fn with_config(mut config: DhtConfig) -> anyhow::Result> { let socket = match config.listen_addr { Some(addr) => UdpSocket::bind(addr) .await @@ -1151,6 +1165,8 @@ impl DhtState { .bootstrap_addrs .unwrap_or_else(|| crate::DHT_BOOTSTRAP.iter().map(|v| v.to_string()).collect()); + let token = config.cancellation_token.take().unwrap_or_default(); + let (in_tx, in_rx) = unbounded_channel(); let state = Arc::new(Self::new_internal( peer_id, @@ -1158,14 +1174,14 @@ impl DhtState { config.routing_table, listen_addr, config.peer_store.unwrap_or_else(|| PeerStore::new(peer_id)), + token, )); - spawn(error_span!("dht"), { + spawn_with_cancel(error_span!("dht"), state.cancellation_token.clone(), { let state = state.clone(); async move { let worker = DhtWorker { socket, dht: state }; - worker.start(in_rx, &bootstrap_addrs).await?; - Ok(()) + worker.start(in_rx, &bootstrap_addrs).await } }); Ok(state) diff --git a/crates/dht/src/persistence.rs b/crates/dht/src/persistence.rs index 2c002bb8..30d3f9b0 100644 --- a/crates/dht/src/persistence.rs +++ b/crates/dht/src/persistence.rs @@ -1,13 +1,14 @@ // TODO: this now stores only the routing table, but we also need AT LEAST the same socket address... use librqbit_core::directories::get_configuration_directory; -use librqbit_core::spawn_utils::spawn; +use librqbit_core::spawn_utils::spawn_with_cancel; use serde::{Deserialize, Serialize}; use std::fs::OpenOptions; use std::io::{BufReader, BufWriter}; use std::net::SocketAddr; use std::path::{Path, PathBuf}; use std::time::Duration; +use tokio_util::sync::CancellationToken; use anyhow::Context; use tracing::{debug, error, error_span, info, trace, warn}; @@ -68,18 +69,27 @@ fn dump_dht(dht: &Dht, filename: &Path, tempfile_name: &Path) -> anyhow::Result< } impl PersistentDht { - pub async fn create(config: Option) -> anyhow::Result { + pub fn default_persistence_filename() -> anyhow::Result { + let dirs = get_configuration_directory("dht")?; + let path = dirs.cache_dir().join("dht.json"); + Ok(path) + } + + pub async fn create( + config: Option, + cancellation_token: Option, + ) -> anyhow::Result { let mut config = config.unwrap_or_default(); let config_filename = match config.config_filename.take() { Some(config_filename) => config_filename, - None => { - let dirs = get_configuration_directory("dht")?; - let path = dirs.cache_dir().join("dht.json"); - info!("will store DHT routing table to {:?} periodically", &path); - path - } + None => Self::default_persistence_filename()?, }; + info!( + "will store DHT routing table to {:?} periodically", + &config_filename + ); + if let Some(parent) = config_filename.parent() { std::fs::create_dir_all(parent) .with_context(|| format!("error creating dir {:?}", &parent))?; @@ -117,34 +127,41 @@ impl PersistentDht { routing_table, listen_addr, peer_store, + cancellation_token, ..Default::default() }; let dht = DhtState::with_config(dht_config).await?; - - spawn(error_span!("dht_persistence"), { - let dht = dht.clone(); - let dump_interval = config - .dump_interval - .unwrap_or_else(|| Duration::from_secs(3)); - async move { - let tempfile_name = { - let file_name = format!("dht.json.tmp.{}", std::process::id()); - let mut tmp = config_filename.clone(); - tmp.set_file_name(file_name); - tmp - }; - - loop { - trace!("sleeping for {:?}", &dump_interval); - tokio::time::sleep(dump_interval).await; - - match dump_dht(&dht, &config_filename, &tempfile_name) { - Ok(_) => debug!("dumped DHT to {:?}", &config_filename), - Err(e) => error!("error dumping DHT to {:?}: {:#}", &config_filename, e), + spawn_with_cancel( + error_span!("dht_persistence"), + dht.cancellation_token().clone(), + { + let dht = dht.clone(); + let dump_interval = config + .dump_interval + .unwrap_or_else(|| Duration::from_secs(3)); + async move { + let tempfile_name = { + let file_name = format!("dht.json.tmp.{}", std::process::id()); + let mut tmp = config_filename.clone(); + tmp.set_file_name(file_name); + tmp + }; + + loop { + trace!("sleeping for {:?}", &dump_interval); + tokio::time::sleep(dump_interval).await; + + match dump_dht(&dht, &config_filename, &tempfile_name) { + Ok(_) => debug!("dumped DHT to {:?}", &config_filename), + Err(e) => { + error!("error dumping DHT to {:?}: {:#}", &config_filename, e) + } + } } } - } - }); + }, + ); + Ok(dht) } } diff --git a/crates/librqbit/Cargo.toml b/crates/librqbit/Cargo.toml index e79e2239..d3a00bf8 100644 --- a/crates/librqbit/Cargo.toml +++ b/crates/librqbit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "librqbit" -version = "5.0.0-beta.0" +version = "5.0.0-beta.1" authors = ["Igor Katson "] edition = "2021" description = "The main library used by rqbit torrent client. The binary is just a small wrapper on top of it." @@ -28,7 +28,7 @@ librqbit-core = {path = "../librqbit_core", version = "3.3.0"} clone_to_owned = {path = "../clone_to_owned", package="librqbit-clone-to-owned", version = "2.2.1"} peer_binary_protocol = {path = "../peer_binary_protocol", package="librqbit-peer-protocol", version = "3.3.0"} sha1w = {path = "../sha1w", default-features=false, package="librqbit-sha1-wrapper", version="2.2.1"} -dht = {path = "../dht", package="librqbit-dht", version="4.1.0"} +dht = {path = "../dht", package="librqbit-dht", version="5.0.0-beta.1"} librqbit-upnp = {path = "../upnp", version = "0.1.0"} tokio = {version = "1", features = ["macros", "rt-multi-thread"]} @@ -64,8 +64,9 @@ backoff = "0.4.0" dashmap = "5.5.3" base64 = "0.21.5" serde_with = "3.4.0" +tokio-util = "0.7.10" [dev-dependencies] futures = {version = "0.3"} tracing-subscriber = "0.3" -tokio-test = "0.4" \ No newline at end of file +tokio-test = "0.4" diff --git a/crates/librqbit/src/api.rs b/crates/librqbit/src/api.rs index bdfb41bd..3c9454d1 100644 --- a/crates/librqbit/src/api.rs +++ b/crates/librqbit/src/api.rs @@ -26,6 +26,7 @@ pub type Result = std::result::Result; /// Library API for use in different web frameworks. /// Contains all methods you might want to expose with (de)serializable inputs/outputs. +#[derive(Clone)] pub struct Api { session: Arc, rust_log_reload_tx: Option>, @@ -39,6 +40,10 @@ impl Api { } } + pub fn session(&self) -> &Arc { + &self.session + } + pub fn mgr_handle(&self, idx: TorrentId) -> Result { self.session .get(idx) diff --git a/crates/librqbit/src/api_error.rs b/crates/librqbit/src/api_error.rs index 7f7e4f45..82b5e278 100644 --- a/crates/librqbit/src/api_error.rs +++ b/crates/librqbit/src/api_error.rs @@ -27,6 +27,14 @@ impl ApiError { } } + pub const fn new_from_text(status: StatusCode, text: &'static str) -> Self { + Self { + status: Some(status), + kind: ApiErrorKind::Text(text), + plaintext: false, + } + } + #[allow(dead_code)] pub fn not_implemented(msg: &str) -> Self { Self { @@ -69,6 +77,7 @@ impl ApiError { enum ApiErrorKind { TorrentNotFound(usize), DhtDisabled, + Text(&'static str), Other(anyhow::Error), } @@ -91,6 +100,7 @@ impl Serialize for ApiError { ApiErrorKind::TorrentNotFound(_) => "torrent_not_found", ApiErrorKind::DhtDisabled => "dht_disabled", ApiErrorKind::Other(_) => "internal_error", + ApiErrorKind::Text(_) => "internal_error", }, human_readable: format!("{self}"), status: self.status().as_u16(), @@ -130,6 +140,7 @@ impl std::fmt::Display for ApiError { ApiErrorKind::TorrentNotFound(idx) => write!(f, "torrent {idx} not found"), ApiErrorKind::Other(err) => write!(f, "{err:?}"), ApiErrorKind::DhtDisabled => write!(f, "DHT is disabled"), + ApiErrorKind::Text(t) => write!(f, "{t}"), } } } diff --git a/crates/librqbit/src/dht_utils.rs b/crates/librqbit/src/dht_utils.rs index ea1225b7..fb4f72cb 100644 --- a/crates/librqbit/src/dht_utils.rs +++ b/crates/librqbit/src/dht_utils.rs @@ -108,6 +108,7 @@ mod tests { let info_hash = Id20::from_str("cab507494d02ebb1178b38f2e9d7be299c86b862").unwrap(); let dht = DhtBuilder::new().await.unwrap(); + let peer_rx = dht.get_peers(info_hash, None).unwrap(); let peer_id = generate_peer_id(); match read_metainfo_from_peer_receiver(peer_id, info_hash, Vec::new(), peer_rx, None).await diff --git a/crates/librqbit/src/http_api.rs b/crates/librqbit/src/http_api.rs index a6c8c41a..7d9f6f8b 100644 --- a/crates/librqbit/src/http_api.rs +++ b/crates/librqbit/src/http_api.rs @@ -66,6 +66,7 @@ impl HttpApi { "GET /web/": "Web UI", }, "server": "rqbit", + "version": env!("CARGO_PKG_VERSION"), })) } diff --git a/crates/librqbit/src/session.rs b/crates/librqbit/src/session.rs index dcc9bd66..3a93459b 100644 --- a/crates/librqbit/src/session.rs +++ b/crates/librqbit/src/session.rs @@ -21,6 +21,7 @@ use librqbit_core::{ directories::get_configuration_directory, magnet::Magnet, peer_id::generate_peer_id, + spawn_utils::spawn_with_cancel, torrent_metainfo::{torrent_from_bytes, TorrentMetaV1Info, TorrentMetaV1Owned}, }; use parking_lot::RwLock; @@ -32,12 +33,13 @@ use tokio::{ io::AsyncReadExt, net::{TcpListener, TcpStream}, }; +use tokio_util::sync::CancellationToken; use tracing::{debug, error, error_span, info, trace, warn, Instrument}; use crate::{ dht_utils::{read_metainfo_from_peer_receiver, ReadMetainfoResult}, peer_connection::{with_timeout, PeerConnectionOptions}, - spawn_utils::{spawn, BlockingSpawner}, + spawn_utils::BlockingSpawner, torrent_state::{ ManagedTorrentBuilder, ManagedTorrentHandle, ManagedTorrentState, TorrentStateLive, }, @@ -161,8 +163,7 @@ pub struct Session { tcp_listen_port: Option, - cancel_tx: tokio::sync::watch::Sender<()>, - cancel_rx: tokio::sync::watch::Receiver<()>, + cancellation_token: CancellationToken, } async fn torrent_from_url(url: &str) -> anyhow::Result { @@ -373,12 +374,22 @@ impl Session { Self::new_with_opts(output_folder, SessionOptions::default()).await } + pub fn default_persistence_filename() -> anyhow::Result { + let dir = get_configuration_directory("session")?; + Ok(dir.data_dir().join("session.json")) + } + + pub fn cancellation_token(&self) -> &CancellationToken { + &self.cancellation_token + } + /// Create a new session with options. pub async fn new_with_opts( output_folder: PathBuf, mut opts: SessionOptions, ) -> anyhow::Result> { let peer_id = opts.peer_id.unwrap_or_else(generate_peer_id); + let token = CancellationToken::new(); let (tcp_listener, tcp_listen_port) = if let Some(port_range) = opts.listen_port_range { let (l, p) = create_tcp_listener(port_range) @@ -394,25 +405,28 @@ impl Session { None } else { let dht = if opts.disable_dht_persistence { - DhtBuilder::with_config(DhtConfig::default()).await + DhtBuilder::with_config(DhtConfig { + cancellation_token: Some(token.child_token()), + ..Default::default() + }) + .await + .context("error initializing DHT")? } else { let pdht_config = opts.dht_config.take().unwrap_or_default(); - PersistentDht::create(Some(pdht_config)).await - } - .context("error initializing DHT")?; + PersistentDht::create(Some(pdht_config), Some(token.clone())) + .await + .context("error initializing persistent DHT")? + }; + Some(dht) }; let peer_opts = opts.peer_opts.unwrap_or_default(); let persistence_filename = match opts.persistence_filename { Some(filename) => filename, - None => get_configuration_directory("session")? - .data_dir() - .join("session.json"), + None => Self::default_persistence_filename()?, }; let spawner = BlockingSpawner::default(); - let (cancel_tx, cancel_rx) = tokio::sync::watch::channel(()); - let session = Arc::new(Self { persistence_filename, peer_id, @@ -421,14 +435,12 @@ impl Session { spawner, output_folder, db: RwLock::new(Default::default()), - cancel_rx, - cancel_tx, + cancellation_token: token, tcp_listen_port, }); if let Some(tcp_listener) = tcp_listener { session.spawn( - "tcp listener", error_span!("tcp_listen", port = tcp_listen_port), session.clone().task_tcp_listener(tcp_listener), ); @@ -437,7 +449,6 @@ impl Session { if let Some(listen_port) = tcp_listen_port { if opts.enable_upnp_port_forwarding { session.spawn( - "upnp_forward", error_span!("upnp_forward", port = listen_port), session.clone().task_upnp_port_forwarder(listen_port), ); @@ -455,11 +466,7 @@ impl Session { })?; } let persistence_task = session.clone().task_persistence(); - session.spawn( - "session persistene", - error_span!("session_persistence"), - persistence_task, - ); + session.spawn(error_span!("session_persistence"), persistence_task); } Ok(session) @@ -608,26 +615,32 @@ impl Session { } } - fn spawn( + /// Spawn a task in the context of the session. + pub fn spawn( &self, - name: &str, span: tracing::Span, fut: impl std::future::Future> + Send + 'static, ) { - let mut cancel_rx = self.cancel_rx.clone(); - spawn(name, span, async move { - tokio::select! { - r = fut => r, - _ = cancel_rx.changed() => { - debug!("task canceled"); - Ok(()) - } - } - }); + spawn_with_cancel(span, self.cancellation_token.clone(), fut); } - pub fn stop(&self) { - let _ = self.cancel_tx.send(()); + /// Stop the session and all managed tasks. + pub async fn stop(&self) { + let torrents = self + .db + .read() + .torrents + .values() + .cloned() + .collect::>(); + for torrent in torrents { + if let Err(e) = torrent.pause() { + debug!("error pausing torrent: {e:#}"); + } + } + self.cancellation_token.cancel(); + // this sucks, but hopefully will be enough + tokio::time::sleep(Duration::from_secs(1)).await; } async fn populate_from_stored(self: &Arc) -> anyhow::Result<()> { @@ -958,6 +971,7 @@ impl Session { builder .overwrite(opts.overwrite) .spawner(self.spawner) + .cancellation_token(self.cancellation_token.child_token()) .peer_id(self.peer_id); if opts.disable_trackers { diff --git a/crates/librqbit/src/torrent_state/live/mod.rs b/crates/librqbit/src/torrent_state/live/mod.rs index 13bc1973..e73e91ff 100644 --- a/crates/librqbit/src/torrent_state/live/mod.rs +++ b/crates/librqbit/src/torrent_state/live/mod.rs @@ -65,6 +65,7 @@ use itertools::Itertools; use librqbit_core::{ id20::Id20, lengths::{ChunkInfo, Lengths, ValidPieceIndex}, + spawn_utils::spawn_with_cancel, speed_estimator::SpeedEstimator, torrent_metainfo::TorrentMetaV1Info, }; @@ -80,6 +81,7 @@ use tokio::{ }, time::timeout, }; +use tokio_util::sync::CancellationToken; use tracing::{debug, error, error_span, info, trace, warn}; use url::Url; @@ -90,7 +92,6 @@ use crate::{ PeerConnection, PeerConnectionHandler, PeerConnectionOptions, WriterRequest, }, session::CheckedIncomingConnection, - spawn_utils::spawn, torrent_state::{peer::Peer, utils::atomic_inc}, tracker_comms::{TrackerError, TrackerRequest, TrackerRequestEvent, TrackerResponse}, type_aliases::{PeerHandle, BF}, @@ -185,17 +186,16 @@ pub struct TorrentStateLive { finished_notify: Notify, - cancel_tx: tokio::sync::watch::Sender<()>, - cancel_rx: tokio::sync::watch::Receiver<()>, - down_speed_estimator: SpeedEstimator, up_speed_estimator: SpeedEstimator, + cancellation_token: CancellationToken, } impl TorrentStateLive { pub(crate) fn new( paused: TorrentStatePaused, fatal_errors_tx: tokio::sync::oneshot::Sender, + cancellation_token: CancellationToken, ) -> Arc { let (peer_queue_tx, peer_queue_rx) = unbounded_channel(); @@ -206,8 +206,6 @@ impl TorrentStateLive { let needed_bytes = paused.info.lengths.total_length() - have_bytes; let lengths = *paused.chunk_tracker.get_lengths(); - let (cancel_tx, cancel_rx) = tokio::sync::watch::channel(()); - let state = Arc::new(TorrentStateLive { meta: paused.info.clone(), peers: Default::default(), @@ -229,20 +227,17 @@ impl TorrentStateLive { finished_notify: Notify::new(), down_speed_estimator, up_speed_estimator, - cancel_rx, - cancel_tx, + cancellation_token, }); for tracker in state.meta.trackers.iter() { state.spawn( - "tracker_monitor", error_span!(parent: state.meta.span.clone(), "tracker_monitor", url = tracker.to_string()), state.clone().task_single_tracker_monitor(tracker.clone()), ); } state.spawn( - "speed_estimator_updater", error_span!(parent: state.meta.span.clone(), "speed_estimator_updater"), { let state = Arc::downgrade(&state); @@ -273,29 +268,18 @@ impl TorrentStateLive { ); state.spawn( - "peer_adder", error_span!(parent: state.meta.span.clone(), "peer_adder"), state.clone().task_peer_adder(peer_queue_rx), ); state } - fn spawn( + pub(crate) fn spawn( &self, - name: &str, span: tracing::Span, fut: impl std::future::Future> + Send + 'static, ) { - let mut cancel_rx = self.cancel_rx.clone(); - spawn(name, span, async move { - tokio::select! { - r = fut => r, - _ = cancel_rx.changed() => { - debug!("task canceled"); - Ok(()) - } - } - }); + spawn_with_cancel(span, self.cancellation_token.clone(), fut); } pub fn down_speed_estimator(&self) -> &SpeedEstimator { @@ -418,7 +402,6 @@ impl TorrentStateLive { atomic_inc(&counters.incoming_connections); self.spawn( - "incoming peer", error_span!( parent: self.meta.span.clone(), "manage_incoming_peer", @@ -570,7 +553,6 @@ impl TorrentStateLive { let permit = state.peer_semaphore.clone().acquire_owned().await?; state.spawn( - "manage_peer", error_span!(parent: state.meta.span.clone(), "manage_peer", peer = addr.to_string()), state.clone().task_manage_outgoing_peer(addr, permit), ); @@ -682,7 +664,6 @@ impl TorrentStateLive { // We don't want to remember this task as there may be too many. self.spawn( - "transmit_haves", error_span!( parent: self.meta.span.clone(), "transmit_haves", @@ -744,7 +725,7 @@ impl TorrentStateLive { } pub fn pause(&self) -> anyhow::Result { - let _ = self.cancel_tx.send(()); + self.cancellation_token.cancel(); let mut g = self.locked.write(); @@ -856,7 +837,10 @@ impl<'a> PeerConnectionHandler for &'a PeerHandler { } Message::Have(h) => self.on_have(h), Message::NotInterested => { - debug!("received \"not interested\", but we don't care yet") + debug!("received \"not interested\", but we don't process it yet") + } + Message::Cancel(_) => { + debug!("received \"cancel\", but we don't process it yet") } message => { warn!("received unsupported message {:?}, ignoring", message); @@ -968,7 +952,6 @@ impl PeerHandler { if let Some(dur) = backoff { self.state.clone().spawn( - "wait_for_peer", error_span!( parent: self.state.meta.span.clone(), "wait_for_peer", diff --git a/crates/librqbit/src/torrent_state/mod.rs b/crates/librqbit/src/torrent_state/mod.rs index 5639e31f..6df68fea 100644 --- a/crates/librqbit/src/torrent_state/mod.rs +++ b/crates/librqbit/src/torrent_state/mod.rs @@ -20,12 +20,14 @@ use librqbit_core::id20::Id20; use librqbit_core::lengths::Lengths; use librqbit_core::peer_id::generate_peer_id; +use librqbit_core::spawn_utils::spawn_with_cancel; use librqbit_core::torrent_metainfo::TorrentMetaV1Info; pub use live::*; use parking_lot::RwLock; use tokio::time::timeout; use tokio_stream::StreamExt; +use tokio_util::sync::CancellationToken; use tracing::debug; use tracing::error_span; use tracing::trace; @@ -33,7 +35,6 @@ use tracing::warn; use url::Url; use crate::chunk_tracker::ChunkTracker; -use crate::spawn_utils::spawn; use crate::spawn_utils::BlockingSpawner; use crate::torrent_state::stats::LiveStats; @@ -91,6 +92,7 @@ pub struct ManagedTorrentInfo { pub struct ManagedTorrent { pub info: Arc, + pub cancellation_token: CancellationToken, pub(crate) only_files: Option>, locked: RwLock, } @@ -179,10 +181,11 @@ impl ManagedTorrent { let spawn_fatal_errors_receiver = |state: &Arc, rx: tokio::sync::oneshot::Receiver| { let span = state.info.span.clone(); + let token = state.cancellation_token.clone(); let state = Arc::downgrade(state); - spawn( - "fatal_errors_receiver", + spawn_with_cancel( error_span!(parent: span, "fatal_errors_receiver"), + token, async move { let e = match rx.await { Ok(e) => e, @@ -191,7 +194,7 @@ impl ManagedTorrent { if let Some(state) = state.upgrade() { state.stop_with_error(e); } else { - warn!("tried to stop the torrent with error, but it's couldn't upgrade the arc"); + warn!("tried to stop the torrent with error, but couldn't upgrade the arc"); } Ok(()) }, @@ -203,40 +206,42 @@ impl ManagedTorrent { initial_peers: Vec, peer_rx: Option, ) { - let span = live.meta().span.clone(); - let live = Arc::downgrade(live); - spawn( - "external_peer_adder", - error_span!(parent: span, "external_peer_adder"), - async move { - { - let live: Arc = - live.upgrade().context("no longer live")?; + live.spawn( + error_span!(parent: live.meta().span.clone(), "external_peer_adder"), + { + let live = live.clone(); + async move { trace!("adding {} initial peers", initial_peers.len()); for peer in initial_peers { live.add_peer_if_not_seen(peer).context("torrent closed")?; } - } - let mut peer_rx = if let Some(peer_rx) = peer_rx { - peer_rx - } else { - return Ok(()); - }; - - loop { - match timeout(Duration::from_secs(5), peer_rx.next()).await { - Ok(Some(peer)) => { - let live = match live.upgrade() { - Some(live) => live, - None => return Ok(()), - }; - live.add_peer_if_not_seen(peer).context("torrent closed")?; + let live = { + let weak = Arc::downgrade(&live); + drop(live); + weak + }; + + let mut peer_rx = if let Some(peer_rx) = peer_rx { + peer_rx + } else { + return Ok(()); + }; + + loop { + match timeout(Duration::from_secs(5), peer_rx.next()).await { + Ok(Some(peer)) => { + let live = match live.upgrade() { + Some(live) => live, + None => return Ok(()), + }; + live.add_peer_if_not_seen(peer).context("torrent closed")?; + } + Ok(None) => return Ok(()), + // If timeout, check if the torrent is live. + Err(_) if live.strong_count() == 0 => return Ok(()), + Err(_) => continue, } - Ok(None) => return Ok(()), - // If timeout, check if the torrent is live. - Err(_) if live.strong_count() == 0 => return Ok(()), - Err(_) => continue, } } }, @@ -252,9 +257,10 @@ impl ManagedTorrent { drop(g); let t = self.clone(); let span = self.info().span.clone(); - spawn( - "initialize_and_start", + let token = self.cancellation_token.clone(); + spawn_with_cancel( error_span!(parent: span.clone(), "initialize_and_start"), + token.clone(), async move { match init.check().await { Ok(paused) => { @@ -271,7 +277,7 @@ impl ManagedTorrent { } let (tx, rx) = tokio::sync::oneshot::channel(); - let live = TorrentStateLive::new(paused, tx); + let live = TorrentStateLive::new(paused, tx, token.child_token()); g.state = ManagedTorrentState::Live(live.clone()); spawn_fatal_errors_receiver(&t, rx); @@ -292,7 +298,11 @@ impl ManagedTorrent { ManagedTorrentState::Paused(_) => { let paused = g.state.take().assert_paused(); let (tx, rx) = tokio::sync::oneshot::channel(); - let live = TorrentStateLive::new(paused, tx); + let live = TorrentStateLive::new( + paused, + tx, + self.cancellation_token.child_token().clone(), + ); g.state = ManagedTorrentState::Live(live.clone()); spawn_fatal_errors_receiver(self, rx); spawn_peer_adder(&live, initial_peers, peer_rx); @@ -409,6 +419,7 @@ pub struct ManagedTorrentBuilder { peer_id: Option, overwrite: bool, spawner: Option, + cancellation_token: Option, } impl ManagedTorrentBuilder { @@ -429,9 +440,15 @@ impl ManagedTorrentBuilder { trackers: Default::default(), peer_id: None, overwrite: false, + cancellation_token: None, } } + pub fn cancellation_token(&mut self, token: CancellationToken) -> &mut Self { + self.cancellation_token = Some(token); + self + } + pub fn only_files(&mut self, only_files: Vec) -> &mut Self { self.only_files = Some(only_files); self @@ -472,7 +489,7 @@ impl ManagedTorrentBuilder { self } - pub(crate) fn build(self, span: tracing::Span) -> anyhow::Result { + pub(crate) fn build(mut self, span: tracing::Span) -> anyhow::Result { let lengths = Lengths::from_torrent(&self.info)?; let info = Arc::new(ManagedTorrentInfo { span, @@ -499,6 +516,7 @@ impl ManagedTorrentBuilder { locked: RwLock::new(ManagedTorrentLocked { state: ManagedTorrentState::Initializing(initializing), }), + cancellation_token: self.cancellation_token.take().unwrap_or_default(), info, })) } diff --git a/crates/librqbit/webui/dist/assets/index.js b/crates/librqbit/webui/dist/assets/index.js index bb33f79f..789d3382 100644 --- a/crates/librqbit/webui/dist/assets/index.js +++ b/crates/librqbit/webui/dist/assets/index.js @@ -1,4 +1,4 @@ -(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 o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function Yl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sa={exports:{}},Xl={},xa={exports:{}},F={};/** +(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 o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function Yl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ea={exports:{}},Xl={},ka={exports:{}},F={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var zr=Symbol.for("react.element"),Wd=Symbol.for("react.portal"),Vd=Symbol.for("react.fragment"),Qd=Symbol.for("react.strict_mode"),Kd=Symbol.for("react.profiler"),Gd=Symbol.for("react.provider"),Yd=Symbol.for("react.context"),Xd=Symbol.for("react.forward_ref"),Zd=Symbol.for("react.suspense"),Jd=Symbol.for("react.memo"),qd=Symbol.for("react.lazy"),qu=Symbol.iterator;function bd(e){return e===null||typeof e!="object"?null:(e=qu&&e[qu]||e["@@iterator"],typeof e=="function"?e:null)}var ka={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ea=Object.assign,Ca={};function Bn(e,t,n){this.props=e,this.context=t,this.refs=Ca,this.updater=n||ka}Bn.prototype.isReactComponent={};Bn.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")};Bn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Na(){}Na.prototype=Bn.prototype;function Yi(e,t,n){this.props=e,this.context=t,this.refs=Ca,this.updater=n||ka}var Xi=Yi.prototype=new Na;Xi.constructor=Yi;Ea(Xi,Bn.prototype);Xi.isPureReactComponent=!0;var bu=Array.isArray,_a=Object.prototype.hasOwnProperty,Zi={current:null},Ta={key:!0,ref:!0,__self:!0,__source:!0};function ja(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)_a.call(t,r)&&!Ta.hasOwnProperty(r)&&(l[r]=t[r]);var u=arguments.length-2;if(u===1)l.children=n;else if(1>>1,A=C[I];if(0>>1;Il(et,O))Oel(mt,et)?(C[I]=mt,C[Oe]=O,I=Oe):(C[I]=et,C[Re]=O,I=Re);else if(Oel(mt,O))C[I]=mt,C[Oe]=O,I=Oe;else break e}}return R}function l(C,R){var O=C.sortIndex-R.sortIndex;return O!==0?O:C.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,u=i.now();e.unstable_now=function(){return i.now()-u}}var s=[],a=[],m=1,h=null,d=3,w=!1,g=!1,k=!1,L=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(C){for(var R=n(a);R!==null;){if(R.callback===null)r(a);else if(R.startTime<=C)r(a),R.sortIndex=R.expirationTime,t(s,R);else break;R=n(a)}}function S(C){if(k=!1,v(C),!g)if(n(s)!==null)g=!0,Le(_);else{var R=n(a);R!==null&&Ye(S,R.startTime-C)}}function _(C,R){g=!1,k&&(k=!1,p(j),j=-1),w=!0;var O=d;try{for(v(R),h=n(s);h!==null&&(!(h.expirationTime>R)||C&&!ie());){var I=h.callback;if(typeof I=="function"){h.callback=null,d=h.priorityLevel;var A=I(h.expirationTime<=R);R=e.unstable_now(),typeof A=="function"?h.callback=A:h===n(s)&&r(s),v(R)}else r(s);h=n(s)}if(h!==null)var fe=!0;else{var Re=n(a);Re!==null&&Ye(S,Re.startTime-R),fe=!1}return fe}finally{h=null,d=O,w=!1}}var E=!1,N=null,j=-1,U=5,P=-1;function ie(){return!(e.unstable_now()-PC||125I?(C.sortIndex=O,t(a,C),n(s)===null&&C===n(a)&&(k?(p(j),j=-1):k=!0,Ye(S,O-I))):(C.sortIndex=A,t(s,C),g||w||(g=!0,Le(_))),C},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(C){var R=d;return function(){var O=d;d=R;try{return C.apply(this,arguments)}finally{d=O}}}})(Pa);Oa.exports=Pa;var cp=Oa.exports;/** + */(function(e){function t(C,R){var O=C.length;C.push(R);e:for(;0>>1,A=C[I];if(0>>1;Il(et,O))Oel(ht,et)?(C[I]=ht,C[Oe]=O,I=Oe):(C[I]=et,C[Re]=O,I=Re);else if(Oel(ht,O))C[I]=ht,C[Oe]=O,I=Oe;else break e}}return R}function l(C,R){var O=C.sortIndex-R.sortIndex;return O!==0?O:C.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,u=i.now();e.unstable_now=function(){return i.now()-u}}var s=[],a=[],m=1,h=null,d=3,g=!1,w=!1,E=!1,L=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(C){for(var R=n(a);R!==null;){if(R.callback===null)r(a);else if(R.startTime<=C)r(a),R.sortIndex=R.expirationTime,t(s,R);else break;R=n(a)}}function S(C){if(E=!1,v(C),!w)if(n(s)!==null)w=!0,Le(T);else{var R=n(a);R!==null&&Ye(S,R.startTime-C)}}function T(C,R){w=!1,E&&(E=!1,p(j),j=-1),g=!0;var O=d;try{for(v(R),h=n(s);h!==null&&(!(h.expirationTime>R)||C&&!ie());){var I=h.callback;if(typeof I=="function"){h.callback=null,d=h.priorityLevel;var A=I(h.expirationTime<=R);R=e.unstable_now(),typeof A=="function"?h.callback=A:h===n(s)&&r(s),v(R)}else r(s);h=n(s)}if(h!==null)var fe=!0;else{var Re=n(a);Re!==null&&Ye(S,Re.startTime-R),fe=!1}return fe}finally{h=null,d=O,g=!1}}var k=!1,N=null,j=-1,U=5,P=-1;function ie(){return!(e.unstable_now()-PC||125I?(C.sortIndex=O,t(a,C),n(s)===null&&C===n(a)&&(E?(p(j),j=-1):E=!0,Ye(S,O-I))):(C.sortIndex=A,t(s,C),w||g||(w=!0,Le(T))),C},e.unstable_shouldYield=ie,e.unstable_wrapCallback=function(C){var R=d;return function(){var O=d;d=R;try{return C.apply(this,arguments)}finally{d=O}}}})(Ma);Fa.exports=Ma;var fp=Fa.exports;/** * @license React * react-dom.production.min.js * @@ -30,15 +30,15 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Fa=y,_e=cp;function x(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"),Xo=Object.prototype.hasOwnProperty,fp=/^[: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]*$/,ts={},ns={};function dp(e){return Xo.call(ns,e)?!0:Xo.call(ts,e)?!1:fp.test(e)?ns[e]=!0:(ts[e]=!0,!1)}function pp(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 mp(e,t,n,r){if(t===null||typeof t>"u"||pp(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 ve(e,t,n,r,l,o,i){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=o,this.removeEmptyString=i}var oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){oe[e]=new ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];oe[t]=new ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){oe[e]=new ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){oe[e]=new ve(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){oe[e]=new ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){oe[e]=new ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){oe[e]=new ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){oe[e]=new ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){oe[e]=new ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var qi=/[\-:]([a-z])/g;function bi(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(qi,bi);oe[t]=new ve(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(qi,bi);oe[t]=new ve(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(qi,bi);oe[t]=new ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){oe[e]=new ve(e,1,!1,e.toLowerCase(),null,!1,!1)});oe.xlinkHref=new ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){oe[e]=new ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function eu(e,t,n,r){var l=oe.hasOwnProperty(t)?oe[t]:null;(l!==null?l.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xo=Object.prototype.hasOwnProperty,dp=/^[: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]*$/,ns={},rs={};function pp(e){return Xo.call(rs,e)?!0:Xo.call(ns,e)?!1:dp.test(e)?rs[e]=!0:(ns[e]=!0,!1)}function mp(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 hp(e,t,n,r){if(t===null||typeof t>"u"||mp(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 ve(e,t,n,r,l,o,i){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=o,this.removeEmptyString=i}var oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){oe[e]=new ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];oe[t]=new ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){oe[e]=new ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){oe[e]=new ve(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){oe[e]=new ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){oe[e]=new ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){oe[e]=new ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){oe[e]=new ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){oe[e]=new ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var qi=/[\-:]([a-z])/g;function bi(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(qi,bi);oe[t]=new ve(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(qi,bi);oe[t]=new ve(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(qi,bi);oe[t]=new ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){oe[e]=new ve(e,1,!1,e.toLowerCase(),null,!1,!1)});oe.xlinkHref=new ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){oe[e]=new ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function eu(e,t,n,r){var l=oe.hasOwnProperty(t)?oe[t]:null;(l!==null?l.type!==0:r||!(2u||l[i]!==o[u]){var s=` -`+l[i].replace(" at new "," at ");return e.displayName&&s.includes("")&&(s=s.replace("",e.displayName)),s}while(1<=i&&0<=u);break}}}finally{go=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?rr(e):""}function hp(e){switch(e.tag){case 5:return rr(e.type);case 16:return rr("Lazy");case 13:return rr("Suspense");case 19:return rr("SuspenseList");case 0:case 2:case 15:return e=wo(e.type,!1),e;case 11:return e=wo(e.type.render,!1),e;case 1:return e=wo(e.type,!0),e;default:return""}}function bo(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 hn:return"Fragment";case mn:return"Portal";case Zo:return"Profiler";case tu:return"StrictMode";case Jo:return"Suspense";case qo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case $a:return(e.displayName||"Context")+".Consumer";case za:return(e._context.displayName||"Context")+".Provider";case nu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ru:return t=e.displayName||null,t!==null?t:bo(e.type)||"Memo";case gt:t=e._payload,e=e._init;try{return bo(e(t))}catch{}}return null}function vp(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 bo(t);case 8:return t===tu?"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 Ft(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Da(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function yp(e){var t=Da(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,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Qr(e){e._valueTracker||(e._valueTracker=yp(e))}function Aa(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Da(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Sl(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 ei(e,t){var n=t.checked;return X({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ls(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ft(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 Ua(e,t){t=t.checked,t!=null&&eu(e,"checked",t,!1)}function ti(e,t){Ua(e,t);var n=Ft(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")?ni(e,t.type,n):t.hasOwnProperty("defaultValue")&&ni(e,t.type,Ft(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function os(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 ni(e,t,n){(t!=="number"||Sl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var lr=Array.isArray;function Tn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Kr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var sr={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},gp=["Webkit","ms","Moz","O"];Object.keys(sr).forEach(function(e){gp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),sr[t]=sr[e]})});function Va(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||sr.hasOwnProperty(e)&&sr[e]?(""+t).trim():t+"px"}function Qa(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Va(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var wp=X({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 oi(e,t){if(t){if(wp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(x(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(x(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(x(61))}if(t.style!=null&&typeof t.style!="object")throw Error(x(62))}}function ii(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 ui=null;function lu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var si=null,jn=null,Ln=null;function ss(e){if(e=Dr(e)){if(typeof si!="function")throw Error(x(280));var t=e.stateNode;t&&(t=eo(t),si(e.stateNode,e.type,t))}}function Ka(e){jn?Ln?Ln.push(e):Ln=[e]:jn=e}function Ga(){if(jn){var e=jn,t=Ln;if(Ln=jn=null,ss(e),t)for(e=0;e>>=0,e===0?32:31-(Rp(e)/Op|0)|0}var Gr=64,Yr=4194304;function or(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 Cl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var u=i&~l;u!==0?r=or(u):(o&=i,o!==0&&(r=or(o)))}else i=n&~l,i!==0?r=or(i):o!==0&&(r=or(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&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 $r(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-We(t),e[t]=n}function zp(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=cr),ys=String.fromCharCode(32),gs=!1;function pc(e,t){switch(e){case"keyup":return am.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function mc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vn=!1;function fm(e,t){switch(e){case"compositionend":return mc(t);case"keypress":return t.which!==32?null:(gs=!0,ys);case"textInput":return e=t.data,e===ys&&gs?null:e;default:return null}}function dm(e,t){if(vn)return e==="compositionend"||!du&&pc(e,t)?(e=fc(),fl=au=Et=null,vn=!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=ks(n)}}function gc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wc(){for(var e=window,t=Sl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Sl(e.document)}return t}function pu(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 xm(e){var t=wc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&gc(n.ownerDocument.documentElement,n)){if(r!==null&&pu(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,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Es(n,o);var i=Es(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.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,yn=null,mi=null,dr=null,hi=!1;function Cs(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hi||yn==null||yn!==Sl(r)||(r=yn,"selectionStart"in r&&pu(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}),dr&&Cr(dr,r)||(dr=r,r=Tl(mi,"onSelect"),0Sn||(e.current=xi[Sn],xi[Sn]=null,Sn--)}function B(e,t){Sn++,xi[Sn]=e.current,e.current=t}var Mt={},ce=$t(Mt),Se=$t(!1),Zt=Mt;function Mn(e,t){var n=e.type.contextTypes;if(!n)return Mt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function Ll(){V(Se),V(ce)}function Os(e,t,n){if(ce.current!==Mt)throw Error(x(168));B(ce,t),B(Se,n)}function jc(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(x(108,vp(e)||"Unknown",l));return X({},n,r)}function Rl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Mt,Zt=ce.current,B(ce,e),B(Se,Se.current),!0}function Ps(e,t,n){var r=e.stateNode;if(!r)throw Error(x(169));n?(e=jc(e,t,Zt),r.__reactInternalMemoizedMergedChildContext=e,V(Se),V(ce),B(ce,e)):V(Se),B(Se,n)}var nt=null,to=!1,Fo=!1;function Lc(e){nt===null?nt=[e]:nt.push(e)}function Fm(e){to=!0,Lc(e)}function It(){if(!Fo&&nt!==null){Fo=!0;var e=0,t=D;try{var n=nt;for(D=1;e>=i,l-=i,rt=1<<32-We(t)+l|n<j?(U=N,N=null):U=N.sibling;var P=d(p,N,v[j],S);if(P===null){N===null&&(N=U);break}e&&N&&P.alternate===null&&t(p,N),c=o(P,c,j),E===null?_=P:E.sibling=P,E=P,N=U}if(j===v.length)return n(p,N),Q&&At(p,j),_;if(N===null){for(;jj?(U=N,N=null):U=N.sibling;var ie=d(p,N,P.value,S);if(ie===null){N===null&&(N=U);break}e&&N&&ie.alternate===null&&t(p,N),c=o(ie,c,j),E===null?_=ie:E.sibling=ie,E=ie,N=U}if(P.done)return n(p,N),Q&&At(p,j),_;if(N===null){for(;!P.done;j++,P=v.next())P=h(p,P.value,S),P!==null&&(c=o(P,c,j),E===null?_=P:E.sibling=P,E=P);return Q&&At(p,j),_}for(N=r(p,N);!P.done;j++,P=v.next())P=w(N,p,j,P.value,S),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?j:P.key),c=o(P,c,j),E===null?_=P:E.sibling=P,E=P);return e&&N.forEach(function(Ke){return t(p,Ke)}),Q&&At(p,j),_}function L(p,c,v,S){if(typeof v=="object"&&v!==null&&v.type===hn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Vr:e:{for(var _=v.key,E=c;E!==null;){if(E.key===_){if(_=v.type,_===hn){if(E.tag===7){n(p,E.sibling),c=l(E,v.props.children),c.return=p,p=c;break e}}else if(E.elementType===_||typeof _=="object"&&_!==null&&_.$$typeof===gt&&As(_)===E.type){n(p,E.sibling),c=l(E,v.props),c.ref=er(p,E,v),c.return=p,p=c;break e}n(p,E);break}else t(p,E);E=E.sibling}v.type===hn?(c=Yt(v.props.children,p.mode,S,v.key),c.return=p,p=c):(S=wl(v.type,v.key,v.props,null,p.mode,S),S.ref=er(p,c,v),S.return=p,p=S)}return i(p);case mn:e:{for(E=v.key;c!==null;){if(c.key===E)if(c.tag===4&&c.stateNode.containerInfo===v.containerInfo&&c.stateNode.implementation===v.implementation){n(p,c.sibling),c=l(c,v.children||[]),c.return=p,p=c;break e}else{n(p,c);break}else t(p,c);c=c.sibling}c=Bo(v,p.mode,S),c.return=p,p=c}return i(p);case gt:return E=v._init,L(p,c,E(v._payload),S)}if(lr(v))return g(p,c,v,S);if(Xn(v))return k(p,c,v,S);tl(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,c!==null&&c.tag===6?(n(p,c.sibling),c=l(c,v),c.return=p,p=c):(n(p,c),c=Uo(v,p.mode,S),c.return=p,p=c),i(p)):n(p,c)}return L}var $n=Ic(!0),Dc=Ic(!1),Ar={},be=$t(Ar),jr=$t(Ar),Lr=$t(Ar);function Kt(e){if(e===Ar)throw Error(x(174));return e}function ku(e,t){switch(B(Lr,t),B(jr,e),B(be,Ar),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:li(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=li(t,e)}V(be),B(be,t)}function In(){V(be),V(jr),V(Lr)}function Ac(e){Kt(Lr.current);var t=Kt(be.current),n=li(t,e.type);t!==n&&(B(jr,e),B(be,n))}function Eu(e){jr.current===e&&(V(be),V(jr))}var G=$t(0);function $l(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Mo=[];function Cu(){for(var e=0;en?n:4,e(!0);var r=zo.transition;zo.transition={};try{e(!1),t()}finally{D=n,zo.transition=r}}function tf(){return De().memoizedState}function Im(e,t,n){var r=Ot(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},nf(e))rf(t,n);else if(n=Fc(e,t,n,r),n!==null){var l=me();Ve(n,e,r,l),lf(n,t,r)}}function Dm(e,t,n){var r=Ot(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(nf(e))rf(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,u=o(i,n);if(l.hasEagerState=!0,l.eagerState=u,Qe(u,i)){var s=t.interleaved;s===null?(l.next=l,Su(t)):(l.next=s.next,s.next=l),t.interleaved=l;return}}catch{}finally{}n=Fc(e,t,l,r),n!==null&&(l=me(),Ve(n,e,r,l),lf(n,t,r))}}function nf(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function rf(e,t){pr=Il=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function lf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,iu(e,n)}}var Dl={readContext:Ie,useCallback:ue,useContext:ue,useEffect:ue,useImperativeHandle:ue,useInsertionEffect:ue,useLayoutEffect:ue,useMemo:ue,useReducer:ue,useRef:ue,useState:ue,useDebugValue:ue,useDeferredValue:ue,useTransition:ue,useMutableSource:ue,useSyncExternalStore:ue,useId:ue,unstable_isNewReconciler:!1},Am={readContext:Ie,useCallback:function(e,t){return Ze().memoizedState=[e,t===void 0?null:t],e},useContext:Ie,useEffect:Bs,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,hl(4194308,4,Zc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return hl(4194308,4,e,t)},useInsertionEffect:function(e,t){return hl(4,2,e,t)},useMemo:function(e,t){var n=Ze();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ze();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=Im.bind(null,Y,e),[r.memoizedState,e]},useRef:function(e){var t=Ze();return e={current:e},t.memoizedState=e},useState:Us,useDebugValue:Lu,useDeferredValue:function(e){return Ze().memoizedState=e},useTransition:function(){var e=Us(!1),t=e[0];return e=$m.bind(null,e[1]),Ze().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Y,l=Ze();if(Q){if(n===void 0)throw Error(x(407));n=n()}else{if(n=t(),ne===null)throw Error(x(349));qt&30||Hc(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Bs(Vc.bind(null,r,o,e),[e]),r.flags|=2048,Pr(9,Wc.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Ze(),t=ne.identifierPrefix;if(Q){var n=lt,r=rt;n=(r&~(1<<32-We(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Rr++,0")&&(s=s.replace("",e.displayName)),s}while(1<=i&&0<=u);break}}}finally{go=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?rr(e):""}function vp(e){switch(e.tag){case 5:return rr(e.type);case 16:return rr("Lazy");case 13:return rr("Suspense");case 19:return rr("SuspenseList");case 0:case 2:case 15:return e=wo(e.type,!1),e;case 11:return e=wo(e.type.render,!1),e;case 1:return e=wo(e.type,!0),e;default:return""}}function bo(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 hn:return"Fragment";case mn:return"Portal";case Zo:return"Profiler";case tu:return"StrictMode";case Jo:return"Suspense";case qo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Da:return(e.displayName||"Context")+".Consumer";case Ia:return(e._context.displayName||"Context")+".Provider";case nu:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ru:return t=e.displayName||null,t!==null?t:bo(e.type)||"Memo";case gt:t=e._payload,e=e._init;try{return bo(e(t))}catch{}}return null}function yp(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 bo(t);case 8:return t===tu?"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 Ft(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ua(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function gp(e){var t=Ua(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,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Qr(e){e._valueTracker||(e._valueTracker=gp(e))}function Ba(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ua(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Sl(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 ei(e,t){var n=t.checked;return X({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function os(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ft(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 Ha(e,t){t=t.checked,t!=null&&eu(e,"checked",t,!1)}function ti(e,t){Ha(e,t);var n=Ft(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")?ni(e,t.type,n):t.hasOwnProperty("defaultValue")&&ni(e,t.type,Ft(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function is(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 ni(e,t,n){(t!=="number"||Sl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var lr=Array.isArray;function _n(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Kr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function gr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var sr={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},wp=["Webkit","ms","Moz","O"];Object.keys(sr).forEach(function(e){wp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),sr[t]=sr[e]})});function Ka(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||sr.hasOwnProperty(e)&&sr[e]?(""+t).trim():t+"px"}function Ga(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=Ka(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Sp=X({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 oi(e,t){if(t){if(Sp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(x(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(x(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(x(61))}if(t.style!=null&&typeof t.style!="object")throw Error(x(62))}}function ii(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 ui=null;function lu(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var si=null,jn=null,Ln=null;function as(e){if(e=Dr(e)){if(typeof si!="function")throw Error(x(280));var t=e.stateNode;t&&(t=eo(t),si(e.stateNode,e.type,t))}}function Ya(e){jn?Ln?Ln.push(e):Ln=[e]:jn=e}function Xa(){if(jn){var e=jn,t=Ln;if(Ln=jn=null,as(e),t)for(e=0;e>>=0,e===0?32:31-(Op(e)/Pp|0)|0}var Gr=64,Yr=4194304;function or(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 Cl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var u=i&~l;u!==0?r=or(u):(o&=i,o!==0&&(r=or(o)))}else i=n&~l,i!==0?r=or(i):o!==0&&(r=or(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&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 zr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ve(t),e[t]=n}function zp(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=cr),gs=String.fromCharCode(32),ws=!1;function hc(e,t){switch(e){case"keyup":return cm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vn=!1;function dm(e,t){switch(e){case"compositionend":return vc(t);case"keypress":return t.which!==32?null:(ws=!0,gs);case"textInput":return e=t.data,e===gs&&ws?null:e;default:return null}}function pm(e,t){if(vn)return e==="compositionend"||!du&&hc(e,t)?(e=pc(),fl=au=kt=null,vn=!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=ks(n)}}function Sc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Sc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xc(){for(var e=window,t=Sl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Sl(e.document)}return t}function pu(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 Em(e){var t=xc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Sc(n.ownerDocument.documentElement,n)){if(r!==null&&pu(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,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Cs(n,o);var i=Cs(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.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,yn=null,mi=null,dr=null,hi=!1;function Ns(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;hi||yn==null||yn!==Sl(r)||(r=yn,"selectionStart"in r&&pu(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}),dr&&Cr(dr,r)||(dr=r,r=_l(mi,"onSelect"),0Sn||(e.current=xi[Sn],xi[Sn]=null,Sn--)}function B(e,t){Sn++,xi[Sn]=e.current,e.current=t}var Mt={},ce=zt(Mt),Se=zt(!1),Zt=Mt;function Mn(e,t){var n=e.type.contextTypes;if(!n)return Mt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function Ll(){W(Se),W(ce)}function Ps(e,t,n){if(ce.current!==Mt)throw Error(x(168));B(ce,t),B(Se,n)}function Rc(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(x(108,yp(e)||"Unknown",l));return X({},n,r)}function Rl(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Mt,Zt=ce.current,B(ce,e),B(Se,Se.current),!0}function Fs(e,t,n){var r=e.stateNode;if(!r)throw Error(x(169));n?(e=Rc(e,t,Zt),r.__reactInternalMemoizedMergedChildContext=e,W(Se),W(ce),B(ce,e)):W(Se),B(Se,n)}var rt=null,to=!1,Fo=!1;function Oc(e){rt===null?rt=[e]:rt.push(e)}function Mm(e){to=!0,Oc(e)}function It(){if(!Fo&&rt!==null){Fo=!0;var e=0,t=D;try{var n=rt;for(D=1;e>=i,l-=i,lt=1<<32-Ve(t)+l|n<j?(U=N,N=null):U=N.sibling;var P=d(p,N,v[j],S);if(P===null){N===null&&(N=U);break}e&&N&&P.alternate===null&&t(p,N),c=o(P,c,j),k===null?T=P:k.sibling=P,k=P,N=U}if(j===v.length)return n(p,N),Q&&At(p,j),T;if(N===null){for(;jj?(U=N,N=null):U=N.sibling;var ie=d(p,N,P.value,S);if(ie===null){N===null&&(N=U);break}e&&N&&ie.alternate===null&&t(p,N),c=o(ie,c,j),k===null?T=ie:k.sibling=ie,k=ie,N=U}if(P.done)return n(p,N),Q&&At(p,j),T;if(N===null){for(;!P.done;j++,P=v.next())P=h(p,P.value,S),P!==null&&(c=o(P,c,j),k===null?T=P:k.sibling=P,k=P);return Q&&At(p,j),T}for(N=r(p,N);!P.done;j++,P=v.next())P=g(N,p,j,P.value,S),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?j:P.key),c=o(P,c,j),k===null?T=P:k.sibling=P,k=P);return e&&N.forEach(function(Ke){return t(p,Ke)}),Q&&At(p,j),T}function L(p,c,v,S){if(typeof v=="object"&&v!==null&&v.type===hn&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Wr:e:{for(var T=v.key,k=c;k!==null;){if(k.key===T){if(T=v.type,T===hn){if(k.tag===7){n(p,k.sibling),c=l(k,v.props.children),c.return=p,p=c;break e}}else if(k.elementType===T||typeof T=="object"&&T!==null&&T.$$typeof===gt&&Us(T)===k.type){n(p,k.sibling),c=l(k,v.props),c.ref=er(p,k,v),c.return=p,p=c;break e}n(p,k);break}else t(p,k);k=k.sibling}v.type===hn?(c=Yt(v.props.children,p.mode,S,v.key),c.return=p,p=c):(S=wl(v.type,v.key,v.props,null,p.mode,S),S.ref=er(p,c,v),S.return=p,p=S)}return i(p);case mn:e:{for(k=v.key;c!==null;){if(c.key===k)if(c.tag===4&&c.stateNode.containerInfo===v.containerInfo&&c.stateNode.implementation===v.implementation){n(p,c.sibling),c=l(c,v.children||[]),c.return=p,p=c;break e}else{n(p,c);break}else t(p,c);c=c.sibling}c=Bo(v,p.mode,S),c.return=p,p=c}return i(p);case gt:return k=v._init,L(p,c,k(v._payload),S)}if(lr(v))return w(p,c,v,S);if(Xn(v))return E(p,c,v,S);tl(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,c!==null&&c.tag===6?(n(p,c.sibling),c=l(c,v),c.return=p,p=c):(n(p,c),c=Uo(v,p.mode,S),c.return=p,p=c),i(p)):n(p,c)}return L}var zn=Ac(!0),Uc=Ac(!1),Ar={},be=zt(Ar),jr=zt(Ar),Lr=zt(Ar);function Kt(e){if(e===Ar)throw Error(x(174));return e}function Eu(e,t){switch(B(Lr,t),B(jr,e),B(be,Ar),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:li(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=li(t,e)}W(be),B(be,t)}function In(){W(be),W(jr),W(Lr)}function Bc(e){Kt(Lr.current);var t=Kt(be.current),n=li(t,e.type);t!==n&&(B(jr,e),B(be,n))}function ku(e){jr.current===e&&(W(be),W(jr))}var G=zt(0);function zl(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Mo=[];function Cu(){for(var e=0;en?n:4,e(!0);var r=$o.transition;$o.transition={};try{e(!1),t()}finally{D=n,$o.transition=r}}function rf(){return De().memoizedState}function Dm(e,t,n){var r=Ot(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},lf(e))of(t,n);else if(n=$c(e,t,n,r),n!==null){var l=me();We(n,e,r,l),uf(n,t,r)}}function Am(e,t,n){var r=Ot(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(lf(e))of(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,u=o(i,n);if(l.hasEagerState=!0,l.eagerState=u,Qe(u,i)){var s=t.interleaved;s===null?(l.next=l,Su(t)):(l.next=s.next,s.next=l),t.interleaved=l;return}}catch{}finally{}n=$c(e,t,l,r),n!==null&&(l=me(),We(n,e,r,l),uf(n,t,r))}}function lf(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function of(e,t){pr=Il=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function uf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,iu(e,n)}}var Dl={readContext:Ie,useCallback:ue,useContext:ue,useEffect:ue,useImperativeHandle:ue,useInsertionEffect:ue,useLayoutEffect:ue,useMemo:ue,useReducer:ue,useRef:ue,useState:ue,useDebugValue:ue,useDeferredValue:ue,useTransition:ue,useMutableSource:ue,useSyncExternalStore:ue,useId:ue,unstable_isNewReconciler:!1},Um={readContext:Ie,useCallback:function(e,t){return Ze().memoizedState=[e,t===void 0?null:t],e},useContext:Ie,useEffect:Hs,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,hl(4194308,4,qc.bind(null,t,e),n)},useLayoutEffect:function(e,t){return hl(4194308,4,e,t)},useInsertionEffect:function(e,t){return hl(4,2,e,t)},useMemo:function(e,t){var n=Ze();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ze();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=Dm.bind(null,Y,e),[r.memoizedState,e]},useRef:function(e){var t=Ze();return e={current:e},t.memoizedState=e},useState:Bs,useDebugValue:Lu,useDeferredValue:function(e){return Ze().memoizedState=e},useTransition:function(){var e=Bs(!1),t=e[0];return e=Im.bind(null,e[1]),Ze().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Y,l=Ze();if(Q){if(n===void 0)throw Error(x(407));n=n()}else{if(n=t(),ne===null)throw Error(x(349));qt&30||Wc(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Hs(Kc.bind(null,r,o,e),[e]),r.flags|=2048,Pr(9,Qc.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Ze(),t=ne.identifierPrefix;if(Q){var n=ot,r=lt;n=(r&~(1<<32-Ve(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Rr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Je]=t,e[Tr]=r,mf(e,t,!1,!1),t.stateNode=e;e:{switch(i=ii(n,r),n){case"dialog":W("cancel",e),W("close",e),l=r;break;case"iframe":case"object":case"embed":W("load",e),l=r;break;case"video":case"audio":for(l=0;lAn&&(t.flags|=128,r=!0,tr(o,!1),t.lanes=4194304)}else{if(!r)if(e=$l(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),tr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Q)return se(t),null}else 2*J()-o.renderingStartTime>An&&n!==1073741824&&(t.flags|=128,r=!0,tr(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=J(),t.sibling=null,n=G.current,B(G,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return zu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ee&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(x(156,t.tag))}function Gm(e,t){switch(hu(t),t.tag){case 1:return xe(t.type)&&Ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return In(),V(Se),V(ce),Cu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Eu(t),null;case 13:if(V(G),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(x(340));zn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(G),null;case 4:return In(),null;case 10:return wu(t.type._context),null;case 22:case 23:return zu(),null;case 24:return null;default:return null}}var rl=!1,ae=!1,Ym=typeof WeakSet=="function"?WeakSet:Set,T=null;function Cn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Z(e,t,r)}else n.current=null}function Fi(e,t,n){try{n()}catch(r){Z(e,t,r)}}var Zs=!1;function Xm(e,t){if(vi=Nl,e=wc(),pu(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,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,u=-1,s=-1,a=0,m=0,h=e,d=null;t:for(;;){for(var w;h!==n||l!==0&&h.nodeType!==3||(u=i+l),h!==o||r!==0&&h.nodeType!==3||(s=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(w=h.firstChild)!==null;)d=h,h=w;for(;;){if(h===e)break t;if(d===n&&++a===l&&(u=i),d===o&&++m===r&&(s=i),(w=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=w}n=u===-1||s===-1?null:{start:u,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(yi={focusedElem:e,selectionRange:n},Nl=!1,T=t;T!==null;)if(t=T,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,T=e;else for(;T!==null;){t=T;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var k=g.memoizedProps,L=g.memoizedState,p=t.stateNode,c=p.getSnapshotBeforeUpdate(t.elementType===t.type?k:Ue(t.type,k),L);p.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(S){Z(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,T=e;break}T=t.return}return g=Zs,Zs=!1,g}function mr(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 o=l.destroy;l.destroy=void 0,o!==void 0&&Fi(t,n,o)}l=l.next}while(l!==r)}}function lo(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 Mi(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 yf(e){var t=e.alternate;t!==null&&(e.alternate=null,yf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Je],delete t[Tr],delete t[Si],delete t[Om],delete t[Pm])),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 gf(e){return e.tag===5||e.tag===3||e.tag===4}function Js(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||gf(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 zi(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=jl));else if(r!==4&&(e=e.child,e!==null))for(zi(e,t,n),e=e.sibling;e!==null;)zi(e,t,n),e=e.sibling}function $i(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($i(e,t,n),e=e.sibling;e!==null;)$i(e,t,n),e=e.sibling}var re=null,Be=!1;function ht(e,t,n){for(n=n.child;n!==null;)wf(e,t,n),n=n.sibling}function wf(e,t,n){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Zl,n)}catch{}switch(n.tag){case 5:ae||Cn(n,t);case 6:var r=re,l=Be;re=null,ht(e,t,n),re=r,Be=l,re!==null&&(Be?(e=re,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):re.removeChild(n.stateNode));break;case 18:re!==null&&(Be?(e=re,n=n.stateNode,e.nodeType===8?Po(e.parentNode,n):e.nodeType===1&&Po(e,n),kr(e)):Po(re,n.stateNode));break;case 4:r=re,l=Be,re=n.stateNode.containerInfo,Be=!0,ht(e,t,n),re=r,Be=l;break;case 0:case 11:case 14:case 15:if(!ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&Fi(n,t,i),l=l.next}while(l!==r)}ht(e,t,n);break;case 1:if(!ae&&(Cn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Z(n,t,u)}ht(e,t,n);break;case 21:ht(e,t,n);break;case 22:n.mode&1?(ae=(r=ae)||n.memoizedState!==null,ht(e,t,n),ae=r):ht(e,t,n);break;default:ht(e,t,n)}}function qs(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ym),t.forEach(function(r){var l=lh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ae(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=J()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Jm(r/1960))-r,10e?16:e,Ct===null)var r=!1;else{if(e=Ct,Ct=null,Bl=0,z&6)throw Error(x(331));var l=z;for(z|=4,T=e.current;T!==null;){var o=T,i=o.child;if(T.flags&16){var u=o.deletions;if(u!==null){for(var s=0;sJ()-Fu?Gt(e,0):Pu|=n),ke(e,t)}function Tf(e,t){t===0&&(e.mode&1?(t=Yr,Yr<<=1,!(Yr&130023424)&&(Yr=4194304)):t=1);var n=me();e=at(e,t),e!==null&&($r(e,t,n),ke(e,n))}function rh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tf(e,n)}function lh(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(x(314))}r!==null&&r.delete(t),Tf(e,n)}var jf;jf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Se.current)we=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return we=!1,Qm(e,t,n);we=!!(e.flags&131072)}else we=!1,Q&&t.flags&1048576&&Rc(t,Pl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;vl(e,t),e=t.pendingProps;var l=Mn(t,ce.current);On(t,n),l=_u(null,t,r,e,l,n);var o=Tu();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,xe(r)?(o=!0,Rl(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,xu(t),l.updater=no,t.stateNode=l,l._reactInternals=t,_i(t,r,e,n),t=Li(null,t,r,!0,o,n)):(t.tag=0,Q&&o&&mu(t),de(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(vl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=ih(r),e=Ue(r,e),l){case 0:t=ji(null,t,r,e,n);break e;case 1:t=Gs(null,t,r,e,n);break e;case 11:t=Qs(null,t,r,e,n);break e;case 14:t=Ks(null,t,r,Ue(r.type,e),n);break e}throw Error(x(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),ji(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),Gs(e,t,r,l,n);case 3:e:{if(ff(t),e===null)throw Error(x(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Mc(e,t),zl(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=Dn(Error(x(423)),t),t=Ys(e,t,r,n,l);break e}else if(r!==l){l=Dn(Error(x(424)),t),t=Ys(e,t,r,n,l);break e}else for(Ce=jt(t.stateNode.containerInfo.firstChild),Ne=t,Q=!0,He=null,n=Dc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(zn(),r===l){t=ct(e,t,n);break e}de(e,t,r,n)}t=t.child}return t;case 5:return Ac(t),e===null&&Ei(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,gi(r,l)?i=null:o!==null&&gi(r,o)&&(t.flags|=32),cf(e,t),de(e,t,i,n),t.child;case 6:return e===null&&Ei(t),null;case 13:return df(e,t,n);case 4:return ku(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$n(t,null,r,n):de(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),Qs(e,t,r,l,n);case 7:return de(e,t,t.pendingProps,n),t.child;case 8:return de(e,t,t.pendingProps.children,n),t.child;case 12:return de(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,B(Fl,r._currentValue),r._currentValue=i,o!==null)if(Qe(o.value,i)){if(o.children===l.children&&!Se.current){t=ct(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var u=o.dependencies;if(u!==null){i=o.child;for(var s=u.firstContext;s!==null;){if(s.context===r){if(o.tag===1){s=ot(-1,n&-n),s.tag=2;var a=o.updateQueue;if(a!==null){a=a.shared;var m=a.pending;m===null?s.next=s:(s.next=m.next,m.next=s),a.pending=s}}o.lanes|=n,s=o.alternate,s!==null&&(s.lanes|=n),Ci(o.return,n,t),u.lanes|=n;break}s=s.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(x(341));i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ci(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}de(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,On(t,n),l=Ie(l),r=r(l),t.flags|=1,de(e,t,r,n),t.child;case 14:return r=t.type,l=Ue(r,t.pendingProps),l=Ue(r.type,l),Ks(e,t,r,l,n);case 15:return sf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),vl(e,t),t.tag=1,xe(r)?(e=!0,Rl(t)):e=!1,On(t,n),$c(t,r,l),_i(t,r,l,n),Li(null,t,r,!0,e,n);case 19:return pf(e,t,n);case 22:return af(e,t,n)}throw Error(x(156,t.tag))};function Lf(e,t){return ec(e,t)}function oh(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 ze(e,t,n,r){return new oh(e,t,n,r)}function Iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ih(e){if(typeof e=="function")return Iu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===nu)return 11;if(e===ru)return 14}return 2}function Pt(e,t){var n=e.alternate;return n===null?(n=ze(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 wl(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")Iu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case hn:return Yt(n.children,l,o,t);case tu:i=8,l|=8;break;case Zo:return e=ze(12,n,t,l|2),e.elementType=Zo,e.lanes=o,e;case Jo:return e=ze(13,n,t,l),e.elementType=Jo,e.lanes=o,e;case qo:return e=ze(19,n,t,l),e.elementType=qo,e.lanes=o,e;case Ia:return io(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case za:i=10;break e;case $a:i=9;break e;case nu:i=11;break e;case ru:i=14;break e;case gt:i=16,r=null;break e}throw Error(x(130,e==null?e:typeof e,""))}return t=ze(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Yt(e,t,n,r){return e=ze(7,e,r,t),e.lanes=n,e}function io(e,t,n,r){return e=ze(22,e,r,t),e.elementType=Ia,e.lanes=n,e.stateNode={isHidden:!1},e}function Uo(e,t,n){return e=ze(6,e,null,t),e.lanes=n,e}function Bo(e,t,n){return t=ze(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function uh(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=xo(0),this.expirationTimes=xo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xo(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Du(e,t,n,r,l,o,i,u,s){return e=new uh(e,t,n,u,s),t===1?(t=1,o===!0&&(t|=8)):t=0,o=ze(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},xu(o),e}function sh(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ff)}catch(e){console.error(e)}}Ff(),Ra.exports=Te;var Mf=Ra.exports;const _n=Yl(Mf);var ia=Mf;Yo.createRoot=ia.createRoot,Yo.hydrateRoot=ia.hydrateRoot;var zf={exports:{}};/*! +`+o.stack}return{value:e,source:t,stack:l,digest:null}}function Do(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function _i(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var Vm=typeof WeakMap=="function"?WeakMap:Map;function sf(e,t,n){n=it(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Ul||(Ul=!0,Ii=r),_i(e,t)},n}function af(e,t,n){n=it(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var l=t.value;n.payload=function(){return r(l)},n.callback=function(){_i(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){_i(e,t),typeof r!="function"&&(Rt===null?Rt=new Set([this]):Rt.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function Vs(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Vm;var l=new Set;r.set(t,l)}else l=r.get(t),l===void 0&&(l=new Set,r.set(t,l));l.has(n)||(l.add(n),e=rh.bind(null,e,t,n),t.then(e,e))}function Ws(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function Qs(e,t,n,r,l){return e.mode&1?(e.flags|=65536,e.lanes=l,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=it(-1,1),t.tag=2,Lt(n,t,1))),n.lanes|=1),e)}var Wm=pt.ReactCurrentOwner,we=!1;function de(e,t,n,r){t.child=e===null?Uc(t,null,n,r):zn(t,e.child,n,r)}function Ks(e,t,n,r,l){n=n.render;var o=t.ref;return On(t,l),r=Tu(e,t,n,r,o,l),n=_u(),e!==null&&!we?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,ft(e,t,l)):(Q&&n&&mu(t),t.flags|=1,de(e,t,r,l),t.child)}function Gs(e,t,n,r,l){if(e===null){var o=n.type;return typeof o=="function"&&!Iu(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,cf(e,t,o,r,l)):(e=wl(n.type,null,r,t,t.mode,l),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&l)){var i=o.memoizedProps;if(n=n.compare,n=n!==null?n:Cr,n(i,r)&&e.ref===t.ref)return ft(e,t,l)}return t.flags|=1,e=Pt(o,r),e.ref=t.ref,e.return=t,t.child=e}function cf(e,t,n,r,l){if(e!==null){var o=e.memoizedProps;if(Cr(o,r)&&e.ref===t.ref)if(we=!1,t.pendingProps=r=o,(e.lanes&l)!==0)e.flags&131072&&(we=!0);else return t.lanes=e.lanes,ft(e,t,l)}return ji(e,t,n,r,l)}function ff(e,t,n){var r=t.pendingProps,l=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},B(Nn,ke),ke|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,B(Nn,ke),ke|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,B(Nn,ke),ke|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,B(Nn,ke),ke|=r;return de(e,t,l,n),t.child}function df(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ji(e,t,n,r,l){var o=xe(n)?Zt:ce.current;return o=Mn(t,o),On(t,l),n=Tu(e,t,n,r,o,l),r=_u(),e!==null&&!we?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~l,ft(e,t,l)):(Q&&r&&mu(t),t.flags|=1,de(e,t,n,l),t.child)}function Ys(e,t,n,r,l){if(xe(n)){var o=!0;Rl(t)}else o=!1;if(On(t,l),t.stateNode===null)vl(e,t),Dc(t,n,r),Ti(t,n,r,l),r=!0;else if(e===null){var i=t.stateNode,u=t.memoizedProps;i.props=u;var s=i.context,a=n.contextType;typeof a=="object"&&a!==null?a=Ie(a):(a=xe(n)?Zt:ce.current,a=Mn(t,a));var m=n.getDerivedStateFromProps,h=typeof m=="function"||typeof i.getSnapshotBeforeUpdate=="function";h||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(u!==r||s!==a)&&As(t,i,r,a),wt=!1;var d=t.memoizedState;i.state=d,$l(t,r,i,l),s=t.memoizedState,u!==r||d!==s||Se.current||wt?(typeof m=="function"&&(Ni(t,n,m,r),s=t.memoizedState),(u=wt||Ds(t,n,u,r,d,s,a))?(h||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=s),i.props=r,i.state=s,i.context=a,r=u):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,zc(e,t),u=t.memoizedProps,a=t.type===t.elementType?u:Ue(t.type,u),i.props=a,h=t.pendingProps,d=i.context,s=n.contextType,typeof s=="object"&&s!==null?s=Ie(s):(s=xe(n)?Zt:ce.current,s=Mn(t,s));var g=n.getDerivedStateFromProps;(m=typeof g=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(u!==h||d!==s)&&As(t,i,r,s),wt=!1,d=t.memoizedState,i.state=d,$l(t,r,i,l);var w=t.memoizedState;u!==h||d!==w||Se.current||wt?(typeof g=="function"&&(Ni(t,n,g,r),w=t.memoizedState),(a=wt||Ds(t,n,a,r,d,w,s)||!1)?(m||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,w,s),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,w,s)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||u===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=w),i.props=r,i.state=w,i.context=s,r=a):(typeof i.componentDidUpdate!="function"||u===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||u===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return Li(e,t,n,r,o,l)}function Li(e,t,n,r,l,o){df(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return l&&Fs(t,n,!1),ft(e,t,o);r=t.stateNode,Wm.current=t;var u=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=zn(t,e.child,null,o),t.child=zn(t,null,u,o)):de(e,t,u,o),t.memoizedState=r.state,l&&Fs(t,n,!0),t.child}function pf(e){var t=e.stateNode;t.pendingContext?Ps(e,t.pendingContext,t.pendingContext!==t.context):t.context&&Ps(e,t.context,!1),Eu(e,t.containerInfo)}function Xs(e,t,n,r,l){return $n(),vu(l),t.flags|=256,de(e,t,n,r),t.child}var Ri={dehydrated:null,treeContext:null,retryLane:0};function Oi(e){return{baseLanes:e,cachePool:null,transitions:null}}function mf(e,t,n){var r=t.pendingProps,l=G.current,o=!1,i=(t.flags&128)!==0,u;if((u=i)||(u=e!==null&&e.memoizedState===null?!1:(l&2)!==0),u?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(l|=1),B(G,l&1),e===null)return ki(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,o?(r=t.mode,o=t.child,i={mode:"hidden",children:i},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=i):o=io(i,r,0,null),e=Yt(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Oi(n),t.memoizedState=Ri,e):Ru(t,i));if(l=e.memoizedState,l!==null&&(u=l.dehydrated,u!==null))return Qm(e,t,i,r,u,l,n);if(o){o=r.fallback,i=t.mode,l=e.child,u=l.sibling;var s={mode:"hidden",children:r.children};return!(i&1)&&t.child!==l?(r=t.child,r.childLanes=0,r.pendingProps=s,t.deletions=null):(r=Pt(l,s),r.subtreeFlags=l.subtreeFlags&14680064),u!==null?o=Pt(u,o):(o=Yt(o,i,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,i=e.child.memoizedState,i=i===null?Oi(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},o.memoizedState=i,o.childLanes=e.childLanes&~n,t.memoizedState=Ri,r}return o=e.child,e=o.sibling,r=Pt(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Ru(e,t){return t=io({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function nl(e,t,n,r){return r!==null&&vu(r),zn(t,e.child,null,n),e=Ru(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Qm(e,t,n,r,l,o,i){if(n)return t.flags&256?(t.flags&=-257,r=Do(Error(x(422))),nl(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,l=t.mode,r=io({mode:"visible",children:r.children},l,0,null),o=Yt(o,l,i,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&zn(t,e.child,null,i),t.child.memoizedState=Oi(i),t.memoizedState=Ri,o);if(!(t.mode&1))return nl(e,t,i,null);if(l.data==="$!"){if(r=l.nextSibling&&l.nextSibling.dataset,r)var u=r.dgst;return r=u,o=Error(x(419)),r=Do(o,r,void 0),nl(e,t,i,r)}if(u=(i&e.childLanes)!==0,we||u){if(r=ne,r!==null){switch(i&-i){case 4:l=2;break;case 16:l=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:l=32;break;case 536870912:l=268435456;break;default:l=0}l=l&(r.suspendedLanes|i)?0:l,l!==0&&l!==o.retryLane&&(o.retryLane=l,ct(e,l),We(r,e,l,-1))}return zu(),r=Do(Error(x(421))),nl(e,t,i,r)}return l.data==="$?"?(t.flags|=128,t.child=e.child,t=lh.bind(null,e),l._reactRetry=t,null):(e=o.treeContext,Ce=jt(l.nextSibling),Ne=t,Q=!0,He=null,e!==null&&(Pe[Fe++]=lt,Pe[Fe++]=ot,Pe[Fe++]=Jt,lt=e.id,ot=e.overflow,Jt=t),t=Ru(t,r.children),t.flags|=4096,t)}function Zs(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Ci(e.return,t,n)}function Ao(e,t,n,r,l){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:l}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=l)}function hf(e,t,n){var r=t.pendingProps,l=r.revealOrder,o=r.tail;if(de(e,t,r.children,n),r=G.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Zs(e,n,t);else if(e.tag===19)Zs(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(B(G,r),!(t.mode&1))t.memoizedState=null;else switch(l){case"forwards":for(n=t.child,l=null;n!==null;)e=n.alternate,e!==null&&zl(e)===null&&(l=n),n=n.sibling;n=l,n===null?(l=t.child,t.child=null):(l=n.sibling,n.sibling=null),Ao(t,!1,l,n,o);break;case"backwards":for(n=null,l=t.child,t.child=null;l!==null;){if(e=l.alternate,e!==null&&zl(e)===null){t.child=l;break}e=l.sibling,l.sibling=n,n=l,l=e}Ao(t,!0,n,null,o);break;case"together":Ao(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function vl(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ft(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),bt|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(x(153));if(t.child!==null){for(e=t.child,n=Pt(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Pt(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Km(e,t,n){switch(t.tag){case 3:pf(t),$n();break;case 5:Bc(t);break;case 1:xe(t.type)&&Rl(t);break;case 4:Eu(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,l=t.memoizedProps.value;B(Fl,r._currentValue),r._currentValue=l;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(B(G,G.current&1),t.flags|=128,null):n&t.child.childLanes?mf(e,t,n):(B(G,G.current&1),e=ft(e,t,n),e!==null?e.sibling:null);B(G,G.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return hf(e,t,n);t.flags|=128}if(l=t.memoizedState,l!==null&&(l.rendering=null,l.tail=null,l.lastEffect=null),B(G,G.current),r)break;return null;case 22:case 23:return t.lanes=0,ff(e,t,n)}return ft(e,t,n)}var vf,Pi,yf,gf;vf=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Pi=function(){};yf=function(e,t,n,r){var l=e.memoizedProps;if(l!==r){e=t.stateNode,Kt(be.current);var o=null;switch(n){case"input":l=ei(e,l),r=ei(e,r),o=[];break;case"select":l=X({},l,{value:void 0}),r=X({},r,{value:void 0}),o=[];break;case"textarea":l=ri(e,l),r=ri(e,r),o=[];break;default:typeof l.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=jl)}oi(n,r);var i;n=null;for(a in l)if(!r.hasOwnProperty(a)&&l.hasOwnProperty(a)&&l[a]!=null)if(a==="style"){var u=l[a];for(i in u)u.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else a!=="dangerouslySetInnerHTML"&&a!=="children"&&a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(yr.hasOwnProperty(a)?o||(o=[]):(o=o||[]).push(a,null));for(a in r){var s=r[a];if(u=l!=null?l[a]:void 0,r.hasOwnProperty(a)&&s!==u&&(s!=null||u!=null))if(a==="style")if(u){for(i in u)!u.hasOwnProperty(i)||s&&s.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in s)s.hasOwnProperty(i)&&u[i]!==s[i]&&(n||(n={}),n[i]=s[i])}else n||(o||(o=[]),o.push(a,n)),n=s;else a==="dangerouslySetInnerHTML"?(s=s?s.__html:void 0,u=u?u.__html:void 0,s!=null&&u!==s&&(o=o||[]).push(a,s)):a==="children"?typeof s!="string"&&typeof s!="number"||(o=o||[]).push(a,""+s):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&(yr.hasOwnProperty(a)?(s!=null&&a==="onScroll"&&V("scroll",e),o||u===s||(o=[])):(o=o||[]).push(a,s))}n&&(o=o||[]).push("style",n);var a=o;(t.updateQueue=a)&&(t.flags|=4)}};gf=function(e,t,n,r){n!==r&&(t.flags|=4)};function tr(e,t){if(!Q)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function se(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags&14680064,r|=l.flags&14680064,l.return=e,l=l.sibling;else for(l=e.child;l!==null;)n|=l.lanes|l.childLanes,r|=l.subtreeFlags,r|=l.flags,l.return=e,l=l.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Gm(e,t,n){var r=t.pendingProps;switch(hu(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return se(t),null;case 1:return xe(t.type)&&Ll(),se(t),null;case 3:return r=t.stateNode,In(),W(Se),W(ce),Cu(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(el(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,He!==null&&(Ui(He),He=null))),Pi(e,t),se(t),null;case 5:ku(t);var l=Kt(Lr.current);if(n=t.type,e!==null&&t.stateNode!=null)yf(e,t,n,r,l),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(x(166));return se(t),null}if(e=Kt(be.current),el(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Je]=t,r[_r]=o,e=(t.mode&1)!==0,n){case"dialog":V("cancel",r),V("close",r);break;case"iframe":case"object":case"embed":V("load",r);break;case"video":case"audio":for(l=0;l<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Je]=t,e[_r]=r,vf(e,t,!1,!1),t.stateNode=e;e:{switch(i=ii(n,r),n){case"dialog":V("cancel",e),V("close",e),l=r;break;case"iframe":case"object":case"embed":V("load",e),l=r;break;case"video":case"audio":for(l=0;lAn&&(t.flags|=128,r=!0,tr(o,!1),t.lanes=4194304)}else{if(!r)if(e=zl(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),tr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Q)return se(t),null}else 2*J()-o.renderingStartTime>An&&n!==1073741824&&(t.flags|=128,r=!0,tr(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=J(),t.sibling=null,n=G.current,B(G,r?n&1|2:n&1),t):(se(t),null);case 22:case 23:return $u(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ke&1073741824&&(se(t),t.subtreeFlags&6&&(t.flags|=8192)):se(t),null;case 24:return null;case 25:return null}throw Error(x(156,t.tag))}function Ym(e,t){switch(hu(t),t.tag){case 1:return xe(t.type)&&Ll(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return In(),W(Se),W(ce),Cu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ku(t),null;case 13:if(W(G),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(x(340));$n()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(G),null;case 4:return In(),null;case 10:return wu(t.type._context),null;case 22:case 23:return $u(),null;case 24:return null;default:return null}}var rl=!1,ae=!1,Xm=typeof WeakSet=="function"?WeakSet:Set,_=null;function Cn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Z(e,t,r)}else n.current=null}function Fi(e,t,n){try{n()}catch(r){Z(e,t,r)}}var Js=!1;function Zm(e,t){if(vi=Nl,e=xc(),pu(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,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,u=-1,s=-1,a=0,m=0,h=e,d=null;t:for(;;){for(var g;h!==n||l!==0&&h.nodeType!==3||(u=i+l),h!==o||r!==0&&h.nodeType!==3||(s=i+r),h.nodeType===3&&(i+=h.nodeValue.length),(g=h.firstChild)!==null;)d=h,h=g;for(;;){if(h===e)break t;if(d===n&&++a===l&&(u=i),d===o&&++m===r&&(s=i),(g=h.nextSibling)!==null)break;h=d,d=h.parentNode}h=g}n=u===-1||s===-1?null:{start:u,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(yi={focusedElem:e,selectionRange:n},Nl=!1,_=t;_!==null;)if(t=_,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,_=e;else for(;_!==null;){t=_;try{var w=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(w!==null){var E=w.memoizedProps,L=w.memoizedState,p=t.stateNode,c=p.getSnapshotBeforeUpdate(t.elementType===t.type?E:Ue(t.type,E),L);p.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(x(163))}}catch(S){Z(t,t.return,S)}if(e=t.sibling,e!==null){e.return=t.return,_=e;break}_=t.return}return w=Js,Js=!1,w}function mr(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 o=l.destroy;l.destroy=void 0,o!==void 0&&Fi(t,n,o)}l=l.next}while(l!==r)}}function lo(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 Mi(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 wf(e){var t=e.alternate;t!==null&&(e.alternate=null,wf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Je],delete t[_r],delete t[Si],delete t[Pm],delete t[Fm])),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 Sf(e){return e.tag===5||e.tag===3||e.tag===4}function qs(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Sf(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 $i(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=jl));else if(r!==4&&(e=e.child,e!==null))for($i(e,t,n),e=e.sibling;e!==null;)$i(e,t,n),e=e.sibling}function zi(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(zi(e,t,n),e=e.sibling;e!==null;)zi(e,t,n),e=e.sibling}var re=null,Be=!1;function vt(e,t,n){for(n=n.child;n!==null;)xf(e,t,n),n=n.sibling}function xf(e,t,n){if(qe&&typeof qe.onCommitFiberUnmount=="function")try{qe.onCommitFiberUnmount(Zl,n)}catch{}switch(n.tag){case 5:ae||Cn(n,t);case 6:var r=re,l=Be;re=null,vt(e,t,n),re=r,Be=l,re!==null&&(Be?(e=re,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):re.removeChild(n.stateNode));break;case 18:re!==null&&(Be?(e=re,n=n.stateNode,e.nodeType===8?Po(e.parentNode,n):e.nodeType===1&&Po(e,n),Er(e)):Po(re,n.stateNode));break;case 4:r=re,l=Be,re=n.stateNode.containerInfo,Be=!0,vt(e,t,n),re=r,Be=l;break;case 0:case 11:case 14:case 15:if(!ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&Fi(n,t,i),l=l.next}while(l!==r)}vt(e,t,n);break;case 1:if(!ae&&(Cn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(u){Z(n,t,u)}vt(e,t,n);break;case 21:vt(e,t,n);break;case 22:n.mode&1?(ae=(r=ae)||n.memoizedState!==null,vt(e,t,n),ae=r):vt(e,t,n);break;default:vt(e,t,n)}}function bs(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Xm),t.forEach(function(r){var l=oh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ae(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=J()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*qm(r/1960))-r,10e?16:e,Ct===null)var r=!1;else{if(e=Ct,Ct=null,Bl=0,$&6)throw Error(x(331));var l=$;for($|=4,_=e.current;_!==null;){var o=_,i=o.child;if(_.flags&16){var u=o.deletions;if(u!==null){for(var s=0;sJ()-Fu?Gt(e,0):Pu|=n),Ee(e,t)}function Lf(e,t){t===0&&(e.mode&1?(t=Yr,Yr<<=1,!(Yr&130023424)&&(Yr=4194304)):t=1);var n=me();e=ct(e,t),e!==null&&(zr(e,t,n),Ee(e,n))}function lh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Lf(e,n)}function oh(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(x(314))}r!==null&&r.delete(t),Lf(e,n)}var Rf;Rf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Se.current)we=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return we=!1,Km(e,t,n);we=!!(e.flags&131072)}else we=!1,Q&&t.flags&1048576&&Pc(t,Pl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;vl(e,t),e=t.pendingProps;var l=Mn(t,ce.current);On(t,n),l=Tu(null,t,r,e,l,n);var o=_u();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,xe(r)?(o=!0,Rl(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,xu(t),l.updater=no,t.stateNode=l,l._reactInternals=t,Ti(t,r,e,n),t=Li(null,t,r,!0,o,n)):(t.tag=0,Q&&o&&mu(t),de(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(vl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=uh(r),e=Ue(r,e),l){case 0:t=ji(null,t,r,e,n);break e;case 1:t=Ys(null,t,r,e,n);break e;case 11:t=Ks(null,t,r,e,n);break e;case 14:t=Gs(null,t,r,Ue(r.type,e),n);break e}throw Error(x(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),ji(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),Ys(e,t,r,l,n);case 3:e:{if(pf(t),e===null)throw Error(x(387));r=t.pendingProps,o=t.memoizedState,l=o.element,zc(e,t),$l(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=Dn(Error(x(423)),t),t=Xs(e,t,r,n,l);break e}else if(r!==l){l=Dn(Error(x(424)),t),t=Xs(e,t,r,n,l);break e}else for(Ce=jt(t.stateNode.containerInfo.firstChild),Ne=t,Q=!0,He=null,n=Uc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if($n(),r===l){t=ft(e,t,n);break e}de(e,t,r,n)}t=t.child}return t;case 5:return Bc(t),e===null&&ki(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,gi(r,l)?i=null:o!==null&&gi(r,o)&&(t.flags|=32),df(e,t),de(e,t,i,n),t.child;case 6:return e===null&&ki(t),null;case 13:return mf(e,t,n);case 4:return Eu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=zn(t,null,r,n):de(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),Ks(e,t,r,l,n);case 7:return de(e,t,t.pendingProps,n),t.child;case 8:return de(e,t,t.pendingProps.children,n),t.child;case 12:return de(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,B(Fl,r._currentValue),r._currentValue=i,o!==null)if(Qe(o.value,i)){if(o.children===l.children&&!Se.current){t=ft(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var u=o.dependencies;if(u!==null){i=o.child;for(var s=u.firstContext;s!==null;){if(s.context===r){if(o.tag===1){s=it(-1,n&-n),s.tag=2;var a=o.updateQueue;if(a!==null){a=a.shared;var m=a.pending;m===null?s.next=s:(s.next=m.next,m.next=s),a.pending=s}}o.lanes|=n,s=o.alternate,s!==null&&(s.lanes|=n),Ci(o.return,n,t),u.lanes|=n;break}s=s.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(x(341));i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),Ci(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}de(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,On(t,n),l=Ie(l),r=r(l),t.flags|=1,de(e,t,r,n),t.child;case 14:return r=t.type,l=Ue(r,t.pendingProps),l=Ue(r.type,l),Gs(e,t,r,l,n);case 15:return cf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),vl(e,t),t.tag=1,xe(r)?(e=!0,Rl(t)):e=!1,On(t,n),Dc(t,r,l),Ti(t,r,l,n),Li(null,t,r,!0,e,n);case 19:return hf(e,t,n);case 22:return ff(e,t,n)}throw Error(x(156,t.tag))};function Of(e,t){return nc(e,t)}function ih(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 $e(e,t,n,r){return new ih(e,t,n,r)}function Iu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function uh(e){if(typeof e=="function")return Iu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===nu)return 11;if(e===ru)return 14}return 2}function Pt(e,t){var n=e.alternate;return n===null?(n=$e(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 wl(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")Iu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case hn:return Yt(n.children,l,o,t);case tu:i=8,l|=8;break;case Zo:return e=$e(12,n,t,l|2),e.elementType=Zo,e.lanes=o,e;case Jo:return e=$e(13,n,t,l),e.elementType=Jo,e.lanes=o,e;case qo:return e=$e(19,n,t,l),e.elementType=qo,e.lanes=o,e;case Aa:return io(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Ia:i=10;break e;case Da:i=9;break e;case nu:i=11;break e;case ru:i=14;break e;case gt:i=16,r=null;break e}throw Error(x(130,e==null?e:typeof e,""))}return t=$e(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Yt(e,t,n,r){return e=$e(7,e,r,t),e.lanes=n,e}function io(e,t,n,r){return e=$e(22,e,r,t),e.elementType=Aa,e.lanes=n,e.stateNode={isHidden:!1},e}function Uo(e,t,n){return e=$e(6,e,null,t),e.lanes=n,e}function Bo(e,t,n){return t=$e(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function sh(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=xo(0),this.expirationTimes=xo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xo(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Du(e,t,n,r,l,o,i,u,s){return e=new sh(e,t,n,u,s),t===1?(t=1,o===!0&&(t|=8)):t=0,o=$e(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},xu(o),e}function ah(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE($f)}catch(e){console.error(e)}}$f(),Pa.exports=_e;var zf=Pa.exports;const Tn=Yl(zf);var ua=zf;Yo.createRoot=ua.createRoot,Yo.hydrateRoot=ua.hydrateRoot;var If={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function ua(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function mh(e){var t=hh(e,"string");return typeof t=="symbol"?t:String(t)}function hh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function vh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),d=1;d{o.target===e&&(l(),t(o))},n+r)}function Uh(e){e.offsetHeight}const ca=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Bh(e,t){const n=ca(e),r=ca(t);return l=>{n&&n(l),r&&r(l)}}function mo(e,t){return y.useMemo(()=>Bh(e,t),[e,t])}function Hh(e){return e&&"setState"in e?_n.findDOMNode(e):e??null}const Wh=Wt.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),d=mo(h,s),w=E=>{d(Hh(E))},g=E=>N=>{E&&h.current&&E(h.current,N)},k=y.useCallback(g(e),[e]),L=y.useCallback(g(t),[t]),p=y.useCallback(g(n),[n]),c=y.useCallback(g(r),[r]),v=y.useCallback(g(l),[l]),S=y.useCallback(g(o),[o]),_=y.useCallback(g(i),[i]);return f.jsx(zh,{ref:m,...a,onEnter:k,onEntered:p,onEntering:L,onExit:c,onExited:S,onExiting:v,addEndListener:_,nodeRef:h,children:typeof u=="function"?(E,N)=>u(E,{...N,ref:w}):Wt.cloneElement(u,{ref:w})})}),Vh=Wh;function Qh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function Me(e){const t=Qh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Qf=e=>y.forwardRef((t,n)=>f.jsx("div",{...t,ref:n,className:M(t.className,e)})),Kf=Qf("h4");Kf.displayName="DivStyledAsH4";const Gf=y.forwardRef(({className:e,bsPrefix:t,as:n=Kf,...r},l)=>(t=H(t,"alert-heading"),f.jsx(n,{ref:l,className:M(e,t),...r})));Gf.displayName="AlertHeading";const Kh=Gf;function Gh(){return y.useState(null)}function Yh(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Xh(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const Zh=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",Jh=typeof document<"u",fa=Jh||Zh?y.useLayoutEffect:y.useEffect,qh=["as","disabled"];function bh(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function ev(e){return!e||e.trim()==="#"}function Hu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=d=>{if((t||e==="a"&&ev(n))&&d.preventDefault(),t){d.stopPropagation();return}i==null||i(d)},h=d=>{d.key===" "&&(d.preventDefault(),m(d))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const tv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=bh(e,qh);const[o,{tagName:i}]=Hu(Object.assign({tagName:n,disabled:r},l));return f.jsx(i,Object.assign({},l,o,{ref:t}))});tv.displayName="Button";const nv=["onKeyDown"];function rv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function lv(e){return!e||e.trim()==="#"}const Yf=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=rv(e,nv);const[l]=Hu(Object.assign({tagName:"a"},r)),o=Me(i=>{l.onKeyDown(i),n==null||n(i)});return lv(r.href)||r.role==="button"?f.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):f.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});Yf.displayName="Anchor";const ov=Yf,Xf=y.forwardRef(({className:e,bsPrefix:t,as:n=ov,...r},l)=>(t=H(t,"alert-link"),f.jsx(n,{ref:l,className:M(e,t),...r})));Xf.displayName="AlertLink";const iv=Xf,uv={[St]:"show",[Ht]:"show"},Zf=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Uh(s),r==null||r(s,a)},[r]);return f.jsx(Vh,{ref:o,addEndListener:Ah,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,uv[s],n[s])})})});Zf.displayName="Fade";const Ql=Zf,sv={"aria-label":it.string,onClick:it.func,variant:it.oneOf(["white"])},Wu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>f.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Wu.displayName="CloseButton";Wu.propTypes=sv;const Jf=Wu,qf=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Ql,...d}=yh(e,{show:"onClose"}),w=H(n,"alert"),g=Me(p=>{a&&a(!1,p)}),k=h===!0?Ql:h,L=f.jsxs("div",{role:"alert",...k?void 0:d,ref:t,className:M(i,w,s&&`${w}-${s}`,m&&`${w}-dismissible`),children:[m&&f.jsx(Jf,{onClick:g,"aria-label":l,variant:o}),u]});return k?f.jsx(k,{unmountOnExit:!0,...d,ref:void 0,in:r,children:L}):r?L:null});qf.displayName="Alert";const da=Object.assign(qf,{Link:iv,Heading:Kh}),bf=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Hu({tagName:e,disabled:o,...u}),d=h;return f.jsx(d,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});bf.displayName="Button";const tn=bf;function av(e){const t=y.useRef(e);return t.current=e,t}function ed(e){const t=av(e);y.useEffect(()=>()=>t.current(),[])}function cv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function fv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function dv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=If(),o=Df(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,d;typeof a=="object"&&a!=null?{span:m,offset:h,order:d}=a:m=a;const w=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${w}`:`${t}${w}-${m}`),d!=null&&u.push(`order${w}-${d}`),h!=null&&u.push(`offset${w}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const td=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=dv(e);return f.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});td.displayName="Col";const Vu=td,nd=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return f.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});nd.displayName="Container";const pv=nd;var mv=Function.prototype.bind.call(Function.prototype.call,[].slice);function dn(e,t){return mv(e.querySelectorAll(t))}function pa(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const hv="data-rr-ui-";function vv(e){return`${hv}${e}`}const rd=y.createContext(Vn?window:void 0);rd.Provider;function Qu(){return y.useContext(rd)}const yv={type:it.string,tooltip:it.bool,as:it.elementType},Ku=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>f.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Ku.displayName="Feedback";Ku.propTypes=yv;const ld=Ku,gv=y.createContext({}),ft=gv,od=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(ft);return t=H(t,"form-check-input"),f.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});od.displayName="FormCheckInput";const id=od,ud=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-check-label"),f.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});ud.displayName="FormCheckLabel";const Gi=ud,sd=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:d,title:w="",type:g="checkbox",label:k,children:L,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:S}=y.useContext(ft),_=y.useMemo(()=>({controlId:e||S}),[S,e]),E=!L&&k!=null&&k!==!1||fv(L,Gi),N=f.jsx(id,{...c,type:g==="switch"?"checkbox":g,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return f.jsx(ft.Provider,{value:_,children:f.jsx("div",{style:d,className:M(h,E&&t,r&&`${t}-inline`,l&&`${t}-reverse`,g==="switch"&&n),children:L||f.jsxs(f.Fragment,{children:[N,E&&f.jsx(Gi,{title:w,children:k}),a&&f.jsx(ld,{type:m,tooltip:s,children:a})]})})})});sd.displayName="FormCheck";const Kl=Object.assign(sd,{Input:id,Label:Gi}),ad=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},d)=>{const{controlId:w}=y.useContext(ft);return e=H(e,"form-control"),f.jsx(m,{...h,type:t,size:r,ref:d,readOnly:a,id:l||w,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});ad.displayName="FormControl";const wv=Object.assign(ad,{Feedback:ld}),cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),f.jsx(n,{ref:l,className:M(e,t),...r})));cd.displayName="FormFloating";const Sv=cd,fd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return f.jsx(ft.Provider,{value:l,children:f.jsx(t,{...n,ref:r})})});fd.displayName="FormGroup";const dd=fd,pd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(ft);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?f.jsx(Vu,{ref:u,as:"label",className:m,htmlFor:o,...i}):f.jsx(e,{ref:u,className:m,htmlFor:o,...i})});pd.displayName="FormLabel";const xv=pd,md=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(ft);return e=H(e,"form-range"),f.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});md.displayName="FormRange";const kv=md,hd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(ft);return e=H(e,"form-select"),f.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});hd.displayName="FormSelect";const Ev=hd,vd=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),f.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));vd.displayName="FormText";const Cv=vd,yd=y.forwardRef((e,t)=>f.jsx(Kl,{...e,ref:t,type:"switch"}));yd.displayName="Switch";const Nv=Object.assign(yd,{Input:Kl.Input,Label:Kl.Label}),gd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),f.jsxs(dd,{ref:i,className:M(t,e),controlId:r,...o,children:[n,f.jsx("label",{htmlFor:r,children:l})]})));gd.displayName="FloatingLabel";const _v=gd,Tv={_ref:it.any,validated:it.bool,as:it.elementType},Gu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>f.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Gu.displayName="Form";Gu.propTypes=Tv;const pe=Object.assign(Gu,{Group:dd,Control:wv,Floating:Sv,Check:Kl,Switch:Nv,Label:xv,Text:Cv,Range:kv,Select:Ev,FloatingLabel:_v});var ul;function ma(e){if((!ul&&ul!==0||e)&&Vn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),ul=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return ul}function Wo(e){e===void 0&&(e=po());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function jv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const ha=vv("modal-open");class Lv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return jv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Xt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(ha,""),Xt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(ha),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=Lv,Vo=(e,t)=>Vn?e==null?(t||po()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function Rv(e,t){const n=Qu(),[r,l]=y.useState(()=>Vo(e,n==null?void 0:n.document));if(!r){const o=Vo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Vo(e);o!==r&&l(o)},[e,r]),r}function Ov({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=Me(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=mo(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Pv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=Me(t);return fa(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),fa(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Fv({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Pv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=mo(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function va(e,t,n){return e?f.jsx(e,Object.assign({},n)):t?f.jsx(Fv,Object.assign({},n,{transition:t})):f.jsx(Ov,Object.assign({},n))}function Mv(e){return e.code==="Escape"||e.keyCode===27}const zv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function $v(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Qo;function Iv(e){return Qo||(Qo=new Yu({ownerDocument:e==null?void 0:e.document})),Qo}function Dv(e){const t=Qu(),n=e||Iv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const wd=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:d,backdropTransition:w,runBackdropTransition:g,autoFocus:k=!0,enforceFocus:L=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:S=K=>f.jsx("div",Object.assign({},K)),manager:_,container:E,onShow:N,onHide:j=()=>{},onExit:U,onExited:P,onExiting:ie,onEnter:Ke,onEntering:Ge,onEntered:on}=e,Qn=$v(e,zv);const Le=Qu(),Ye=Rv(E),C=Dv(_),R=Yh(),O=Xh(n),[I,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Vn&&!O&&n&&(fe.current=Wo(Le==null?void 0:Le.document)),n&&I&&A(!1);const Re=Me(()=>{if(C.add(),sn.current=Vl(document,"keydown",ho),un.current=Vl(document,"focus",()=>setTimeout(Oe),!0),N&&N(),k){var K,Hr;const Yn=Wo((K=(Hr=C.dialog)==null?void 0:Hr.ownerDocument)!=null?K:Le==null?void 0:Le.document);C.dialog&&Yn&&!pa(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),et=Me(()=>{if(C.remove(),sn.current==null||sn.current(),un.current==null||un.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Re()},[n,Ye,Re]),y.useEffect(()=>{I&&et()},[I,et]),ed(()=>{et()});const Oe=Me(()=>{if(!L||!R()||!C.isTopModal())return;const K=Wo(Le==null?void 0:Le.document);C.dialog&&K&&!pa(C.dialog,K)&&C.dialog.focus()}),mt=Me(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),ho=Me(K=>{s&&Mv(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),un=y.useRef(),sn=y.useRef(),Kn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Br=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Qn,{style:o,className:l,tabIndex:-1});let Gn=v?v(Br):f.jsx("div",Object.assign({},Br,{children:y.cloneElement(i,{role:"document"})}));Gn=va(h,d,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:U,onExiting:ie,onExited:Kn,onEnter:Ke,onEntering:Ge,onEntered:on,children:Gn});let Dt=null;return u&&(Dt=S({ref:C.setBackdropRef,onClick:mt}),Dt=va(w,g,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:Dt})),f.jsx(f.Fragment,{children:_n.createPortal(f.jsxs(f.Fragment,{children:[Dt,Gn]}),Ye)})});wd.displayName="Modal";const Av=Object.assign(wd,{Manager:Yu});function Uv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Bv(e,t){e.classList?e.classList.add(t):Uv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function ya(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Hv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=ya(e.className,t):e.setAttribute("class",ya(e.className&&e.className.baseVal||"",t))}const pn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Wv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Xt(n,{[t]:`${parseFloat(Xt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Xt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Bv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Hv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Ko;function Vv(e){return Ko||(Ko=new Wv(e)),Ko}const Sd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),f.jsx(n,{ref:l,className:M(e,t),...r})));Sd.displayName="ModalBody";const Qv=Sd,Kv=y.createContext({onHide(){}}),xd=Kv,kd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return f.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:f.jsx("div",{className:M(`${e}-content`,n),children:i})})});kd.displayName="ModalDialog";const Ed=kd,Cd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),f.jsx(n,{ref:l,className:M(e,t),...r})));Cd.displayName="ModalFooter";const Gv=Cd,Yv=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(xd),s=Me(()=>{u==null||u.onHide(),r==null||r()});return f.jsxs("div",{ref:i,...o,children:[l,n&&f.jsx(Jf,{"aria-label":e,variant:t,onClick:s})]})}),Xv=Yv,Nd=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),f.jsx(Xv,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));Nd.displayName="ModalHeader";const Zv=Nd,Jv=Qf("h4"),_d=y.forwardRef(({className:e,bsPrefix:t,as:n=Jv,...r},l)=>(t=H(t,"modal-title"),f.jsx(n,{ref:l,className:M(e,t),...r})));_d.displayName="ModalTitle";const qv=_d;function bv(e){return f.jsx(Ql,{...e,timeout:null})}function ey(e){return f.jsx(Ql,{...e,timeout:null})}const Td=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Ed,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:d=!0,keyboard:w=!0,onEscapeKeyDown:g,onShow:k,onHide:L,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:S=!0,restoreFocusOptions:_,onEntered:E,onExit:N,onExiting:j,onEnter:U,onEntering:P,onExited:ie,backdropClassName:Ke,manager:Ge,...on},Qn)=>{const[Le,Ye]=y.useState({}),[C,R]=y.useState(!1),O=y.useRef(!1),I=y.useRef(!1),A=y.useRef(null),[fe,Re]=Gh(),et=mo(Qn,Re),Oe=Me(L),mt=xh();e=H(e,"modal");const ho=y.useMemo(()=>({onHide:Oe}),[Oe]);function un(){return Ge||Vv({isRTL:mt})}function sn($){if(!Vn)return;const an=un().getScrollbarWidth()>0,Ju=$.scrollHeight>po($).documentElement.clientHeight;Ye({paddingRight:an&&!Ju?ma():void 0,paddingLeft:!an&&Ju?ma():void 0})}const Kn=Me(()=>{fe&&sn(fe.dialog)});ed(()=>{Ki(window,"resize",Kn),A.current==null||A.current()});const Br=()=>{O.current=!0},Gn=$=>{O.current&&fe&&$.target===fe.dialog&&(I.current=!0),O.current=!1},Dt=()=>{R(!0),A.current=Vf(fe.dialog,()=>{R(!1)})},K=$=>{$.target===$.currentTarget&&Dt()},Hr=$=>{if(d==="static"){K($);return}if(I.current||$.target!==$.currentTarget){I.current=!1;return}L==null||L()},Yn=$=>{w?g==null||g($):($.preventDefault(),d==="static"&&Dt())},Id=($,an)=>{$&&sn($),U==null||U($,an)},Dd=$=>{A.current==null||A.current(),N==null||N($)},Ad=($,an)=>{P==null||P($,an),Wf(window,"resize",Kn)},Ud=$=>{$&&($.style.display=""),ie==null||ie($),Ki(window,"resize",Kn)},Bd=y.useCallback($=>f.jsx("div",{...$,className:M(`${e}-backdrop`,Ke,!h&&"show")}),[h,Ke,e]),Zu={...n,...Le};Zu.display="block";const Hd=$=>f.jsx("div",{role:"dialog",...$,style:Zu,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:d?Hr:void 0,onMouseUp:Gn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:f.jsx(i,{...on,onMouseDown:Br,className:r,contentClassName:l,children:o})});return f.jsx(xd.Provider,{value:ho,children:f.jsx(Av,{show:m,ref:et,backdrop:d,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:S,restoreFocusOptions:_,onEscapeKeyDown:Yn,onShow:k,onHide:L,onEnter:Id,onEntering:Ad,onEntered:E,onExit:Dd,onExiting:j,onExited:Ud,manager:un(),transition:h?bv:void 0,backdropTransition:h?ey:void 0,renderBackdrop:Bd,renderDialog:Hd})})});Td.displayName="Modal";const ge=Object.assign(Td,{Body:Qv,Header:Zv,Title:qv,Footer:Gv,Dialog:Ed,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),ga=1e3;function ty(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*ga)/ga}function wa({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},d){return f.jsx("div",{ref:d,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${ty(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?f.jsx("span",{className:"visually-hidden",children:r}):r})}const jd=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return wa(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d,className:w,children:g,...k}=r;return f.jsx("div",{ref:n,...k,className:M(w,h),children:g?cv(g,L=>y.cloneElement(L,{isChild:!0})):wa({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d},n)})});jd.displayName="ProgressBar";const ny=jd,Ld=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=If(),u=Df(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let d;h!=null&&typeof h=="object"?{cols:d}=h:d=h;const w=m!==u?`-${m}`:"";d!=null&&a.push(`${s}${w}-${d}`)}),f.jsx(n,{ref:l,...r,className:M(t,o,...a)})});Ld.displayName="Row";const Rd=Ld,Od=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return f.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Od.displayName="Spinner";const Un=Od,Gl="initializing",Pd="paused",Fd="live",ry="error",ln=y.createContext({listTorrents:()=>{throw new Error("Function not implemented.")},getTorrentDetails:()=>{throw new Error("Function not implemented.")},getTorrentStats:()=>{throw new Error("Function not implemented.")},uploadTorrent:()=>{throw new Error("Function not implemented.")},pause:()=>{throw new Error("Function not implemented.")},start:()=>{throw new Error("Function not implemented.")},forget:()=>{throw new Error("Function not implemented.")},delete:()=>{throw new Error("Function not implemented.")}}),Ur=y.createContext({setCloseableError:e=>{},refreshTorrents:()=>{}}),Md=y.createContext({refresh:()=>{}}),Go=({className:e,onClick:t,disabled:n,color:r})=>{const l=o=>{o.stopPropagation(),!n&&t()};return f.jsx("a",{className:`bi ${e} p-1`,onClick:l,href:"#"})},ly=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(ln),h=()=>{l(!1),i(null),s(!1),n()},d=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(g=>{i({text:`Error deleting torrent id=${e}`,details:g}),s(!1)})};return f.jsxs(ge,{show:t,onHide:h,children:[f.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),f.jsxs(ge.Body,{children:[f.jsx(pe,{children:f.jsx(pe.Group,{controlId:"delete-torrent",children:f.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&f.jsx(Mr,{error:o})]}),f.jsxs(ge.Footer,{children:[u&&f.jsx(Un,{}),f.jsx(tn,{variant:"primary",onClick:d,disabled:u,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})},oy=({id:e,statsResponse:t})=>{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(Md);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(ln),d=()=>{l(!0),h.start(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:L})}).finally(()=>l(!1))},w=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:L})}).finally(()=>l(!1))},g=()=>{l(!0),i(!0)},k=()=>{l(!1),i(!1)};return f.jsx(Rd,{children:f.jsxs(Vu,{children:[a&&f.jsx(Go,{className:"bi-play-circle",onClick:d,disabled:r,color:"success"}),s&&f.jsx(Go,{className:"bi-pause-circle",onClick:w,disabled:r}),f.jsx(Go,{className:"bi-x-circle",onClick:g,disabled:r,color:"danger"}),f.jsx(ly,{id:e,show:o,onHide:k})]})})},iy=({statsResponse:e})=>{switch(e.state){case Pd:return"Paused";case Gl:return"Checking files";case ry:return"Error"}return e.state!="live"||e.live===null?e.state:f.jsxs(f.Fragment,{children:[!e.finished&&f.jsxs("div",{className:"download-speed",children:["↓ ",e.live.download_speed.human_readable]}),f.jsxs("div",{className:"upload-speed",children:["↑ ",e.live.upload_speed.human_readable,e.live.snapshot.uploaded_bytes>0&&f.jsxs("span",{children:[" (",Xu(e.live.snapshot.uploaded_bytes),")"]})]})]})},uy=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Gl||r==Fd)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Gl?"warning":"primary",d=()=>{var k;let g=(k=n==null?void 0:n.live)==null?void 0:k.snapshot.peer_stats;return g?`${g.live} / ${g.seen}`:""};let w=[];return l?w.push("bg-warning"):e%2==0&&w.push("bg-light"),f.jsxs(Rd,{className:w.join(" "),children:[f.jsx(vt,{size:3,label:"Name",children:t?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"text-truncate",children:gy(t)}),l&&f.jsxs("p",{className:"text-danger",children:[f.jsx("strong",{children:"Error:"})," ",l]})]}):f.jsx(Un,{})}),n?f.jsxs(f.Fragment,{children:[f.jsx(vt,{label:"Size",children:`${Xu(o)} `}),f.jsx(vt,{size:2,label:(r==Pd,"Progress"),children:f.jsx(ny,{now:s,label:m,animated:a,variant:h})}),f.jsx(vt,{size:2,label:"Speed",children:f.jsx(iy,{statsResponse:n})}),f.jsx(vt,{label:"ETA",children:wy(n)}),f.jsx(vt,{size:2,label:"Peers",children:d()}),f.jsx(vt,{label:"Actions",children:f.jsx(oy,{id:e,statsResponse:n})})]}):f.jsx(vt,{label:"Loading stats",size:8,children:f.jsx(Un,{})})]})},vt=({size:e,label:t,children:n})=>f.jsxs(Vu,{md:e||1,className:"py-3",children:[f.jsx("div",{className:"fw-bold",children:t}),n]}),sy=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(ln),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return xy(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>$d(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.finished?1e4:g.state==Gl||g.state==Fd?1e3:1e4,()=>1e4),0),[i]),f.jsx(Md.Provider,{value:{refresh:a},children:f.jsx(uy,{id:e,detailsResponse:n,statsResponse:l})})},ay=e=>{if(e.torrents===null&&e.loading)return f.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?f.jsx("div",{className:"text-center",children:f.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):f.jsx("div",{style:{fontSize:"smaller"},children:e.torrents.map(t=>f.jsx(sy,{id:t.id,torrent:t},t.id))})},cy=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(ln),m=async()=>{s(!0);let d=await a.listTorrents().finally(()=>s(!1));i(d.torrents)};y.useEffect(()=>$d(async()=>m().then(()=>(l(null),5e3),d=>(l({text:"Error refreshing torrents",details:d}),console.error(d),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return f.jsx(Ur.Provider,{value:h,children:f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"mt-3 mb-4",children:e.title}),f.jsx(yy,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},fy=e=>{let{details:t}=e;return t?f.jsxs(f.Fragment,{children:[t.statusText&&f.jsx("p",{children:f.jsx("strong",{children:t.statusText})}),f.jsx("pre",{children:t.text})]}):null},Mr=e=>{let{error:t,remove:n}=e;return t==null?null:f.jsxs(da,{variant:"danger",onClose:n,dismissible:n!=null,children:[f.jsx(da.Heading,{children:t.text}),f.jsx(fy,{details:t.details})]})},zd=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(ln);y.useEffect(()=>{if(n===null)return;let w=setTimeout(async()=>{i(!0);try{const g=await h.uploadTorrent(n,{list_only:!0});s(g)}catch(g){m({text:"Error listing torrent files",details:g})}finally{i(!1)}},0);return()=>clearTimeout(w)},[n]);const d=()=>{r(),m(null),s(null),i(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(tn,{variant:l,onClick:t,className:"m-1",children:e}),n&&f.jsx(hy,{onHide:d,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},dy=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return f.jsxs(ge,{show:e,onHide:n,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsx(ge.Body,{children:f.jsx(pe,{children:f.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[f.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),f.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),f.jsxs(ge.Footer,{children:[f.jsx(tn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},py=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return f.jsxs(f.Fragment,{children:[f.jsx(zd,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),f.jsx(dy,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},my=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return f.jsxs(f.Fragment,{children:[f.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),f.jsx(zd,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},hy=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[d,w]=y.useState(!1),[g,k]=y.useState(""),L=y.useContext(Ur),p=y.useContext(ln);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((E,N)=>N):[]),k((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=E=>{i.includes(E)?u(i.filter(N=>N!==E)):u([...i,E])},S=async()=>{if(!n)return;a(!0);let E=n.seen_peers?n.seen_peers.slice(0,32):null,N={overwrite:!0,only_files:i,initial_peers:E,output_folder:g};d&&(N.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,N).then(()=>{t(),L.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},_=()=>{if(l)return f.jsx(Un,{});if(r)return f.jsx(Mr,{error:r});if(n)return f.jsxs(pe,{children:[f.jsxs("fieldset",{className:"mb-4",children:[f.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((E,N)=>f.jsx(pe.Group,{controlId:`check-${N}`,children:f.jsx(pe.Check,{type:"checkbox",label:`${E.name} (${Xu(E.length)})`,checked:i.includes(N),onChange:()=>v(N)})},N))]}),f.jsxs("fieldset",{children:[f.jsx("legend",{children:"Options"}),f.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[f.jsx(pe.Label,{children:"Output folder"}),f.jsx(pe.Control,{type:"text",value:g,onChange:E=>k(E.target.value)})]}),f.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[f.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:d,onChange:()=>w(!d)}),f.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return f.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsxs(ge.Body,{children:[_(),f.jsx(Mr,{error:m})]}),f.jsxs(ge.Footer,{children:[s&&f.jsx(Un,{}),f.jsx(tn,{variant:"primary",onClick:S,disabled:l||s||i.length==0,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},vy=()=>f.jsxs("div",{id:"buttons-container",className:"mt-3",children:[f.jsx(py,{}),f.jsx(my,{})]}),yy=e=>{let t=y.useContext(Ur);return f.jsxs(pv,{children:[f.jsx(Mr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),f.jsx(Mr,{error:e.otherError}),f.jsx(ay,{torrents:e.torrents,loading:e.torrentsLoading}),f.jsx(vy,{})]})};function Xu(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function gy(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function wy(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":Sy(t)}function Sy(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function $d(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function xy(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const ky=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",yt=async(e,t,n)=>{console.log(e,t);const r=ky+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=`${i.status} ${i.statusText}`,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},Ey={listTorrents:()=>yt("GET","/torrents"),getTorrentDetails:e=>yt("GET",`/torrents/${e}`),getTorrentStats:e=>yt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),yt("POST",n,e)},pause:e=>yt("POST",`/torrents/${e}/pause`),start:e=>yt("POST",`/torrents/${e}/start`),forget:e=>yt("POST",`/torrents/${e}/forget`),delete:e=>yt("POST",`/torrents/${e}/delete`)};Yo.createRoot(document.getElementById("app")).render(f.jsx(y.StrictMode,{children:f.jsx(ln.Provider,{value:Ey,children:f.jsx(cy,{title:"rqbit web UI - version 4.0.0"})})})); +*/(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r=[],l=0;l=0)&&(n[l]=e[l]);return n}function sa(e){return"default"+e.charAt(0).toUpperCase()+e.substr(1)}function hh(e){var t=vh(e,"string");return typeof t=="symbol"?t:String(t)}function vh(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function yh(e,t,n){var r=y.useRef(e!==void 0),l=y.useState(t),o=l[0],i=l[1],u=e!==void 0,s=r.current;return r.current=u,!u&&s&&o!==t&&i(t),[u?e:o,y.useCallback(function(a){for(var m=arguments.length,h=new Array(m>1?m-1:0),d=1;d{o.target===e&&(l(),t(o))},n+r)}function Bh(e){e.offsetHeight}const fa=e=>!e||typeof e=="function"?e:t=>{e.current=t};function Hh(e,t){const n=fa(e),r=fa(t);return l=>{n&&n(l),r&&r(l)}}function mo(e,t){return y.useMemo(()=>Hh(e,t),[e,t])}function Vh(e){return e&&"setState"in e?Tn.findDOMNode(e):e??null}const Wh=Vt.forwardRef(({onEnter:e,onEntering:t,onEntered:n,onExit:r,onExiting:l,onExited:o,addEndListener:i,children:u,childRef:s,...a},m)=>{const h=y.useRef(null),d=mo(h,s),g=k=>{d(Vh(k))},w=k=>N=>{k&&h.current&&k(h.current,N)},E=y.useCallback(w(e),[e]),L=y.useCallback(w(t),[t]),p=y.useCallback(w(n),[n]),c=y.useCallback(w(r),[r]),v=y.useCallback(w(l),[l]),S=y.useCallback(w(o),[o]),T=y.useCallback(w(i),[i]);return f.jsx(zh,{ref:m,...a,onEnter:E,onEntered:p,onEntering:L,onExit:c,onExited:S,onExiting:v,addEndListener:T,nodeRef:h,children:typeof u=="function"?(k,N)=>u(k,{...N,ref:g}):Vt.cloneElement(u,{ref:g})})}),Qh=Wh;function Kh(e){const t=y.useRef(e);return y.useEffect(()=>{t.current=e},[e]),t}function Me(e){const t=Kh(e);return y.useCallback(function(...n){return t.current&&t.current(...n)},[t])}const Gf=e=>y.forwardRef((t,n)=>f.jsx("div",{...t,ref:n,className:M(t.className,e)})),Yf=Gf("h4");Yf.displayName="DivStyledAsH4";const Xf=y.forwardRef(({className:e,bsPrefix:t,as:n=Yf,...r},l)=>(t=H(t,"alert-heading"),f.jsx(n,{ref:l,className:M(e,t),...r})));Xf.displayName="AlertHeading";const Gh=Xf;function Yh(){return y.useState(null)}function Xh(){const e=y.useRef(!0),t=y.useRef(()=>e.current);return y.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Zh(e){const t=y.useRef(null);return y.useEffect(()=>{t.current=e}),t.current}const Jh=typeof global<"u"&&global.navigator&&global.navigator.product==="ReactNative",qh=typeof document<"u",da=qh||Jh?y.useLayoutEffect:y.useEffect,bh=["as","disabled"];function ev(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function tv(e){return!e||e.trim()==="#"}function Hu({tagName:e,disabled:t,href:n,target:r,rel:l,role:o,onClick:i,tabIndex:u=0,type:s}){e||(n!=null||r!=null||l!=null?e="a":e="button");const a={tagName:e};if(e==="button")return[{type:s||"button",disabled:t},a];const m=d=>{if((t||e==="a"&&tv(n))&&d.preventDefault(),t){d.stopPropagation();return}i==null||i(d)},h=d=>{d.key===" "&&(d.preventDefault(),m(d))};return e==="a"&&(n||(n="#"),t&&(n=void 0)),[{role:o??"button",disabled:void 0,tabIndex:t?void 0:u,href:n,target:e==="a"?r:void 0,"aria-disabled":t||void 0,rel:e==="a"?l:void 0,onClick:m,onKeyDown:h},a]}const nv=y.forwardRef((e,t)=>{let{as:n,disabled:r}=e,l=ev(e,bh);const[o,{tagName:i}]=Hu(Object.assign({tagName:n,disabled:r},l));return f.jsx(i,Object.assign({},l,o,{ref:t}))});nv.displayName="Button";const rv=["onKeyDown"];function lv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}function ov(e){return!e||e.trim()==="#"}const Zf=y.forwardRef((e,t)=>{let{onKeyDown:n}=e,r=lv(e,rv);const[l]=Hu(Object.assign({tagName:"a"},r)),o=Me(i=>{l.onKeyDown(i),n==null||n(i)});return ov(r.href)||r.role==="button"?f.jsx("a",Object.assign({ref:t},r,l,{onKeyDown:o})):f.jsx("a",Object.assign({ref:t},r,{onKeyDown:n}))});Zf.displayName="Anchor";const iv=Zf,Jf=y.forwardRef(({className:e,bsPrefix:t,as:n=iv,...r},l)=>(t=H(t,"alert-link"),f.jsx(n,{ref:l,className:M(e,t),...r})));Jf.displayName="AlertLink";const uv=Jf,sv={[St]:"show",[Ht]:"show"},qf=y.forwardRef(({className:e,children:t,transitionClasses:n={},onEnter:r,...l},o)=>{const i={in:!1,timeout:300,mountOnEnter:!1,unmountOnExit:!1,appear:!1,...l},u=y.useCallback((s,a)=>{Bh(s),r==null||r(s,a)},[r]);return f.jsx(Qh,{ref:o,addEndListener:Uh,...i,onEnter:u,childRef:t.ref,children:(s,a)=>y.cloneElement(t,{...a,className:M("fade",e,t.props.className,sv[s],n[s])})})});qf.displayName="Fade";const Ql=qf,av={"aria-label":ut.string,onClick:ut.func,variant:ut.oneOf(["white"])},Vu=y.forwardRef(({className:e,variant:t,"aria-label":n="Close",...r},l)=>f.jsx("button",{ref:l,type:"button",className:M("btn-close",t&&`btn-close-${t}`,e),"aria-label":n,...r}));Vu.displayName="CloseButton";Vu.propTypes=av;const bf=Vu,ed=y.forwardRef((e,t)=>{const{bsPrefix:n,show:r=!0,closeLabel:l="Close alert",closeVariant:o,className:i,children:u,variant:s="primary",onClose:a,dismissible:m,transition:h=Ql,...d}=gh(e,{show:"onClose"}),g=H(n,"alert"),w=Me(p=>{a&&a(!1,p)}),E=h===!0?Ql:h,L=f.jsxs("div",{role:"alert",...E?void 0:d,ref:t,className:M(i,g,s&&`${g}-${s}`,m&&`${g}-dismissible`),children:[m&&f.jsx(bf,{onClick:w,"aria-label":l,variant:o}),u]});return E?f.jsx(E,{unmountOnExit:!0,...d,ref:void 0,in:r,children:L}):r?L:null});ed.displayName="Alert";const pa=Object.assign(ed,{Link:uv,Heading:Gh}),td=y.forwardRef(({as:e,bsPrefix:t,variant:n="primary",size:r,active:l=!1,disabled:o=!1,className:i,...u},s)=>{const a=H(t,"btn"),[m,{tagName:h}]=Hu({tagName:e,disabled:o,...u}),d=h;return f.jsx(d,{...m,...u,ref:s,disabled:o,className:M(i,a,l&&"active",n&&`${a}-${n}`,r&&`${a}-${r}`,u.href&&o&&"disabled")})});td.displayName="Button";const tn=td;function cv(e){const t=y.useRef(e);return t.current=e,t}function nd(e){const t=cv(e);y.useEffect(()=>()=>t.current(),[])}function fv(e,t){let n=0;return y.Children.map(e,r=>y.isValidElement(r)?t(r,n++):r)}function dv(e,t){return y.Children.toArray(e).some(n=>y.isValidElement(n)&&n.type===t)}function pv({as:e,bsPrefix:t,className:n,...r}){t=H(t,"col");const l=Af(),o=Uf(),i=[],u=[];return l.forEach(s=>{const a=r[s];delete r[s];let m,h,d;typeof a=="object"&&a!=null?{span:m,offset:h,order:d}=a:m=a;const g=s!==o?`-${s}`:"";m&&i.push(m===!0?`${t}${g}`:`${t}${g}-${m}`),d!=null&&u.push(`order${g}-${d}`),h!=null&&u.push(`offset${g}-${h}`)}),[{...r,className:M(n,...i,...u)},{as:e,bsPrefix:t,spans:i}]}const rd=y.forwardRef((e,t)=>{const[{className:n,...r},{as:l="div",bsPrefix:o,spans:i}]=pv(e);return f.jsx(l,{...r,ref:t,className:M(n,!i.length&&o)})});rd.displayName="Col";const Wu=rd,ld=y.forwardRef(({bsPrefix:e,fluid:t=!1,as:n="div",className:r,...l},o)=>{const i=H(e,"container"),u=typeof t=="string"?`-${t}`:"-fluid";return f.jsx(n,{ref:o,...l,className:M(r,t?`${i}${u}`:i)})});ld.displayName="Container";const mv=ld;var hv=Function.prototype.bind.call(Function.prototype.call,[].slice);function dn(e,t){return hv(e.querySelectorAll(t))}function ma(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}const vv="data-rr-ui-";function yv(e){return`${vv}${e}`}const od=y.createContext(Wn?window:void 0);od.Provider;function Qu(){return y.useContext(od)}const gv={type:ut.string,tooltip:ut.bool,as:ut.elementType},Ku=y.forwardRef(({as:e="div",className:t,type:n="valid",tooltip:r=!1,...l},o)=>f.jsx(e,{...l,ref:o,className:M(t,`${n}-${r?"tooltip":"feedback"}`)}));Ku.displayName="Feedback";Ku.propTypes=gv;const id=Ku,wv=y.createContext({}),dt=wv,ud=y.forwardRef(({id:e,bsPrefix:t,className:n,type:r="checkbox",isValid:l=!1,isInvalid:o=!1,as:i="input",...u},s)=>{const{controlId:a}=y.useContext(dt);return t=H(t,"form-check-input"),f.jsx(i,{...u,ref:s,type:r,id:e||a,className:M(n,t,l&&"is-valid",o&&"is-invalid")})});ud.displayName="FormCheckInput";const sd=ud,ad=y.forwardRef(({bsPrefix:e,className:t,htmlFor:n,...r},l)=>{const{controlId:o}=y.useContext(dt);return e=H(e,"form-check-label"),f.jsx("label",{...r,ref:l,htmlFor:n||o,className:M(t,e)})});ad.displayName="FormCheckLabel";const Gi=ad,cd=y.forwardRef(({id:e,bsPrefix:t,bsSwitchPrefix:n,inline:r=!1,reverse:l=!1,disabled:o=!1,isValid:i=!1,isInvalid:u=!1,feedbackTooltip:s=!1,feedback:a,feedbackType:m,className:h,style:d,title:g="",type:w="checkbox",label:E,children:L,as:p="input",...c},v)=>{t=H(t,"form-check"),n=H(n,"form-switch");const{controlId:S}=y.useContext(dt),T=y.useMemo(()=>({controlId:e||S}),[S,e]),k=!L&&E!=null&&E!==!1||dv(L,Gi),N=f.jsx(sd,{...c,type:w==="switch"?"checkbox":w,ref:v,isValid:i,isInvalid:u,disabled:o,as:p});return f.jsx(dt.Provider,{value:T,children:f.jsx("div",{style:d,className:M(h,k&&t,r&&`${t}-inline`,l&&`${t}-reverse`,w==="switch"&&n),children:L||f.jsxs(f.Fragment,{children:[N,k&&f.jsx(Gi,{title:g,children:E}),a&&f.jsx(id,{type:m,tooltip:s,children:a})]})})})});cd.displayName="FormCheck";const Kl=Object.assign(cd,{Input:sd,Label:Gi}),fd=y.forwardRef(({bsPrefix:e,type:t,size:n,htmlSize:r,id:l,className:o,isValid:i=!1,isInvalid:u=!1,plaintext:s,readOnly:a,as:m="input",...h},d)=>{const{controlId:g}=y.useContext(dt);return e=H(e,"form-control"),f.jsx(m,{...h,type:t,size:r,ref:d,readOnly:a,id:l||g,className:M(o,s?`${e}-plaintext`:e,n&&`${e}-${n}`,t==="color"&&`${e}-color`,i&&"is-valid",u&&"is-invalid")})});fd.displayName="FormControl";const Sv=Object.assign(fd,{Feedback:id}),dd=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"form-floating"),f.jsx(n,{ref:l,className:M(e,t),...r})));dd.displayName="FormFloating";const xv=dd,pd=y.forwardRef(({controlId:e,as:t="div",...n},r)=>{const l=y.useMemo(()=>({controlId:e}),[e]);return f.jsx(dt.Provider,{value:l,children:f.jsx(t,{...n,ref:r})})});pd.displayName="FormGroup";const md=pd,hd=y.forwardRef(({as:e="label",bsPrefix:t,column:n=!1,visuallyHidden:r=!1,className:l,htmlFor:o,...i},u)=>{const{controlId:s}=y.useContext(dt);t=H(t,"form-label");let a="col-form-label";typeof n=="string"&&(a=`${a} ${a}-${n}`);const m=M(l,t,r&&"visually-hidden",n&&a);return o=o||s,n?f.jsx(Wu,{ref:u,as:"label",className:m,htmlFor:o,...i}):f.jsx(e,{ref:u,className:m,htmlFor:o,...i})});hd.displayName="FormLabel";const Ev=hd,vd=y.forwardRef(({bsPrefix:e,className:t,id:n,...r},l)=>{const{controlId:o}=y.useContext(dt);return e=H(e,"form-range"),f.jsx("input",{...r,type:"range",ref:l,className:M(t,e),id:n||o})});vd.displayName="FormRange";const kv=vd,yd=y.forwardRef(({bsPrefix:e,size:t,htmlSize:n,className:r,isValid:l=!1,isInvalid:o=!1,id:i,...u},s)=>{const{controlId:a}=y.useContext(dt);return e=H(e,"form-select"),f.jsx("select",{...u,size:n,ref:s,className:M(r,e,t&&`${e}-${t}`,l&&"is-valid",o&&"is-invalid"),id:i||a})});yd.displayName="FormSelect";const Cv=yd,gd=y.forwardRef(({bsPrefix:e,className:t,as:n="small",muted:r,...l},o)=>(e=H(e,"form-text"),f.jsx(n,{...l,ref:o,className:M(t,e,r&&"text-muted")})));gd.displayName="FormText";const Nv=gd,wd=y.forwardRef((e,t)=>f.jsx(Kl,{...e,ref:t,type:"switch"}));wd.displayName="Switch";const Tv=Object.assign(wd,{Input:Kl.Input,Label:Kl.Label}),Sd=y.forwardRef(({bsPrefix:e,className:t,children:n,controlId:r,label:l,...o},i)=>(e=H(e,"form-floating"),f.jsxs(md,{ref:i,className:M(t,e),controlId:r,...o,children:[n,f.jsx("label",{htmlFor:r,children:l})]})));Sd.displayName="FloatingLabel";const _v=Sd,jv={_ref:ut.any,validated:ut.bool,as:ut.elementType},Gu=y.forwardRef(({className:e,validated:t,as:n="form",...r},l)=>f.jsx(n,{...r,ref:l,className:M(e,t&&"was-validated")}));Gu.displayName="Form";Gu.propTypes=jv;const pe=Object.assign(Gu,{Group:md,Control:Sv,Floating:xv,Check:Kl,Switch:Tv,Label:Ev,Text:Nv,Range:kv,Select:Cv,FloatingLabel:_v});var ul;function ha(e){if((!ul&&ul!==0||e)&&Wn){var t=document.createElement("div");t.style.position="absolute",t.style.top="-9999px",t.style.width="50px",t.style.height="50px",t.style.overflow="scroll",document.body.appendChild(t),ul=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return ul}function Vo(e){e===void 0&&(e=po());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function Lv(e=document){const t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}const va=yv("modal-open");class Rv{constructor({ownerDocument:t,handleContainerOverflow:n=!0,isRTL:r=!1}={}){this.handleContainerOverflow=n,this.isRTL=r,this.modals=[],this.ownerDocument=t}getScrollbarWidth(){return Lv(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(t){}removeModalAttributes(t){}setContainerStyle(t){const n={overflow:"hidden"},r=this.isRTL?"paddingLeft":"paddingRight",l=this.getElement();t.style={overflow:l.style.overflow,[r]:l.style[r]},t.scrollBarWidth&&(n[r]=`${parseInt(Xt(l,r)||"0",10)+t.scrollBarWidth}px`),l.setAttribute(va,""),Xt(l,n)}reset(){[...this.modals].forEach(t=>this.remove(t))}removeContainerStyle(t){const n=this.getElement();n.removeAttribute(va),Object.assign(n.style,t.style)}add(t){let n=this.modals.indexOf(t);return n!==-1||(n=this.modals.length,this.modals.push(t),this.setModalAttributes(t),n!==0)||(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state)),n}remove(t){const n=this.modals.indexOf(t);n!==-1&&(this.modals.splice(n,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(t))}isTopModal(t){return!!this.modals.length&&this.modals[this.modals.length-1]===t}}const Yu=Rv,Wo=(e,t)=>Wn?e==null?(t||po()).body:(typeof e=="function"&&(e=e()),e&&"current"in e&&(e=e.current),e&&("nodeType"in e||e.getBoundingClientRect)?e:null):null;function Ov(e,t){const n=Qu(),[r,l]=y.useState(()=>Wo(e,n==null?void 0:n.document));if(!r){const o=Wo(e);o&&l(o)}return y.useEffect(()=>{t&&r&&t(r)},[t,r]),y.useEffect(()=>{const o=Wo(e);o!==r&&l(o)},[e,r]),r}function Pv({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:l}){const o=y.useRef(null),i=y.useRef(t),u=Me(n);y.useEffect(()=>{t?i.current=!0:u(o.current)},[t,u]);const s=mo(o,e.ref),a=y.cloneElement(e,{ref:s});return t?a:l||!i.current&&r?null:a}function Fv({in:e,onTransition:t}){const n=y.useRef(null),r=y.useRef(!0),l=Me(t);return da(()=>{if(!n.current)return;let o=!1;return l({in:e,element:n.current,initial:r.current,isStale:()=>o}),()=>{o=!0}},[e,l]),da(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function Mv({children:e,in:t,onExited:n,onEntered:r,transition:l}){const[o,i]=y.useState(!t);t&&o&&i(!1);const u=Fv({in:!!t,onTransition:a=>{const m=()=>{a.isStale()||(a.in?r==null||r(a.element,a.initial):(i(!0),n==null||n(a.element)))};Promise.resolve(l(a)).then(m,h=>{throw a.in||i(!0),h})}}),s=mo(u,e.ref);return o&&!t?null:y.cloneElement(e,{ref:s})}function ya(e,t,n){return e?f.jsx(e,Object.assign({},n)):t?f.jsx(Mv,Object.assign({},n,{transition:t})):f.jsx(Pv,Object.assign({},n))}function $v(e){return e.code==="Escape"||e.keyCode===27}const zv=["show","role","className","style","children","backdrop","keyboard","onBackdropClick","onEscapeKeyDown","transition","runTransition","backdropTransition","runBackdropTransition","autoFocus","enforceFocus","restoreFocus","restoreFocusOptions","renderDialog","renderBackdrop","manager","container","onShow","onHide","onExit","onExited","onExiting","onEnter","onEntering","onEntered"];function Iv(e,t){if(e==null)return{};var n={},r=Object.keys(e),l,o;for(o=0;o=0)&&(n[l]=e[l]);return n}let Qo;function Dv(e){return Qo||(Qo=new Yu({ownerDocument:e==null?void 0:e.document})),Qo}function Av(e){const t=Qu(),n=e||Dv(t),r=y.useRef({dialog:null,backdrop:null});return Object.assign(r.current,{add:()=>n.add(r.current),remove:()=>n.remove(r.current),isTopModal:()=>n.isTopModal(r.current),setDialogRef:y.useCallback(l=>{r.current.dialog=l},[]),setBackdropRef:y.useCallback(l=>{r.current.backdrop=l},[])})}const xd=y.forwardRef((e,t)=>{let{show:n=!1,role:r="dialog",className:l,style:o,children:i,backdrop:u=!0,keyboard:s=!0,onBackdropClick:a,onEscapeKeyDown:m,transition:h,runTransition:d,backdropTransition:g,runBackdropTransition:w,autoFocus:E=!0,enforceFocus:L=!0,restoreFocus:p=!0,restoreFocusOptions:c,renderDialog:v,renderBackdrop:S=K=>f.jsx("div",Object.assign({},K)),manager:T,container:k,onShow:N,onHide:j=()=>{},onExit:U,onExited:P,onExiting:ie,onEnter:Ke,onEntering:Ge,onEntered:on}=e,Qn=Iv(e,zv);const Le=Qu(),Ye=Ov(k),C=Av(T),R=Xh(),O=Zh(n),[I,A]=y.useState(!n),fe=y.useRef(null);y.useImperativeHandle(t,()=>C,[C]),Wn&&!O&&n&&(fe.current=Vo(Le==null?void 0:Le.document)),n&&I&&A(!1);const Re=Me(()=>{if(C.add(),sn.current=Wl(document,"keydown",ho),un.current=Wl(document,"focus",()=>setTimeout(Oe),!0),N&&N(),E){var K,Hr;const Yn=Vo((K=(Hr=C.dialog)==null?void 0:Hr.ownerDocument)!=null?K:Le==null?void 0:Le.document);C.dialog&&Yn&&!ma(C.dialog,Yn)&&(fe.current=Yn,C.dialog.focus())}}),et=Me(()=>{if(C.remove(),sn.current==null||sn.current(),un.current==null||un.current(),p){var K;(K=fe.current)==null||K.focus==null||K.focus(c),fe.current=null}});y.useEffect(()=>{!n||!Ye||Re()},[n,Ye,Re]),y.useEffect(()=>{I&&et()},[I,et]),nd(()=>{et()});const Oe=Me(()=>{if(!L||!R()||!C.isTopModal())return;const K=Vo(Le==null?void 0:Le.document);C.dialog&&K&&!ma(C.dialog,K)&&C.dialog.focus()}),ht=Me(K=>{K.target===K.currentTarget&&(a==null||a(K),u===!0&&j())}),ho=Me(K=>{s&&$v(K)&&C.isTopModal()&&(m==null||m(K),K.defaultPrevented||j())}),un=y.useRef(),sn=y.useRef(),Kn=(...K)=>{A(!0),P==null||P(...K)};if(!Ye)return null;const Br=Object.assign({role:r,ref:C.setDialogRef,"aria-modal":r==="dialog"?!0:void 0},Qn,{style:o,className:l,tabIndex:-1});let Gn=v?v(Br):f.jsx("div",Object.assign({},Br,{children:y.cloneElement(i,{role:"document"})}));Gn=ya(h,d,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:U,onExiting:ie,onExited:Kn,onEnter:Ke,onEntering:Ge,onEntered:on,children:Gn});let Dt=null;return u&&(Dt=S({ref:C.setBackdropRef,onClick:ht}),Dt=ya(g,w,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:Dt})),f.jsx(f.Fragment,{children:Tn.createPortal(f.jsxs(f.Fragment,{children:[Dt,Gn]}),Ye)})});xd.displayName="Modal";const Uv=Object.assign(xd,{Manager:Yu});function Bv(e,t){return e.classList?!!t&&e.classList.contains(t):(" "+(e.className.baseVal||e.className)+" ").indexOf(" "+t+" ")!==-1}function Hv(e,t){e.classList?e.classList.add(t):Bv(e,t)||(typeof e.className=="string"?e.className=e.className+" "+t:e.setAttribute("class",(e.className&&e.className.baseVal||"")+" "+t))}function ga(e,t){return e.replace(new RegExp("(^|\\s)"+t+"(?:\\s|$)","g"),"$1").replace(/\s+/g," ").replace(/^\s*|\s*$/g,"")}function Vv(e,t){e.classList?e.classList.remove(t):typeof e.className=="string"?e.className=ga(e.className,t):e.setAttribute("class",ga(e.className&&e.className.baseVal||"",t))}const pn={FIXED_CONTENT:".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",STICKY_CONTENT:".sticky-top",NAVBAR_TOGGLER:".navbar-toggler"};class Wv extends Yu{adjustAndStore(t,n,r){const l=n.style[t];n.dataset[t]=l,Xt(n,{[t]:`${parseFloat(Xt(n,t))+r}px`})}restore(t,n){const r=n.dataset[t];r!==void 0&&(delete n.dataset[t],Xt(n,{[t]:r}))}setContainerStyle(t){super.setContainerStyle(t);const n=this.getElement();if(Hv(n,"modal-open"),!t.scrollBarWidth)return;const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.adjustAndStore(r,o,t.scrollBarWidth)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.adjustAndStore(l,o,-t.scrollBarWidth)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.adjustAndStore(l,o,t.scrollBarWidth))}removeContainerStyle(t){super.removeContainerStyle(t);const n=this.getElement();Vv(n,"modal-open");const r=this.isRTL?"paddingLeft":"paddingRight",l=this.isRTL?"marginLeft":"marginRight";dn(n,pn.FIXED_CONTENT).forEach(o=>this.restore(r,o)),dn(n,pn.STICKY_CONTENT).forEach(o=>this.restore(l,o)),dn(n,pn.NAVBAR_TOGGLER).forEach(o=>this.restore(l,o))}}let Ko;function Qv(e){return Ko||(Ko=new Wv(e)),Ko}const Ed=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-body"),f.jsx(n,{ref:l,className:M(e,t),...r})));Ed.displayName="ModalBody";const Kv=Ed,Gv=y.createContext({onHide(){}}),kd=Gv,Cd=y.forwardRef(({bsPrefix:e,className:t,contentClassName:n,centered:r,size:l,fullscreen:o,children:i,scrollable:u,...s},a)=>{e=H(e,"modal");const m=`${e}-dialog`,h=typeof o=="string"?`${e}-fullscreen-${o}`:`${e}-fullscreen`;return f.jsx("div",{...s,ref:a,className:M(m,t,l&&`${e}-${l}`,r&&`${m}-centered`,u&&`${m}-scrollable`,o&&h),children:f.jsx("div",{className:M(`${e}-content`,n),children:i})})});Cd.displayName="ModalDialog";const Nd=Cd,Td=y.forwardRef(({className:e,bsPrefix:t,as:n="div",...r},l)=>(t=H(t,"modal-footer"),f.jsx(n,{ref:l,className:M(e,t),...r})));Td.displayName="ModalFooter";const Yv=Td,Xv=y.forwardRef(({closeLabel:e="Close",closeVariant:t,closeButton:n=!1,onHide:r,children:l,...o},i)=>{const u=y.useContext(kd),s=Me(()=>{u==null||u.onHide(),r==null||r()});return f.jsxs("div",{ref:i,...o,children:[l,n&&f.jsx(bf,{"aria-label":e,variant:t,onClick:s})]})}),Zv=Xv,_d=y.forwardRef(({bsPrefix:e,className:t,closeLabel:n="Close",closeButton:r=!1,...l},o)=>(e=H(e,"modal-header"),f.jsx(Zv,{ref:o,...l,className:M(t,e),closeLabel:n,closeButton:r})));_d.displayName="ModalHeader";const Jv=_d,qv=Gf("h4"),jd=y.forwardRef(({className:e,bsPrefix:t,as:n=qv,...r},l)=>(t=H(t,"modal-title"),f.jsx(n,{ref:l,className:M(e,t),...r})));jd.displayName="ModalTitle";const bv=jd;function ey(e){return f.jsx(Ql,{...e,timeout:null})}function ty(e){return f.jsx(Ql,{...e,timeout:null})}const Ld=y.forwardRef(({bsPrefix:e,className:t,style:n,dialogClassName:r,contentClassName:l,children:o,dialogAs:i=Nd,"aria-labelledby":u,"aria-describedby":s,"aria-label":a,show:m=!1,animation:h=!0,backdrop:d=!0,keyboard:g=!0,onEscapeKeyDown:w,onShow:E,onHide:L,container:p,autoFocus:c=!0,enforceFocus:v=!0,restoreFocus:S=!0,restoreFocusOptions:T,onEntered:k,onExit:N,onExiting:j,onEnter:U,onEntering:P,onExited:ie,backdropClassName:Ke,manager:Ge,...on},Qn)=>{const[Le,Ye]=y.useState({}),[C,R]=y.useState(!1),O=y.useRef(!1),I=y.useRef(!1),A=y.useRef(null),[fe,Re]=Yh(),et=mo(Qn,Re),Oe=Me(L),ht=Eh();e=H(e,"modal");const ho=y.useMemo(()=>({onHide:Oe}),[Oe]);function un(){return Ge||Qv({isRTL:ht})}function sn(z){if(!Wn)return;const an=un().getScrollbarWidth()>0,qu=z.scrollHeight>po(z).documentElement.clientHeight;Ye({paddingRight:an&&!qu?ha():void 0,paddingLeft:!an&&qu?ha():void 0})}const Kn=Me(()=>{fe&&sn(fe.dialog)});nd(()=>{Ki(window,"resize",Kn),A.current==null||A.current()});const Br=()=>{O.current=!0},Gn=z=>{O.current&&fe&&z.target===fe.dialog&&(I.current=!0),O.current=!1},Dt=()=>{R(!0),A.current=Kf(fe.dialog,()=>{R(!1)})},K=z=>{z.target===z.currentTarget&&Dt()},Hr=z=>{if(d==="static"){K(z);return}if(I.current||z.target!==z.currentTarget){I.current=!1;return}L==null||L()},Yn=z=>{g?w==null||w(z):(z.preventDefault(),d==="static"&&Dt())},Dd=(z,an)=>{z&&sn(z),U==null||U(z,an)},Ad=z=>{A.current==null||A.current(),N==null||N(z)},Ud=(z,an)=>{P==null||P(z,an),Qf(window,"resize",Kn)},Bd=z=>{z&&(z.style.display=""),ie==null||ie(z),Ki(window,"resize",Kn)},Hd=y.useCallback(z=>f.jsx("div",{...z,className:M(`${e}-backdrop`,Ke,!h&&"show")}),[h,Ke,e]),Ju={...n,...Le};Ju.display="block";const Vd=z=>f.jsx("div",{role:"dialog",...z,style:Ju,className:M(t,e,C&&`${e}-static`,!h&&"show"),onClick:d?Hr:void 0,onMouseUp:Gn,"aria-label":a,"aria-labelledby":u,"aria-describedby":s,children:f.jsx(i,{...on,onMouseDown:Br,className:r,contentClassName:l,children:o})});return f.jsx(kd.Provider,{value:ho,children:f.jsx(Uv,{show:m,ref:et,backdrop:d,container:p,keyboard:!0,autoFocus:c,enforceFocus:v,restoreFocus:S,restoreFocusOptions:T,onEscapeKeyDown:Yn,onShow:E,onHide:L,onEnter:Dd,onEntering:Ud,onEntered:k,onExit:Ad,onExiting:j,onExited:Bd,manager:un(),transition:h?ey:void 0,backdropTransition:h?ty:void 0,renderBackdrop:Hd,renderDialog:Vd})})});Ld.displayName="Modal";const ge=Object.assign(Ld,{Body:Kv,Header:Jv,Title:bv,Footer:Yv,Dialog:Nd,TRANSITION_DURATION:300,BACKDROP_TRANSITION_DURATION:150}),wa=1e3;function ny(e,t,n){const r=(e-t)/(n-t)*100;return Math.round(r*wa)/wa}function Sa({min:e,now:t,max:n,label:r,visuallyHidden:l,striped:o,animated:i,className:u,style:s,variant:a,bsPrefix:m,...h},d){return f.jsx("div",{ref:d,...h,role:"progressbar",className:M(u,`${m}-bar`,{[`bg-${a}`]:a,[`${m}-bar-animated`]:i,[`${m}-bar-striped`]:i||o}),style:{width:`${ny(t,e,n)}%`,...s},"aria-valuenow":t,"aria-valuemin":e,"aria-valuemax":n,children:l?f.jsx("span",{className:"visually-hidden",children:r}):r})}const Rd=y.forwardRef(({isChild:e=!1,...t},n)=>{const r={min:0,max:100,animated:!1,visuallyHidden:!1,striped:!1,...t};if(r.bsPrefix=H(r.bsPrefix,"progress"),e)return Sa(r,n);const{min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d,className:g,children:w,...E}=r;return f.jsx("div",{ref:n,...E,className:M(g,h),children:w?fv(w,L=>y.cloneElement(L,{isChild:!0})):Sa({min:l,now:o,max:i,label:u,visuallyHidden:s,striped:a,animated:m,bsPrefix:h,variant:d},n)})});Rd.displayName="ProgressBar";const ry=Rd,Od=y.forwardRef(({bsPrefix:e,className:t,as:n="div",...r},l)=>{const o=H(e,"row"),i=Af(),u=Uf(),s=`${o}-cols`,a=[];return i.forEach(m=>{const h=r[m];delete r[m];let d;h!=null&&typeof h=="object"?{cols:d}=h:d=h;const g=m!==u?`-${m}`:"";d!=null&&a.push(`${s}${g}-${d}`)}),f.jsx(n,{ref:l,...r,className:M(t,o,...a)})});Od.displayName="Row";const Pd=Od,Fd=y.forwardRef(({bsPrefix:e,variant:t,animation:n="border",size:r,as:l="div",className:o,...i},u)=>{e=H(e,"spinner");const s=`${e}-${n}`;return f.jsx(l,{ref:u,...i,className:M(o,s,r&&`${s}-${r}`,t&&`text-${t}`)})});Fd.displayName="Spinner";const Un=Fd,Gl="initializing",Md="paused",$d="live",ly="error",ln=y.createContext({listTorrents:()=>{throw new Error("Function not implemented.")},getTorrentDetails:()=>{throw new Error("Function not implemented.")},getTorrentStats:()=>{throw new Error("Function not implemented.")},uploadTorrent:()=>{throw new Error("Function not implemented.")},pause:()=>{throw new Error("Function not implemented.")},start:()=>{throw new Error("Function not implemented.")},forget:()=>{throw new Error("Function not implemented.")},delete:()=>{throw new Error("Function not implemented.")}}),Ur=y.createContext({setCloseableError:e=>{},refreshTorrents:()=>{}}),zd=y.createContext({refresh:()=>{}}),Go=({className:e,onClick:t,disabled:n,color:r})=>{const l=o=>{o.stopPropagation(),!n&&t()};return f.jsx("a",{className:`bi ${e} p-1`,onClick:l,href:"#"})},oy=({id:e,show:t,onHide:n})=>{if(!t)return null;const[r,l]=y.useState(!1),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(Ur),m=y.useContext(ln),h=()=>{l(!1),i(null),s(!1),n()},d=()=>{s(!0),(r?m.delete:m.forget)(e).then(()=>{a.refreshTorrents(),h()}).catch(w=>{i({text:`Error deleting torrent id=${e}`,details:w}),s(!1)})};return f.jsxs(ge,{show:t,onHide:h,children:[f.jsx(ge.Header,{closeButton:!0,children:"Delete torrent"}),f.jsxs(ge.Body,{children:[f.jsx(pe,{children:f.jsx(pe.Group,{controlId:"delete-torrent",children:f.jsx(pe.Check,{type:"checkbox",label:"Also delete files",checked:r,onChange:()=>l(!r)})})}),o&&f.jsx(Mr,{error:o})]}),f.jsxs(ge.Footer,{children:[u&&f.jsx(Un,{}),f.jsx(tn,{variant:"primary",onClick:d,disabled:u,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:h,children:"Cancel"})]})]})},iy=({id:e,statsResponse:t})=>{let n=t.state,[r,l]=y.useState(!1),[o,i]=y.useState(!1),u=y.useContext(zd);const s=n=="live",a=n=="paused"||n=="error",m=y.useContext(Ur),h=y.useContext(ln),d=()=>{l(!0),h.start(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error starting torrent id=${e}`,details:L})}).finally(()=>l(!1))},g=()=>{l(!0),h.pause(e).then(()=>{u.refresh()},L=>{m.setCloseableError({text:`Error pausing torrent id=${e}`,details:L})}).finally(()=>l(!1))},w=()=>{l(!0),i(!0)},E=()=>{l(!1),i(!1)};return f.jsx(Pd,{children:f.jsxs(Wu,{children:[a&&f.jsx(Go,{className:"bi-play-circle",onClick:d,disabled:r,color:"success"}),s&&f.jsx(Go,{className:"bi-pause-circle",onClick:g,disabled:r}),f.jsx(Go,{className:"bi-x-circle",onClick:w,disabled:r,color:"danger"}),f.jsx(oy,{id:e,show:o,onHide:E})]})})},uy=({statsResponse:e})=>{switch(e.state){case Md:return"Paused";case Gl:return"Checking files";case ly:return"Error"}return e.state!="live"||e.live===null?e.state:f.jsxs(f.Fragment,{children:[!e.finished&&f.jsxs("div",{className:"download-speed",children:["↓ ",e.live.download_speed.human_readable]}),f.jsxs("div",{className:"upload-speed",children:["↑ ",e.live.upload_speed.human_readable,e.live.snapshot.uploaded_bytes>0&&f.jsxs("span",{children:[" (",Xu(e.live.snapshot.uploaded_bytes),")"]})]})]})},sy=({id:e,detailsResponse:t,statsResponse:n})=>{const r=(n==null?void 0:n.state)??"",l=n==null?void 0:n.error,o=(n==null?void 0:n.total_bytes)??1,i=(n==null?void 0:n.progress_bytes)??0,u=(n==null?void 0:n.finished)||!1,s=l?100:i/o*100,a=(r==Gl||r==$d)&&!u,m=l?"Error":`${s.toFixed(2)}%`,h=l?"danger":u?"success":r==Gl?"warning":"primary",d=()=>{var E;let w=(E=n==null?void 0:n.live)==null?void 0:E.snapshot.peer_stats;return w?`${w.live} / ${w.seen}`:""};let g=[];return l?g.push("bg-warning"):e%2==0&&g.push("bg-light"),f.jsxs(Pd,{className:g.join(" "),children:[f.jsx(yt,{size:3,label:"Name",children:t?f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"text-truncate",children:wy(t)}),l&&f.jsxs("p",{className:"text-danger",children:[f.jsx("strong",{children:"Error:"})," ",l]})]}):f.jsx(Un,{})}),n?f.jsxs(f.Fragment,{children:[f.jsx(yt,{label:"Size",children:`${Xu(o)} `}),f.jsx(yt,{size:2,label:(r==Md,"Progress"),children:f.jsx(ry,{now:s,label:m,animated:a,variant:h})}),f.jsx(yt,{size:2,label:"Speed",children:f.jsx(uy,{statsResponse:n})}),f.jsx(yt,{label:"ETA",children:Sy(n)}),f.jsx(yt,{size:2,label:"Live / Seen",children:d()}),f.jsx(yt,{label:"Actions",children:f.jsx(iy,{id:e,statsResponse:n})})]}):f.jsx(yt,{label:"Loading stats",size:8,children:f.jsx(Un,{})})]})},yt=({size:e,label:t,children:n})=>f.jsxs(Wu,{md:e||1,className:"py-3",children:[f.jsx("div",{className:"fw-bold",children:t}),n]}),ay=({id:e,torrent:t})=>{const[n,r]=y.useState(null),[l,o]=y.useState(null),[i,u]=y.useState(0),s=y.useContext(ln),a=()=>{u(i+1)};return y.useEffect(()=>{if(n===null)return Ey(async()=>{await s.getTorrentDetails(t.id).then(r)},1e3)},[n]),y.useEffect(()=>Zu(async()=>s.getTorrentStats(t.id).then(g=>(o(g),g)).then(g=>g.state==Gl||g.state==$d?1e3:1e4,()=>1e4),0),[i]),f.jsx(zd.Provider,{value:{refresh:a},children:f.jsx(sy,{id:e,detailsResponse:n,statsResponse:l})})},cy=e=>{if(e.torrents===null&&e.loading)return f.jsx(Un,{});if(e.torrents!==null)return e.torrents.length===0?f.jsx("div",{className:"text-center",children:f.jsx("p",{children:"No existing torrents found. Add them through buttons below."})}):f.jsx("div",{style:{fontSize:"smaller"},children:e.torrents.map(t=>f.jsx(ay,{id:t.id,torrent:t},t.id))})},fy=e=>{const[t,n]=y.useState(null),[r,l]=y.useState(null),[o,i]=y.useState(null),[u,s]=y.useState(!1),a=y.useContext(ln),m=async()=>{s(!0);let d=await a.listTorrents().finally(()=>s(!1));i(d.torrents)};y.useEffect(()=>Zu(async()=>m().then(()=>(l(null),5e3),d=>(l({text:"Error refreshing torrents",details:d}),console.error(d),5e3)),0),[]);const h={setCloseableError:n,refreshTorrents:m};return f.jsx(Ur.Provider,{value:h,children:f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"mt-3 mb-4",children:e.title}),f.jsx(gy,{closeableError:t,otherError:r,torrents:o,torrentsLoading:u})]})})},dy=e=>{let{details:t}=e;return t?f.jsxs(f.Fragment,{children:[t.statusText&&f.jsx("p",{children:f.jsx("strong",{children:t.statusText})}),f.jsx("pre",{children:t.text})]}):null},Mr=e=>{let{error:t,remove:n}=e;return t==null?null:f.jsxs(pa,{variant:"danger",onClose:n,dismissible:n!=null,children:[f.jsx(pa.Heading,{children:t.text}),f.jsx(dy,{details:t.details})]})},Id=({buttonText:e,onClick:t,data:n,resetData:r,variant:l})=>{const[o,i]=y.useState(!1),[u,s]=y.useState(null),[a,m]=y.useState(null),h=y.useContext(ln);y.useEffect(()=>{if(n===null)return;let g=setTimeout(async()=>{i(!0);try{const w=await h.uploadTorrent(n,{list_only:!0});s(w)}catch(w){m({text:"Error listing torrent files",details:w})}finally{i(!1)}},0);return()=>clearTimeout(g)},[n]);const d=()=>{r(),m(null),s(null),i(!1)};return f.jsxs(f.Fragment,{children:[f.jsx(tn,{variant:l,onClick:t,className:"m-1",children:e}),n&&f.jsx(vy,{onHide:d,listTorrentError:a,listTorrentResponse:u,data:n,listTorrentLoading:o})]})},py=({show:e,setUrl:t,cancel:n})=>{let[r,l]=y.useState("");return f.jsxs(ge,{show:e,onHide:n,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsx(ge.Body,{children:f.jsx(pe,{children:f.jsxs(pe.Group,{className:"mb-3",controlId:"url",children:[f.jsx(pe.Label,{children:"Enter magnet or HTTP(S) URL to the .torrent"}),f.jsx(pe.Control,{value:r,placeholder:"magnet:?xt=urn:btih:...",onChange:o=>{l(o.target.value)}})]})})}),f.jsxs(ge.Footer,{children:[f.jsx(tn,{variant:"primary",onClick:()=>{t(r),l("")},disabled:r.length==0,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:n,children:"Cancel"})]})]})},my=()=>{let[e,t]=y.useState(null),[n,r]=y.useState(!1);return f.jsxs(f.Fragment,{children:[f.jsx(Id,{variant:"primary",buttonText:"Add Torrent from Magnet / URL",onClick:()=>{r(!0)},data:e,resetData:()=>t(null)}),f.jsx(py,{show:n,setUrl:l=>{r(!1),t(l)},cancel:()=>{r(!1),t(null)}})]})},hy=()=>{const e=y.useRef(),[t,n]=y.useState(null),r=async()=>{var u;if(!((u=e==null?void 0:e.current)!=null&&u.files))return;const i=e.current.files[0];n(i)},l=()=>{e!=null&&e.current&&(e.current.value="",n(null))},o=()=>{e!=null&&e.current&&e.current.click()};return f.jsxs(f.Fragment,{children:[f.jsx("input",{type:"file",ref:e,accept:".torrent",onChange:r,className:"d-none"}),f.jsx(Id,{variant:"secondary",buttonText:"Upload .torrent File",onClick:o,data:t,resetData:l})]})},vy=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:l,data:o}=e;const[i,u]=y.useState([]),[s,a]=y.useState(!1),[m,h]=y.useState(null),[d,g]=y.useState(!1),[w,E]=y.useState(""),L=y.useContext(Ur),p=y.useContext(ln);y.useEffect(()=>{console.log(n),u(n?n.details.files.map((k,N)=>N):[]),E((n==null?void 0:n.output_folder)||"")},[n]);const c=()=>{t(),u([]),h(null),a(!1)},v=k=>{i.includes(k)?u(i.filter(N=>N!==k)):u([...i,k])},S=async()=>{if(!n)return;a(!0);let k=n.seen_peers?n.seen_peers.slice(0,32):null,N={overwrite:!0,only_files:i,initial_peers:k,output_folder:w};d&&(N.peer_opts={connect_timeout:20,read_write_timeout:60}),p.uploadTorrent(o,N).then(()=>{t(),L.refreshTorrents()},j=>{h({text:"Error starting torrent",details:j})}).finally(()=>a(!1))},T=()=>{if(l)return f.jsx(Un,{});if(r)return f.jsx(Mr,{error:r});if(n)return f.jsxs(pe,{children:[f.jsxs("fieldset",{className:"mb-4",children:[f.jsx("legend",{children:"Pick the files to download"}),n.details.files.map((k,N)=>f.jsx(pe.Group,{controlId:`check-${N}`,children:f.jsx(pe.Check,{type:"checkbox",label:`${k.name} (${Xu(k.length)})`,checked:i.includes(N),onChange:()=>v(N)})},N))]}),f.jsxs("fieldset",{children:[f.jsx("legend",{children:"Options"}),f.jsxs(pe.Group,{controlId:"output-folder",className:"mb-3",children:[f.jsx(pe.Label,{children:"Output folder"}),f.jsx(pe.Control,{type:"text",value:w,onChange:k=>E(k.target.value)})]}),f.jsxs(pe.Group,{controlId:"unpopular-torrent",className:"mb-3",children:[f.jsx(pe.Check,{type:"checkbox",label:"Increase timeouts",checked:d,onChange:()=>g(!d)}),f.jsx("small",{id:"emailHelp",className:"form-text text-muted",children:"This might be useful for unpopular torrents with few peers. It will slow down fast torrents though."})]})]})]})};return f.jsxs(ge,{show:!0,onHide:c,size:"lg",children:[f.jsx(ge.Header,{closeButton:!0,children:f.jsx(ge.Title,{children:"Add torrent"})}),f.jsxs(ge.Body,{children:[T(),f.jsx(Mr,{error:m})]}),f.jsxs(ge.Footer,{children:[s&&f.jsx(Un,{}),f.jsx(tn,{variant:"primary",onClick:S,disabled:l||s||i.length==0,children:"OK"}),f.jsx(tn,{variant:"secondary",onClick:c,children:"Cancel"})]})]})},yy=()=>f.jsxs("div",{id:"buttons-container",className:"mt-3",children:[f.jsx(my,{}),f.jsx(hy,{})]}),gy=e=>{let t=y.useContext(Ur);return f.jsxs(mv,{children:[f.jsx(Mr,{error:e.closeableError,remove:()=>t.setCloseableError(null)}),f.jsx(Mr,{error:e.otherError}),f.jsx(cy,{torrents:e.torrents,loading:e.torrentsLoading}),f.jsx(yy,{})]})};function Xu(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function wy(e){return e.files.filter(n=>n.included).reduce((n,r)=>n.length>r.length?n:r).name}function Sy(e){var n,r,l;let t=(l=(r=(n=e==null?void 0:e.live)==null?void 0:n.time_remaining)==null?void 0:r.duration)==null?void 0:l.secs;return t==null?"N/A":xy(t)}function xy(e){const t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60,l=(o,i)=>o>0?`${o}${i}`:"";return t>0?`${l(t,"h")} ${l(n,"m")}`.trim():n>0?`${l(n,"m")} ${l(r,"s")}`.trim():`${l(r,"s")}`.trim()}function Zu(e,t){let n,r=t;const l=async()=>{if(r=await e(),r==null)throw"asyncCallback returned null or undefined";o()};let o=()=>{n=setTimeout(l,r)};return o(),()=>{clearTimeout(n)}}function Ey(e,t){let n;const r=async()=>{await e().then(()=>!1,()=>!0)&&l()};let l=o=>{n=setTimeout(r,o!==void 0?o:t)};return l(0),()=>clearTimeout(n)}const ky=window.origin==="null"||window.origin==="http://localhost:3031"?"http://localhost:3030":"",tt=async(e,t,n)=>{console.log(e,t);const r=ky+t,l={method:e,headers:{Accept:"application/json"},body:n};let o={method:e,path:t,text:""},i;try{i=await fetch(r,l)}catch{return o.text="network error",Promise.reject(o)}if(o.status=i.status,o.statusText=`${i.status} ${i.statusText}`,!i.ok){const s=await i.text();try{const a=JSON.parse(s);o.text=a.human_readable!==void 0?a.human_readable:JSON.stringify(a,null,2)}catch{o.text=s}return Promise.reject(o)}return await i.json()},xa={listTorrents:()=>tt("GET","/torrents"),getTorrentDetails:e=>tt("GET",`/torrents/${e}`),getTorrentStats:e=>tt("GET",`/torrents/${e}/stats/v1`),uploadTorrent:(e,t)=>{var r,l;let n="/torrents?&overwrite=true";return t!=null&&t.list_only&&(n+="&list_only=true"),(t==null?void 0:t.only_files)!=null&&(n+=`&only_files=${t.only_files.join(",")}`),(r=t==null?void 0:t.peer_opts)!=null&&r.connect_timeout&&(n+=`&peer_connect_timeout=${t.peer_opts.connect_timeout}`),(l=t==null?void 0:t.peer_opts)!=null&&l.read_write_timeout&&(n+=`&peer_read_write_timeout=${t.peer_opts.read_write_timeout}`),t!=null&&t.initial_peers&&(n+=`&initial_peers=${t.initial_peers.join(",")}`),t!=null&&t.output_folder&&(n+=`&output_folder=${t.output_folder}`),typeof e=="string"&&(n+="&is_url=true"),tt("POST",n,e)},pause:e=>tt("POST",`/torrents/${e}/pause`),start:e=>tt("POST",`/torrents/${e}/start`),forget:e=>tt("POST",`/torrents/${e}/forget`),delete:e=>tt("POST",`/torrents/${e}/delete`),getVersion:async()=>(await tt("GET","/")).version},Cy=()=>{let[e,t]=y.useState("rqbit web UI");return y.useEffect(()=>Zu(()=>xa.getVersion().then(r=>(t(`rqbit web UI - v${r}`),1e4),r=>1e3),0),[]),f.jsx(y.StrictMode,{children:f.jsx(ln.Provider,{value:xa,children:f.jsx(fy,{title:e})})})};Yo.createRoot(document.getElementById("app")).render(f.jsx(Cy,{})); diff --git a/crates/librqbit/webui/dist/manifest.json b/crates/librqbit/webui/dist/manifest.json index a5cc1f73..b63cb10e 100644 --- a/crates/librqbit/webui/dist/manifest.json +++ b/crates/librqbit/webui/dist/manifest.json @@ -4,7 +4,7 @@ "src": "assets/logo.svg" }, "index.html": { - "file": "assets/index-687608b7.js", + "file": "assets/index-f791e636.js", "isEntry": true, "src": "index.html" } diff --git a/crates/librqbit/webui/src/http-api.ts b/crates/librqbit/webui/src/http-api.ts index cdeab88a..b4859124 100644 --- a/crates/librqbit/webui/src/http-api.ts +++ b/crates/librqbit/webui/src/http-api.ts @@ -46,7 +46,7 @@ const makeRequest = async (method: string, path: string, data?: any): Promise Promise } = { listTorrents: (): Promise => makeRequest('GET', '/torrents'), getTorrentDetails: (index: number): Promise => { return makeRequest('GET', `/torrents/${index}`); @@ -95,5 +95,9 @@ export const API: RqbitAPI = { delete: (index: number): Promise => { return makeRequest('POST', `/torrents/${index}/delete`); + }, + getVersion: async (): Promise => { + const r = await makeRequest('GET', '/'); + return r.version; } } \ No newline at end of file diff --git a/crates/librqbit/webui/src/main.tsx b/crates/librqbit/webui/src/main.tsx index 1e5d451c..07aeeff3 100644 --- a/crates/librqbit/webui/src/main.tsx +++ b/crates/librqbit/webui/src/main.tsx @@ -1,12 +1,27 @@ -import { StrictMode } from "react"; +import { StrictMode, useEffect, useState } from "react"; import ReactDOM from 'react-dom/client'; -import { RqbitWebUI, APIContext } from "./rqbit-web"; +import { RqbitWebUI, APIContext, customSetInterval } from "./rqbit-web"; import { API } from "./http-api"; -ReactDOM.createRoot(document.getElementById('app') as HTMLInputElement).render( - +const RootWithVersion = () => { + let [title, setTitle] = useState("rqbit web UI"); + useEffect(() => { + const refreshVersion = () => API.getVersion().then((version) => { + setTitle(`rqbit web UI - v${version}`); + return 10000; + }, (e) => { + return 1000; + }); + return customSetInterval(refreshVersion, 0) + }, []) + + return - + - + ; +} + +ReactDOM.createRoot(document.getElementById('app') as HTMLInputElement).render( + ); diff --git a/crates/librqbit/webui/src/rqbit-web.tsx b/crates/librqbit/webui/src/rqbit-web.tsx index ac87ac03..846dc26e 100644 --- a/crates/librqbit/webui/src/rqbit-web.tsx +++ b/crates/librqbit/webui/src/rqbit-web.tsx @@ -2,7 +2,7 @@ import { MouseEventHandler, RefObject, createContext, useContext, useEffect, use import { ProgressBar, Button, Container, Row, Col, Alert, Modal, Form, Spinner } from 'react-bootstrap'; import { AddTorrentResponse, TorrentDetails, TorrentId, TorrentStats, ErrorDetails as ApiErrorDetails, STATE_INITIALIZING, STATE_LIVE, STATE_PAUSED, STATE_ERROR, RqbitAPI, AddTorrentOptions } from './api-types'; -interface Error { +export interface Error { text: string, details?: ApiErrorDetails, } @@ -409,7 +409,7 @@ const ErrorDetails = (props: { details: ApiErrorDetails | null | undefined }) => } -const ErrorComponent = (props: { error: Error | null, remove?: () => void }) => { +export const ErrorComponent = (props: { error: Error | null, remove?: () => void }) => { let { error, remove } = props; if (error == null) { @@ -786,7 +786,7 @@ function formatSecondsToTime(seconds: number): string { // Run a function with initial interval, then run it forever with the interval that the // callback returns. // Returns a callback to clear it. -function customSetInterval(asyncCallback: () => Promise, initialInterval: number): () => void { +export function customSetInterval(asyncCallback: () => Promise, initialInterval: number): () => void { let timeoutId: number; let currentInterval: number = initialInterval; @@ -809,7 +809,7 @@ function customSetInterval(asyncCallback: () => Promise, initialInterval }; } -function loopUntilSuccess(callback: () => Promise, interval: number): () => void { +export function loopUntilSuccess(callback: () => Promise, interval: number): () => void { let timeoutId: number; const executeCallback = async () => { diff --git a/crates/librqbit_core/Cargo.toml b/crates/librqbit_core/Cargo.toml index 0ddd412a..ab7db32a 100644 --- a/crates/librqbit_core/Cargo.toml +++ b/crates/librqbit_core/Cargo.toml @@ -30,6 +30,7 @@ bencode = {path = "../bencode", default-features=false, package="librqbit-bencod clone_to_owned = {path="../clone_to_owned", package="librqbit-clone-to-owned", version = "2.2.1"} itertools = "0.12" directories = "5" +tokio-util = "0.7.10" [dev-dependencies] serde_json = "1" diff --git a/crates/librqbit_core/src/spawn_utils.rs b/crates/librqbit_core/src/spawn_utils.rs index ac0dd658..7479ca35 100644 --- a/crates/librqbit_core/src/spawn_utils.rs +++ b/crates/librqbit_core/src/spawn_utils.rs @@ -1,3 +1,5 @@ +use anyhow::bail; +use tokio_util::sync::CancellationToken; use tracing::{error, trace, Instrument}; /// Spawns a future with tracing instrumentation. @@ -32,3 +34,18 @@ pub fn spawn( .instrument(span); tokio::task::spawn(fut) } + +pub fn spawn_with_cancel( + span: tracing::Span, + cancellation_token: CancellationToken, + fut: impl std::future::Future> + Send + 'static, +) -> tokio::task::JoinHandle<()> { + spawn(span, async move { + tokio::select! { + _ = cancellation_token.cancelled() => { + bail!("cancelled"); + }, + r = fut => r + } + }) +} diff --git a/crates/peer_binary_protocol/src/lib.rs b/crates/peer_binary_protocol/src/lib.rs index b99edc50..4811ab40 100644 --- a/crates/peer_binary_protocol/src/lib.rs +++ b/crates/peer_binary_protocol/src/lib.rs @@ -40,6 +40,7 @@ const MSGID_HAVE: u8 = 4; const MSGID_BITFIELD: u8 = 5; const MSGID_REQUEST: u8 = 6; const MSGID_PIECE: u8 = 7; +const MSGID_CANCEL: u8 = 8; const MSGID_EXTENDED: u8 = 20; pub const MY_EXTENDED_UT_METADATA: u8 = 3; @@ -169,6 +170,7 @@ impl From for MessageDeserializeError { #[derive(Debug)] pub enum Message { Request(Request), + Cancel(Request), Bitfield(ByteBuf), KeepAlive, Have(u32), @@ -200,6 +202,7 @@ where fn clone_to_owned(&self) -> Self::Target { match self { Message::Request(req) => Message::Request(*req), + Message::Cancel(req) => Message::Cancel(*req), Message::Bitfield(b) => Message::Bitfield(b.clone_to_owned()), Message::Choke => Message::Choke, Message::Unchoke => Message::Unchoke, @@ -240,7 +243,7 @@ where { pub fn len_prefix_and_msg_id(&self) -> (u32, u8) { match self { - Message::Request(_) => (LEN_PREFIX_REQUEST, MSGID_REQUEST), + Message::Request(_) | Message::Cancel(_) => (LEN_PREFIX_REQUEST, MSGID_REQUEST), Message::Bitfield(b) => (1 + b.as_ref().len() as u32, MSGID_BITFIELD), Message::Choke => (LEN_PREFIX_CHOKE, MSGID_CHOKE), Message::Unchoke => (LEN_PREFIX_UNCHOKE, MSGID_UNCHOKE), @@ -270,7 +273,7 @@ where let ser = bopts(); match self { - Message::Request(request) => { + Message::Request(request) | Message::Cancel(request) => { const MSG_LEN: usize = PREAMBLE_LEN + 12; out.resize(MSG_LEN, 0); debug_assert_eq!(out[PREAMBLE_LEN..].len(), 12); @@ -411,16 +414,28 @@ where } } } - MSGID_REQUEST => { + MSGID_REQUEST | MSGID_CANCEL => { let expected_len = 12; match rest.get(..expected_len) { Some(b) => { let request = decoder_config.deserialize::(b).unwrap(); - Ok((Message::Request(request), PREAMBLE_LEN + expected_len)) + let req = if msg_id == MSGID_REQUEST { + Message::Request(request) + } else { + Message::Cancel(request) + }; + Ok((req, PREAMBLE_LEN + expected_len)) } None => { let missing = expected_len - rest.len(); - Err(MessageDeserializeError::NotEnoughData(missing, "request")) + Err(MessageDeserializeError::NotEnoughData( + missing, + if msg_id == MSGID_REQUEST { + "request" + } else { + "cancel" + }, + )) } } } diff --git a/crates/rqbit/Cargo.toml b/crates/rqbit/Cargo.toml index 00b6fd33..b4469d82 100644 --- a/crates/rqbit/Cargo.toml +++ b/crates/rqbit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rqbit" -version = "5.0.0-beta.0" +version = "5.0.0-beta.1" authors = ["Igor Katson "] edition = "2021" description = "A bittorrent command line client and server." @@ -23,7 +23,7 @@ default-tls = ["librqbit/default-tls"] rust-tls = ["librqbit/rust-tls"] [dependencies] -librqbit = {path="../librqbit", default-features=false, version = "5.0.0-beta.0"} +librqbit = {path="../librqbit", default-features=false, version = "5.0.0-beta.1"} tokio = {version = "1", features = ["macros", "rt-multi-thread"]} console-subscriber = {version = "0.2", optional = true} anyhow = "1" diff --git a/crates/rqbit/src/main.rs b/crates/rqbit/src/main.rs index 95a7277c..45bfe809 100644 --- a/crates/rqbit/src/main.rs +++ b/crates/rqbit/src/main.rs @@ -501,6 +501,7 @@ async fn async_main(opts: Opts) -> anyhow::Result<()> { ) .await .context("error initializing rqbit session")?; + librqbit_spawn( "stats_printer", trace_span!("stats_printer"), diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index 0c7c4be2..e7c8989c 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -1867,7 +1867,7 @@ dependencies = [ [[package]] name = "librqbit" -version = "5.0.0-beta.0" +version = "5.0.0-beta.1" dependencies = [ "anyhow", "axum", @@ -1900,6 +1900,7 @@ dependencies = [ "size_format", "tokio", "tokio-stream", + "tokio-util", "tower-http", "tracing", "url", @@ -1944,6 +1945,7 @@ dependencies = [ "parking_lot", "serde", "tokio", + "tokio-util", "tracing", "url", "uuid", @@ -1951,7 +1953,7 @@ dependencies = [ [[package]] name = "librqbit-dht" -version = "4.1.0" +version = "5.0.0-beta.1" dependencies = [ "anyhow", "backoff", @@ -1970,6 +1972,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", + "tokio-util", "tracing", ] @@ -3015,8 +3018,10 @@ dependencies = [ "directories", "http 1.0.0", "librqbit", + "parking_lot", "serde", "serde_json", + "serde_with", "tauri", "tauri-build", "tokio", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 5a1f860d..317b51b0 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -24,6 +24,8 @@ http = "1.0.0" directories = "5.0.1" tracing-subscriber = {version = "0.3.18", features = ["env-filter"] } tracing = "0.1" +serde_with = "3.4.0" +parking_lot = "0.12.1" [features] # this feature is used for production builds or when `devPath` points to the filesystem diff --git a/desktop/src-tauri/src/config.rs b/desktop/src-tauri/src/config.rs new file mode 100644 index 00000000..6e4c8a00 --- /dev/null +++ b/desktop/src-tauri/src/config.rs @@ -0,0 +1,132 @@ +use std::{ + net::{Ipv4Addr, SocketAddr, SocketAddrV4}, + path::PathBuf, + time::Duration, +}; + +use librqbit::{dht::PersistentDht, Session}; +use serde::{Deserialize, Serialize}; +use serde_with::serde_as; + +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigDht { + pub disable: bool, + pub disable_persistence: bool, + pub persistence_filename: PathBuf, +} + +impl Default for RqbitDesktopConfigDht { + fn default() -> Self { + Self { + disable: false, + disable_persistence: false, + persistence_filename: PersistentDht::default_persistence_filename().unwrap(), + } + } +} + +#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigTcpListen { + pub disable: bool, + pub min_port: u16, + pub max_port: u16, +} + +impl Default for RqbitDesktopConfigTcpListen { + fn default() -> Self { + Self { + disable: false, + // TODO: use consts from librqbit + min_port: 4240, + max_port: 4260, + } + } +} + +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigPersistence { + pub disable: bool, + pub filename: PathBuf, +} + +impl Default for RqbitDesktopConfigPersistence { + fn default() -> Self { + Self { + disable: false, + filename: Session::default_persistence_filename().unwrap(), + } + } +} + +#[serde_as] +#[derive(Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigPeerOpts { + #[serde_as(as = "serde_with::DurationSeconds")] + pub connect_timeout: Duration, + + #[serde_as(as = "serde_with::DurationSeconds")] + pub read_write_timeout: Duration, +} + +impl Default for RqbitDesktopConfigPeerOpts { + fn default() -> Self { + Self { + connect_timeout: Duration::from_secs(2), + read_write_timeout: Duration::from_secs(10), + } + } +} + +#[serde_as] +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigHttpApi { + pub disable: bool, + pub listen_addr: SocketAddr, + pub read_only: bool, +} + +impl Default for RqbitDesktopConfigHttpApi { + fn default() -> Self { + Self { + disable: Default::default(), + listen_addr: SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 3030)), + read_only: false, + } + } +} + +#[derive(Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfigUpnp { + pub disable: bool, +} + +#[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] +pub struct RqbitDesktopConfig { + pub default_download_location: PathBuf, + pub dht: RqbitDesktopConfigDht, + pub tcp_listen: RqbitDesktopConfigTcpListen, + pub upnp: RqbitDesktopConfigUpnp, + pub persistence: RqbitDesktopConfigPersistence, + pub peer_opts: RqbitDesktopConfigPeerOpts, + pub http_api: RqbitDesktopConfigHttpApi, +} + +impl Default for RqbitDesktopConfig { + fn default() -> Self { + let download_folder = directories::UserDirs::new() + .expect("directories::UserDirs::new()") + .download_dir() + .expect("download_dir()") + .to_path_buf(); + + Self { + default_download_location: download_folder, + dht: Default::default(), + tcp_listen: Default::default(), + upnp: Default::default(), + persistence: Default::default(), + peer_opts: Default::default(), + http_api: Default::default(), + } + } +} diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index 9cb16217..3004fab4 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -1,24 +1,211 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +mod config; + +use std::{ + fs::{File, OpenOptions}, + io::{BufReader, BufWriter}, + sync::Arc, +}; + use anyhow::Context; +use config::RqbitDesktopConfig; use http::StatusCode; use librqbit::{ api::{ ApiAddTorrentResponse, EmptyJsonResponse, TorrentDetailsResponse, TorrentListResponse, TorrentStats, }, - librqbit_spawn, AddTorrent, AddTorrentOptions, Api, ApiError, Session, SessionOptions, + dht::PersistentDhtConfig, + librqbit_spawn, AddTorrent, AddTorrentOptions, Api, ApiError, PeerConnectionOptions, Session, + SessionOptions, }; -use tracing::error_span; +use parking_lot::RwLock; +use serde::Serialize; +use tracing::{error, error_span}; + +const ERR_NOT_CONFIGURED: ApiError = + ApiError::new_from_text(StatusCode::FAILED_DEPENDENCY, "not configured"); + +struct StateShared { + config: config::RqbitDesktopConfig, + api: Option, +} + +type RustLogReloadTx = tokio::sync::mpsc::UnboundedSender; + +impl StateShared {} struct State { - api: Api, + config_filename: String, + shared: Arc>>, + rust_log_reload_tx: RustLogReloadTx, +} + +fn read_config(path: &str) -> anyhow::Result { + let rdr = BufReader::new(File::open(path)?); + Ok(serde_json::from_reader(rdr)?) +} + +fn write_config(path: &str, config: &RqbitDesktopConfig) -> anyhow::Result<()> { + let tmp = format!("{}.tmp", path); + let mut tmp_file = BufWriter::new( + OpenOptions::new() + .write(true) + .truncate(true) + .create(true) + .open(&tmp)?, + ); + serde_json::to_writer(&mut tmp_file, config)?; + std::fs::rename(tmp, path)?; + Ok(()) +} + +async fn api_from_config( + rust_log_reload_tx: &RustLogReloadTx, + config: &RqbitDesktopConfig, +) -> anyhow::Result { + let session = Session::new_with_opts( + config.default_download_location.clone(), + SessionOptions { + disable_dht: config.dht.disable, + disable_dht_persistence: config.dht.disable_persistence, + dht_config: Some(PersistentDhtConfig { + config_filename: Some(config.dht.persistence_filename.clone()), + ..Default::default() + }), + persistence: !config.persistence.disable, + persistence_filename: Some(config.persistence.filename.clone()), + peer_opts: Some(PeerConnectionOptions { + connect_timeout: Some(config.peer_opts.connect_timeout), + read_write_timeout: Some(config.peer_opts.read_write_timeout), + ..Default::default() + }), + listen_port_range: if !config.tcp_listen.disable { + Some(config.tcp_listen.min_port..config.tcp_listen.max_port) + } else { + None + }, + enable_upnp_port_forwarding: !config.upnp.disable, + ..Default::default() + }, + ) + .await + .context("couldn't set up librqbit session")?; + + let api = Api::new(session.clone(), None); + + if !config.http_api.disable { + let http_api_task = + librqbit::http_api::HttpApi::new(session.clone(), Some(rust_log_reload_tx.clone())) + .make_http_api_and_run(config.http_api.listen_addr, config.http_api.read_only); + + session.spawn(error_span!("http_api"), http_api_task); + } + Ok(api) +} + +impl State { + async fn new(rust_log_reload_tx: tokio::sync::mpsc::UnboundedSender) -> Self { + let config_filename = directories::ProjectDirs::from("com", "rqbit", "desktop") + .expect("directories::ProjectDirs::from") + .config_dir() + .to_str() + .expect("to_str()") + .to_owned(); + + if let Ok(config) = read_config(&config_filename) { + let api = api_from_config(&rust_log_reload_tx, &config).await.ok(); + let shared = Arc::new(RwLock::new(Some(StateShared { config, api }))); + + return Self { + config_filename, + shared, + rust_log_reload_tx, + }; + } + + Self { + config_filename, + rust_log_reload_tx, + shared: Arc::new(RwLock::new(None)), + } + } + + fn api(&self) -> Result { + let g = self.shared.read(); + match g.as_ref().and_then(|s| s.api.as_ref()) { + Some(api) => Ok(api.clone()), + None => Err(ERR_NOT_CONFIGURED), + } + } + + async fn configure(&self, config: RqbitDesktopConfig) -> Result<(), ApiError> { + { + let g = self.shared.read(); + if let Some(shared) = g.as_ref() { + if shared.api.is_some() && shared.config == config { + // The config didn't change, and the API is running, nothing to do. + return Ok(()); + } + } + } + + let existing = self.shared.write().as_mut().and_then(|s| s.api.take()); + + if let Some(api) = existing { + api.session().stop().await; + } + + let api = api_from_config(&self.rust_log_reload_tx, &config).await?; + if let Err(e) = write_config(&self.config_filename, &config) { + error!("error writing config: {:#}", e); + } + + let mut g = self.shared.write(); + *g = Some(StateShared { + config, + api: Some(api), + }); + Ok(()) + } +} + +#[derive(Default, Serialize)] +struct CurrentState { + config: Option, + configured: bool, } #[tauri::command] -fn torrents_list(state: tauri::State) -> TorrentListResponse { - state.api.api_torrent_list() +fn config_default() -> config::RqbitDesktopConfig { + config::RqbitDesktopConfig::default() +} + +#[tauri::command] +fn config_current(state: tauri::State<'_, State>) -> CurrentState { + let g = state.shared.read(); + match &*g { + Some(s) => CurrentState { + config: Some(s.config.clone()), + configured: s.api.is_some(), + }, + None => Default::default(), + } +} + +#[tauri::command] +async fn config_change( + state: tauri::State<'_, State>, + config: RqbitDesktopConfig, +) -> Result { + state.configure(config).await.map(|_| EmptyJsonResponse {}) +} + +#[tauri::command] +fn torrents_list(state: tauri::State) -> Result { + Ok(state.api()?.api_torrent_list()) } #[tauri::command] @@ -28,7 +215,7 @@ async fn torrent_create_from_url( opts: Option, ) -> Result { state - .api + .api()? .api_add_torrent(AddTorrent::Url(url.into()), opts) .await } @@ -45,7 +232,7 @@ async fn torrent_create_from_base64_file( .context("invalid base64") .map_err(|e| ApiError::new_from_anyhow(StatusCode::BAD_REQUEST, e))?; state - .api + .api()? .api_add_torrent(AddTorrent::TorrentFileBytes(bytes.into()), opts) .await } @@ -55,7 +242,7 @@ async fn torrent_details( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_torrent_details(id) + state.api()?.api_torrent_details(id) } #[tauri::command] @@ -63,7 +250,7 @@ async fn torrent_stats( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_stats_v1(id) + state.api()?.api_stats_v1(id) } #[tauri::command] @@ -71,7 +258,7 @@ async fn torrent_action_delete( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_torrent_action_delete(id) + state.api()?.api_torrent_action_delete(id) } #[tauri::command] @@ -79,7 +266,7 @@ async fn torrent_action_pause( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_torrent_action_pause(id) + state.api()?.api_torrent_action_pause(id) } #[tauri::command] @@ -87,7 +274,7 @@ async fn torrent_action_forget( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_torrent_action_forget(id) + state.api()?.api_torrent_action_forget(id) } #[tauri::command] @@ -95,7 +282,7 @@ async fn torrent_action_start( state: tauri::State<'_, State>, id: usize, ) -> Result { - state.api.api_torrent_action_start(id) + state.api()?.api_torrent_action_start(id) } #[tauri::command] @@ -133,41 +320,14 @@ fn init_logging() -> tokio::sync::mpsc::UnboundedSender { reload_tx } -async fn start_session() { - let rust_log_reload_tx = init_logging(); - +async fn start() { tauri::async_runtime::set(tokio::runtime::Handle::current()); + let rust_log_reload_tx = init_logging(); - let download_folder = directories::UserDirs::new() - .expect("directories::UserDirs::new()") - .download_dir() - .expect("download_dir()") - .to_path_buf(); - - let session = Session::new_with_opts( - download_folder, - SessionOptions { - disable_dht: false, - disable_dht_persistence: false, - persistence: true, - listen_port_range: Some(4240..4260), - ..Default::default() - }, - ) - .await - .expect("couldn't set up librqbit session"); - - let api = Api::new(session.clone(), None); - - librqbit_spawn( - "http api", - error_span!("http_api"), - librqbit::http_api::HttpApi::new(session, Some(rust_log_reload_tx)) - .make_http_api_and_run("127.0.0.1:3030".parse().unwrap(), false), - ); + let state = State::new(rust_log_reload_tx).await; tauri::Builder::default() - .manage(State { api }) + .manage(state) .invoke_handler(tauri::generate_handler![ torrents_list, torrent_details, @@ -178,7 +338,10 @@ async fn start_session() { torrent_action_forget, torrent_action_start, torrent_create_from_base64_file, - get_version + get_version, + config_default, + config_current, + config_change, ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -189,5 +352,5 @@ fn main() { .enable_all() .build() .expect("couldn't set up tokio runtime") - .block_on(start_session()) + .block_on(start()) } diff --git a/desktop/src/api.tsx b/desktop/src/api.tsx index e64531c3..8bcb7e0c 100644 --- a/desktop/src/api.tsx +++ b/desktop/src/api.tsx @@ -23,7 +23,7 @@ function errorToUIError(path: string): (e: InvokeErrorResponse) => Promise(name: string, params?: InvokeArgs): Promise { +export async function invokeAPI(name: string, params?: InvokeArgs): Promise { console.log("invoking", name, params); const result = await invoke(name, params).catch(errorToUIError(name)); console.log(result); diff --git a/desktop/src/configuration.tsx b/desktop/src/configuration.tsx new file mode 100644 index 00000000..da39cc32 --- /dev/null +++ b/desktop/src/configuration.tsx @@ -0,0 +1,50 @@ +type PathLike = string; +type Duration = string; +type SocketAddr = string; + +interface RqbitDesktopConfigDht { + disable: boolean; + disable_persistence: boolean; + persistence_filename: PathLike; +} + +interface RqbitDesktopConfigTcpListen { + disable: boolean; + min_port: number; + max_port: number; +} + +interface RqbitDesktopConfigPersistence { + disable: boolean; + filename: PathLike; +} + +interface RqbitDesktopConfigPeerOpts { + connect_timeout: Duration; + read_write_timeout: Duration; +} + +interface RqbitDesktopConfigHttpApi { + disable: boolean; + listen_addr: SocketAddr; + read_only: boolean; +} + +interface RqbitDesktopConfigUpnp { + disable: boolean; +} + +export interface RqbitDesktopConfig { + default_download_location: PathLike; + dht: RqbitDesktopConfigDht; + tcp_listen: RqbitDesktopConfigTcpListen; + upnp: RqbitDesktopConfigUpnp; + persistence: RqbitDesktopConfigPersistence; + peer_opts: RqbitDesktopConfigPeerOpts; + http_api: RqbitDesktopConfigHttpApi; +} + +export interface CurrentDesktopState { + config: RqbitDesktopConfig | null, + configured: boolean, +} \ No newline at end of file diff --git a/desktop/src/configure.tsx b/desktop/src/configure.tsx new file mode 100644 index 00000000..fe36eee0 --- /dev/null +++ b/desktop/src/configure.tsx @@ -0,0 +1,315 @@ +import React, { useState } from "react"; +import { RqbitDesktopConfig } from "./configuration"; +import { Button, Form, Modal, Row, Tab, Tabs } from "react-bootstrap"; +import { ErrorComponent } from "./rqbit-webui-src/rqbit-web"; +import { invokeAPI } from "./api"; +import { ErrorDetails } from "./rqbit-webui-src/api-types"; + +const FormCheck: React.FC<{ + label: string, + name: string, + checked: boolean, + onChange: (e: any) => void, + disabled?: boolean, + help?: string, +}> = ({ label, name, checked, onChange, disabled, help }) => { + return + {label} +
+ +
+ {help &&
{help}
} +
+} + +const FormInput: React.FC<{ + label: string, + name: string, + value: string | number, + inputType: string, + onChange: (e: any) => void, + disabled?: boolean, + help?: string +}> = ({ label, name, value, inputType, onChange, disabled, help }) => { + return + {label} +
+ +
+ {help &&
{help}
} +
+} + +export const ConfigModal: React.FC<{ + show: boolean, + handleStartReconfigure: () => void, + handleConfigured: (config: RqbitDesktopConfig) => void, + handleCancel?: () => void, + initialConfig: RqbitDesktopConfig, + defaultConfig: RqbitDesktopConfig, +}> = ({ show, handleStartReconfigure, handleConfigured, handleCancel, initialConfig, defaultConfig }) => { + let [config, setConfig] = useState(initialConfig); + let [loading, setLoading] = useState(false); + + const [error, setError] = useState(null); + + const handleInputChange = (e: any) => { + const name: string = e.target.name; + const value: any = e.target.value; + const [mainField, subField] = name.split('.', 2); + + if (subField) { + setConfig((prevConfig: any) => ({ + ...prevConfig, + [mainField]: { + ...prevConfig[mainField], + [subField]: value, + }, + })); + } else { + setConfig((prevConfig) => ({ + ...prevConfig, + [name]: value, + })); + } + }; + + const handleToggleChange = (e: any) => { + const name: string = e.target.name; + const [mainField, subField] = name.split('.', 2); + + if (subField) { + setConfig((prevConfig: any) => ({ + ...prevConfig, + [mainField]: { + ...prevConfig[mainField], + [subField]: !prevConfig[mainField][subField], + }, + })); + } else { + setConfig((prevConfig: any) => ({ + ...prevConfig, + [name]: !prevConfig[name], + })); + } + }; + + const handleOkClick = () => { + setError(null); + handleStartReconfigure(); + setLoading(true); + invokeAPI<{}>("config_change", { config }).then( + () => { + setLoading(false); + handleConfigured(config); + }, + (e: ErrorDetails) => { + setLoading(false); + setError({ + text: "Error saving configuration", + details: e, + }); + } + ) + }; + + return ( + + + Configure Rqbit desktop + + + + + + + + + + + DHT config + + + + + + + + + + TCP Listener config + + + + + + + + + + + + + Session persistence + + + + + + + + Peer connection options + + + + + + + + HTTP API config + + + + + + + + + + + + + {!!handleCancel && + + } + + + + + ); +}; diff --git a/desktop/src/main.tsx b/desktop/src/main.tsx index a67f5acf..d65c7872 100644 --- a/desktop/src/main.tsx +++ b/desktop/src/main.tsx @@ -1,19 +1,29 @@ import { StrictMode } from "react"; import ReactDOM from 'react-dom/client'; -import { APIContext, RqbitWebUI } from "./rqbit-webui-src/rqbit-web"; +import { APIContext } from "./rqbit-webui-src/rqbit-web"; import { API } from "./api"; import { invoke } from "@tauri-apps/api"; +import { CurrentDesktopState, RqbitDesktopConfig } from "./configuration"; +import { RqbitDesktop } from "./rqbit-desktop"; -let version = invoke("get_version").then((version) => { +async function get_version(): Promise { + return invoke("get_version"); +} + +async function get_default_config(): Promise { + return invoke("config_default"); +} + +async function get_current_config(): Promise { + return invoke("config_current"); +} + +Promise.all([get_version(), get_default_config(), get_current_config()]).then(([version, defaultConfig, currentState]) => { ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - + ); -}); - - - - +}) \ No newline at end of file diff --git a/desktop/src/rqbit-desktop.tsx b/desktop/src/rqbit-desktop.tsx new file mode 100644 index 00000000..f61015d5 --- /dev/null +++ b/desktop/src/rqbit-desktop.tsx @@ -0,0 +1,43 @@ +import { useState } from "react"; +import { RqbitWebUI } from "./rqbit-webui-src/rqbit-web"; +import { CurrentDesktopState, RqbitDesktopConfig } from "./configuration"; +import { ConfigModal } from "./configure"; + + +export const RqbitDesktop: React.FC<{ + version: string, + defaultConfig: RqbitDesktopConfig, + currentState: CurrentDesktopState, +}> = ({ version, defaultConfig, currentState }) => { + let [configured, setConfigured] = useState(currentState.configured); + let [config, setConfig] = useState(currentState.config ?? defaultConfig); + let [configurationOpened, setConfigurationOpened] = useState(false); + + return <> + {configured && } + {configured && { + e.stopPropagation(); + setConfigurationOpened(true); + }} + href="#" + aria-label="Settings" />} + { + setConfigured(false); + }} + handleCancel={() => { + setConfigurationOpened(false); + }} + handleConfigured={(config) => { + setConfig(config); + setConfigurationOpened(false); + setConfigured(true); + }} + initialConfig={config} + defaultConfig={defaultConfig} + /> + +} \ No newline at end of file