From 582e331f48502ddc5ee80541d70d612f24da11c6 Mon Sep 17 00:00:00 2001 From: TheDancingDeveloper Date: Fri, 31 Jul 2026 08:48:50 +0000 Subject: [PATCH] release: prepare v0.1.0-beta.3 --- Cargo.lock | 2 +- RELEASE_NOTES_v0.1.0-beta.3.md | 92 +++++++++++++++++++ crates/librtbit-dht/src/persistence.rs | 2 +- crates/librtbit/src/http_api_client.rs | 4 +- crates/librtbit/src/storage/filesystem/fs.rs | 2 +- .../src/torrent_state/live/peer_handler.rs | 8 +- crates/librtbit/webui/src/main-mock.tsx | 2 +- crates/rtbit/Cargo.toml | 2 +- documentation/ReleaseProcess.md | 29 +++--- website/demo/assets/mock-5UlMa0Nf.js | 15 +++ website/demo/assets/mock-Fgd9Vka6.js | 15 --- website/demo/index.html | 2 +- 12 files changed, 133 insertions(+), 42 deletions(-) create mode 100644 RELEASE_NOTES_v0.1.0-beta.3.md create mode 100644 website/demo/assets/mock-5UlMa0Nf.js delete mode 100644 website/demo/assets/mock-Fgd9Vka6.js diff --git a/Cargo.lock b/Cargo.lock index ed8ba0e..bac524e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4966,7 +4966,7 @@ dependencies = [ [[package]] name = "rtbit" -version = "0.1.0-beta.2" +version = "0.1.0-beta.3" dependencies = [ "anyhow", "bytes", diff --git a/RELEASE_NOTES_v0.1.0-beta.3.md b/RELEASE_NOTES_v0.1.0-beta.3.md new file mode 100644 index 0000000..b5131e5 --- /dev/null +++ b/RELEASE_NOTES_v0.1.0-beta.3.md @@ -0,0 +1,92 @@ +# rustTorrent v0.1.0-beta.3 + +## Summary + +rustTorrent 0.1.0-beta.3 improves migration safety, torrent recovery, and +qBittorrent compatibility. It adds fail-closed read-only payload access, +restores tracker lists that are missing from imported metainfo, supports force +rechecks, and corrects save-path handling for multi-file torrents. + +This remains beta software. Back up the persistent session directory before +upgrading and avoid using it for data that cannot be downloaded again. + +## Torrent recovery and verification + +- Tracker URLs can be added to existing torrents at runtime and are retained + across JSON and PostgreSQL session reloads. +- Restored trackers start announcing immediately for live torrents. This + recovers qBittorrent imports whose effective tracker lists existed only in + `.fastresume` data rather than the exported `.torrent` file. +- Native and qBittorrent-compatible force-recheck endpoints verify payloads + while preserving whether a torrent was paused or live. +- The Web UI exposes **Force Recheck** in the torrent context menu with + appropriate disabled-state handling. + +## Read-only payload migration + +- `--storage-read-only` and `RTBIT_STORAGE_READ_ONLY` opt into filesystem + storage that refuses payload writes, creation, resizing, deletion, and + directory removal. +- Existing payloads can be verified without modification, and missing payload + paths remain absent instead of being created implicitly. +- qBittorrent `savepath` values are now treated as payload roots for multi-file + torrents, including the single-entry multi-file metainfo edge case. +- Corrected output-folder roots persist through both JSON and PostgreSQL + session backends and are reflected by qBittorrent-compatible API responses. + +## SwarmForge library family + +- The reusable BitTorrent engine and protocol packages are now published as + the coordinated `swarmforge` / `swarmforge-*` 0.1.0 family on crates.io. +- Cargo package identities changed, while compatible Rust library and import + names such as `librtbit::Session` and `librtbit_core::Id20` remain available + through dependency aliases. +- All 12 family members must be migrated atomically in a consumer dependency + graph. Mixing historical and SwarmForge package identities can duplicate + shared types. +- The historical repositories and packages remain available as rollback + sources. NGMS independently verified consumption of the complete public + SwarmForge family before this release. + +## Web UI and deployment + +- Production `/web/` routes now use the same-origin API instead of incorrectly + redirecting requests to the Vite development port. +- Source, CI, binary releases, containers, and website delivery now use the + canonical GitHub repository and GitHub Actions workflows. +- Main builds publish immutable commit images and release tags publish public + multi-architecture `linux/amd64` and `linux/arm64` images to GHCR. + +## Upgrade notes + +- No intentional destructive session or RSS database migration is included. +- Keep `/home/rtbit/db` and `/home/rtbit/cache` persistent and back them up + before upgrading. +- For qBittorrent migrations, use read-only storage for the first verification + pass and confirm the payload root expected by each imported torrent. +- Consumers of the reusable libraries should follow the atomic migration and + rollback guidance in `docs/SWARMFORGE-0.1.0-RELEASE.md`. +- `latest` and `beta` move to this release after publication. Pin + `v0.1.0-beta.3` when reproducibility matters. + +## Validation + +- `cargo fmt --all -- --check` +- `cargo check --workspace --exclude rtbit-desktop --no-default-features --features default-tls` +- `cargo test --workspace --exclude rtbit-desktop --no-default-features --features default-tls` +- `cargo clippy --workspace --exclude rtbit-desktop --no-default-features --features default-tls -- -D warnings` +- Web UI unit tests, lint, production build, and Playwright browser tests +- Website structural validation +- GitHub release binary build and multi-architecture container publication + +## Downloads + +- Linux x86_64: `rtbit-v0.1.0-beta.3-linux-x86_64` +- Windows x86_64: `rtbit-v0.1.0-beta.3-windows-x86_64.exe` +- Debian/Ubuntu amd64: `rtbit-v0.1.0-beta.3-amd64.deb` +- Checksums: `SHA256SUMS-v0.1.0-beta.3.txt` +- Docker: `ghcr.io/thedancingdeveloper-org/rusttorrent:v0.1.0-beta.3` +- Source: automatic `.zip` and `.tar.gz` archives on the GitHub release tag + +Release files are attached to the canonical GitHub release and are also +published at `https://dl.rusttorrent.dev/v0.1.0-beta.3/`. diff --git a/crates/librtbit-dht/src/persistence.rs b/crates/librtbit-dht/src/persistence.rs index 73b38bb..73fbc4a 100644 --- a/crates/librtbit-dht/src/persistence.rs +++ b/crates/librtbit-dht/src/persistence.rs @@ -103,7 +103,7 @@ impl PersistentDht { if let Some(parent) = config_filename.parent() { std::fs::create_dir_all(parent) - .with_context(|| format!("error creating dir {:?}", &parent))?; + .with_context(|| format!("error creating dir {:?}", parent))?; } let de = match OpenOptions::new().read(true).open(&config_filename) { diff --git a/crates/librtbit/src/http_api_client.rs b/crates/librtbit/src/http_api_client.rs index 1bc0a01..4202751 100644 --- a/crates/librtbit/src/http_api_client.rs +++ b/crates/librtbit/src/http_api_client.rs @@ -80,7 +80,7 @@ impl HttpApiClient { if root.server == "rtbit" { return Ok(()); } - anyhow::bail!("not an rtbit server at {}", &self.base_url) + anyhow::bail!("not an rtbit server at {}", self.base_url) } .boxed() } @@ -103,7 +103,7 @@ impl HttpApiClient { ..Default::default() }; let qs = serde_urlencoded::to_string(¶ms).unwrap(); - let url = format!("{}torrents?{}", &self.base_url, qs); + let url = format!("{}torrents?{}", self.base_url, qs); let response = check_response( self.client .post(&url) diff --git a/crates/librtbit/src/storage/filesystem/fs.rs b/crates/librtbit/src/storage/filesystem/fs.rs index 7feea84..601e493 100644 --- a/crates/librtbit/src/storage/filesystem/fs.rs +++ b/crates/librtbit/src/storage/filesystem/fs.rs @@ -207,7 +207,7 @@ impl TorrentStorage for FilesystemStorage { .with_context(|| { format!( "error creating a new file (because allow_overwrite = false) {:?}", - &full_path + full_path ) })?; OpenOptions::new().read(true).write(true).open(&full_path)? diff --git a/crates/librtbit/src/torrent_state/live/peer_handler.rs b/crates/librtbit/src/torrent_state/live/peer_handler.rs index 400f305..8ee8ff3 100644 --- a/crates/librtbit/src/torrent_state/live/peer_handler.rs +++ b/crates/librtbit/src/torrent_state/live/peer_handler.rs @@ -591,7 +591,7 @@ impl PeerHandler { { anyhow::bail!( "got request for a chunk that is not ready to upload. chunk {:?}", - &chunk_info + chunk_info ); } @@ -866,7 +866,7 @@ impl PeerHandler { ) { Some(i) => i, None => { - anyhow::bail!("peer sent us an invalid piece {:?}", &piece,); + anyhow::bail!("peer sent us an invalid piece {:?}", piece,); } }; @@ -884,8 +884,8 @@ impl PeerHandler { if !h.inflight_requests.remove(&chunk_info) { anyhow::bail!( "peer sent us a piece we did not ask. Requested pieces: {:?}. Got: {:?}", - &h.inflight_requests, - &piece, + h.inflight_requests, + piece, ); } Ok(()) diff --git a/crates/librtbit/webui/src/main-mock.tsx b/crates/librtbit/webui/src/main-mock.tsx index b7cba3d..f1b1b9d 100644 --- a/crates/librtbit/webui/src/main-mock.tsx +++ b/crates/librtbit/webui/src/main-mock.tsx @@ -14,7 +14,7 @@ Object.assign(RssAPI, MockRssAPI); const RootWithMockAPI = () => { return ( - + ); }; diff --git a/crates/rtbit/Cargo.toml b/crates/rtbit/Cargo.toml index 884a6ae..ffa1da6 100644 --- a/crates/rtbit/Cargo.toml +++ b/crates/rtbit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rtbit" -version = "0.1.0-beta.2" +version = "0.1.0-beta.3" authors = ["AusAgentSmith "] edition = "2024" description = "A bittorrent command line client and server." diff --git a/documentation/ReleaseProcess.md b/documentation/ReleaseProcess.md index 26c4105..1ffe971 100644 --- a/documentation/ReleaseProcess.md +++ b/documentation/ReleaseProcess.md @@ -5,11 +5,11 @@ rusttorrent.dev website. The historical Forgejo/Woodpecker path is retired. ## Versioning -The current beta release is `0.1.0-beta.2`. +The current beta release is `0.1.0-beta.3`. - Crate version: `crates/rtbit/Cargo.toml` -- Release tag: `v0.1.0-beta.2` -- Docker tag: `ghcr.io/thedancingdeveloper-org/rusttorrent:v0.1.0-beta.2` +- Release tag: `v0.1.0-beta.3` +- Docker tag: `ghcr.io/thedancingdeveloper-org/rusttorrent:v0.1.0-beta.3` ## CI Flow @@ -53,15 +53,16 @@ Known permission failure modes: MyDevEnv2 container has not picked up the Komodo stack env values. Redeploy `prod-mydevenv2` from outside the active session; restarting the current container terminates the agent session. -- Woodpecker API calls must use numeric repo IDs. Owner/name pipeline endpoints - can return the frontend HTML with HTTP 200 and do no useful work. -- GHCR copy and GitHub release steps use the Woodpecker `gh_release_token` - secret. If GitHub validation returns `401` or GHCR returns `403`, rotate - `GITHUB_PAT` / `GH_RELEASE_TOKEN` in Infisical `cicd`, then refresh the - Woodpecker `gh_release_token` secret before tagging a release. The token - needs repository release access and GHCR package write access. +- Binary releases use the workflow-scoped `GITHUB_TOKEN` with `contents: write`. +- Container publication uses the repository `GHCR_TOKEN` secret and requires + `packages: write`. If GHCR login or publication fails, validate or rotate that + repository secret with the destination-organization credential documented in + the workspace guidance. +- Download-host publication uses the repository `DEPLOY_SSH_KEY` secret. +- Do not restore the retired Woodpecker release path or the revoked + `GITHUB_PAT` / `GH_RELEASE_TOKEN` credentials. -## v0.1.0-beta.1 Outcome +## Historical v0.1.0-beta.1 Outcome Woodpecker pipeline 71 published the Forgejo release and download artifacts on 2026-06-12. The initial GHCR and GitHub release stages failed because the @@ -82,9 +83,7 @@ updated with `manual`, `push`, and `tag` event access. - GitHub issues `#11` through `#15`: closed with direct links to the `librtbit` implementation commit and the rustTorrent release-integration commit -The PAT used for the repair was provided in chat. Rotate it again after the -release repair is complete, then update Infisical `GITHUB_PAT` / -`GH_RELEASE_TOKEN` and the Woodpecker `gh_release_token` secret with the -replacement value. +This section records the retired Forgejo/Woodpecker release outcome only. The +credentials and repair procedure used for beta.1 must not be reused. Do not print tokens, use `set -x`, or write credentials to repo files. diff --git a/website/demo/assets/mock-5UlMa0Nf.js b/website/demo/assets/mock-5UlMa0Nf.js new file mode 100644 index 0000000..55ad95c --- /dev/null +++ b/website/demo/assets/mock-5UlMa0Nf.js @@ -0,0 +1,15 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function k(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+k(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function k(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1F||(e.current=ie[F],ie[F]=null,F--)}function R(e,t){F++,ie[F]=e.current,e.current=t}var z=I(null),ae=I(null),B=I(null),V=I(null);function oe(e,t){switch(R(B,t),R(ae,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(z),R(z,e)}function H(){L(z),L(ae),L(B)}function se(e){e.memoizedState!==null&&R(V,e);var t=z.current,n=Hd(t,e.type);t!==n&&(R(ae,e),R(z,n))}function ce(e){ae.current===e&&(L(z),L(ae)),V.current===e&&(L(V),Qf._currentValue=P)}var le,U;function ue(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,U=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{de=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ue(n):``}function fe(e,t){switch(e.tag){case 26:case 27:case 5:return ue(e.type);case 16:return ue(`Lazy`);case 13:return e.child!==t&&t!==null?ue(`Suspense Fallback`):ue(`Suspense`);case 19:return ue(`SuspenseList`);case 0:case 15:return W(e.type,!1);case 11:return W(e.type.render,!1);case 1:return W(e.type,!0);case 31:return ue(`Activity`);default:return``}}function G(e){try{var t=``,n=null;do t+=fe(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var pe=Object.prototype.hasOwnProperty,K=t.unstable_scheduleCallback,me=t.unstable_cancelCallback,he=t.unstable_shouldYield,ge=t.unstable_requestPaint,q=t.unstable_now,_e=t.unstable_getCurrentPriorityLevel,J=t.unstable_ImmediatePriority,ve=t.unstable_UserBlockingPriority,ye=t.unstable_NormalPriority,be=t.unstable_LowPriority,xe=t.unstable_IdlePriority,Se=t.log,Ce=t.unstable_setDisableYieldValue,we=null,Te=null;function Ee(e){if(typeof Se==`function`&&Ce(e),Te&&typeof Te.setStrictMode==`function`)try{Te.setStrictMode(we,e)}catch{}}var De=Math.clz32?Math.clz32:Ae,Oe=Math.log,ke=Math.LN2;function Ae(e){return e>>>=0,e===0?32:31-(Oe(e)/ke|0)|0}var je=256,Me=262144,Ne=4194304;function Pe(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Fe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Pe(n))):i=Pe(o):i=Pe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Pe(n))):i=Pe(o)):i=Pe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Ie(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Le(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Re(){var e=Ne;return Ne<<=1,!(Ne&62914560)&&(Ne=4194304),e}function ze(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Be(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ve(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),$t=!1;if(Qt)try{var en={};Object.defineProperty(en,"passive",{get:function(){$t=!0}}),window.addEventListener(`test`,en,en),window.removeEventListener(`test`,en,en)}catch{$t=!1}var tn=null,nn=null,rn=null;function an(){if(rn)return rn;var e,t=nn,n=t.length,r,i=`value`in tn?tn.value:tn.textContent,a=i.length;for(e=0;e=Ln),Bn=` `,Vn=!1;function Hn(e,t){switch(e){case`keyup`:return Fn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Un(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Wn=!1;function Gn(e,t){switch(e){case`compositionend`:return Un(t);case`keypress`:return t.which===32?(Vn=!0,Bn):null;case`textInput`:return e=t.data,e===Bn&&Vn?null:e;default:return null}}function Kn(e,t){if(Wn)return e===`compositionend`||!In&&Hn(e,t)?(e=an(),rn=nn=tn=null,Wn=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=pr(n)}}function hr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?hr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Et(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Et(e.document)}return t}function _r(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`)}var X=Qt&&`documentMode`in document&&11>=document.documentMode,vr=null,yr=null,br=null,xr=!1;function Sr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;xr||vr==null||vr!==Et(r)||(r=vr,`selectionStart`in r&&_r(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}),br&&fr(br,r)||(br=r,r=Td(yr,`onSelect`),0>=o,i-=o,pi=1<<32-De(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Si&&hi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Si&&hi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Si&&hi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Si&&hi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&ha(l)===r.type){n(e,r.sibling),c=a(r,o.props),Sa(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ti(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ei(o.type,o.key,o.props,null,e.mode,c),Sa(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ii(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=ha(o),b(e,r,o,c)}if(re(o))return h(e,r,o,c);if(ne(o)){if(l=ne(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,xa(o),c);if(o.$$typeof===C)return b(e,r,Wi(e,o),c);Ca(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ni(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ba=0;var i=b(e,t,n,r);return ya=null,i}catch(t){if(t===ua||t===Q)throw t;var a=Xr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ta=wa(!0),Ea=wa(!1),Da=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ka(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Aa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ja(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,jl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=qr(e),Kr(e,null,n),t}return Ur(e,r,t,n),qr(e)}function Ma(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ue(e,n)}}function Na(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Pa=!1;function Fa(){if(Pa){var e=ta;if(e!==null)throw e}}function Ia(e,t,n,r){Pa=!1;var i=e.updateQueue;Da=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Pl&f)===f:(r&f)===f){f!==0&&f===ea&&(Pa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Da=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Hl|=o,e.lanes=o,e.memoizedState=d}}function La(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ra(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=M.T,s={};M.T=s,ws(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Cs(e,t,ia(c,r),uu(e)):Cs(e,t,r,uu(e))}catch(n){Cs(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function ps(){}function ms(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=hs(e).queue;fs(e,a,t,P,n===null?ps:function(){return gs(e),n(r)})}function hs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:P},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:To,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function gs(e){var t=hs(e);t.next===null&&(t=e.alternate.memoizedState),Cs(e,t.next.queue,{},uu())}function _s(){return Ui(Qf)}function vs(){return bo().memoizedState}function ys(){return bo().memoizedState}function bs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=Aa(n);var r=ja(t,e,n);r!==null&&(fu(r,t,n),Ma(r,t,n)),t={cache:Xi()},e.payload=t;return}t=t.return}}function xs(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ts(e)?Es(t,n):(n=Wr(e,t,n,r),n!==null&&(fu(n,e,r),Ds(n,t,r)))}function Ss(e,t,n){Cs(e,t,n,uu())}function Cs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ts(e))Es(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,dr(s,o))return Ur(e,t,i,0),Ml===null&&Hr(),!1}catch{}if(n=Wr(e,t,i,r),n!==null)return fu(n,e,r),Ds(n,t,r),!0}return!1}function ws(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ts(e)){if(t)throw Error(i(479))}else t=Wr(e,n,r,2),t!==null&&fu(t,e,2)}function Ts(e){var t=e.alternate;return e===$||t!==null&&t===$}function Es(e,t){ro=no=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ds(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ue(e,n)}}var Os={readContext:Ui,use:Co,useCallback:lo,useContext:lo,useEffect:lo,useImperativeHandle:lo,useLayoutEffect:lo,useInsertionEffect:lo,useMemo:lo,useReducer:lo,useRef:lo,useState:lo,useDebugValue:lo,useDeferredValue:lo,useTransition:lo,useSyncExternalStore:lo,useId:lo,useHostTransitionStatus:lo,useFormState:lo,useActionState:lo,useOptimistic:lo,useMemoCache:lo,useCacheRefresh:lo};Os.useEffectEvent=lo;var ks={readContext:Ui,use:Co,useCallback:function(e,t){return yo().memoizedState=[e,t===void 0?null:t],e},useContext:Ui,useEffect:$o,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Zo(4194308,4,as.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Zo(4194308,4,e,t)},useInsertionEffect:function(e,t){Zo(4,2,e,t)},useMemo:function(e,t){var n=yo();t=t===void 0?null:t;var r=e();if(io){Ee(!0);try{e()}finally{Ee(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=yo();if(n!==void 0){var i=n(t);if(io){Ee(!0);try{n(t)}finally{Ee(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=xs.bind(null,$,e),[r.memoizedState,e]},useRef:function(e){var t=yo();return e={current:e},t.memoizedState=e},useState:function(e){e=Fo(e);var t=e.queue,n=Ss.bind(null,$,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ss,useDeferredValue:function(e,t){return us(yo(),e,t)},useTransition:function(){var e=Fo(!1);return e=fs.bind(null,$,e.queue,!0,!1),yo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=$,a=yo();if(Si){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Ml===null)throw Error(i(349));Pl&127||Ao(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,$o(Mo.bind(null,r,o,e),[e]),r.flags|=2048,Yo(9,{destroy:void 0},jo.bind(null,r,o,n,t),null),n},useId:function(){var e=yo(),t=Ml.identifierPrefix;if(Si){var n=mi,r=pi;n=(r&~(1<<32-De(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ao++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Xe]=t,o[Ze]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Cc(t)}}return Oc(t),wc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Cc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=B.current,ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Xe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Ei(t,!0)}else e=Bd(e).createTextNode(r),e[Xe]=t,t.stateNode=e}return Oc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Xe]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),e=!1}else n=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Xa(t),t):(Xa(t),null);if(t.flags&128)throw Error(i(558))}return Oc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Xe]=t}else Ai(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Oc(t),a=!1}else a=ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Xa(t),t):(Xa(t),null)}return Xa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ec(t,t.updateQueue),Oc(t),null);case 4:return H(),e===null&&xd(t.stateNode.containerInfo),Oc(t),null;case 10:return Li(t.type),Oc(t),null;case 19:if(L(Za),r=t.memoizedState,r===null)return Oc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Dc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Qa(e),o!==null){for(t.flags|=128,Dc(r,!1),e=o.updateQueue,t.updateQueue=e,Ec(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)$r(n,e),n=n.sibling;return R(Za,Za.current&1|2),Si&&hi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&q()>Ql&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304)}else{if(!a)if(e=Qa(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ec(t,e),Dc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Si)return Oc(t),null}else 2*q()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Dc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Oc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=q(),e.sibling=null,n=Za.current,R(Za,a?n&1|2:n&1),Si&&hi(t,r.treeForkCount),e);case 22:case 23:return Xa(t),Ua(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Oc(t),t.subtreeFlags&6&&(t.flags|=8192)):Oc(t),n=t.updateQueue,n!==null&&Ec(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&L(oa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Li(Yi),Oc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Ac(e,t){switch(vi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Li(Yi),H(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(Xa(t),t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Xa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ai()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(Za),null;case 4:return H(),null;case 10:return Li(t.type),null;case 22:case 23:return Xa(t),Ua(),e!==null&&L(oa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Li(Yi),null;case 25:return null;default:return null}}function jc(e,t){switch(vi(t),t.tag){case 3:Li(Yi),H();break;case 26:case 27:case 5:ce(t);break;case 4:H();break;case 31:t.memoizedState!==null&&Xa(t);break;case 13:Xa(t);break;case 19:L(Za);break;case 10:Li(t.type);break;case 22:case 23:Xa(t),Ua(),e!==null&&L(oa);break;case 24:Li(Yi)}}function Mc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Nc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Pc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ra(t,n)}catch(t){Hu(e,e.return,t)}}}function Fc(e,t,n){n.props=Is(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Ic(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Lc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}function Rc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function zc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[Ze]=t}catch(t){Hu(e,e.return,t)}}function Bc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Vc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Bc(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.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Hc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Ut));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Hc(e,t,n),e=e.sibling;e!==null;)Hc(e,t,n),e=e.sibling}function Uc(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&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Xe]=e,t[Ze]=n}catch(t){Hu(e,e.return,t)}}var Gc=!1,Kc=!1,qc=!1,Jc=typeof WeakSet==`function`?WeakSet:Set,Yc=null;function Xc(e,t){if(e=e.containerInfo,Rd=sp,e=gr(e),_r(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Yc=t;Yc!==null;)if(t=Yc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Yc=e;else for(;Yc!==null;){switch(t=Yc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(o,r,n),o[Xe]=e,lt(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=mr(s,h),v=mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,M.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,jl&6)throw Error(i(331));var c=jl;if(jl|=4,El(o.current),vl(o,o.current,s,n),jl=c,nd(0,!1),Te&&typeof Te.onPostCommitFiberRoot==`function`)try{Te.onPostCommitFiberRoot(we,o)}catch{}return!0}finally{N.p=a,M.T=r,Ru(e,t)}}function Vu(e,t,n){t=oi(n,t),t=Hs(e.stateNode,t,2),e=ja(e,t,2),e!==null&&(Be(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=oi(n,e),n=Us(2),r=ja(t,n,2),r!==null&&(Ws(n,r,t,e),Be(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Al;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ml===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>q()-Xl?!(jl&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=Re()),e=Gr(e,t),e!==null&&(Be(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return K(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-De(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Fe(r,r===Ml?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Ie(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=q(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Ot(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Ot(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Ot(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Ot(n.imageSizes)+`"]`)):i+=`[href="`+Ot(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),lt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Ot(r)+`"][href="`+Ot(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),lt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=ct(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);lt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=ct(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=ct(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),lt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=B.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=ct(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=ct(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=ct(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Ot(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),lt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Ot(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Ot(n.href)+`"]`);if(r)return t.instance=r,lt(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),lt(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,lt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),lt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,lt(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),lt(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,lt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),lt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=(0,_.createContext)({listTorrents:()=>{throw Error(`Function not implemented.`)},getTorrentDetails:()=>{throw Error(`Function not implemented.`)},getTorrentStats:()=>{throw Error(`Function not implemented.`)},getTrackerStatus:()=>{throw Error(`Function not implemented.`)},getPeerStats:()=>{throw Error(`Function not implemented.`)},uploadTorrent:()=>{throw Error(`Function not implemented.`)},updateOnlyFiles:()=>{throw Error(`Function not implemented.`)},pause:()=>{throw Error(`Function not implemented.`)},start:()=>{throw Error(`Function not implemented.`)},recheck:()=>{throw Error(`Function not implemented.`)},addTrackers:()=>{throw Error(`Function not implemented.`)},forget:()=>{throw Error(`Function not implemented.`)},delete:()=>{throw Error(`Function not implemented.`)},getTorrentStreamUrl:()=>{throw Error(`Function not implemented.`)},getStreamLogsUrl:function(){throw Error(`Function not implemented.`)},getPlaylistUrl:function(e){throw Error(`Function not implemented.`)},stats:function(){throw Error(`Function not implemented.`)},getTorrentHaves:function(e){throw Error(`Function not implemented.`)},getLimits:function(){throw Error(`Function not implemented.`)},setLimits:function(e){throw Error(`Function not implemented.`)},getDhtStats:function(){throw Error(`Function not implemented.`)},setRustLog:function(e){throw Error(`Function not implemented.`)},getMetadata:function(e){throw Error(`Function not implemented.`)},getCategories:function(){throw Error(`Function not implemented.`)},createCategory:function(e,t){throw Error(`Function not implemented.`)},deleteCategory:function(e){throw Error(`Function not implemented.`)},setTorrentCategory:function(e,t){throw Error(`Function not implemented.`)},getAltSpeed:function(){throw Error(`Function not implemented.`)},toggleAltSpeed:function(e){throw Error(`Function not implemented.`)},setAltSpeedConfig:function(e){throw Error(`Function not implemented.`)},getSpeedSchedule:function(){throw Error(`Function not implemented.`)},setSpeedSchedule:function(e){throw Error(`Function not implemented.`)},getSeedLimits:function(){throw Error(`Function not implemented.`)},setSeedLimits:function(e){throw Error(`Function not implemented.`)},setTorrentSeedLimits:function(e,t){throw Error(`Function not implemented.`)},getTorrentLimits:function(e){throw Error(`Function not implemented.`)},setTorrentLimits:function(e,t){throw Error(`Function not implemented.`)},setSequential:function(e,t){throw Error(`Function not implemented.`)},setSuperSeed:function(e,t){throw Error(`Function not implemented.`)},queueMoveTop:function(e){throw Error(`Function not implemented.`)},queueMoveBottom:function(e){throw Error(`Function not implemented.`)},queueMoveUp:function(e){throw Error(`Function not implemented.`)},queueMoveDown:function(e){throw Error(`Function not implemented.`)},getFolders:function(){throw Error(`Function not implemented.`)},setFolders:function(e){throw Error(`Function not implemented.`)},browseDirectory:function(e){throw Error(`Function not implemented.`)}}),y=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),b=o(((e,t)=>{t.exports=y()}))(),x=c(m(),1),S=0,C=1,w=2,T=4;function E(e){return()=>e}function D(e){e()}function O(e,t){return n=>e(t(n))}function ee(e,t){return()=>e(t)}function te(e,t){return n=>e(t,n)}function k(e){return e!==void 0}function ne(...e){return()=>{e.map(D)}}function A(){}function j(e,t){return t(e),e}function re(e,t){return t(e)}function M(...e){return e}function N(e,t){return e(C,t)}function P(e,t){e(S,t)}function ie(e){e(w)}function F(e){return e(T)}function I(e,t){return N(e,te(t,S))}function L(e,t){let n=e(C,e=>{n(),t(e)});return n}function R(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function z(e,t){return e===t}function ae(e=z){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function B(e){return t=>n=>{e(n)&&t(n)}}function V(e){return t=>O(t,e)}function oe(e){return t=>()=>{t(e)}}function H(e,...t){let n=ue(...t);return((t,r)=>{switch(t){case w:ie(e);return;case C:return N(e,n(r))}})}function se(e,t){return n=>r=>{n(t=e(t,r))}}function ce(e){return t=>n=>{e>0?e--:t(n)}}function le(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function U(...e){let t=Array(e.length),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;N(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function ue(...e){return t=>e.reduceRight(re,t)}function de(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case C:return a?n===a?void 0:(r(),n=a,t=N(e,a),t):(r(),A);case w:r(),n=null;return}}}function W(e){let t=e,n=G();return((e,r)=>{switch(e){case S:t=r;break;case C:r(t);break;case T:return t}return n(e,r)})}function fe(e,t){return j(W(t),t=>I(e,t))}function G(){let e=[];return((t,n)=>{switch(t){case S:e.slice().forEach(e=>{e(n)});return;case w:e.splice(0,e.length);return;case C:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function pe(e){return j(G(),t=>I(e,t))}function K(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:me(),singleton:n}}var me=()=>Symbol();function he(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function ge(...e){let t=G(),n=Array(e.length),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;N(e,e=>{n[a]=e,r|=o,r===i&&P(t,n)})}),function(e,a){switch(e){case w:ie(t);return;case C:return r===i&&a(n),N(t,a)}}}function q(e,t=z){return H(e,ae(t))}function _e(...e){return function(t,n){switch(t){case w:return;case C:return ne(...e.map(e=>N(e,n)))}}}var J={DEBUG:0,INFO:1,WARN:2,ERROR:3},ve={[J.DEBUG]:`debug`,[J.ERROR]:`error`,[J.INFO]:`log`,[J.WARN]:`warn`},ye=()=>typeof globalThis>`u`?window:globalThis,be=K(()=>{let e=W(J.ERROR);return{log:W((t,n,r=J.INFO)=>{r>=(ye().VIRTUOSO_LOG_LEVEL??F(e))&&console[ve[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),xe=new WeakMap;function Se(e){return`self`in e?e.document.documentElement:e}function Ce(e){let t=Se(e),n=xe.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return xe.set(t,r),r}function we(e){xe.delete(Se(e))}function Te(e,t){return Ce(e)?-t:t}var Ee=Te;function De(e,t){return Te(e,t)}function Oe(e,t,n){return ke(e,t,n).callbackRef}function ke(e,t,n){let r=_.useRef(null),i=e=>{},a=_.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function Ae(e,t,n,r,i,a,o,s,c){return ke(_.useCallback(n=>{let c=je(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?Ee(o,o.scrollLeft):o.scrollTop:u?s?Ee(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?Ee(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Me(`column-gap`,getComputedStyle(n).columnGap,i):Me(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function je(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=ke(i,!0,n),s=_.useCallback(()=>{i(o.current)},[i,o]);return _.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var Pe=K(()=>{let e=G(),t=G(),n=W(0),r=G(),i=W(0),a=G(),o=G(),s=W(0),c=W(0),l=W(0),u=W(0),d=G(),f=G(),p=W(!1),m=W(!1),h=W(!1);return I(H(e,V(({scrollTop:e})=>e)),t),I(H(e,V(({scrollHeight:e})=>e)),o),I(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),Fe={lvl:0};function Ie(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;ot&&(s=s.concat(Ge(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(Ge(a,t,n))),s}function Ke(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Ye(t))return $e(qe(e,{lvl:n-1}));if(!Le(t)&&!Le(t.r))return qe(t.r,{l:qe(t,{r:t.r.l}),lvl:n,r:qe(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Ye(e))return et(qe(e,{lvl:n-1}));if(!Le(r)&&!Le(r.l)){let t=r.l,i=Ye(t)?r.lvl-1:r.lvl;return qe(t,{l:qe(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:et(qe(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function qe(e,t){return Ze(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function Je(e){return Le(e.r)?e.l:Ke(qe(e,{r:Je(e.r)}))}function Ye(e){return Le(e)||e.lvl>e.r.lvl}function Xe(e){return Le(e.r)?[e.k,e.v]:Xe(e.r)}function Ze(e,t,n,r=Fe,i=Fe){return{k:e,l:r,lvl:n,r:i,v:t}}function Qe(e){return et($e(e))}function $e(e){let{l:t}=e;return!Le(t)&&t.lvl===e.lvl?qe(t,{r:qe(e,{l:t.r})}):e}function et(e){let{lvl:t,r:n}=e;return!Le(n)&&!Le(n.r)&&n.lvl===t&&n.r.lvl===t?qe(n,{l:qe(e,{r:n.l}),lvl:t+1}):e}function tt(e){return Ie(e,({k:e,v:t})=>({index:e,value:t}))}function nt(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function rt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var it=K(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function at(e,t,n){return e[ot(e,t,n)]}function ot(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function st(e,t,n,r){let i=ot(e,t,r),a=ot(e,n,r,i);return e.slice(i,a+1)}function ct(e,t){return Math.round(e.getBoundingClientRect()[t])}function lt(e){return!Le(e.groupOffsetTree)}function ut({index:e},t){return t===e?0:t=r||i===a)&&(e=Ue(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Be(e,t+1,a));c&&(e=Be(e,a,i))}return[e,n]}function pt(e){return typeof e.groupIndex<`u`}function mt({offset:e},t){return t===e?0:t0?s+n:s}function gt(e,t){if(!lt(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function _t(e,t,n){if(pt(e))return t.groupIndices[e.groupIndex]+1;let r=gt(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function vt(e,t,n,r=0){return r>0&&(t=Math.max(t,at(e,r,ut).offset)),Ie(st(e,t,n,mt),Ct)}function yt(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,J.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Le(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Be(Be(t,n,e),n+1,r),o)}else [o,s]=ft(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=St(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Be(e,t,ht(t,d,i)),Ve()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function bt(e){return We(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function xt(e,t){let n=0,r=0;for(;ne.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var Tt={offsetHeight:`height`,offsetWidth:`width`},Et=K(([{log:e},{recalcInProgress:t}])=>{let n=G(),r=G(),i=fe(r,0),a=G(),o=G(),s=W(0),c=W([]),l=W(void 0),u=W(void 0),d=W(void 0),f=W(void 0),p=W((e,t)=>ct(e,Tt[t])),m=W(void 0),h=W(0),g=dt(),_=fe(H(n,U(c,e,h),se(yt,g),ae()),g),v=fe(H(c,ae(),se((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),V(({prev:e})=>e)),[]);I(H(c,B(e=>e.length>0),U(_,h),V(([e,t,n])=>{let r=e.reduce((e,r,i)=>Be(e,r,ht(r,t.offsetTree,n)||i),Ve());return{...t,groupIndices:e,groupOffsetTree:r}})),_),I(H(r,U(_),B(([e,{lastIndex:t}])=>e[{endIndex:t,size:n,startIndex:e}])),n),I(l,u);let y=fe(H(l,V(e=>e===void 0)),!0);I(H(u,B(e=>e!==void 0&&Le(F(_).sizeTree)),V(e=>{let t=F(d),n=F(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),I(H(f,B(e=>e!==void 0&&e.length>0&&Le(F(_).sizeTree)),V(e=>{let t=[],n=e[0],r=0;for(let i=1;ie!==void 0&&t!==void 0),V(([e,t,n])=>{let r=[];for(let i=0;i({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),V(e=>e.changed)));N(H(s,se((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),V(e=>e.diff)),e=>{let{groupIndices:n}=F(_);if(e>0)P(t,!0),P(a,e+xt(e,n));else if(e<0){let t=F(v);t.length>0&&(e-=xt(-e,t)),P(o,e)}}),N(H(s,U(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},J.ERROR)});let x=pe(a);I(H(a,U(_),V(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=Re(t.sizeTree,0),a=0,o=0;for(;a{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return We(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=pe(H(o,U(_,h),V(([e,{offsetTree:t},n])=>ht(-e,t,n))));return I(H(o,U(_,h),V(([e,t,n])=>{if(t.groupIndices.length>0){if(Le(t.sizeTree))return t;let r=Ve(),i=F(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=We(t.sizeTree).reduce((t,{k:n,v:r})=>Be(t,Math.max(0,n+e),r),r),a!==-e){let n=Re(t.sizeTree,s);r=Be(r,0,n);let i=ze(t.sizeTree,-e+1)[1];r=Be(r,1,i)}return{...t,sizeTree:r,...St(t.offsetTree,0,r,n)}}let r=We(t.sizeTree).reduce((t,{k:n,v:r})=>Be(t,Math.max(0,n+e),r),Ve());return{...t,sizeTree:r,...St(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},M(be,it),{singleton:!0});function Dt(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var Ot=K(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=G(),o=G(),s=pe(H(a,V(Dt)));return I(H(s,V(e=>e.totalCount)),n),I(H(s,V(e=>e.groupIndices)),e),I(H(ge(i,t,r),B(([e,t])=>lt(t)),V(([e,t,n])=>ze(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),ae(),V(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},M(Et,Pe)),kt=K(([{log:e}])=>{let t=W(!1),n=pe(H(t,B(e=>e),ae()));return N(t,t=>{t&&F(e)(`props updated`,{},J.DEBUG)}),{didMount:n,propsReady:t}},M(be),{singleton:!0}),At=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function jt(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!At)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var Mt=K(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=G(),m=G(),h=W(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),P(c,!1)}return I(H(p,U(n,d,r,h,s,o,f),U(e,a,i),V(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=jt(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=_t(b,n,w),E=ht(T,n.offsetTree,d)+o;x===`end`?(E+=f+ze(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+ze(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},J.DEBUG),P(p,e)):(P(m,!0),l(`list did not change, scroll successful`,{},J.DEBUG))};if(y(),S===`smooth`){let e=!1;v=N(t,t=>{e||=t}),g=L(u,()=>{D(e)})}else g=L(H(t,Nt(150)),D);return _=setTimeout(()=>{y()},1200),P(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},J.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},M(Et,Pe,be),{singleton:!0});function Nt(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function Pt(e,t){e===0?t():requestAnimationFrame(()=>{Pt(e-1,t)})}function Ft(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var It=K(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=W(!0),c=W(0),l=W(!0);return I(H(o,U(c),B(([e,t])=>t!==0),oe(!1)),s),I(H(o,U(c),B(([e,t])=>t!==0),oe(!1)),l),N(H(ge(t,o),U(s,n,e,l),B(([[,e],t,{sizeTree:n},r,i])=>e&&(!Le(n)||k(r))&&!t&&!i),U(c)),([,e])=>{L(i,()=>{P(l,!0)}),Pt(4,()=>{L(r,()=>{P(s,!0)}),P(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},M(Et,Pe,Mt,kt),{singleton:!0});function Lt(e,t){return Math.abs(e-t)<1.01}var Rt=`up`,zt=`down`,Bt=`none`,Vt={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ht=0,Ut=K(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=W(!1),s=W(!0),c=G(),l=G(),u=W(4),d=W(Ht),f=fe(H(_e(H(q(i),ce(1),oe(!0)),H(q(i),ce(1),oe(!1),R(100))),ae()),!1),p=fe(H(_e(H(n,oe(!0)),H(n,oe(!1),R(200))),ae()),!1);I(H(ge(q(i),q(d)),V(([e,t])=>e<=t),ae()),s),I(H(s,le(50)),l);let m=pe(H(ge(r,q(a),q(t),q(e),q(u)),se((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:re!==void 0&&e.atBottom===t.atBottom))),h=fe(H(r,se((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Lt(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),B(e=>e.changed),V(e=>e.jump)),0);I(H(m,V(e=>e.atBottom)),o),I(H(o,le(50)),c);let g=W(zt);I(H(r,V(({scrollTop:e})=>e),ae(),se((e,t)=>F(p)?{direction:e.direction,prevScrollTop:t}:{direction:te.direction)),g),I(H(r,le(50),oe(Bt)),g);let _=W(0);return I(H(f,B(e=>!e),oe(0)),_),I(H(i,le(100),U(f),B(([e,t])=>t),se(([e,t],[n])=>[t,n],[0,0]),V(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},M(Pe)),Wt=`top`,Gt=`bottom`,Kt=`none`;function qt(e,t,n){return typeof e==`number`?n===Rt&&t===Wt||n===zt&&t===Gt?e:0:n===Rt?t===Wt?e.main:e.reverse:t===Gt?e.main:e.reverse}function Jt(e,t){return typeof e==`number`?e:e[t]??0}var Yt=K(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=G(),o=W(0),s=W(0),c=W(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:fe(H(ge(q(r),q(i),q(n),q(a,rt),q(c),q(o),q(t),q(e),q(s)),V(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=Kt,m=Jt(l,Wt),h=Jt(l,Gt);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=Rt),ie!==null),ae(rt)),[0,0])}},M(Pe),{singleton:!0});function Xt(e,t,n){if(lt(t)){let r=gt(e,t);return[{index:ze(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var Zt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Qt(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:en(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:en(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function $t(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=Ft(t,s);return Qt(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function en(e,t,n){if(e.length===0)return[];if(!lt(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=He(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end{let h=W([]),g=W(0),_=G(),v=W(0);I(a.topItemsIndexes,h);let y=fe(H(ge(p,m,q(c,rt),q(i),q(r),q(l),u,q(h),q(t),q(n),q(v),e),B(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),V(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=F(g);if(n===0)return{...Zt,totalCount:n};if(e===0&&t===0)return m===0?{...Zt,totalCount:n}:$t(m,i,r,s,c,u||[]);if(Le(p))return m>0?null:Qt(Xt(Ft(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of He(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return Qt([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=vt(f,e,t,_);if(v.length===0)return null;let y=n-1,b=j([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=tn(l,Wt),S=tn(l,Gt);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=He(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.indexe!==null),ae()),Zt);I(H(e,B(k),V(e=>e?.length)),i),I(H(y,V(e=>e.topListHeight)),d),I(d,s),I(H(y,V(e=>[e.top,e.bottom])),o),I(H(y,V(e=>e.items)),_);let b=pe(H(y,B(({items:e})=>e.length>0),U(i,e),B(([{items:e},t])=>e[e.length-1].originalIndex===t-1),V(([,e,t])=>[e-1,t]),ae(rt),V(([e])=>e))),x=pe(H(y,le(200),B(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),V(({items:e})=>e[0].index),ae()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:pe(H(y,B(({items:e})=>e.length>0),V(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&tt;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),ae(nt))),startReached:x,topItemsIndexes:h,...f}},M(Et,Ot,Yt,It,Mt,Ut,kt,it),{singleton:!0}),rn=K(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=G(),o=fe(H(ge(n,e,r,t,i),V(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return I(q(o),a),{totalListHeight:o,totalListHeightChanged:a}},M(Pe,nn),{singleton:!0}),an=K(([{viewportHeight:e},{totalListHeight:t}])=>{let n=W(!1);return{alignToBottom:n,paddingTopAddition:fe(H(ge(n,e,t),B(([e])=>e),V(([,e,t])=>Math.max(0,e-t)),le(0),ae()),0)}},M(Pe,rn),{singleton:!0}),on=K(()=>({context:W(null)})),sn=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>ta?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,cn=K(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=G();return I(H(u,U(t,c,n,a,i,r,s),U(e),V(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=sn,done:d,...f}=e,p=_t(e,t,r-1),m=ht(p,t.offsetTree,l)+i+a,h=m+ze(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&L(H(o,B(e=>!e),ce(F(o)?1:2)),d),_}),B(e=>e!==null)),l),{scrollIntoView:u}},M(Et,Pe,Mt,nn,be),{singleton:!0});function ln(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var un=(e,t)=>typeof e==`function`?ln(e(t)):t&&ln(e),dn=K(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=W(!1),h=G(),g=null;function _(e){P(o,{align:`end`,behavior:e,index:`LAST`})}N(H(ge(H(q(t),ce(1)),c),U(q(m),a,s,d),V(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=un(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),B(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),F(n)===void 0?g=L(e,()=>{F(u)(`following output to `,{totalCount:r},J.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{F(u)(`following output to `,{totalCount:r},J.DEBUG),_(t)})});function v(e){let t=L(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(F(u)(`scrolling to bottom due to increased size`,{},J.DEBUG),_(`auto`))});setTimeout(t,100)}N(H(ge(q(m),t,l),B(([e,,t])=>e!==!1&&t),se(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),B(({refreshed:e})=>e),U(m,t)),([,e])=>{F(s)&&v(e!==!1)}),N(h,()=>{v(F(m)!==!1)}),N(ge(q(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=W(null),b=G();return I(_e(H(q(r),V(e=>e?.length??0)),H(q(t))),b),N(H(ge(H(b,ce(1)),c),U(q(y),s,d,f),V(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),B(e=>!!e),le(0)),t=>{g!==null&&(g(),g=null),F(n)===void 0?g=L(e,()=>{F(u)(`scrolling into view`,{}),P(p,t),g=null}):requestAnimationFrame(()=>{F(u)(`scrolling into view`,{}),P(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},M(Et,Ut,Mt,It,kt,be,Pe,on,cn)),fn=K(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(I(H(s,U(a),B(([,e])=>e!==0),U(i,r,t,n,e),V(([[,e],t,n,r,i,a=[]])=>$t(e,t,n,r,i,a))),o),{}),M(Et,It,nn,kt),{singleton:!0}),pn=K(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=W(0);return N(H(e,U(r),B(([,e])=>e!==0),V(([,e])=>({top:e}))),e=>{L(H(n,ce(1),B(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{P(t,e)})})}),{initialScrollTop:r}},M(kt,Pe,nn),{singleton:!0}),mn=K(([{scrollVelocity:e}])=>{let t=W(!1),n=G(),r=W(!1);return I(H(e,U(r,t,n),B(([e,t])=>t!==!1&&t!==void 0),V(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),ae()),t),N(H(ge(t,e,n),U(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},M(Ut),{singleton:!0}),hn=K(([{scrollContainerState:e,scrollTo:t}])=>{let n=G(),r=G(),i=G(),a=W(!1),o=W(void 0);return I(H(ge(n,r),V(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),I(H(t,U(r),V(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},M(Pe)),gn=K(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=G(),u=W(void 0),d=W(null),f=W(null);return I(s,d),I(c,f),N(H(l,U(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=bt(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),I(H(u,B(k),V(_n)),i),I(H(a,U(u),B(([,e])=>e!==void 0),ae(),V(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},M(Et,Pe,It,kt,hn));function _n(e){return{align:`start`,index:0,offset:e.scrollTop}}var vn=K(([{topItemsIndexes:e}])=>{let t=W(0);return I(H(t,B(e=>e>=0),V(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},M(nn));function yn(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var bn=yn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),xn=K(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:ee,...te}=b;return I(ee,T.scrollSeekRangeChanged),I(H(T.windowViewportRect,V(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:ee,...te,...T,..._,sizes:u,...v}},M(Et,It,Pe,gn,dn,nn,Mt,K(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=pe(H(c,U(o),se(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),B(([e])=>e!==0),U(r,s,n,i,p,m),B(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===Rt),V(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},J.DEBUG),e))));function g(n){n>0?(P(t,{behavior:`auto`,top:-n}),P(e,0)):(P(e,0),P(t,{behavior:`auto`,top:-n}))}return N(H(h,U(e,a)),([t,n,r])=>{r&&bn()?P(e,n-t):g(-t)}),N(H(ge(fe(a,!1),e,m),B(([e,t,n])=>!e&&!n&&t!==0),V(([e,t])=>t),le(1)),g),I(H(d,V(e=>({top:-e}))),t),N(H(l,U(f,u),V(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=Re(r,0),c=0,l=0;for(;ce&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{P(e,n),requestAnimationFrame(()=>{P(t,{top:n}),requestAnimationFrame(()=>{P(e,0),P(m,!1)})})}),{deviation:e}},M(Pe,Ut,nn,Et,be,it)),vn,Ot,K(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),M(Yt,fn,kt,mn,rn,pn,an,hn,cn,be,on))));function Sn(e,t){let n={},r={},i=0,a=e.length;for(;i(n[r]=n=>{let i=e[t.methods[r]];P(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=de(e[t.events[r]]),n),{})}return{Component:_.forwardRef(function(t,a){let{children:d,...f}=t,[p]=_.useState(()=>j(he(e),e=>{c(e,f)})),[m]=_.useState(ee(u,p));Cn(()=>{for(let e of o)e in f&&N(m[e],f[e]);return()=>{Object.values(m).map(ie)}},[f,m,p]),Cn(()=>{c(p,f)}),_.useImperativeHandle(a,E(l(p)));let h=n;return(0,b.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,b.jsx)(h,{...Sn([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=_.useContext(s)[e];Cn(()=>N(n,t),[t,n])},useEmitterValue:e=>{let t=_.useContext(s)[e],n=_.useCallback(e=>N(t,e),[t]);return _.useSyncExternalStore(n,()=>F(t),()=>F(t))},usePublisher:e=>{let t=_.useContext(s);return _.useCallback(n=>{P(t[e],n)},[t,e])}}}var Tn=_.createContext(void 0),En=_.createContext(void 0),Dn=`-webkit-sticky`,On=`sticky`,kn=yn(()=>{if(typeof document>`u`)return On;let e=document.createElement(`div`);return e.style.position=Dn,e.style.position===Dn?Dn:On}),An=typeof document<`u`?_.useLayoutEffect:_.useEffect;function jn(e){return`self`in e}function Mn(e){return`body`in e}function Nn(e,t,n,r=A,i,a){let o=_.useRef(null),s=_.useRef(null),c=_.useRef(null),l=_.useCallback(n=>{let r,i,o,l=n.target;if(Mn(l)||jn(l)){let e=jn(l)?l:l.defaultView;o=a===!0?Ee(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?Ee(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():x.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);_.useEffect(()=>{let e=i||o.current;return we(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{we(e),r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;jn(r)?(u=Math.max(ct(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?Ee(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=ct(r,a===!0?`width`:`height`),d=a===!0?Ee(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,Lt(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:De(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:De(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function Pn(e){return e}var Fn=K(([e,t])=>({...e,...t}),M(xn,K(()=>{let e=W(e=>`Item ${e}`),t=W(e=>`Group ${e}`),n=W({}),r=W(Pn),i=W(`div`),a=W(A),o=(e,t=null)=>fe(H(n,V(t=>t[e]),ae()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),In=({height:e})=>(0,b.jsx)(`div`,{style:{height:e}}),Ln={overflowAnchor:`none`,position:kn(),zIndex:1},Rn={overflowAnchor:`none`},zn={...Rn,display:`inline-block`,height:`100%`},Bn=_.memo(function({showTopList:e=!1}){let t=Y(`listState`),n=rr(`sizeRanges`),r=Y(`useWindowScroll`),i=Y(`customScrollParent`),a=rr(`windowScrollContainerState`),o=rr(`scrollContainerState`),s=i||r?a:o,c=Y(`itemContent`),l=Y(`context`),u=Y(`groupContent`),d=Y(`trackItemSizes`),f=Y(`itemSize`),p=Y(`log`),m=rr(`gap`),h=Y(`horizontalDirection`),{callbackRef:g}=Ae(n,f,d,e?A:s,p,m,i,h,Y(`skipAnimationFrameInResizeObserver`)),[v,y]=_.useState(0);nr(`deviation`,e=>{v!==e&&y(e)});let x=Y(`EmptyPlaceholder`),S=Y(`ScrollSeekPlaceholder`)??In,C=Y(`ListComponent`),w=Y(`ItemComponent`),T=Y(`GroupComponent`),E=Y(`computeItemKey`),D=Y(`isSeeking`),O=Y(`groupIndices`).length>0,ee=Y(`alignToBottom`),te=Y(`initialItemFinalLocationReached`),k=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:v===0?ee?`auto`:0:v,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:v===0?ee?`auto`:0:v,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...te?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&x!=null?(0,b.jsx)(x,{...Kn(x,l)}):(0,b.jsx)(C,{...Kn(C,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:k,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=E(n+t.firstItemIndex,e.data,l);return D?(0,_.createElement)(S,{...Kn(S,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,_.createElement)(T,{...Kn(T,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:Ln},u(e.index,l)):(0,_.createElement)(w,{...Kn(w,l),...qn(w,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?zn:Rn},O?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),Vn={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},Hn={outline:`none`,overflowX:`auto`,position:`relative`},Un=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),Wn=(e,t,n=0)=>({...Un(e),position:t?`relative`:`absolute`,top:t?-n:0}),Gn={position:kn(),top:0,width:`100%`,zIndex:1};function Kn(e,t){if(typeof e!=`string`)return{context:t}}function qn(e,t){return{item:typeof e==`string`?void 0:t}}var Jn=_.memo(function(){let e=Y(`HeaderComponent`),t=rr(`headerHeight`),n=Y(`HeaderFooterTag`),r=Oe(_.useMemo(()=>e=>{t(ct(e,`height`))},[t]),!0,Y(`skipAnimationFrameInResizeObserver`)),i=Y(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...Kn(e,i)})})}),Yn=_.memo(function(){let e=Y(`FooterComponent`),t=rr(`footerHeight`),n=Y(`HeaderFooterTag`),r=Oe(_.useMemo(()=>e=>{t(ct(e,`height`))},[t]),!0,Y(`skipAnimationFrameInResizeObserver`)),i=Y(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...Kn(e,i)})})});function Xn({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=Nn(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,b.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?Hn:Vn,...i},tabIndex:0,...o,...Kn(c,a),children:r})})}function Zn({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=_.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=Nn(s,l,c,t(`scrollerRef`),f);return An(()=>(h.current=f||p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,b.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...Kn(c,a),children:r})})}var Qn=({children:e})=>{let t=_.useContext(Tn),n=rr(`viewportHeight`),r=rr(`fixedItemHeight`),i=Y(`alignToBottom`),a=Y(`horizontalDirection`),o=Oe(_.useMemo(()=>O(n,e=>ct(e,a?`width`:`height`)),[n,a]),!0,Y(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:Un(i),children:e})},$n=({children:e})=>{let t=_.useContext(Tn),n=rr(`windowViewportRect`),r=rr(`fixedItemHeight`),i=Y(`customScrollParent`),a=Y(`useWindowScroll`),o=Y(`topListHeight`),s=Ne(n,i,Y(`skipAnimationFrameInResizeObserver`)),c=Y(`alignToBottom`);return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:Wn(c,a,o),children:e})},er=({children:e})=>{let t=Y(`TopItemListComponent`)??`div`,n=Y(`headerHeight`);return(0,b.jsx)(t,{style:{...Gn,marginTop:`${n}px`},...Kn(t,Y(`context`)),children:e})},{Component:tr,useEmitter:nr,useEmitterValue:Y,usePublisher:rr}=wn(Fn,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=Y(`useWindowScroll`),n=Y(`topItemsIndexes`).length>0,r=Y(`customScrollParent`),i=Y(`context`);return(0,b.jsxs)(r||t?ar:ir,{...e,context:i,children:[n&&(0,b.jsx)(er,{children:(0,b.jsx)(Bn,{showTopList:!0})}),(0,b.jsxs)(r||t?$n:Qn,{children:[(0,b.jsx)(Jn,{}),(0,b.jsx)(Bn,{}),(0,b.jsx)(Yn,{})]})]})})),ir=Xn({useEmitter:nr,useEmitterValue:Y,usePublisher:rr}),ar=Zn({useEmitter:nr,useEmitterValue:Y,usePublisher:rr}),or=tr,sr=K(([e,t])=>({...e,...t}),M(xn,K(()=>{let e=W(e=>(0,b.jsxs)(`td`,{children:[`Item $`,e]})),t=W(null),n=W(e=>(0,b.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=W(null),i=W(null),a=W({}),o=W(Pn),s=W(A),c=(e,t=null)=>fe(H(a,V(t=>t[e]),ae()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),cr=({height:e})=>(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{style:{height:e}})}),lr=({height:e})=>(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),ur={overflowAnchor:`none`},dr={position:kn(),zIndex:2,overflowAnchor:`none`},fr=_.memo(function({showTopList:e=!1}){let t=X(`listState`),n=X(`computeItemKey`),r=X(`firstItemIndex`),i=X(`context`),a=X(`isSeeking`),o=X(`fixedHeaderHeight`),s=X(`groupIndices`).length>0,c=X(`itemContent`),l=X(`groupContent`),u=X(`ScrollSeekPlaceholder`)??cr,d=X(`GroupComponent`),f=X(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,_.createElement)(u,{...Kn(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,_.createElement)(d,{...Kn(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...dr,top:o}},l(t.index,i)):(0,_.createElement)(f,{...Kn(f,i),...qn(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...dr,top:o+g}:ur},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),pr=_.memo(function(){let e=X(`listState`),t=X(`topItemsIndexes`).length>0,n=vr(`sizeRanges`),r=X(`useWindowScroll`),i=X(`customScrollParent`),a=vr(`windowScrollContainerState`),o=vr(`scrollContainerState`),s=i||r?a:o,c=X(`trackItemSizes`),{callbackRef:l,ref:u}=Ae(n,X(`itemSize`),c,s,X(`log`),void 0,i,!1,X(`skipAnimationFrameInResizeObserver`)),[d,f]=_.useState(0);_r(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=X(`EmptyPlaceholder`),m=X(`FillerRow`)??lr,h=X(`TableBodyComponent`),g=X(`paddingTopAddition`),v=X(`statefulTotalCount`),y=X(`context`);if(v===0&&p!=null)return(0,b.jsx)(p,{...Kn(p,y)});let x=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),S=e.offsetTop+g+d-x,C=e.offsetBottom,w=S>0?(0,b.jsx)(m,{context:y,height:S},`padding-top`):null,T=C>0?(0,b.jsx)(m,{context:y,height:C},`padding-bottom`):null;return(0,b.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...Kn(h,y),children:[w,t&&(0,b.jsx)(fr,{showTopList:!0}),(0,b.jsx)(fr,{}),T]})}),mr=({children:e})=>{let t=_.useContext(Tn),n=vr(`viewportHeight`),r=vr(`fixedItemHeight`),i=Oe(_.useMemo(()=>O(n,e=>ct(e,`height`)),[n]),!0,X(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:Un(!1),children:e})},hr=({children:e})=>{let t=_.useContext(Tn),n=vr(`windowViewportRect`),r=vr(`fixedItemHeight`),i=X(`customScrollParent`),a=X(`useWindowScroll`),o=Ne(n,i,X(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:Wn(!1,a),children:e})},{Component:gr,useEmitter:_r,useEmitterValue:X,usePublisher:vr}=wn(sr,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=X(`useWindowScroll`),n=X(`customScrollParent`),r=vr(`fixedHeaderHeight`),i=vr(`fixedFooterHeight`),a=X(`fixedHeaderContent`),o=X(`fixedFooterContent`),s=X(`context`),c=Oe(_.useMemo(()=>O(r,e=>ct(e,`height`)),[r]),!0,X(`skipAnimationFrameInResizeObserver`)),l=Oe(_.useMemo(()=>O(i,e=>ct(e,`height`)),[i]),!0,X(`skipAnimationFrameInResizeObserver`)),u=n||t?br:yr,d=n||t?hr:mr,f=X(`TableComponent`),p=X(`TableHeadComponent`),m=X(`TableFooterComponent`),h=a?(0,b.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...Kn(p,s),children:a()},`TableHead`):null,g=o?(0,b.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...Kn(m,s),children:o()},`TableFoot`):null;return(0,b.jsx)(u,{...e,...Kn(u,s),children:(0,b.jsx)(d,{children:(0,b.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...Kn(f,s),children:[h,(0,b.jsx)(pr,{},`TableBody`),g]})})})})),yr=Xn({useEmitter:_r,useEmitterValue:X,usePublisher:vr}),br=Zn({useEmitter:_r,useEmitterValue:X,usePublisher:vr}),xr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Sr={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Cr,floor:wr,max:Tr,min:Er,round:Dr}=Math;function Or(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function kr(e){return{...Sr,items:e}}function Ar(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function jr(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Mr=K(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=W(0),C=W(0),w=W(xr),T=W({height:0,width:0}),E=W({height:0,width:0}),D=G(),O=G(),ee=W(0),te=W(null),k=W({column:0,row:0}),ne=G(),A=G(),j=W(!1),re=W(0),M=W(!0),ie=W(!1),F=W(!1);N(H(m,U(re),B(([e,t])=>t!==0)),()=>{P(M,!1)}),N(H(ge(m,M,E,T,re,ie),B(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{P(ie,!0),Pt(1,()=>{P(D,e)}),L(H(l),()=>{P(t,[0,0]),P(M,!0)})}),I(H(A,B(e=>e!=null&&e.scrollTop>0),oe(0)),C),N(H(m,U(A),B(([,e])=>e!=null)),([,e])=>{e&&(P(T,e.viewport),P(E,e.item),P(k,e.gap),e.scrollTop>0&&(P(j,!0),L(H(l,ce(1)),e=>{P(j,!1)}),P(c,{top:e.scrollTop})))}),I(H(T,V(({height:e})=>e)),d),I(H(ge(q(T,Ar),q(E,Ar),q(k,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),q(l)),V(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),ne),I(H(ge(q(S),r,q(k,jr),q(E,Ar),q(T,Ar),q(te),q(C),q(j),q(M),q(re)),B(([,,,,,,,e])=>!e),V(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return xr;if(p===0){let t=Ft(l,e);return kr(Or(t,t+Math.max(s-1,0),o))}let h=Nr(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*wr((t+d)/(f+d)),_=h*Cr((n+d)/(f+d))-1,_=Er(e-1,Tr(_,h-1)),g=Er(_,Tr(0,g))):(g=0,_=-1);let v=Or(g,_,o),{bottom:y,top:b}=Pr(a,r,i,v),x=Cr(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),I(H(te,B(e=>e!==null),V(e=>e.length)),S),I(H(ge(T,E,w,k),B(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),V(([e,t,{items:n},r])=>{let{bottom:i,top:a}=Pr(e,r,t,n);return[a,i]}),ae(rt)),t);let R=W(!1);I(H(l,U(R),V(([e,t])=>t||e!==0)),R);let z=pe(H(ge(w,S),B(([{items:e}])=>e.length>0),U(R),B(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),V(([[,e]])=>e-1),ae())),se=pe(H(q(w),B(({items:e})=>e.length>0&&e[0].index===0),oe(0),ae())),ue=pe(H(q(w),U(j),B(([{items:e},t])=>e.length>0&&!t),V(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),ae(nt),le(0)));I(ue,p.scrollSeekRangeChanged),I(H(D,U(T,E,S,k),V(([e,t,n,r,i])=>{let a=jt(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Tr(0,l,Er(r-1,l));let u=Fr(t,i,n,l);return o===`end`?u=Dr(u-t.height+n.height):o===`center`&&(u=Dr(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let de=fe(H(w,V(e=>e.offsetBottom+e.bottom)),0);return I(H(b,V(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:te,deviation:ee,footerHeight:i,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:A,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:F,initialTopMostItemIndex:re,totalListHeight:de,...f,endReached:z,propsReady:h,rangeChanged:ue,startReached:se,stateChanged:ne,stateRestoreInProgress:j,...x}},M(Yt,Pe,Ut,mn,kt,hn,be));function Nr(e,t,n){return Tr(1,wr((e+n)/(wr(t)+n)))}function Pr(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Fr(e,t,n,r[0].index);return{bottom:Fr(e,t,n,r[r.length-1].index)+i,top:a}}function Fr(e,t,n,r){let i=wr(r/Nr(e.width,n.width,t.column)),a=i*n.height+Tr(0,i-1)*t.row;return a>0?a+t.row:a}var Ir=K(([e,t])=>({...e,...t}),M(Mr,K(()=>{let e=W(e=>`Item ${e}`),t=W({}),n=W(null),r=W(`virtuoso-grid-item`),i=W(`virtuoso-grid-list`),a=W(Pn),o=W(`div`),s=W(A),c=(e,n=null)=>fe(H(t,V(t=>t[e]),ae()),n),l=W(!1),u=W(!1);return I(q(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),Lr=_.memo(function(){let e=Wr(`gridState`),t=Wr(`listClassName`),n=Wr(`itemClassName`),r=Wr(`itemContent`),i=Wr(`computeItemKey`),a=Wr(`isSeeking`),o=Gr(`scrollHeight`),s=Wr(`ItemComponent`),c=Wr(`ListComponent`),l=Wr(`ScrollSeekPlaceholder`),u=Wr(`context`),d=Gr(`itemDimensions`),f=Gr(`gap`),p=Wr(`log`),m=Wr(`stateRestoreInProgress`),h=Gr(`reportReadyState`),g=Oe(_.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:Jr(`column-gap`,getComputedStyle(e).columnGap,p),row:Jr(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return An(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,b.jsx)(c,{className:t,ref:g,...Kn(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,b.jsx)(l,{...Kn(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,_.createElement)(s,{...Kn(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),Rr=_.memo(function(){let e=Wr(`HeaderComponent`),t=Gr(`headerHeight`),n=Wr(`headerFooterTag`),r=Oe(_.useMemo(()=>e=>{t(ct(e,`height`))},[t]),!0,!1),i=Wr(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...Kn(e,i)})})}),zr=_.memo(function(){let e=Wr(`FooterComponent`),t=Gr(`footerHeight`),n=Wr(`headerFooterTag`),r=Oe(_.useMemo(()=>e=>{t(ct(e,`height`))},[t]),!0,!1),i=Wr(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...Kn(e,i)})})}),Br=({children:e})=>{let t=_.useContext(En),n=Gr(`itemDimensions`),r=Gr(`viewportDimensions`),i=Oe(_.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return _.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,b.jsx)(`div`,{ref:i,style:Un(!1),children:e})},Vr=({children:e})=>{let t=_.useContext(En),n=Gr(`windowViewportRect`),r=Gr(`itemDimensions`),i=Wr(`customScrollParent`),a=Wr(`useWindowScroll`),o=Ne(n,i,!1);return _.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,b.jsx)(`div`,{ref:o,style:Wn(!1,a),children:e})},{Component:Hr,useEmitter:Ur,useEmitterValue:Wr,usePublisher:Gr}=wn(Ir,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},_.memo(function({...e}){let t=Wr(`useWindowScroll`),n=Wr(`customScrollParent`),r=n||t?qr:Kr,i=n||t?Vr:Br,a=Wr(`context`);return(0,b.jsx)(r,{...e,...Kn(r,a),children:(0,b.jsxs)(i,{children:[(0,b.jsx)(Rr,{}),(0,b.jsx)(Lr,{}),(0,b.jsx)(zr,{})]})})})),Kr=Xn({useEmitter:Ur,useEmitterValue:Wr,usePublisher:Gr}),qr=Zn({useEmitter:Ur,useEmitterValue:Wr,usePublisher:Gr});function Jr(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,J.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Yr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xr=_.createContext&&_.createContext(Yr),Zr=[`attr`,`size`,`title`];function Qr(e,t){if(e==null)return{};var n,r,i=$r(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r_.createElement(e.tag,ni({key:t},e.attr),oi(e.child)))}function Z(e){return t=>_.createElement(si,ei({attr:ni({},e.attr)},t),oi(e.child))}function si(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=Qr(e,Zr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),_.createElement(`svg`,ei({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ni(ni({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&_.createElement(`title`,null,i),e.children)};return Xr===void 0?t(Yr):_.createElement(Xr.Consumer,null,e=>t(e))}function ci(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.72 5.72a.75.75 0 0 1 1.06 0L12 10.94l5.22-5.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L13.06 12l5.22 5.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L12 13.06l-5.22 5.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.94 12 5.72 6.78a.75.75 0 0 1 0-1.06Z`},child:[]}]})(e)}function li(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`m12.354 8.854 5.792 5.792a.5.5 0 0 1-.353.854H6.207a.5.5 0 0 1-.353-.854l5.792-5.792a.5.5 0 0 1 .708 0Z`},child:[]}]})(e)}function ui(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M11.646 15.146 5.854 9.354a.5.5 0 0 1 .353-.854h11.586a.5.5 0 0 1 .353.854l-5.793 5.792a.5.5 0 0 1-.707 0Z`},child:[]}]})(e)}function di(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M10.25 2a8.25 8.25 0 0 1 6.34 13.53l5.69 5.69a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-5.69-5.69A8.25 8.25 0 1 1 10.25 2ZM3.5 10.25a6.75 6.75 0 1 0 13.5 0 6.75 6.75 0 0 0-13.5 0Z`},child:[]}]})(e)}function fi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M3.5 8a5.5 5.5 0 1 1 8.596 4.547 9.005 9.005 0 0 1 5.9 8.18.751.751 0 0 1-1.5.045 7.5 7.5 0 0 0-14.993 0 .75.75 0 0 1-1.499-.044 9.005 9.005 0 0 1 5.9-8.181A5.496 5.496 0 0 1 3.5 8ZM9 4a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm8.29 4c-.148 0-.292.01-.434.03a.75.75 0 1 1-.212-1.484 4.53 4.53 0 0 1 3.38 8.097 6.69 6.69 0 0 1 3.956 6.107.75.75 0 0 1-1.5 0 5.193 5.193 0 0 0-3.696-4.972l-.534-.16v-1.676l.41-.209A3.03 3.03 0 0 0 17.29 8Z`},child:[]}]})(e)}function pi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M3 3a2 2 0 0 1 2-2h9.982a2 2 0 0 1 1.414.586l4.018 4.018A2 2 0 0 1 21 7.018V21a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v18a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V8.5h-4a2 2 0 0 1-2-2v-4Zm10 0v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 0-.146-.336l-4.018-4.018A.5.5 0 0 0 15 2.5Z`},child:[]}]})(e)}function mi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M12.5 7.25a.75.75 0 0 0-1.5 0v5.5c0 .27.144.518.378.651l3.5 2a.75.75 0 0 0 .744-1.302L12.5 12.315V7.25Z`},child:[]},{tag:`path`,attr:{d:`M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Z`},child:[]}]})(e)}function hi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M18.78 15.78a.749.749 0 0 1-1.06 0L12 10.061 6.28 15.78a.749.749 0 1 1-1.06-1.06l6.25-6.25a.749.749 0 0 1 1.06 0l6.25 6.25a.749.749 0 0 1 0 1.06Z`},child:[]}]})(e)}function gi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.22 8.22a.749.749 0 0 0 0 1.06l6.25 6.25a.749.749 0 0 0 1.06 0l6.25-6.25a.749.749 0 1 0-1.06-1.06L12 13.939 6.28 8.22a.749.749 0 0 0-1.06 0Z`},child:[]}]})(e)}function _i(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M18.655 10.405a.75.75 0 0 1-1.06 0l-4.97-4.97v14.44a.75.75 0 0 1-1.5 0V5.435l-4.97 4.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l6.25-6.25a.75.75 0 0 1 1.06 0l6.25 6.25a.75.75 0 0 1 0 1.06Z`},child:[]}]})(e)}function vi(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M7.72 21.78a.75.75 0 0 0 1.06-1.06L5.56 17.5h14.69a.75.75 0 0 0 0-1.5H5.56l3.22-3.22a.75.75 0 1 0-1.06-1.06l-4.5 4.5a.75.75 0 0 0 0 1.06l4.5 4.5Zm8.56-9.5a.75.75 0 1 1-1.06-1.06L18.44 8H3.75a.75.75 0 0 1 0-1.5h14.69l-3.22-3.22a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5Z`},child:[]}]})(e)}var yi=c(o(((e,t)=>{var n=`Expected a function`,r=NaN,i=`[object Symbol]`,a=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt,u=typeof global==`object`&&global&&global.Object===Object&&global,d=typeof self==`object`&&self&&self.Object===Object&&self,f=u||d||Function(`return this`)(),p=Object.prototype.toString,m=Math.max,h=Math.min,g=function(){return f.Date.now()};function _(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,p=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?m(x(r.maxWait)||0,t):o,p=`trailing`in r?!!r.trailing:p);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?h(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=g();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,p&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(g())}function D(){var e=g(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&p.call(e)==i}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(a,``);var n=s.test(e);return n||c.test(e)?l(e.slice(2),n?2:8):o.test(e)?r:+e}t.exports=_}))(),1),bi=({label:e,className:t})=>(0,b.jsxs)(`div`,{className:`flex gap-2 items-center ${t}`,children:[(0,b.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border animate-spin fill-primary`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,b.jsx)(`path`,{d:`M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z`,fill:`currentColor`}),(0,b.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z`,fill:`currentFill`})]}),e?(0,b.jsxs)(`span`,{children:[e,` ...`]}):(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading...`})]});function xi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708`},child:[]}]})(e)}function Si(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z`},child:[]}]})(e)}function Ci(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z`},child:[]},{tag:`path`,attr:{d:`M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z`},child:[]}]})(e)}function wi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0`},child:[]},{tag:`path`,attr:{d:`M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1m0 5.586 7 7L13.586 9l-7-7H2z`},child:[]}]})(e)}function Ti(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2 1a1 1 0 0 0-1 1v4.586a1 1 0 0 0 .293.707l7 7a1 1 0 0 0 1.414 0l4.586-4.586a1 1 0 0 0 0-1.414l-7-7A1 1 0 0 0 6.586 1zm4 3.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0`},child:[]}]})(e)}function Ei(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708`},child:[]}]})(e)}function Di(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z`},child:[]}]})(e)}function Oi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 4a.5.5 0 0 1 .5.5V6a.5.5 0 0 1-1 0V4.5A.5.5 0 0 1 8 4M3.732 5.732a.5.5 0 0 1 .707 0l.915.914a.5.5 0 1 1-.708.708l-.914-.915a.5.5 0 0 1 0-.707M2 10a.5.5 0 0 1 .5-.5h1.586a.5.5 0 0 1 0 1H2.5A.5.5 0 0 1 2 10m9.5 0a.5.5 0 0 1 .5-.5h1.5a.5.5 0 0 1 0 1H12a.5.5 0 0 1-.5-.5m.754-4.246a.39.39 0 0 0-.527-.02L7.547 9.31a.91.91 0 1 0 1.302 1.258l3.434-4.297a.39.39 0 0 0-.029-.518z`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M0 10a8 8 0 1 1 15.547 2.661c-.442 1.253-1.845 1.602-2.932 1.25C11.309 13.488 9.475 13 8 13c-1.474 0-3.31.488-4.615.911-1.087.352-2.49.003-2.932-1.25A8 8 0 0 1 0 10m8-7a7 7 0 0 0-6.603 9.329c.203.575.923.876 1.68.63C4.397 12.533 6.358 12 8 12s3.604.532 4.923.96c.757.245 1.477-.056 1.68-.631A7 7 0 0 0 8 3`},child:[]}]})(e)}function ki(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M10.5 1a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V4H1.5a.5.5 0 0 1 0-1H10V1.5a.5.5 0 0 1 .5-.5M12 3.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5m-6.5 2A.5.5 0 0 1 6 6v1.5h8.5a.5.5 0 0 1 0 1H6V10a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5M1 8a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2A.5.5 0 0 1 1 8m9.5 2a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V13H1.5a.5.5 0 0 1 0-1H10v-1.5a.5.5 0 0 1 .5-.5m1.5 2.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5`},child:[]}]})(e)}function Ai(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z`},child:[]},{tag:`path`,attr:{d:`M5.5 12a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-3-8.5a1 1 0 0 1 1-1c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1-1-1m0 4a1 1 0 0 1 1-1 6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1-1-1`},child:[]}]})(e)}function ji(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4`},child:[]}]})(e)}function Mi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1zm-7.978-1L7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002-.014.002zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4m3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0M6.936 9.28a6 6 0 0 0-1.23-.247A7 7 0 0 0 5 9c-4 0-5 3-5 4q0 1 1 1h4.216A2.24 2.24 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816M4.92 10A5.5 5.5 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0m3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4`},child:[]}]})(e)}function Ni(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325`},child:[]}]})(e)}function Pi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278M4.858 1.311A7.27 7.27 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.32 7.32 0 0 0 5.205-2.162q-.506.063-1.029.063c-4.61 0-8.343-3.714-8.343-8.29 0-1.167.242-2.278.681-3.286`},child:[]}]})(e)}function Fi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m7.5-6.923c-.67.204-1.335.82-1.887 1.855q-.215.403-.395.872c.705.157 1.472.257 2.282.287zM4.249 3.539q.214-.577.481-1.078a7 7 0 0 1 .597-.933A7 7 0 0 0 3.051 3.05q.544.277 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9 9 0 0 1-1.565-.667A6.96 6.96 0 0 0 1.018 7.5zm1.4-2.741a12.3 12.3 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332M8.5 5.09V7.5h2.99a12.3 12.3 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.035.987.176 1.914.399 2.741A13.6 13.6 0 0 1 7.5 10.91V8.5zm3.99 0v2.409c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741zm-3.282 3.696q.18.469.395.872c.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.282.287zm.11 2.276a7 7 0 0 1-.598-.933 9 9 0 0 1-.481-1.079 8.4 8.4 0 0 0-1.198.49 7 7 0 0 0 2.276 1.522zm-1.383-2.964A13.4 13.4 0 0 1 3.508 8.5h-2.49a6.96 6.96 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667m6.728 2.964a7 7 0 0 0 2.275-1.521 8.4 8.4 0 0 0-1.197-.49 9 9 0 0 1-.481 1.078 7 7 0 0 1-.597.933M8.5 11.909v3.014c.67-.204 1.335-.82 1.887-1.855q.216-.403.395-.872A12.6 12.6 0 0 0 8.5 11.91zm3.555-.401c.57.185 1.095.409 1.565.667A6.96 6.96 0 0 0 14.982 8.5h-2.49a13.4 13.4 0 0 1-.437 3.008M14.982 7.5a6.96 6.96 0 0 0-1.362-3.675c-.47.258-.995.482-1.565.667.248.92.4 1.938.437 3.008zM11.27 2.461q.266.502.482 1.078a8.4 8.4 0 0 0 1.196-.49 7 7 0 0 0-2.275-1.52c.218.283.418.597.597.932m-.488 1.343a8 8 0 0 0-.395-.872C9.835 1.897 9.17 1.282 8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z`},child:[]}]})(e)}function Ii(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v.64c.57.265.94.876.856 1.546l-.64 5.124A2.5 2.5 0 0 1 12.733 15H3.266a2.5 2.5 0 0 1-2.481-2.19l-.64-5.124A1.5 1.5 0 0 1 1 6.14zM2 6h12v-.5a.5.5 0 0 0-.5-.5H9c-.964 0-1.71-.629-2.174-1.154C6.374 3.334 5.82 3 5.264 3H2.5a.5.5 0 0 0-.5.5zm-.367 1a.5.5 0 0 0-.496.562l.64 5.124A1.5 1.5 0 0 0 3.266 14h9.468a1.5 1.5 0 0 0 1.489-1.314l.64-5.124A.5.5 0 0 0 14.367 7z`},child:[]}]})(e)}function Li(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.825a2 2 0 0 1-1.991-1.819l-.637-7a2 2 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3m-8.322.12q.322-.119.684-.12h5.396l-.707-.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981z`},child:[]}]})(e)}function Ri(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5`},child:[]},{tag:`path`,attr:{d:`M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z`},child:[]}]})(e)}function zi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2.5 3.5a.5.5 0 0 1 0-1h11a.5.5 0 0 1 0 1zm2-2a.5.5 0 0 1 0-1h7a.5.5 0 0 1 0 1zM0 13a1.5 1.5 0 0 0 1.5 1.5h13A1.5 1.5 0 0 0 16 13V6a1.5 1.5 0 0 0-1.5-1.5h-13A1.5 1.5 0 0 0 0 6zm1.5.5A.5.5 0 0 1 1 13V6a.5.5 0 0 1 .5-.5h13a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-.5.5z`},child:[]}]})(e)}function Bi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z`},child:[]},{tag:`path`,attr:{d:`M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0`},child:[]}]})(e)}function Vi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708`},child:[]}]})(e)}function Hi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0`},child:[]}]})(e)}function Ui(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm10.03 4.97a.75.75 0 0 1 .011 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.75.75 0 0 1 1.08-.022z`},child:[]}]})(e)}function Wi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z`},child:[]}]})(e)}function Gi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707m2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708m5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708m2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0`},child:[]}]})(e)}function Ki(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707m2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708m5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708m2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM6 8a2 2 0 1 1 2.5 1.937V15.5a.5.5 0 0 1-1 0V9.937A2 2 0 0 1 6 8`},child:[]}]})(e)}function qi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0z`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708z`},child:[]}]})(e)}function Ji(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M0 .5A.5.5 0 0 1 .5 0h4a.5.5 0 0 1 0 1h-4A.5.5 0 0 1 0 .5m0 2A.5.5 0 0 1 .5 2h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m9 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-9 2A.5.5 0 0 1 .5 4h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5m5 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m7 0a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5m-12 2A.5.5 0 0 1 .5 6h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5m8 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-8 2A.5.5 0 0 1 .5 8h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m7 0a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m-7 2a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1h-8a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5`},child:[]}]})(e)}function Yi(e){return Z({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41m-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5 5 0 0 0 8 3M3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9z`},child:[]}]})(e)}var Xi=`initializing`,Zi=`paused`,Qi=`live`,$i=`error`,ea=e=>{let{onClick:t,disabled:n,color:r,children:i,className:a,href:o,title:s,...c}=e;return(0,b.jsx)(`a`,{className:`p-1 text-blue-500 flex items-center justify-center cursor-pointer ${r?`text-${r}`:``} ${a}`,onClick:e=>{e.stopPropagation(),e.preventDefault(),!n&&t()},href:o??`#`,title:s,...c,children:i})},ta=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},na=(e=>e?ta(e):ta),ra=e=>e;function ia(e,t=ra){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var aa=e=>{let t=na(e),n=e=>ia(t,e);return Object.assign(n,t),n},oa=(e=>e?aa(e):aa);function sa(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!sa(e[i],t[i]))return!1;return!0}function ca(e,t){return sa(e,t)}var la=oa((e,t)=>({torrents:null,torrentsLoading:!1,torrentsInitiallyLoading:!1,setTorrentsLoading:t=>e(e=>e.torrents==null?{torrentsInitiallyLoading:t,torrentsLoading:t}:{torrentsInitiallyLoading:!1,torrentsLoading:t}),setTorrents:t=>e(e=>{if(!e.torrents)return{torrents:t};let n=new Map(e.torrents.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&ca(t,e)?t:e});return r.length!==e.torrents.length||r.some((t,n)=>t!==e.torrents[n])?{torrents:r}:{}}),refreshTorrents:()=>{},setRefreshTorrents:t=>e({refreshTorrents:t}),detailsCache:new Map,getDetails:e=>t().detailsCache.get(e)??null,setDetails:(t,n)=>e(e=>({detailsCache:new Map(e.detailsCache).set(t,n)}))})),ua=1024;function da(){return window.innerWidth>=ua?`compact`:`full`}var Q=oa((e,t)=>({currentPage:`torrents`,setCurrentPage:t=>e({currentPage:t}),viewMode:da(),setViewMode:t=>{e({viewMode:t})},toggleViewMode:()=>{e({viewMode:t().viewMode===`compact`?`full`:`compact`})},searchQuery:``,setSearchQuery:t=>e({searchQuery:t}),statusFilter:`all`,setStatusFilter:t=>{e({statusFilter:t})},selectedTorrentIds:new Set,lastSelectedId:null,selectTorrent:t=>{e({selectedTorrentIds:new Set([t]),lastSelectedId:t})},toggleSelection:n=>{let r=t().selectedTorrentIds,i=new Set(r);i.has(n)?i.delete(n):i.add(n),e({selectedTorrentIds:i,lastSelectedId:n})},selectRange:(n,r)=>{let{lastSelectedId:i,selectedTorrentIds:a}=t();if(i===null){e({selectedTorrentIds:new Set([n]),lastSelectedId:n});return}if(a.has(n)){let t=new Set(a);t.delete(n),e({selectedTorrentIds:t});return}let o=r.indexOf(i),s=r.indexOf(n);if(o===-1||s===-1){e({selectedTorrentIds:new Set([n]),lastSelectedId:n});return}let c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=new Set(a);for(let e of u)d.add(e);e({selectedTorrentIds:d})},deselectTorrent:n=>{let r=t().selectedTorrentIds;if(r.has(n)){let t=new Set(r);t.delete(n),e({selectedTorrentIds:t})}},clearSelection:()=>{e({selectedTorrentIds:new Set,lastSelectedId:null})},selectAll:t=>{e({selectedTorrentIds:new Set(t)})},selectRelative:(n,r)=>{let{selectedTorrentIds:i,lastSelectedId:a}=t();if(r.length===0)return;let o;if(i.size===0){let t=n===`down`?r[0]:r[r.length-1];e({selectedTorrentIds:new Set([t]),lastSelectedId:t});return}if(i.size===1){let e=Array.from(i)[0];o=r.indexOf(e)}else o=a!==null&&r.includes(a)?r.indexOf(a):r.findIndex(e=>i.has(e));if(o===-1){let t=r[0];e({selectedTorrentIds:new Set([t]),lastSelectedId:t});return}let s=r[n===`down`?Math.min(o+1,r.length-1):Math.max(o-1,0)];e({selectedTorrentIds:new Set([s]),lastSelectedId:s})},sidebarCollapsed:!1,sidebarOpen:!1,trackerFilter:null,categoryFilter:null,toggleSidebar:()=>e(e=>({sidebarCollapsed:!e.sidebarCollapsed})),setSidebarOpen:t=>e({sidebarOpen:t}),setTrackerFilter:t=>e({trackerFilter:t}),setCategoryFilter:t=>e({categoryFilter:t}),categories:{},setCategories:t=>e({categories:t}),detailsModalTorrentId:null,openDetailsModal:t=>e({detailsModalTorrentId:t,selectedTorrentIds:new Set([t]),lastSelectedId:t}),closeDetailsModal:()=>e({detailsModalTorrentId:null}),detailPaneRequestedTab:null,setDetailPaneTab:t=>e({detailPaneRequestedTab:t})})),fa=({onClick:e,children:t,className:n,disabled:r,variant:i,size:a})=>{let o={sm:`text-sm px-2 py-1`,default:`px-3 py-1.5`}[a??`default`],s={secondary:`bg-surface-raised border-divider hover:bg-primary hover:text-white transition-colors`,danger:`bg-error-bg text-white border-transparent hover:bg-red-600 transition-colors`,primary:`bg-primary-bg text-white border-transparent hover:bg-primary-bg-hover disabled:opacity-50 transition-colors`,cancel:`bg-surface-raised text-secondary border-divider hover:bg-surface-sunken transition-colors`,none:``}[i??`secondary`];return(0,b.jsx)(`button`,{disabled:r,onClick:t=>{t.preventDefault(),e()},className:`inline-flex items-center gap-1 border rounded font-medium cursor-pointer disabled:cursor-not-allowed ${o} ${s} ${n??``}`,children:t})},pa=({title:e,children:t,onClose:n})=>(0,b.jsxs)(`div`,{className:`bg-error/10 p-3 rounded-md mb-3`,children:[(0,b.jsxs)(`div`,{className:`flex justify-between mb-2`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold text-error`,children:e}),n&&(0,b.jsx)(`button`,{onClick:n,className:`text-error hover:text-error/80 transition-colors cursor-pointer`,children:(0,b.jsx)(xi,{})})]}),t]}),ma=e=>{let{error:t,remove:n}=e;return t==null?null:(0,b.jsxs)(pa,{onClose:n,title:t.text,children:[t.details?.statusText&&(0,b.jsx)(`div`,{className:`pb-2 text-md`,children:t.details?.statusText}),(0,b.jsx)(`div`,{className:`whitespace-pre-wrap text-secondary`,children:t.details?.text})]})};function ha(e){return e&&e.ownerDocument||document}function ga(e){e===void 0&&(e=ha());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function _a(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}var va=!!(typeof window<`u`&&window.document&&window.document.createElement),ya=!1,ba=!1;try{var xa={get passive(){return ya=!0},get once(){return ba=ya=!0}};va&&(window.addEventListener(`test`,xa,xa),window.removeEventListener(`test`,xa,!0))}catch{}function Sa(e,t,n,r){if(r&&typeof r!=`boolean`&&!ba){var i=r.once,a=r.capture,o=n;!ba&&i&&(o=n.__once||function e(r){this.removeEventListener(t,e,a),n.call(this,r)},n.__once=o),e.addEventListener(t,o,ya?r:a)}e.addEventListener(t,n,r)}function Ca(e,t,n,r){var i=r&&typeof r!=`boolean`?r.capture:r;e.removeEventListener(t,n,i),n.__once&&e.removeEventListener(t,n.__once,i)}function wa(e,t,n,r){return Sa(e,t,n,r),function(){Ca(e,t,n,r)}}function Ta(){let e=(0,_.useRef)(!0),t=(0,_.useRef)(()=>e.current);return(0,_.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Ea(e){let t=(0,_.useRef)(e);return t.current=e,t}function Da(e){let t=Ea(e);(0,_.useEffect)(()=>()=>t.current(),[])}function Oa(e){let t=(0,_.useRef)(null);return(0,_.useEffect)(()=>{t.current=e}),t.current}function ka(e){let t=(0,_.useRef)(e);return(0,_.useEffect)(()=>{t.current=e},[e]),t}function Aa(e){let t=ka(e);return(0,_.useCallback)(function(...e){return t.current&&t.current(...e)},[t])}function ja(e){var t=ha(e);return t&&t.defaultView||window}function Ma(e,t){return ja(e).getComputedStyle(e,t)}var Na=/([A-Z])/g;function Pa(e){return e.replace(Na,`-$1`).toLowerCase()}var Fa=/^ms-/;function Ia(e){return Pa(e).replace(Fa,`-ms-`)}var La=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;function Ra(e){return!!(e&&La.test(e))}function za(e,t){var n=``,r=``;if(typeof t==`string`)return e.style.getPropertyValue(Ia(t))||Ma(e).getPropertyValue(Ia(t));Object.keys(t).forEach(function(i){var a=t[i];!a&&a!==0?e.style.removeProperty(Ia(i)):Ra(i)?r+=i+`(`+a+`) `:n+=Ia(i)+`: `+a+`;`}),r&&(n+=`transform: `+r+`;`),e.style.cssText+=`;`+n}var Ba=`data-rr-ui-`;function Va(e){return`${Ba}${e}`}function Ha(e=document){let t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}var Ua=Va(`modal-open`),Wa=class{constructor({ownerDocument:e,handleContainerOverflow:t=!0,isRTL:n=!1}={}){this.handleContainerOverflow=t,this.isRTL=n,this.modals=[],this.ownerDocument=e}getScrollbarWidth(){return Ha(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(e){}removeModalAttributes(e){}setContainerStyle(e){let t={overflow:`hidden`},n=this.isRTL?`paddingLeft`:`paddingRight`,r=this.getElement();e.style={overflow:r.style.overflow,[n]:r.style[n]},e.scrollBarWidth&&(t[n]=`${parseInt(za(r,n)||`0`,10)+e.scrollBarWidth}px`),r.setAttribute(Ua,``),za(r,t)}reset(){[...this.modals].forEach(e=>this.remove(e))}removeContainerStyle(e){let t=this.getElement();t.removeAttribute(Ua),Object.assign(t.style,e.style)}add(e){let t=this.modals.indexOf(e);return t!==-1||(t=this.modals.length,this.modals.push(e),this.setModalAttributes(e),t!==0)?t:(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state),t)}remove(e){let t=this.modals.indexOf(e);t!==-1&&(this.modals.splice(t,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(e))}isTopModal(e){return!!this.modals.length&&this.modals[this.modals.length-1]===e}},Ga=(0,_.createContext)(va?window:void 0);Ga.Provider;function Ka(){return(0,_.useContext)(Ga)}var qa=(e,t)=>va?e==null?(t||ha()).body:(typeof e==`function`&&(e=e()),e&&`current`in e&&(e=e.current),e&&(`nodeType`in e||e.getBoundingClientRect)?e:null):null;function Ja(e,t){let n=Ka(),[r,i]=(0,_.useState)(()=>qa(e,n?.document));if(!r){let t=qa(e);t&&i(t)}return(0,_.useEffect)(()=>{t&&r&&t(r)},[t,r]),(0,_.useEffect)(()=>{let t=qa(e);t!==r&&i(t)},[e,r]),r}var Ya=e=>!e||typeof e==`function`?e:t=>{e.current=t};function Xa(e,t){let n=Ya(e),r=Ya(t);return e=>{n&&n(e),r&&r(e)}}function Za(e,t){return(0,_.useMemo)(()=>Xa(e,t),[e,t])}var Qa=typeof global<`u`&&global.navigator&&global.navigator.product===`ReactNative`,$a=typeof document<`u`||Qa?_.useLayoutEffect:_.useEffect;function $(e){return e.code===`Escape`||e.keyCode===27}function eo(){let e=`19.2.7`.split(`.`);return{major:+e[0],minor:+e[1],patch:+e[2]}}function to(e){if(!e||typeof e==`function`)return null;let{major:t}=eo();return t>=19?e.props.ref:e.ref}function no({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:i}){let a=(0,_.useRef)(null),o=(0,_.useRef)(t),s=Aa(n);(0,_.useEffect)(()=>{t?o.current=!0:s(a.current)},[t,s]);let c=(0,_.cloneElement)(e,{ref:Za(a,to(e))});return t?c:i||!o.current&&r?null:c}var ro=[`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`addEndListener`,`children`];function io(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function ao(e){let{onEnter:t,onEntering:n,onEntered:r,onExit:i,onExiting:a,onExited:o,addEndListener:s,children:c}=e,l=io(e,ro),u=(0,_.useRef)(null),d=Za(u,to(c)),f=e=>t=>{e&&u.current&&e(u.current,t)},p=(0,_.useCallback)(f(t),[t]),m=(0,_.useCallback)(f(n),[n]),h=(0,_.useCallback)(f(r),[r]),g=(0,_.useCallback)(f(i),[i]),v=(0,_.useCallback)(f(a),[a]),y=(0,_.useCallback)(f(o),[o]),b=(0,_.useCallback)(f(s),[s]);return Object.assign({},l,{nodeRef:u},t&&{onEnter:p},n&&{onEntering:m},r&&{onEntered:h},i&&{onExit:g},a&&{onExiting:v},o&&{onExited:y},s&&{addEndListener:b},{children:typeof c==`function`?(e,t)=>c(e,Object.assign({},t,{ref:d})):(0,_.cloneElement)(c,{ref:d})})}var oo=[`component`];function so(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var co=_.forwardRef((e,t)=>{let{component:n}=e,r=ao(so(e,oo));return(0,b.jsx)(n,Object.assign({ref:t},r))});function lo({in:e,onTransition:t}){let n=(0,_.useRef)(null),r=(0,_.useRef)(!0),i=Aa(t);return $a(()=>{if(!n.current)return;let t=!1;return i({in:e,element:n.current,initial:r.current,isStale:()=>t}),()=>{t=!0}},[e,i]),$a(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function uo({children:e,in:t,onExited:n,onEntered:r,transition:i}){let[a,o]=(0,_.useState)(!t);t&&a&&o(!1);let s=Za(lo({in:!!t,onTransition:e=>{Promise.resolve(i(e)).then(()=>{e.isStale()||(e.in?r?.(e.element,e.initial):(o(!0),n?.(e.element)))},t=>{throw e.in||o(!0),t})}}),to(e));return a&&!t?null:(0,_.cloneElement)(e,{ref:s})}function fo(e,t,n){return e?(0,b.jsx)(co,Object.assign({},n,{component:e})):t?(0,b.jsx)(uo,Object.assign({},n,{transition:t})):(0,b.jsx)(no,Object.assign({},n))}var po=`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`.split(`.`);function mo(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var ho;function go(e){return ho||=new Wa({ownerDocument:e?.document}),ho}function _o(e){let t=Ka(),n=e||go(t),r=(0,_.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:(0,_.useCallback)(e=>{r.current.dialog=e},[]),setBackdropRef:(0,_.useCallback)(e=>{r.current.backdrop=e},[])})}var vo=(0,_.forwardRef)((e,t)=>{let{show:n=!1,role:r=`dialog`,className:i,style:a,children:o,backdrop:s=!0,keyboard:c=!0,onBackdropClick:l,onEscapeKeyDown:u,transition:d,runTransition:f,backdropTransition:p,runBackdropTransition:m,autoFocus:h=!0,enforceFocus:g=!0,restoreFocus:v=!0,restoreFocusOptions:y,renderDialog:S,renderBackdrop:C=e=>(0,b.jsx)(`div`,Object.assign({},e)),manager:w,container:T,onShow:E,onHide:D=()=>{},onExit:O,onExited:ee,onExiting:te,onEnter:k,onEntering:ne,onEntered:A}=e,j=mo(e,po),re=Ka(),M=Ja(T),N=_o(w),P=Ta(),ie=Oa(n),[F,I]=(0,_.useState)(!n),L=(0,_.useRef)(null);(0,_.useImperativeHandle)(t,()=>N,[N]),va&&!ie&&n&&(L.current=ga(re?.document)),n&&F&&I(!1);let R=Aa(()=>{if(N.add(),H.current=wa(document,`keydown`,V),oe.current=wa(document,`focus`,()=>setTimeout(ae),!0),E&&E(),h){let e=ga(N.dialog?.ownerDocument??re?.document);N.dialog&&e&&!_a(N.dialog,e)&&(L.current=e,N.dialog.focus())}}),z=Aa(()=>{if(N.remove(),H.current==null||H.current(),oe.current==null||oe.current(),v){var e;(e=L.current)==null||e.focus==null||e.focus(y),L.current=null}});(0,_.useEffect)(()=>{!n||!M||R()},[n,M,R]),(0,_.useEffect)(()=>{F&&z()},[F,z]),Da(()=>{z()});let ae=Aa(()=>{if(!g||!P()||!N.isTopModal())return;let e=ga(re?.document);N.dialog&&e&&!_a(N.dialog,e)&&N.dialog.focus()}),B=Aa(e=>{e.target===e.currentTarget&&(l?.(e),s===!0&&D())}),V=Aa(e=>{c&&$(e)&&N.isTopModal()&&(u?.(e),e.defaultPrevented||D())}),oe=(0,_.useRef)(),H=(0,_.useRef)(),se=(...e)=>{I(!0),ee?.(...e)};if(!M)return null;let ce=Object.assign({role:r,ref:N.setDialogRef,"aria-modal":r===`dialog`?!0:void 0},j,{style:a,className:i,tabIndex:-1}),le=S?S(ce):(0,b.jsx)(`div`,Object.assign({},ce,{children:_.cloneElement(o,{role:`document`})}));le=fo(d,f,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:O,onExiting:te,onExited:se,onEnter:k,onEntering:ne,onEntered:A,children:le});let U=null;return s&&(U=C({ref:N.setBackdropRef,onClick:B}),U=fo(p,m,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:U})),(0,b.jsx)(b.Fragment,{children:x.createPortal((0,b.jsxs)(b.Fragment,{children:[U,le]}),M)})});vo.displayName=`Modal`;var yo=Object.assign(vo,{Manager:Wa}),bo=({onClose:e,title:t})=>(0,b.jsxs)(`div`,{className:`flex p-3 justify-between items-center border-b border-divider gap-2`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold truncate min-w-0`,children:t}),e&&(0,b.jsx)(`button`,{className:`flex-shrink-0 p-1 -m-1 text-secondary hover:text-text transition-colors cursor-pointer`,onClick:e,"aria-label":`Close modal`,children:(0,b.jsx)(xi,{className:`w-6 h-6`})})]}),xo=({isOpen:e,onClose:t,title:n,children:r,className:i})=>(0,b.jsx)(yo,{show:e,onHide:t,renderBackdrop:()=>(0,b.jsx)(`div`,{className:`fixed inset-0 bg-black/50 z-300 dark:bg-black/70`}),className:`fixed z-301 top-0 left-0 w-full h-full block overflow-x-hidden overflow-y-auto`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised shadow-lg my-4 mx-4 sm:my-8 sm:mx-auto sm:max-w-2xl rounded ${i}`,children:[(0,b.jsx)(bo,{onClose:t,title:n}),r]})}),So=({children:e})=>(0,b.jsx)(`div`,{className:`p-3 border-b dark:border-slate-500`,children:e}),Co=({children:e,className:t})=>(0,b.jsx)(`div`,{className:`p-3 flex justify-end gap-2 ${t}`,children:e}),wo=({show:e,onHide:t,torrents:n})=>{let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),l=(0,_.useContext)(v),u=la(e=>e.refreshTorrents),d=Q(e=>e.clearSelection);if(!e||n.length===0)return null;let f=()=>{i(!1),o(null),c(!1),t()},p=async()=>{c(!0),o(null);let e=r?l.delete:l.forget,t=[];for(let r of n)try{await e(r.id)}catch(e){let n=r.name||`id=${r.id}`;t.push(`${n}: ${e}`)}t.length>0?(o({text:`Failed to delete ${t.length} torrent${t.length>1?`s`:``}`,details:{text:t.join(` +`)}}),c(!1)):(d(),u(),f())},m=n.length>1;return(0,b.jsxs)(xo,{isOpen:e,onClose:t,title:m?`Delete ${n.length} torrents`:`Delete torrent`,children:[(0,b.jsxs)(So,{children:[(0,b.jsx)(`p`,{className:`text-gray-700 dark:text-slate-300 mb-3`,children:m?`Are you sure you want to delete the following torrents?`:`Are you sure you want to delete this torrent?`}),(0,b.jsx)(`div`,{className:`rounded-md bg-gray-50 dark:bg-slate-700/50 p-3 ${m?`max-h-48 overflow-y-auto`:``}`,children:(0,b.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,b.jsx)(`li`,{className:`text-gray-800 dark:text-slate-200 truncate`,title:e.name??void 0,children:(0,b.jsx)(`span`,{className:`font-medium`,children:e.name||`Torrent #${e.id}`})},e.id))})}),(0,b.jsxs)(`div`,{className:`mt-4 flex items-center`,children:[(0,b.jsx)(`input`,{type:`checkbox`,id:`deleteFiles`,className:`form-checkbox h-4 w-4 text-blue-500 rounded border-gray-300 dark:border-slate-600`,onChange:()=>i(!r),checked:r}),(0,b.jsx)(`label`,{htmlFor:`deleteFiles`,className:`ml-2 text-gray-700 dark:text-slate-300`,children:`Also delete downloaded files`})]}),a&&(0,b.jsx)(ma,{error:a})]}),(0,b.jsxs)(Co,{children:[s&&(0,b.jsx)(bi,{}),(0,b.jsx)(fa,{variant:`cancel`,onClick:f,children:`Cancel`}),(0,b.jsx)(fa,{variant:`danger`,onClick:p,disabled:s,children:m?`Delete ${n.length} Torrents`:`Delete Torrent`})]})]})};function To(e){return Z({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z`},child:[]}]})(e)}function Eo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z`},child:[]}]})(e)}function Do(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z`},child:[]}]})(e)}function Oo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z`},child:[]}]})(e)}function ko(e){return Z({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M288 32C128.94 32 0 160.94 0 320c0 52.8 14.25 102.26 39.06 144.8 5.61 9.62 16.3 15.2 27.44 15.2h443c11.14 0 21.83-5.58 27.44-15.2C561.75 422.26 576 372.8 576 320c0-159.06-128.94-288-288-288zm0 64c14.71 0 26.58 10.13 30.32 23.65-1.11 2.26-2.64 4.23-3.45 6.67l-9.22 27.67c-5.13 3.49-10.97 6.01-17.64 6.01-17.67 0-32-14.33-32-32S270.33 96 288 96zM96 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm48-160c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm246.77-72.41l-61.33 184C343.13 347.33 352 364.54 352 384c0 11.72-3.38 22.55-8.88 32H232.88c-5.5-9.45-8.88-20.28-8.88-32 0-33.94 26.5-61.43 59.9-63.59l61.34-184.01c4.17-12.56 17.73-19.45 30.36-15.17 12.57 4.19 19.35 17.79 15.17 30.36zm14.66 57.2l15.52-46.55c3.47-1.29 7.13-2.23 11.05-2.23 17.67 0 32 14.33 32 32s-14.33 32-32 32c-11.38-.01-20.89-6.28-26.57-15.22zM480 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z`},child:[]}]})(e)}function Ao(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M370.72 133.28C339.458 104.008 298.888 87.962 255.848 88c-77.458.068-144.328 53.178-162.791 126.85-1.344 5.363-6.122 9.15-11.651 9.15H24.103c-7.498 0-13.194-6.807-11.807-14.176C33.933 94.924 134.813 8 256 8c66.448 0 126.791 26.136 171.315 68.685L463.03 40.97C478.149 25.851 504 36.559 504 57.941V192c0 13.255-10.745 24-24 24H345.941c-21.382 0-32.09-25.851-16.971-40.971l41.75-41.749zM32 296h134.059c21.382 0 32.09 25.851 16.971 40.971l-41.75 41.75c31.262 29.273 71.835 45.319 114.876 45.28 77.418-.07 144.315-53.144 162.787-126.849 1.344-5.363 6.122-9.15 11.651-9.15h57.304c7.498 0 13.194 6.807 11.807 14.176C478.067 417.076 377.187 504 256 504c-66.448 0-126.791-26.136-171.315-68.685L48.97 471.03C33.851 486.149 8 475.441 8 454.059V320c0-13.255 10.745-24 24-24z`},child:[]}]})(e)}function jo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M64 96H0c0 123.7 100.3 224 224 224v144c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16V320C288 196.3 187.7 96 64 96zm384-64c-84.2 0-157.4 46.5-195.7 115.2 27.7 30.2 48.2 66.9 59 107.6C424 243.1 512 147.9 512 32h-64z`},child:[]}]})(e)}function Mo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z`},child:[]}]})(e)}function No(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z`},child:[]}]})(e)}function Po(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z`},child:[]}]})(e)}function Fo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z`},child:[]}]})(e)}function Io(e){return Z({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z`},child:[]}]})(e)}function Lo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z`},child:[]}]})(e)}function Ro(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z`},child:[]}]})(e)}function zo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z`},child:[]}]})(e)}function Bo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z`},child:[]}]})(e)}function Vo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`},child:[]}]})(e)}function Ho(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z`},child:[]}]})(e)}function Uo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`},child:[]}]})(e)}function Wo(e){return Z({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M177 255.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 351.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 425.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1zm-34-192L7 199.7c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l96.4-96.4 96.4 96.4c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9l-136-136c-9.2-9.4-24.4-9.4-33.8 0z`},child:[]}]})(e)}function Go(e){return Z({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M143 256.3L7 120.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0L313 86.3c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.4 9.5-24.6 9.5-34 .1zm34 192l136-136c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L160 352.1l-96.4-96.4c-9.4-9.4-24.6-9.4-33.9 0L7 278.3c-9.4 9.4-9.4 24.6 0 33.9l136 136c9.4 9.5 24.6 9.5 34 .1z`},child:[]}]})(e)}var Ko=oa(e=>({closeableError:null,setCloseableError:t=>e(()=>({closeableError:t})),otherError:null,setOtherError:t=>e(()=>({otherError:t})),alert:null,setAlert:t=>e(()=>({alert:t})),removeAlert:()=>e(()=>({alert:null}))})),qo=({torrent:e})=>{let{id:t,name:n,stats:r}=e,i=r.state,[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=la(e=>e.refreshTorrents),u=Q(e=>e.openDetailsModal),d=i==`live`,f=i==`paused`||i==`error`,p=i==`paused`||i==`live`,m=Ko(e=>e.setCloseableError),h=(0,_.useContext)(v);return(0,b.jsxs)(`div`,{className:`flex w-full justify-center gap-1 sm:gap-2 dark:text-slate-300`,children:[f&&(0,b.jsx)(ea,{onClick:()=>{o(!0),h.start(t).then(()=>{l()},e=>{m({text:`Error starting torrent id=${t}`,details:e})}).finally(()=>o(!1))},disabled:a,children:(0,b.jsx)(Po,{className:`hover:text-green-600`})}),d&&(0,b.jsx)(ea,{onClick:()=>{o(!0),h.pause(t).then(()=>{l()},e=>{m({text:`Error pausing torrent id=${t}`,details:e})}).finally(()=>o(!1))},disabled:a,children:(0,b.jsx)(Fo,{className:`hover:text-amber-500`})}),p&&(0,b.jsx)(ea,{onClick:()=>u(t),disabled:a,children:(0,b.jsx)(zo,{className:`hover:text-green-600`})}),(0,b.jsx)(ea,{onClick:()=>{o(!0),c(!0)},disabled:a,children:(0,b.jsx)(Do,{className:`hover:text-red-500`})}),(0,b.jsx)(wo,{show:s,onHide:()=>{o(!1),c(!1)},torrents:[{id:t,name:n}]})]})},Jo={warn:`bg-warning-bg text-white`,info:`bg-primary-bg text-white`,success:`bg-success-bg text-white`,error:`bg-error-bg text-white`},Yo=({now:e,variant:t,label:n,classNames:r})=>{let i=n??`${e.toFixed(2)}%`,a=Jo[t??`info`]??Jo.info;return(0,b.jsx)(`div`,{className:`w-full bg-divider rounded-full mb-1 ${r}`,children:(0,b.jsx)(`div`,{className:`text-sm font-medium transition-all text-center leading-none py-0.5 px-2 rounded-full ${a} ${e<1&&`bg-transparent`}`,style:{width:`${e}%`},children:i})})};function Xo(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(2))+` `+n[r]}var Zo=({statsResponse:e})=>{switch(e.state){case Zi:return(0,b.jsx)(`span`,{className:`text-secondary`,children:`Paused`});case Xi:return(0,b.jsx)(`span`,{className:`text-warning`,children:`Checking files`});case $i:return(0,b.jsx)(`span`,{className:`text-error`,children:`Error`})}return e.state!=`live`||e.live===null?(0,b.jsx)(`span`,{className:`text-secondary`,children:e.state}):(0,b.jsxs)(b.Fragment,{children:[!e.finished&&(0,b.jsxs)(`span`,{className:`text-success`,children:[`↓ `,e.live.download_speed?.human_readable]}),(0,b.jsxs)(`span`,{className:`text-primary`,children:[`↑ `,e.live.upload_speed?.human_readable,e.live.snapshot.uploaded_bytes>0&&(0,b.jsxs)(`span`,{className:`text-secondary`,children:[`(`,Xo(e.live.snapshot.uploaded_bytes),`)`]})]})]})};function Qo(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=(e,t)=>e>0?`${e}${t}`:``;return t>0?`${a(t,`d`)} ${a(n,`h`)} ${a(r,`m`)}`.trim():n>0?`${a(n,`h`)} ${a(r,`m`)}`.trim():r>0?`${a(r,`m`)} ${a(i,`s`)}`.trim():`${a(i,`s`)}`.trim()}function $o(e){let t=e?.live?.time_remaining?.duration?.secs;return t==null?`N/A`:Qo(t)}function es(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z`},child:[]}]})(e)}function ts(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z`},child:[]}]})(e)}function ns(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z`},child:[]}]})(e)}function rs(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z`},child:[]}]})(e)}function is(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M9 16h6v-6h4l-7-7-7 7h4v6zm3-10.17L14.17 8H13v6h-2V8H9.83L12 5.83zM5 18h14v2H5z`},child:[]}]})(e)}function as(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M22 12c0 5.52-4.48 10-10 10S2 17.52 2 12c0-1.19.22-2.32.6-3.38l1.88.68C4.17 10.14 4 11.05 4 12c0 4.41 3.59 8 8 8s8-3.59 8-8-3.59-8-8-8c-.95 0-1.85.17-2.69.48l-.68-1.89C9.69 2.22 10.82 2 12 2c5.52 0 10 4.48 10 10zM5.5 4C4.67 4 4 4.67 4 5.5S4.67 7 5.5 7 7 6.33 7 5.5 6.33 4 5.5 4zM11 16V8H9v8h2zm4 0V8h-2v8h2z`},child:[]}]})(e)}var os=({className:e,finished:t,live:n,error:r,queued:i})=>r?(0,b.jsx)(ts,{className:`text-error ${e}`}):i?(0,b.jsx)(ns,{className:`text-warning ${e}`}):t&&n?(0,b.jsx)(is,{className:`text-success ${e}`}):t?(0,b.jsx)(rs,{className:`text-success ${e}`}):n?(0,b.jsx)(es,{className:`text-primary ${e}`}):(0,b.jsx)(as,{className:`text-secondary ${e}`}),ss=({torrent:e})=>{e.id;let t=e.stats??null,n=t?.state??``,r=t?.error??null,i=t?.total_bytes??1,a=t?.progress_bytes??0,o=t?.finished||!1,s=r||i==0?100:a/i*100,c=()=>{let e=t?.live?.snapshot.peer_stats;return e?`${e.live} / ${e.seen}`:``},l=t?.live?.snapshot.uploaded_bytes??0,u=t?.ratio,d=t?.queue_position,f=t?.sequential,p=e=>(0,b.jsx)(os,{className:e,error:!!r,live:!!t?.live,finished:o});return(0,b.jsx)(`div`,{className:`flex flex-col border p-1.5 sm:p-2 border-divider rounded-xl shadow-xs hover:drop-shadow-sm bg-surface-raised`,children:(0,b.jsxs)(`section`,{className:`flex flex-col lg:flex-row items-center gap-1.5 sm:gap-2`,children:[(0,b.jsx)(`div`,{className:`hidden md:block`,children:p(`w-10 h-10`)}),(0,b.jsxs)(`div`,{className:`w-full flex flex-col gap-1 sm:gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,b.jsx)(`div`,{className:`md:hidden`,children:p(`w-4 h-4 sm:w-5 sm:h-5`)}),(0,b.jsx)(`div`,{className:`text-left text-sm sm:text-base lg:text-lg text-ellipsis break-all line-clamp-2 sm:line-clamp-none`,children:e.name})]}),r?(0,b.jsxs)(`p`,{className:`text-error`,children:[(0,b.jsx)(`strong`,{children:`Error:`}),` `,r]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{children:(0,b.jsx)(Yo,{now:s,label:r,variant:n==`initializing`?`warn`:o?`success`:`info`})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 sm:gap-x-4 sm:gap-y-1 items-center text-nowrap text-xs sm:text-sm font-medium text-secondary`,children:[(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(fi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),` `,c().toString()]}),(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(pi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),(0,b.jsxs)(`div`,{children:[Xo(a),`/`,Xo(i)]})]}),t&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(mi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),$o(t)]}),(0,b.jsx)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:(0,b.jsx)(Zo,{statsResponse:t})}),(l>0||u!=null)&&(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(vi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),(0,b.jsxs)(`span`,{children:[Xo(l),u!=null&&(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(ratio: `,u.toFixed(2),`)`]})]})]}),d!=null&&(0,b.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-surface border border-divider rounded`,children:[`Q: `,d]}),f&&(0,b.jsx)(`span`,{className:`inline-flex items-center`,title:`Sequential download`,children:(0,b.jsx)(Yi,{className:`w-3 h-3 sm:w-4 sm:h-4 text-primary`})})]})]})]})]}),t&&(0,b.jsx)(`div`,{className:``,children:(0,b.jsx)(qo,{torrent:{...e,stats:t}})})]})})},cs=({torrent:e,hidden:t})=>(0,b.jsx)(`div`,{className:t?`hidden`:``,children:(0,b.jsx)(ss,{torrent:e})}),ls={id:`ID`,name:`Name`,size:`Size`,progress:`Progress`,downSpeed:`Down Speed`,upSpeed:`Up Speed`,eta:`ETA`,category:`Category`},us={all:`All`,downloading:`Downloading`,seeding:`Seeding`,paused:`Paused`,queued:`Queued`,error:`Error`};function ds(e,t){switch(t){case`id`:return e.id;case`name`:return(e.name??``).toLowerCase();case`size`:return e.stats?.total_bytes??0;case`progress`:return e.stats?.total_bytes?(e.stats.progress_bytes??0)/e.stats.total_bytes:0;case`downSpeed`:return e.stats?.live?.download_speed?.mbps??0;case`upSpeed`:return e.stats?.live?.upload_speed?.mbps??0;case`eta`:{if(!e.stats?.live)return 1/0;let t=(e.stats.total_bytes??0)-(e.stats.progress_bytes??0),n=e.stats.live.download_speed?.mbps??0;return n<=0||t<=0?t<=0?0:1/0:t/(n*1024*1024)}case`category`:return(e.category??``).toLowerCase()}}function fs(e,t,n,r){let i=ds(e,n),a=ds(t,n),o=typeof i==`string`?i.localeCompare(a):i-a;return r===`asc`?o:-o}function ps(e,t){return t?(e??``).toLowerCase().includes(t):!0}function ms(e){let t=/^[a-z+]+:\/\/([^/:?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function hs(e){let t=new Set;for(let n of e.trackers??[]){let e=ms(n);e&&t.add(e)}return Array.from(t)}function gs(e,t){if(t===null)return!0;let n=hs(e);return t===``?n.length===0:n.includes(t)}function _s(e,t){return t===null?!0:t===``?!e.category:e.category===t}function vs(e,t){if(t===`all`)return!0;let n=e.stats?.state,r=e.stats?.finished;switch(t){case`downloading`:return n===`live`&&!r;case`seeding`:return n===`live`&&!!r;case`paused`:return n===`paused`;case`queued`:return e.stats?.queue_state===`Queued`;case`error`:return n===`error`}}function ys(e,t,n,r,i){return ps(e.name,t)&&vs(e,n)&&_s(e,r??null)&&gs(e,i??null)}function bs(e){let t=la(e=>e.torrents),n=Q(e=>e.searchQuery),r=Q(e=>e.statusFilter),i=Q(e=>e.categoryFilter),a=Q(e=>e.selectAll),o=Q(e=>e.clearSelection),s=Q(e=>e.selectedTorrentIds);(0,_.useEffect)(()=>{let c=c=>{let l=c.target;if(l.tagName===`INPUT`||l.tagName===`TEXTAREA`||l.isContentEditable||document.querySelector(`[role="dialog"]`))return;let u=c.metaKey||c.ctrlKey;if(u&&c.key===`a`){if(c.preventDefault(),t){let e=n.toLowerCase();a(t.filter(t=>ys(t,e,r,i)).map(e=>e.id))}return}if(u&&c.key===`f`){c.preventDefault();let e=document.querySelector(`[data-search-input]`);e?.focus(),e?.select();return}if(c.key===`Escape`){c.preventDefault(),o();return}if((c.key===`Delete`||c.key===`Backspace`)&&s.size>0){c.preventDefault(),e?.onDelete?.();return}if(c.key===`b`||c.key===`B`){c.preventDefault(),e?.onToggleSidebar?.();return}if(u&&c.key===`,`){c.preventDefault(),e?.onOpenSettings?.();return}if(u&&c.key===`l`){c.preventDefault(),e?.onOpenLogs?.();return}};return window.addEventListener(`keydown`,c),()=>window.removeEventListener(`keydown`,c)},[t,n,r,i,a,o,s,e])}var xs=({hideFilters:e})=>{let t=Q(e=>e.selectedTorrentIds),n=Q(e=>e.searchQuery),r=Q(e=>e.setSearchQuery),i=Q(e=>e.statusFilter),a=Q(e=>e.setStatusFilter),o=la(e=>e.torrents),s=la(e=>e.refreshTorrents),c=Ko(e=>e.setCloseableError),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(n),y=(0,_.useCallback)((0,yi.default)(e=>r(e),150),[r]),x=e=>{let t=e.target.value;g(t),y(t)},S=()=>{g(``),r(``)},C=(0,_.useContext)(v),w=t.size,T=w>0,E=e=>o?.find(t=>t.id===e),D=(0,_.useCallback)(()=>{m(Array.from(t).map(e=>({id:e,name:E(e)?.name??null}))),f(!0)},[t,o]);bs((0,_.useMemo)(()=>({onDelete:D}),[D]));let O=async(e,n,r)=>{u(!0);try{for(let i of t)if(E(i)?.stats?.state!==n)try{await e(i),s()}catch(e){c({text:`Error ${r} torrent id=${i}`,details:e})}}finally{u(!1)}};return(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 bg-surface-raised border-b border-divider`,children:[(0,b.jsxs)(fa,{onClick:()=>O(e=>C.start(e),Qi,`starting`),disabled:l||!T,variant:`secondary`,children:[(0,b.jsx)(Po,{className:`w-2.5 h-2.5`}),`Resume`]}),(0,b.jsxs)(fa,{onClick:()=>O(e=>C.pause(e),Zi,`pausing`),disabled:l||!T,variant:`secondary`,children:[(0,b.jsx)(Fo,{className:`w-2.5 h-2.5`}),`Pause`]}),(0,b.jsxs)(fa,{onClick:D,disabled:l||!T,variant:`danger`,children:[(0,b.jsx)(Do,{className:`w-2.5 h-2.5`}),`Delete`]}),(0,b.jsx)(fa,{onClick:async()=>{u(!0);try{for(let e of t)try{await C.queueMoveUp(e)}catch(t){c({text:`Error moving torrent id=${e} up in queue`,details:t})}s()}finally{u(!1)}},disabled:l||!T,variant:`secondary`,children:(0,b.jsx)(Vo,{className:`w-2.5 h-2.5`})}),(0,b.jsx)(fa,{onClick:async()=>{u(!0);try{for(let e of t)try{await C.queueMoveDown(e)}catch(t){c({text:`Error moving torrent id=${e} down in queue`,details:t})}s()}finally{u(!1)}},disabled:l||!T,variant:`secondary`,children:(0,b.jsx)(Uo,{className:`w-2.5 h-2.5`})}),!e&&(0,b.jsxs)(b.Fragment,{children:[T&&(0,b.jsxs)(`span`,{className:`ml-1.5 text-secondary`,children:[w,` selected`]}),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`py-1 px-2 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:Object.keys(us).map(e=>(0,b.jsx)(`option`,{value:e,children:us[e]},e))}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(di,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:h,onChange:x,placeholder:`Search...`,className:`pl-7 pr-7 py-1 w-48 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`}),h&&(0,b.jsx)(`button`,{onClick:S,className:`absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(ci,{className:`w-3.5 h-3.5`})})]})]}),(0,b.jsx)(wo,{show:d,onHide:()=>f(!1),torrents:p})]})};function Ss(e,t){let n,r=async()=>{await e().then(()=>!1,()=>!0)&&i()},i=e=>{n=setTimeout(r,e===void 0?t:e)};return i(0),()=>clearTimeout(n)}function Cs(e,t){let n,r=t,i=async()=>{if(r=await e(),r==null)throw`asyncCallback returned null or undefined`;a()},a=()=>{n=setTimeout(i,r)};return a(),()=>{clearTimeout(n)}}var ws=12,Ts=({torrentId:e,totalPieces:t,stats:n})=>{let r=(0,_.useRef)(null),i=(0,_.useRef)(null),a=(0,_.useContext)(v),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t!==0)return Cs(async()=>{try{s(await a.getTorrentHaves(e))}catch(e){console.error(`Failed to fetch haves:`,e)}let t=n?.state===`live`||n?.state===`initializing`,r=n?.finished??!1;return t&&!r?2e3:3e4},0)},[e,t,n?.state,n?.finished]),(0,_.useEffect)(()=>{let e=r.current,n=i.current;if(!e||!n||!o||t===0)return;let a=e.getContext(`2d`);if(!a)return;let s=n.clientWidth,c=Math.max(s,100);e.width=c,e.height=ws;let l=getComputedStyle(document.body),u=l.getPropertyValue(`--color-success-bg`).trim()||`#22c55e`;a.fillStyle=l.getPropertyValue(`--color-divider`).trim()||`#374151`,a.fillRect(0,0,c,ws);let d=e=>{let t=Math.floor(e/8),n=7-e%8;return t>n&1)==1},f=c/t;a.fillStyle=u;let p=-1;for(let e=0;e{if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m ${e%60}s`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`},Ds=({label:e,value:t,mono:n})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[e,` `]}),(0,b.jsx)(`span`,{className:n?`font-mono`:``,children:t})]}),Os=({torrent:e})=>{let t=(0,_.useContext)(v),n=Q(e=>e.categories),r=Q(e=>e.setCategories),i=la(e=>e.refreshTorrents),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),l=e?.stats??null,u=(0,_.useRef)(!1);if((0,_.useEffect)(()=>{u.current||(u.current=!0,t.getCategories().then(e=>r(e)).catch(()=>{}))},[t,r]),!e||!l)return(0,b.jsx)(`div`,{className:`p-3 text-tertiary`,children:`Loading...`});let d=e.name??``,f=e.info_hash,p=l.state,m=l.error,h=l.total_bytes??1,g=l.progress_bytes??0,y=l.finished||!1,x=e.total_pieces??0,S=l.live?.snapshot.downloaded_and_checked_pieces??0,C=x>0?h/x:0,w=l.live?.snapshot.uploaded_bytes??0,T=m||h===0?100:g/h*100,E=l.live?.download_speed?.human_readable??`-`,D=l.live?.upload_speed?.human_readable??`-`,O=$o(l),ee=l.live?.snapshot.peer_stats,te=m?{text:`Error`,color:`text-error`}:p===`initializing`?{text:`Initializing`,color:`text-warning`}:p===`paused`?{text:`Paused`,color:`text-secondary`}:p===`live`&&y?{text:`Seeding`,color:`text-success`}:p===`live`?{text:`Downloading`,color:`text-primary`}:{text:p,color:`text-secondary`};return(0,b.jsxs)(`div`,{className:`p-3 flex flex-col gap-3 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`truncate font-medium flex-1`,title:d,children:d}),(0,b.jsx)(`span`,{className:`shrink-0 ${te.color}`,children:te.text})]}),x>0&&(0,b.jsx)(`div`,{children:(0,b.jsx)(Ts,{torrentId:e.id,totalPieces:x,stats:l})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Progress`,value:`${T.toFixed(1)}%`}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(g),`/`,Xo(h),`)`]})]}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Down`,value:E})}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Up`,value:D}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(w),` total)`]})]}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`ETA`,value:y?`Complete`:O})}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Ratio`,value:l.ratio?.toFixed(2)??`N/A`})})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[x>0&&(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Pieces`,value:`${S.toLocaleString()}/${x.toLocaleString()}`}),C>0&&(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(C),` each)`]})]}),ee&&(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Peers`,value:``}),(0,b.jsx)(`span`,{className:`text-success`,children:ee.live}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` live, `}),(0,b.jsx)(`span`,{className:`text-primary`,children:ee.connecting}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` connecting, `}),(0,b.jsx)(`span`,{className:`text-warning`,children:ee.queued}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` queued, `}),(0,b.jsx)(`span`,{children:ee.seen}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` seen, `}),(0,b.jsx)(`span`,{className:`text-error`,children:ee.dead}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` dead`})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`truncate`,children:(0,b.jsx)(Ds,{label:`Hash`,value:f,mono:!0})}),(0,b.jsx)(`div`,{className:`truncate`,children:(0,b.jsx)(Ds,{label:`Output`,value:e.output_folder,mono:!0})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(Ds,{label:`Category`,value:``}),a?(0,b.jsxs)(`select`,{value:s,onChange:n=>{let r=n.target.value;c(r),t.setTorrentCategory(e.id,r||null).then(()=>i()).catch(()=>{}),o(!1)},onBlur:()=>o(!1),autoFocus:!0,className:`px-1 py-0.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:[(0,b.jsx)(`option`,{value:``,children:`None`}),Object.keys(n).sort((e,t)=>e.localeCompare(t)).map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}):(0,b.jsx)(`button`,{onClick:()=>{c(e.category??``),o(!0)},className:`text-sm text-primary hover:underline cursor-pointer`,children:e.category||`None`})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[l.seeding_time_secs!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Seeding Time`,value:Es(l.seeding_time_secs)})}),l.queue_state!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Queue State`,value:l.queue_state})}),l.queue_position!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Queue Position`,value:l.queue_position})}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Sequential`,value:l.sequential?`Yes`:`No`})}),y&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Super-seeding`,value:l.super_seeding?`Yes`:`No`})}),(l.min_piece_availability!=null||l.avg_piece_availability!=null)&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Availability`,value:`${l.min_piece_availability?.toFixed(2)??`?`} min / ${l.avg_piece_availability?.toFixed(2)??`?`} avg`})})]}),m&&(0,b.jsx)(`div`,{className:`text-error`,children:m})]})},ks=({checked:e,name:t,disabled:n,onChange:r,label:i,help:a,inputType:o,children:s,labelLink:c})=>(0,b.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,b.jsx)(`div`,{className:`flex`,children:(0,b.jsx)(`input`,{type:o||`checkbox`,className:`block mt-1`,id:t,name:t,disabled:n,checked:e,onChange:r})}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c?(0,b.jsx)(`a`,{href:c,target:`_blank`,className:`text-blue-600 dark:text-blue-500 hover:underline`,children:i}):(0,b.jsx)(`label`,{htmlFor:t,children:i}),a&&(0,b.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-300 mb-3`,children:a})]}),s]});function As(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`g`,attr:{id:`Square_Plus`},child:[{tag:`g`,attr:{},child:[{tag:`path`,attr:{d:`M18.438,20.938H5.563a2.5,2.5,0,0,1-2.5-2.5V5.564a2.5,2.5,0,0,1,2.5-2.5H18.438a2.5,2.5,0,0,1,2.5,2.5V18.438A2.5,2.5,0,0,1,18.438,20.938ZM5.563,4.064a1.5,1.5,0,0,0-1.5,1.5V18.438a1.5,1.5,0,0,0,1.5,1.5H18.438a1.5,1.5,0,0,0,1.5-1.5V5.564a1.5,1.5,0,0,0-1.5-1.5Z`},child:[]},{tag:`path`,attr:{d:`M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z`},child:[]}]}]}]})(e)}function js(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`g`,attr:{id:`Square_Minus`},child:[{tag:`g`,attr:{},child:[{tag:`path`,attr:{d:`M18.438,20.938H5.564a2.5,2.5,0,0,1-2.5-2.5V5.564a2.5,2.5,0,0,1,2.5-2.5H18.438a2.5,2.5,0,0,1,2.5,2.5V18.438A2.5,2.5,0,0,1,18.438,20.938ZM5.564,4.064a1.5,1.5,0,0,0-1.5,1.5V18.438a1.5,1.5,0,0,0,1.5,1.5H18.438a1.5,1.5,0,0,0,1.5-1.5V5.564a1.5,1.5,0,0,0-1.5-1.5Z`},child:[]},{tag:`path`,attr:{d:`M9,12.5a.5.5,0,0,1,0-1h6a.5.5,0,0,1,0,1Z`},child:[]}]}]}]})(e)}var Ms=c(o(((e,t)=>{var n=200,r=`Expected a function`,i=`__lodash_hash_undefined__`,a=1,o=2,s=1/0,c=9007199254740991,l=`[object Arguments]`,u=`[object Array]`,d=`[object Boolean]`,f=`[object Date]`,p=`[object Error]`,m=`[object Function]`,h=`[object GeneratorFunction]`,g=`[object Map]`,_=`[object Number]`,v=`[object Object]`,y=`[object Promise]`,b=`[object RegExp]`,x=`[object Set]`,S=`[object String]`,C=`[object Symbol]`,w=`[object WeakMap]`,T=`[object ArrayBuffer]`,E=`[object DataView]`,D=`[object Float32Array]`,O=`[object Float64Array]`,ee=`[object Int8Array]`,te=`[object Int16Array]`,k=`[object Int32Array]`,ne=`[object Uint8Array]`,A=`[object Uint8ClampedArray]`,j=`[object Uint16Array]`,re=`[object Uint32Array]`,M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,N=/^\w*$/,P=/^\./,ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,F=/[\\^$.*+?()[\]{}|]/g,I=/\\(\\)?/g,L=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,z={};z[D]=z[O]=z[ee]=z[te]=z[k]=z[ne]=z[A]=z[j]=z[re]=!0,z[l]=z[u]=z[T]=z[d]=z[E]=z[f]=z[p]=z[m]=z[g]=z[_]=z[v]=z[b]=z[x]=z[S]=z[w]=!1;var ae=typeof global==`object`&&global&&global.Object===Object&&global,B=typeof self==`object`&&self&&self.Object===Object&&self,V=ae||B||Function(`return this`)(),oe=typeof e==`object`&&e&&!e.nodeType&&e,H=oe&&typeof t==`object`&&t&&!t.nodeType&&t,se=H&&H.exports===oe&&ae.process,ce=function(){try{return se&&se.binding(`util`)}catch{}}(),le=ce&&ce.isTypedArray;function U(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function ue(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n-1}function it(e,t){var n=this.__data__,r=xt(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}$e.prototype.clear=et,$e.prototype.delete=tt,$e.prototype.get=nt,$e.prototype.has=rt,$e.prototype.set=it;function at(e){var t=-1,n=e?e.length:0;for(this.clear();++t0&&n(s)?t>1?Ct(s,t-1,n,r,i):de(i,s):r||(i[i.length]=s)}return i}var wt=qt();function Tt(e,t){return e&&wt(e,t,jn)}function Et(e,t){t=on(t,e)?[t]:Ut(t);for(var n=0,r=t.length;e!=null&&nt||a&&o&&c&&!s&&!l||r&&o&&c||!n&&c||!i)return 1;if(!r&&!a&&!l&&e=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function Kt(e,t){return function(n,r){if(n==null)return n;if(!bn(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++al))return!1;var d=s.get(e);if(d&&s.get(t))return d==t;var f=-1,p=!0,m=i&a?new dt:void 0;for(s.set(e,t),s.set(t,e);++f-1&&e%1==0&&e1&&an(e,t[0],t[1])?t=[]:n>2&&an(t[0],t[1],t[2])&&(t=[t[0]]),zt(e,Ct(t,1),[])});function gn(e,t){if(typeof e!=`function`||t&&typeof t!=`function`)throw TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o),o};return n.cache=new(gn.Cache||at),n}gn.Cache=at;function _n(e,t){return e===t||e!==e&&t!==t}function vn(e){return xn(e)&&Ce.call(e,`callee`)&&(!Oe.call(e,`callee`)||we.call(e)==l)}var yn=Array.isArray;function bn(e){return e!=null&&Cn(e.length)&&!Sn(e)}function xn(e){return Tn(e)&&bn(e)}function Sn(e){var t=wn(e)?we.call(e):``;return t==m||t==h}function Cn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=c}function wn(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function Tn(e){return!!e&&typeof e==`object`}function En(e){return typeof e==`symbol`||Tn(e)&&we.call(e)==C}var Dn=le?K(le):Nt;function On(e){return e==null?``:Ht(e)}function kn(e,t,n){var r=e==null?void 0:Et(e,t);return r===void 0?n:r}function An(e,t){return e!=null&&tn(e,t,Ot)}function jn(e){return bn(e)?bt(e):Ft(e)}function Mn(e){return e}function Nn(e){return on(e)?fe(pn(e)):Bt(e)}t.exports=hn}))(),1),Ns=(e,t)=>{let n=(e,t,r,i)=>{let a=[],o=[],s={},c=e=>(s[e]=s[e]||[],s[e]);r.forEach(e=>{if(i==e.pathComponents.length-1){a.push(e);return}c(e.pathComponents[i]).push(e)}),a=(0,Ms.default)(a,e=>e.filename);let l=(0,Ms.default)(Object.entries(s),([e,t])=>e),u=0;for(let[e,r]of l)o.push(n(e,t+`.`+u,r,i+1)),u+=1;return{name:e,id:t,dirs:o,files:a}};return n(``,`filetree-root`,e.files.map((e,n)=>e.attributes.padding?null:{id:n,filename:e.components[e.components.length-1],pathComponents:e.components,length:e.length,have_bytes:t?t.file_progress[n]??0:0}).filter(e=>e!==null),0)},Ps=({torrentId:e,tree:t,selectedFiles:n,setSelectedFiles:r,initialExpanded:i,torrentDetails:a,torrentStats:o,showProgressBar:s,disabled:c,allowStream:l})=>{let u=(0,_.useContext)(v),[d,f]=(0,_.useState)(i),p=(0,_.useMemo)(()=>{let e=t=>{let n=t.dirs.flatMap(e);return n.push(...t.files.map(e=>e.id)),n};return e(t)},[t]),m=e=>{if(e.target.checked){let e=new Set(n);p.forEach(t=>e.add(t)),r(e)}else{let e=new Set(n);p.forEach(t=>e.delete(t)),r(e)}},h=e=>{if(n.has(e)){let t=new Set(n);t.delete(e),r(t)}else{let t=new Set(n);t.add(e),r(t)}},g=()=>p.filter(e=>n.has(e)).length,y=()=>p.filter(e=>n.has(e)).map(e=>a.files[e].length).reduce((e,t)=>e+t,0),x=t=>{if(l&&e!=null)return u.getTorrentStreamUrl(e,t.id,t.filename)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(ea,{onClick:()=>f(!d),children:d?(0,b.jsx)(js,{}):(0,b.jsx)(As,{})}),(0,b.jsx)(ks,{checked:p.every(e=>n.has(e)),label:`${t.name?t.name+`, `:``} ${g()} files, ${Xo(y())}`,name:t.id,onChange:m})]}),(0,b.jsxs)(`div`,{className:`pl-5`,hidden:!d,children:[t.dirs.map(t=>(0,b.jsx)(Ps,{torrentId:e,torrentDetails:a,torrentStats:o,tree:t,selectedFiles:n,setSelectedFiles:r,initialExpanded:!1,showProgressBar:s,disabled:c,allowStream:l},t.name)),(0,b.jsx)(`div`,{className:`pl-1`,children:t.files.map(t=>(0,b.jsxs)(`div`,{className:`${s?`grid grid-cols-1 gap-1 items-start lg:grid-cols-2 mb-2 lg:mb-0`:``}`,children:[(0,b.jsx)(ks,{checked:n.has(t.id),label:`${t.filename} (${Xo(t.length)})`,name:`torrent-${e}-file-${t.id}`,disabled:c,onChange:()=>h(t.id),labelLink:x(t)}),s&&(0,b.jsx)(Yo,{now:t.have_bytes/t.length*100,variant:t.have_bytes==t.length?`success`:`info`})]},t.id))})]})]})},Fs=({torrentId:e,torrentDetails:t,selectedFiles:n,setSelectedFiles:r,torrentStats:i,showProgressBar:a,disabled:o,allowStream:s})=>(0,b.jsx)(Ps,{torrentId:e,torrentDetails:t,torrentStats:i,tree:(0,_.useMemo)(()=>Ns(t,i),[t,i]),selectedFiles:n,setSelectedFiles:r,initialExpanded:!0,showProgressBar:a,disabled:o,allowStream:s}),Is=({torrentId:e,detailsResponse:t,statsResponse:n,onRefresh:r})=>{let[i,a]=(0,_.useState)(new Set),[o,s]=(0,_.useState)(!1),c=(0,_.useContext)(v),l=Ko(e=>e.setCloseableError);return(0,_.useEffect)(()=>{a(new Set(t?.files.map((e,t)=>({f:e,id:t})).filter(({f:e})=>e.included).map(({id:e})=>e)??[]))},[t]),t?(0,b.jsx)(`div`,{className:`p-2 text-sm`,children:(0,b.jsx)(Fs,{torrentId:e,torrentDetails:t,torrentStats:n,selectedFiles:i,setSelectedFiles:t=>{s(!0),c.updateOnlyFiles(e,Array.from(t)).then(()=>{r?.(),l(null)},e=>{l({text:`Error configuring torrent`,details:e})}).finally(()=>s(!1))},disabled:o,allowStream:!0,showProgressBar:!0})}):(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`Loading...`})};function Ls({column:e,sortColumn:t,sortDirection:n}){return e===t?n===`asc`?(0,b.jsx)(hi,{className:`inline ml-0.5 w-4 h-4`}):(0,b.jsx)(gi,{className:`inline ml-0.5 w-4 h-4`}):null}var Rs=5e3,zs=e=>e===0?`-`:Xo(e)+`/s`,Bs=({torrent:e})=>{let t=e?.id,n=e?.stats??null,r=(0,_.useContext)(v),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(`downloadSpeed`),[u,d]=(0,_.useState)(`desc`),f=(0,_.useRef)(null),p=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{if(!(t==null||!n?.live))return Cs(()=>r.getPeerStats(t).then(e=>(a(e),1e3),e=>(console.error(e),5e3)),0)},[t,!!n?.live]),(0,_.useEffect)(()=>{if(!i){s([]);return}let e=Date.now(),t=f.current,n=p.current,r=Object.entries(i.peers).map(([r,i])=>{let a=0,o=0;if(t&&t.snapshot.peers[r]){let n=(e-t.timestamp)/1e3;if(n>0){let e=t.snapshot.peers[r],s=i.counters.fetched_bytes-e.counters.fetched_bytes,c=i.counters.uploaded_bytes-e.counters.uploaded_bytes;a=Math.max(0,s/n),o=Math.max(0,c/n)}}let s=n.get(r)??[];s.push({downloadSpeed:a,uploadSpeed:o,timestamp:e}),s=s.filter(t=>e-t.timestamp<=Rs),n.set(r,s);let c=0,l=0;return s.length>0&&(c=s.reduce((e,t)=>e+t.downloadSpeed,0)/s.length,l=s.reduce((e,t)=>e+t.uploadSpeed,0)/s.length),{addr:r,stats:i,downloadSpeed:c,uploadSpeed:l}});for(let e of n.keys())i.peers[e]||n.delete(e);s(r),f.current={snapshot:i,timestamp:e}},[i]);let m=(0,_.useCallback)(e=>{l(t=>t===e?(d(e=>e===`asc`?`desc`:`asc`),e):(d(`desc`),e))},[]),h=(0,_.useMemo)(()=>[...o].sort((e,t)=>{let n=0;switch(c){case`addr`:n=e.addr.localeCompare(t.addr);break;case`connKind`:n=(e.stats.conn_kind??``).localeCompare(t.stats.conn_kind??``);break;case`downloadSpeed`:n=e.downloadSpeed-t.downloadSpeed;break;case`uploadSpeed`:n=e.uploadSpeed-t.uploadSpeed;break;case`downloaded`:n=e.stats.counters.fetched_bytes-t.stats.counters.fetched_bytes;break;case`uploaded`:n=e.stats.counters.uploaded_bytes-t.stats.counters.uploaded_bytes;break}return u===`asc`?n:-n}),[o,c,u]);if(!n)return(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`Loading...`});if(!n.live)return(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`No live peer information available (torrent is not live)`});let g=`px-2 py-1.5 text-left text-sm text-secondary cursor-pointer hover:text-text select-none`;return(0,b.jsx)(`div`,{className:`p-3`,children:(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`min-w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`addr`),children:[`IP Address`,(0,b.jsx)(Ls,{column:`addr`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`connKind`),children:[`Type`,(0,b.jsx)(Ls,{column:`connKind`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`downloadSpeed`),children:[`Down Speed`,(0,b.jsx)(Ls,{column:`downloadSpeed`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`uploadSpeed`),children:[`Up Speed`,(0,b.jsx)(Ls,{column:`uploadSpeed`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`downloaded`),children:[`Downloaded`,(0,b.jsx)(Ls,{column:`downloaded`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`uploaded`),children:[`Uploaded`,(0,b.jsx)(Ls,{column:`uploaded`,sortColumn:c,sortDirection:u})]})]})}),(0,b.jsx)(`tbody`,{children:h.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-2 py-3 text-center text-sm text-tertiary`,children:i===null?`Loading peer list...`:`No connected peers`})}):h.map(e=>(0,b.jsxs)(`tr`,{className:`hover:bg-surface-raised`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm font-mono`,children:e.addr}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:e.stats.conn_kind??`-`}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-success`,children:zs(e.downloadSpeed)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-primary`,children:zs(e.uploadSpeed)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:Xo(e.stats.counters.fetched_bytes)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:Xo(e.stats.counters.uploaded_bytes)})]},e.addr))})]})})})};function Vs(e,t){let n=t;for(;n=48&&e[n]<=57;)n++;if(n===t||e[n]!==58)return null;let r=parseInt(new TextDecoder().decode(e.slice(t,n)),10);return n++,n+r>e.length?null:[new TextDecoder().decode(e.slice(n,n+r)),n+r]}function Hs(e,t){if(e[t]!==105)return null;let n=t+1;for(;n=e.length?null:[parseInt(new TextDecoder().decode(e.slice(t+1,n)),10),n+1]}function Us(e,t){if(t>=e.length)return null;let n=e[t];if(n>=48&&n<=57)return Vs(e,t);if(n===105)return Hs(e,t);if(n===108){let n=[],r=t+1;for(;rtypeof e==`string`);t.length>0&&i.push(t)}}return{announce:r,announceList:i}}var Gs={not_contacted:`Not contacted`,updating:`Updating...`,working:`Working`,error:`Error`,disabled:`Disabled`},Ks={not_contacted:`bg-surface-sunken text-tertiary`,updating:`bg-warning/15 text-warning`,working:`bg-success/15 text-success`,error:`bg-error/15 text-error`,disabled:`bg-surface-sunken text-tertiary`},qs=({state:e})=>(0,b.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium whitespace-nowrap ${Ks[e]}`,children:Gs[e]});function Js(e){if(!e)return`—`;let t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<5?`just now`:t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}var Ys=`px-2 py-1.5 text-left text-xs font-semibold text-tertiary uppercase tracking-wide whitespace-nowrap`,Xs=`px-2 py-1 text-center text-secondary tabular-nums`,Zs=({torrent:e})=>{let t=(0,_.useContext)(v),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=e?.id;return(0,_.useEffect)(()=>{if(u!=null)return r(null),a(!0),s(!1),l(null),Cs(async()=>{try{return r((await t.getTrackerStatus(u)).trackers),a(!1),5e3}catch{return a(!1),s(!0),6e4}},0)},[u,t]),(0,_.useEffect)(()=>{u==null||!o||t.getMetadata(u).then(e=>{let t=Ws(e),n=new Set;t.announce&&n.add(t.announce);for(let e of t.announceList)for(let t of e)n.add(t);l(Array.from(n))}).catch(()=>l([]))},[u,o,t]),e?(0,b.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-secondary font-medium`,children:`Info Hash:`}),(0,b.jsx)(`code`,{className:`bg-surface-sunken px-1.5 py-0.5 rounded text-xs font-mono`,children:e.info_hash})]}),i&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-tertiary`,children:[(0,b.jsx)(bi,{}),(0,b.jsx)(`span`,{children:`Loading tracker status...`})]}),!i&&n&&n.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-tertiary`,children:`No trackers configured (DHT/PEX only)`}),!i&&n&&n.length>0&&(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:Ys,children:`Tracker`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Status`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Seeds`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Peers`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Received`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Last Announce`}),(0,b.jsx)(`th`,{className:Ys,children:`Message`})]})}),(0,b.jsx)(`tbody`,{children:n.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider/50 hover:bg-surface-raised`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 font-mono text-xs max-w-[26rem] truncate`,title:e.url,children:e.url}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,b.jsx)(qs,{state:e.state})}),(0,b.jsx)(`td`,{className:Xs,children:e.seeders??`—`}),(0,b.jsx)(`td`,{className:Xs,children:e.leechers??`—`}),(0,b.jsx)(`td`,{className:Xs,children:e.peers_returned??`—`}),(0,b.jsx)(`td`,{className:Xs,children:Js(e.last_announce_unix)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-xs text-tertiary max-w-[18rem] truncate`,title:e.last_error??void 0,children:e.last_error??``})]},e.url))})]})}),o&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-tertiary mb-2`,children:`Live tracker status not available on this server; showing configured trackers.`}),c===null&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-tertiary`,children:[(0,b.jsx)(bi,{}),(0,b.jsx)(`span`,{children:`Loading tracker info...`})]}),c&&c.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-tertiary`,children:`No trackers found (DHT/PEX only)`}),c&&c.length>0&&(0,b.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,b.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-mono bg-surface-sunken px-2 py-1 rounded`,children:(0,b.jsx)(`span`,{className:`truncate text-primary`,title:e,children:e})},e))})]})]}):null},Qs=300,$s=({torrent:e})=>{let t=(0,_.useRef)(null),[n,r]=(0,_.useState)([]),i=(0,_.useContext)(v);(0,_.useEffect)(()=>{r([])},[e?.id]),(0,_.useEffect)(()=>{if(!e||e.stats?.state!==`live`)return;let t=setInterval(async()=>{try{let t=await i.getTorrentStats(e.id);t.live&&r(e=>[...e,{timestamp:Date.now(),downloadSpeed:t.live.download_speed.mbps*1024*1024/8,uploadSpeed:t.live.upload_speed.mbps*1024*1024/8}].slice(-300))}catch{}},1e3);return()=>clearInterval(t)},[e?.id,e?.stats?.state,i]);let a=(0,_.useCallback)(()=>{let e=t.current;if(!e||n.length<2)return;let r=e.getContext(`2d`);if(!r)return;let i=window.devicePixelRatio||1,a=e.clientWidth,o=e.clientHeight;e.width=a*i,e.height=o*i,r.scale(i,i),r.clearRect(0,0,a,o);let s=Math.max(...n.map(e=>Math.max(e.downloadSpeed,e.uploadSpeed)),1024),c=document.documentElement.classList.contains(`dark`);r.strokeStyle=c?`rgba(255,255,255,0.1)`:`rgba(0,0,0,0.1)`,r.lineWidth=1;for(let e=0;e<5;e++){let t=e/4*o;r.beginPath(),r.moveTo(0,t),r.lineTo(a,t),r.stroke()}let l=(e,t,n)=>{r.beginPath(),r.strokeStyle=n,r.lineWidth=2,e.forEach((e,n)=>{let i=n/(Qs-1)*a,c=o-t(e)/s*o;n===0?r.moveTo(i,c):r.lineTo(i,c)}),r.stroke()};l(n,e=>e.downloadSpeed,c?`#60a5fa`:`#2563eb`),l(n,e=>e.uploadSpeed,c?`#34d399`:`#059669`),r.fillStyle=c?`rgba(255,255,255,0.5)`:`rgba(0,0,0,0.5)`,r.font=`10px monospace`,r.textAlign=`right`;for(let e=0;e<=4;e++){let t=s*(1-e/4),n=e/4*o+10;r.fillText(`${Xo(t)}/s`,a-4,n)}},[n]);return(0,_.useEffect)(()=>{a()},[a]),e?e.stats?.state===`live`?(0,b.jsxs)(`div`,{className:`p-3 h-full flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-4 mb-2 text-xs`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`w-3 h-0.5 bg-accent-download inline-block rounded`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`Download`}),e.stats?.live&&(0,b.jsx)(`span`,{className:`text-primary font-medium`,children:e.stats.live.download_speed.human_readable})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`w-3 h-0.5 bg-accent-upload inline-block rounded`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`Upload`}),e.stats?.live&&(0,b.jsx)(`span`,{className:`text-primary font-medium`,children:e.stats.live.upload_speed.human_readable})]})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(`canvas`,{ref:t,className:`w-full h-full bg-surface-sunken rounded`,style:{minHeight:`120px`}})})]}):(0,b.jsx)(`div`,{className:`p-3 text-tertiary text-sm`,children:`Speed chart is only available for active torrents.`}):null},ec=({label:e,active:t,onClick:n})=>(0,b.jsx)(`button`,{onClick:n,className:`px-3 py-1.5 font-medium transition-colors cursor-pointer ${t?`border-b-2 border-primary text-primary -mb-px`:`text-tertiary hover:text-secondary`}`,children:e}),tc=({children:e,className:t})=>(0,b.jsx)(`div`,{className:`flex border-b border-divider ${t??``}`,children:e}),nc=({span:e})=>{let t=Object.entries(e).filter(([e,t])=>e!=`name`);return t.length==0?null:(0,b.jsxs)(b.Fragment,{children:[`{`,t.map(([e,t])=>(0,b.jsxs)(`span`,{children:[e,` = `,t]},e)).reduce((e,t)=>(0,b.jsxs)(b.Fragment,{children:[e,`, `,t]})),`}`]})},rc=({span:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`font-bold`,children:e.name}),(0,b.jsx)(nc,{span:e}),(0,b.jsx)(`span`,{className:`font-bold`,children:`:`})]}),ic=({fields:e})=>(0,b.jsxs)(`span`,{className:`m-1 ${e.message.match(/error|fail/g)?`text-red-500`:`text-slate-500 dark:text-slate-200`}`,children:[e.message,Object.entries(e).filter(([e,t])=>e!=`message`).map(([e,t])=>(0,b.jsxs)(`span`,{className:`m-1`,children:[(0,b.jsx)(`span`,{className:`italic font-bold`,children:e}),`=`,t]},e))]}),ac=_.memo(({line:e})=>{let t=e;return(0,b.jsxs)(`p`,{className:`font-mono m-0 text-break text-[10px]`,children:[(0,b.jsx)(`span`,{className:`m-1 text-slate-500 dark:text-slate-400`,children:t.timestamp}),(0,b.jsx)(`span`,{className:`m-1 ${(e=>{switch(e){case`TRACE`:return`text-slate-400 dark:text-slate-500`;case`DEBUG`:return`text-blue-500`;case`INFO`:return`text-green-500`;case`WARN`:return`text-amber-500`;case`ERROR`:return`text-red-500`;default:return`text-slate-500`}})(t.level)}`,children:t.level}),(0,b.jsx)(`span`,{className:`m-1`,children:t.spans?.map((e,t)=>(0,b.jsx)(rc,{span:e},t))}),(0,b.jsx)(`span`,{className:`m-1 text-slate-500 dark:text-slate-400`,children:t.target}),(0,b.jsx)(ic,{fields:t.fields})]})}),oc=(e,t,n)=>{let r=[...e.spans??[],...e.span?[e.span]:[]];for(let e of r)if(e.name===`torrent`&&Number(e.id)===n.id)return!0;return n.infoHash.length>0&&t.toLowerCase().includes(n.infoHash.toLowerCase())},sc=[`TRACE`,`DEBUG`,`INFO`,`WARN`,`ERROR`],cc=e=>{switch(e){case`TRACE`:return`bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300`;case`DEBUG`:return`bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-400`;case`INFO`:return`bg-green-100 dark:bg-green-900/50 text-green-600 dark:text-green-400`;case`WARN`:return`bg-amber-100 dark:bg-amber-900/50 text-amber-600 dark:text-amber-400`;case`ERROR`:return`bg-red-100 dark:bg-red-900/50 text-red-600 dark:text-red-400`;default:return`bg-surface-sunken text-tertiary`}},lc=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},uc=(e,t,n)=>{let r=new AbortController,i=r.signal,a=!1,o=()=>{console.log(`cancelling fetch`),a=!0,r.abort()},s=async()=>{let r=await fetch(e,{signal:i});if(!r.ok){let e=await r.text();throw n({text:`error fetching logs`,details:{statusText:r.statusText,text:e}}),null}if(!r.body){n({text:`error fetching logs: ReadableStream not supported.`});return}n(null);let a=r.body.getReader(),o=new Uint8Array;for(;;){let{done:e,value:r}=await a.read();if(e)throw n({text:`log stream terminated`}),null;o=lc(o,r);for(let e;(e=o.indexOf(10))!==-1;){let n=o.slice(0,e);t(new TextDecoder().decode(n)),o=o.slice(e+1)}}},c=Ss(()=>s().then(()=>{},e=>{if(!a&&e!==null)throw n({text:`error streaming logs`,details:{text:e.toString()}}),e}),1e3);return()=>{o(),c()}},dc=({url:e,maxLines:t,torrentFilter:n})=>{let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(null),[u,d]=(0,_.useState)(new Set([`TRACE`,`DEBUG`,`INFO`,`WARN`,`ERROR`])),f=t??1e3,p=(0,_.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),m=(0,_.useCallback)(e=>{i(t=>{let n=t.length==0?0:t[0].id+1,r=l.current;return[{id:n,content:e,parsed:JSON.parse(e),show:r?!!e.match(r):!0},...t.slice(0,f-1)]})},[t]),h=(0,_.useRef)(m);h.current=m;let g=(0,yi.default)(e=>{let t=null;try{t=new RegExp(e)}catch{return}l.current=t,i(e=>{let n=[...e];for(let e of n)e.show=!!e.content.match(t);return n})},200),v=e=>{c(e),g(e)};(0,_.useEffect)(()=>g.cancel,[]),(0,_.useEffect)(()=>uc(e,e=>h.current(e),o),[e]);let y=(0,_.useMemo)(()=>r.filter(e=>e.show&&u.has(e.parsed.level)&&(!n||oc(e.parsed,e.content,n))),[r,u,n]),x=(0,_.useCallback)(()=>{let e=y.map(e=>e.content).join(` +`);navigator.clipboard.writeText(e)},[y]),S=(0,_.useCallback)(()=>{let e=y.map(e=>e.content).join(` +`),t=new Blob([e],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`rusttorrent-logs-${new Date().toISOString().slice(0,19)}.log`,r.click(),URL.revokeObjectURL(n)},[y]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsx)(ma,{error:a}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[sc.map(e=>(0,b.jsx)(`button`,{onClick:()=>p(e),className:`px-2 py-0.5 text-xs font-mono rounded cursor-pointer ${u.has(e)?cc(e):`bg-surface-sunken text-tertiary`}`,children:e},e)),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`button`,{onClick:x,className:`text-xs text-secondary hover:text-primary cursor-pointer`,children:`Copy`}),(0,b.jsx)(`button`,{onClick:S,className:`text-xs text-secondary hover:text-primary cursor-pointer`,children:`Download`})]}),(0,b.jsx)(`div`,{className:`mb-2`,children:(0,b.jsx)(`input`,{value:s,onChange:e=>v(e.target.value),placeholder:`Filter (regex)...`,className:`w-full px-3 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`})}),(0,b.jsxs)(`div`,{className:`text-xs text-tertiary mb-1`,children:[`Showing `,y.length,` of `,r.length,` lines (last `,f,` `,`since window opened)`]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,style:{minHeight:`300px`},children:(0,b.jsx)(or,{data:y,followOutput:`smooth`,itemContent:(e,t)=>(0,b.jsx)(ac,{line:t.parsed})})})]})},fc=[`overview`,`files`,`peers`,`trackers`,`speed`,`logs`],pc=()=>{let e=Q(e=>e.selectedTorrentIds),t=Q(e=>e.detailPaneRequestedTab),n=Q(e=>e.setDetailPaneTab),[r,i]=(0,_.useState)(`overview`);(0,_.useEffect)(()=>{t&&fc.includes(t)&&(i(t),n(null))},[t,n]);let a=Array.from(e),o=a.length;if(o===0)return(0,b.jsx)(`div`,{className:`h-full border-t border-divider bg-surface-raised flex items-center justify-center`,children:(0,b.jsx)(`p`,{className:`text-tertiary`,children:`Select a torrent to view details`})});if(o>1)return(0,b.jsx)(`div`,{className:`h-full border-t border-divider bg-surface-raised flex items-center justify-center`,children:(0,b.jsxs)(`p`,{className:`text-tertiary`,children:[o,` torrents selected`]})});let s=a[0];return(0,b.jsxs)(`div`,{className:`h-full border-t border-divider flex flex-col bg-surface`,children:[(0,b.jsxs)(tc,{className:`bg-surface-raised`,children:[(0,b.jsx)(ec,{id:`overview`,label:`Overview`,active:r===`overview`,onClick:()=>i(`overview`)}),(0,b.jsx)(ec,{id:`files`,label:`Files`,active:r===`files`,onClick:()=>i(`files`)}),(0,b.jsx)(ec,{id:`peers`,label:`Peers`,active:r===`peers`,onClick:()=>i(`peers`)}),(0,b.jsx)(ec,{id:`trackers`,label:`Trackers`,active:r===`trackers`,onClick:()=>i(`trackers`)}),(0,b.jsx)(ec,{id:`speed`,label:`Speed`,active:r===`speed`,onClick:()=>i(`speed`)}),(0,b.jsx)(ec,{id:`logs`,label:`Logs`,active:r===`logs`,onClick:()=>i(`logs`)})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,b.jsx)(mc,{torrentId:s,activeTab:r})})]})},mc=({torrentId:e,activeTab:t})=>{let n=(0,_.useContext)(v),[r,i]=(0,_.useState)(!1),a=la(t=>t.torrents?.find(t=>t.id===e)),o=la(t=>t.getDetails(e)),s=la(e=>e.setDetails),c=la(e=>e.refreshTorrents);(0,_.useEffect)(()=>{t===`files`&&(o||i(!0))},[t,e,o]),(0,_.useEffect)(()=>{if(r)return Ss(async()=>{s(e,await n.getTorrentDetails(e)),i(!1)},1e3)},[r,e]);let l=()=>{c(),i(!0)},u=a?.stats??null,d=n.getStreamLogsUrl(),f=a?.info_hash??``,p=(0,_.useMemo)(()=>({id:e,infoHash:f}),[e,f]);return(0,b.jsxs)(b.Fragment,{children:[t===`overview`&&(0,b.jsx)(Os,{torrent:a??null}),t===`files`&&(0,b.jsx)(Is,{torrentId:e,detailsResponse:o,statsResponse:u,onRefresh:l}),t===`peers`&&(0,b.jsx)(Bs,{torrent:a??null}),t===`trackers`&&(0,b.jsx)(Zs,{torrent:a??null}),t===`speed`&&(0,b.jsx)($s,{torrent:a??null}),t===`logs`&&(0,b.jsx)(`div`,{className:`h-full p-2`,children:d?(0,b.jsx)(dc,{url:d,maxLines:500,torrentFilter:p}):(0,b.jsx)(`p`,{className:`text-tertiary p-3`,children:`Log streaming not available`})})]})},hc=({torrentId:e,isOpen:t,onClose:n})=>(0,b.jsxs)(xo,{isOpen:t,onClose:n,title:la(t=>t.torrents?.find(t=>t.id===e))?.name??`Torrent #${e}`,className:`sm:max-w-4xl flex flex-col max-h-[calc(100vh-2rem)] sm:max-h-[calc(100vh-4rem)]`,children:[(0,b.jsx)(xs,{hideFilters:!0}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(pc,{})})]}),gc=({menu:e,onClose:t})=>{let{x:n,y:r}=e,i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(``),[O,ee]=(0,_.useState)(``),te=(0,_.useRef)(null),k=(0,_.useContext)(v),ne=Ko(e=>e.setCloseableError),A=la(e=>e.refreshTorrents),j=Q(e=>e.openDetailsModal),re=Q(e=>e.setDetailPaneTab),M=Q(e=>e.categories),N=Q(e=>e.setCategories),P=e.selectedTorrents,ie=P.length>1,F=P.some(e=>e.stats?.state===`live`),I=P.some(e=>e.stats?.state===`paused`||e.stats?.state===`error`),L=P.length===1?P[0]:null,R=L&&(L.stats?.state===`paused`||L.stats?.state===`live`),z=P.some(e=>e.stats?.finished),ae=P.some(e=>e.stats?.queue_state!=null),B=P.some(e=>e.stats?.state!==`initializing`),V=L?.stats?.sequential??!1,oe=L?.stats?.super_seeding??!1,H=(0,_.useRef)(!1);(0,_.useEffect)(()=>{H.current||(H.current=!0,k.getCategories().then(e=>N(e)).catch(()=>{}))},[k,N]),(0,_.useEffect)(()=>{h&&L&&k.getTorrentLimits(L.id).then(e=>{C(e.download_rate?.toString()??``),T(e.upload_rate?.toString()??``)}).catch(()=>{})},[h,L,k]),(0,_.useEffect)(()=>{if(y&&L){let e=L.stats;D(e?.seed_ratio_limit==null?``:e.seed_ratio_limit.toString()),ee(e?.seed_time_limit_secs==null?``:e.seed_time_limit_secs.toString())}},[y,L]),(0,_.useEffect)(()=>{let e=e=>{e.button!==2&&i.current&&!i.current.contains(e.target)&&t()},n=e=>{e.key===`Escape`&&t()},r=()=>t();return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,n),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,n),window.removeEventListener(`scroll`,r,!0)}},[t]);let se=Math.min(n,window.innerWidth-220-8),ce=Math.min(r,window.innerHeight-500-8),le=async()=>{m(!0);for(let e of P)if(e.stats?.state===`paused`||e.stats?.state===`error`)try{await k.start(e.id)}catch(t){ne({text:`Error starting torrent "${e.name??e.id}"`,details:t})}A(),t()},U=async()=>{m(!0);for(let e of P)if(e.stats?.state===`live`)try{await k.pause(e.id)}catch(t){ne({text:`Error pausing torrent "${e.name??e.id}"`,details:t})}A(),t()},ue=async()=>{m(!0);for(let e of P)if(e.stats?.state!==`initializing`)try{await k.recheck(e.id)}catch(t){ne({text:`Error checking torrent "${e.name??e.id}"`,details:t})}A(),t()},de=()=>{let e=P.map(e=>e.name??``).filter(Boolean).join(` +`);navigator.clipboard.writeText(e),t()},W=()=>{let e=P.map(e=>e.info_hash).join(` +`);navigator.clipboard.writeText(e),t()},fe=()=>{let e=P.map(e=>{let t=`magnet:?xt=urn:btih:${e.info_hash}`;return e.name&&(t+=`&dn=${encodeURIComponent(e.name)}`),t});navigator.clipboard.writeText(e.join(` +`)),t()},G=()=>{L&&(j(L.id),re(`files`)),t()},pe=async e=>{m(!0);for(let t of P)try{await k.setTorrentCategory(t.id,e)}catch(e){ne({text:`Error setting category for "${t.name??t.id}"`,details:e})}A(),t()},K=async()=>{let e=d.trim();if(!e){u(!1);return}m(!0);try{await k.createCategory(e),N(await k.getCategories())}catch{}for(let t of P)try{await k.setTorrentCategory(t.id,e)}catch(e){ne({text:`Error setting category for "${t.name??t.id}"`,details:e})}A(),t()},me=async()=>{m(!0);for(let e of P)try{let t=e.stats?.sequential??!1;await k.setSequential(e.id,!t)}catch(t){ne({text:`Error toggling sequential for "${e.name??e.id}"`,details:t})}A(),t()},he=async()=>{m(!0);for(let e of P)try{let t=e.stats?.super_seeding??!1;await k.setSuperSeed(e.id,!t)}catch(t){ne({text:`Error toggling super-seed for "${e.name??e.id}"`,details:t})}A(),t()},ge=async(e,n)=>{m(!0);for(let t of P)try{await e(t.id)}catch(e){ne({text:`Error ${n} for "${t.name??t.id}"`,details:e})}A(),t()},q=async()=>{if(L){m(!0);try{await k.setTorrentLimits(L.id,{download_rate:S?Number(S):void 0,upload_rate:w?Number(w):void 0})}catch(e){ne({text:`Error setting speed limits`,details:e})}A(),t()}},_e=async()=>{if(L){m(!0);try{await k.setTorrentSeedLimits(L.id,{ratio_limit:E?Number(E):null,time_limit_secs:O?Number(O):null})}catch(e){ne({text:`Error setting seed limits`,details:e})}A(),t()}},J=`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,ve=`w-3.5 h-3.5 shrink-0`,ye=(0,b.jsx)(`div`,{className:`border-t border-divider my-1`}),be=`w-full px-2 py-1 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`,xe=Object.keys(M).sort((e,t)=>e.localeCompare(t)),Se=({checked:e})=>e?(0,b.jsx)(Ui,{className:`${ve} text-primary`}):(0,b.jsx)(Di,{className:`${ve} text-secondary`});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{ref:i,className:`fixed z-50 bg-surface-raised border border-divider rounded-lg shadow-lg py-1 overflow-y-auto`,style:{left:se,top:ce,width:220,maxHeight:500},children:[I&&(0,b.jsxs)(`button`,{className:J,onClick:le,disabled:p,children:[(0,b.jsx)(Po,{className:`${ve} text-green-600`}),ie?`Resume Selected`:`Resume`]}),F&&(0,b.jsxs)(`button`,{className:J,onClick:U,disabled:p,children:[(0,b.jsx)(Fo,{className:`${ve} text-amber-500`}),ie?`Pause Selected`:`Pause`]}),(I||F)&&ye,(0,b.jsxs)(`button`,{className:J,onClick:ue,disabled:p||!B,children:[(0,b.jsx)(Ao,{className:`${ve} text-secondary`}),ie?`Force Recheck Selected`:`Force Recheck`]}),ye,R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:J,onClick:G,children:[(0,b.jsx)(zo,{className:`${ve} text-secondary`}),`Configure Files`]}),ye]}),(0,b.jsxs)(`button`,{className:J,onClick:me,disabled:p,children:[(0,b.jsx)(Se,{checked:ie?!1:V}),`Sequential Download`]}),z&&(0,b.jsxs)(`button`,{className:J,onClick:he,disabled:p,children:[(0,b.jsx)(Se,{checked:ie?!1:oe}),`Super-Seed`]}),ye,ae&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:J,onClick:()=>ge(e=>k.queueMoveTop(e),`moving to top`),disabled:p,children:[(0,b.jsx)(Wo,{className:`${ve} text-secondary`}),`Move to Top`]}),(0,b.jsxs)(`button`,{className:J,onClick:()=>ge(e=>k.queueMoveUp(e),`moving up`),disabled:p,children:[(0,b.jsx)(Vo,{className:`${ve} text-secondary`}),`Move Up`]}),(0,b.jsxs)(`button`,{className:J,onClick:()=>ge(e=>k.queueMoveDown(e),`moving down`),disabled:p,children:[(0,b.jsx)(Uo,{className:`${ve} text-secondary`}),`Move Down`]}),(0,b.jsxs)(`button`,{className:J,onClick:()=>ge(e=>k.queueMoveBottom(e),`moving to bottom`),disabled:p,children:[(0,b.jsx)(Go,{className:`${ve} text-secondary`}),`Move to Bottom`]}),ye]}),L&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:J,onClick:()=>g(e=>!e),disabled:p,children:[(0,b.jsx)(ko,{className:`${ve} text-secondary`}),`Set Speed Limits...`]}),h&&(0,b.jsxs)(`div`,{className:`px-3 py-1.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`input`,{type:`number`,value:S,onChange:e=>C(e.target.value),placeholder:`Download (bytes/s)`,className:be,min:`0`}),(0,b.jsx)(`input`,{type:`number`,value:w,onChange:e=>T(e.target.value),placeholder:`Upload (bytes/s)`,className:be,min:`0`}),(0,b.jsx)(`button`,{className:`px-2 py-1 text-sm bg-primary-bg text-white rounded hover:bg-primary-bg-hover cursor-pointer`,onClick:q,children:`Apply`})]}),(0,b.jsxs)(`button`,{className:J,onClick:()=>x(e=>!e),disabled:p,children:[(0,b.jsx)(jo,{className:`${ve} text-secondary`}),`Set Seed Limits...`]}),y&&(0,b.jsxs)(`div`,{className:`px-3 py-1.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`input`,{type:`number`,value:E,onChange:e=>D(e.target.value),placeholder:`Ratio limit (e.g. 2.0)`,className:be,min:`0`,step:`0.1`}),(0,b.jsx)(`input`,{type:`number`,value:O,onChange:e=>ee(e.target.value),placeholder:`Time limit (seconds)`,className:be,min:`0`}),(0,b.jsx)(`button`,{className:`px-2 py-1 text-sm bg-primary-bg text-white rounded hover:bg-primary-bg-hover cursor-pointer`,onClick:_e,children:`Apply`})]}),ye]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsxs)(`button`,{className:J,onClick:()=>c(e=>!e),disabled:p,children:[(0,b.jsx)(Oo,{className:`${ve} text-secondary`}),`Set Category...`]}),s&&(0,b.jsxs)(`div`,{className:`border-t border-divider bg-surface-raised`,children:[(0,b.jsx)(`button`,{className:`${J} text-tertiary`,onClick:()=>pe(null),children:`None`}),xe.map(e=>(0,b.jsx)(`button`,{className:J,onClick:()=>pe(e),children:e},e)),l?(0,b.jsx)(`div`,{className:`px-3 py-1`,children:(0,b.jsx)(`input`,{ref:te,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&K(),e.key===`Escape`&&(f(``),u(!1))},onBlur:K,placeholder:`Category name...`,autoFocus:!0,className:be})}):(0,b.jsxs)(`button`,{className:J,onClick:()=>u(!0),children:[(0,b.jsx)(No,{className:`${ve} text-tertiary`}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:`New Category...`})]})]})]}),ye,(0,b.jsxs)(`button`,{className:J,onClick:de,children:[(0,b.jsx)(Ro,{className:`${ve} text-secondary`}),`Copy Name`]}),(0,b.jsxs)(`button`,{className:J,onClick:W,children:[(0,b.jsx)(Ro,{className:`${ve} text-secondary`}),`Copy Info Hash`]}),(0,b.jsxs)(`button`,{className:J,onClick:fe,children:[(0,b.jsx)(Ro,{className:`${ve} text-secondary`}),`Copy Magnet Link`]}),ye,(0,b.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left text-error hover:bg-error/10 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,onClick:()=>o(!0),disabled:p,children:[(0,b.jsx)(Do,{className:`${ve}`}),ie?`Delete ${P.length} Torrents...`:`Delete...`]})]}),(0,b.jsx)(wo,{show:a,onHide:()=>{o(!1),t()},torrents:P.map(e=>({id:e.id,name:e.name}))})]})},_c=`id`,vc=`desc`,yc=e=>{let t=Q(e=>e.searchQuery),n=Q(e=>e.setSearchQuery),r=Q(e=>e.statusFilter),i=Q(e=>e.setStatusFilter);bs();let a=Q(e=>e.detailsModalTorrentId),o=Q(e=>e.closeDetailsModal),[s,c]=(0,_.useState)(t),[l,u]=(0,_.useState)(_c),[d,f]=(0,_.useState)(vc),[p,m]=(0,_.useState)(null),h=(0,_.useCallback)((0,yi.default)(e=>n(e),150),[n]),g=e=>{let t=e.target.value;c(t),h(t)},v=()=>{c(``),n(``)},y=e=>{let[t,n]=e.target.value.split(`:`);u(t),f(n)},x=t.toLowerCase().trim(),S=(0,_.useMemo)(()=>e.torrents?[...e.torrents].filter(e=>ys(e,x,r)).sort((e,t)=>fs(e,t,l,d)):null,[e.torrents,x,r,l,d]),C=(0,_.useCallback)(e=>{let t=S[e];return(0,b.jsx)(`div`,{className:`pb-1.5 sm:pb-2 px-2 sm:px-7 max-w-4xl mx-auto w-full`,onContextMenu:e=>{e.preventDefault(),m({x:e.clientX,y:e.clientY,torrent:t,selectedTorrents:[t]})},children:(0,b.jsx)(cs,{torrent:t},t.id)})},[S]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 w-full max-w-2xl mx-auto mb-2 mt-3 px-2 sm:px-7`,children:[(0,b.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,b.jsx)(di,{className:`absolute left-2.5 sm:left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:s,onChange:g,placeholder:`Search...`,className:`w-full pl-8 sm:pl-9 pr-8 sm:pr-9 py-1.5 sm:py-2 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),s&&(0,b.jsx)(`button`,{onClick:v,className:`absolute right-1.5 sm:right-2 top-1/2 -translate-y-1/2 p-1 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(ci,{className:`w-4 h-4`})})]}),(0,b.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),className:`py-1.5 sm:py-2 px-2 sm:px-3 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary`,children:Object.keys(us).map(e=>(0,b.jsx)(`option`,{value:e,children:us[e]},e))}),(0,b.jsx)(`select`,{value:`${l}:${d}`,onChange:y,className:`py-1.5 sm:py-2 px-2 sm:px-3 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary`,children:Object.keys(ls).flatMap(e=>[(0,b.jsxs)(`option`,{value:`${e}:desc`,children:[ls[e],` ↓`]},`${e}:desc`),(0,b.jsxs)(`option`,{value:`${e}:asc`,children:[ls[e],` ↑`]},`${e}:asc`)])})]}),S===null?e.loading?(0,b.jsx)(bi,{className:`justify-center m-5`,label:`Loading torrent list`}):null:S.length===0?(0,b.jsx)(`p`,{className:`text-center`,children:`No existing torrents found.`}):(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(or,{totalCount:S.length,itemContent:C})}),a!==null&&(0,b.jsx)(hc,{torrentId:a,isOpen:!0,onClose:o}),p&&(0,b.jsx)(gc,{menu:p,onClose:()=>m(null)})]})},bc=1024;function xc(){let[e,t]=(0,_.useState)(()=>window.innerWidth>=bc);return(0,_.useEffect)(()=>{let e=()=>{t(window.innerWidth>=bc)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function Sc(e){if(!e)return`—`;let t=new Date(e*1e3);return`${t.toLocaleDateString(void 0,{year:`2-digit`,month:`2-digit`,day:`2-digit`})} ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}var Cc=[`id`,`name`,`size`,`progress`,`downloadedBytes`,`downSpeed`,`upSpeed`,`uploadedBytes`,`eta`,`peers`,`state`,`info_hash`,`ratio`,`category`,`seeding_time`,`queue_position`,`sequential`,`availability`,`added_on`,`tracker`],wc=[{id:`checkbox`,label:``,defaultWidth:32,minWidth:32,align:`center`,defaultVisible:!0,configurable:!1,sortable:!1},{id:`status_icon`,label:``,defaultWidth:32,minWidth:32,align:`center`,defaultVisible:!0,configurable:!1,sortable:!1},{id:`id`,label:`ID`,defaultWidth:48,minWidth:36,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`name`,label:`Name`,defaultWidth:0,minWidth:100,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`size`,label:`Size`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`progress`,label:`Progress`,defaultWidth:120,minWidth:80,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`downloadedBytes`,label:`Recv`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`downSpeed`,label:`↓ Speed`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`upSpeed`,label:`↑ Speed`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`uploadedBytes`,label:`Sent`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`eta`,label:`ETA`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`peers`,label:`Peers`,defaultWidth:64,minWidth:50,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`state`,label:`State`,defaultWidth:100,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`info_hash`,label:`Info Hash`,defaultWidth:150,minWidth:80,align:`center`,defaultVisible:!1,configurable:!0,sortable:!1},{id:`ratio`,label:`Ratio`,defaultWidth:80,minWidth:50,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`category`,label:`Category`,defaultWidth:120,minWidth:60,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`seeding_time`,label:`Seed Time`,defaultWidth:100,minWidth:60,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`queue_position`,label:`Queue`,defaultWidth:60,minWidth:40,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`sequential`,label:`Seq`,defaultWidth:50,minWidth:36,align:`center`,defaultVisible:!1,configurable:!0,sortable:!1},{id:`availability`,label:`Avail`,defaultWidth:70,minWidth:50,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`added_on`,label:`Added On`,defaultWidth:140,minWidth:90,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`tracker`,label:`Tracker`,defaultWidth:150,minWidth:80,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0}],Tc=`rtbit-column-widths`,Ec=`rtbit-column-visible`,Dc=`rtbit-column-order`;function Oc(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):{}}catch{return{}}}function kc(){try{let e=localStorage.getItem(Dc);if(e){let t=JSON.parse(e),n=Cc.filter(e=>!t.includes(e));return[...t,...n]}}catch{}return[...Cc]}var Ac=oa((e,t)=>({columnWidths:Oc(Tc),columnVisibility:Oc(Ec),columnOrder:kc(),getWidth:e=>{let n=t().columnWidths[e];return n===void 0?wc.find(t=>t.id===e)?.defaultWidth??80:n},isVisible:e=>{let n=t().columnVisibility[e];return n===void 0?wc.find(t=>t.id===e)?.defaultVisible??!0:n},getVisibleColumns:()=>{let{isVisible:e,columnOrder:n}=t(),r=wc.filter(t=>!t.configurable&&e(t.id)),i=n.map(e=>wc.find(t=>t.id===e)).filter(t=>t&&e(t.id));return[...r,...i]},setColumnWidth:(t,n)=>{let r=wc.find(e=>e.id===t)?.minWidth??30,i=Math.max(r,n);e(e=>{let n={...e.columnWidths,[t]:i};return localStorage.setItem(Tc,JSON.stringify(n)),{columnWidths:n}})},toggleColumnVisibility:t=>{let n=wc.find(e=>e.id===t);n?.configurable&&e(e=>{let r=e.columnVisibility[t]??n.defaultVisible,i={...e.columnVisibility,[t]:!r};return localStorage.setItem(Ec,JSON.stringify(i)),{columnVisibility:i}})},moveColumn:(t,n)=>{e(e=>{let r=[...e.columnOrder],i=r.indexOf(t);if(i===-1)return e;let a=n===`up`?i-1:i+1;return a<0||a>=r.length?e:([r[i],r[a]]=[r[a],r[i]],localStorage.setItem(Dc,JSON.stringify(r)),{columnOrder:r})})},resetColumns:()=>{localStorage.removeItem(Tc),localStorage.removeItem(Ec),localStorage.removeItem(Dc),e({columnWidths:{},columnVisibility:{},columnOrder:[...Cc]})}}));function jc(e,t,n,r){return n||e===`error`?{label:`Error`,cls:`bg-error/15 text-error`}:r?{label:`Queued`,cls:`bg-surface-sunken text-secondary`}:e===`initializing`?{label:`Checking`,cls:`bg-warning/15 text-warning`}:e===`paused`?{label:`Paused`,cls:`bg-surface-sunken text-tertiary`}:e===`live`&&t?{label:`Seeding`,cls:`bg-success/15 text-success`}:e===`live`?{label:`Downloading`,cls:`bg-accent-download/15 text-accent-download`}:{label:e||`—`,cls:`bg-surface-sunken text-tertiary`}}function Mc({columns:e}){let t=Ac(e=>e.getWidth);return(0,b.jsx)(`colgroup`,{children:e.map(e=>{let n=t(e.id);return(0,b.jsx)(`col`,{style:n>0?{width:`${n}px`}:void 0},e.id)})})}var Nc=(0,_.memo)(({torrent:e,isSelected:t,odd:n,onRowClick:r,onContextMenu:i,onCheckboxChange:a,visibleColumns:o})=>{let s=e.stats,c=s?.state??``,l=s?.error??null,u=s?.total_bytes??1,d=s?.progress_bytes??0,f=s?.finished||!1,p=!!s?.live,m=l||u===0?100:Math.round(d/u*100),h=s?.live?.download_speed?.human_readable??`-`,g=s?.live?.upload_speed?.human_readable??`-`,_=s?.live?.snapshot.uploaded_bytes??0,v=s?.live?.snapshot.peer_stats,y=v?`${v.live}/${v.seen}`:`-`,x=s?$o(s):`-`,S=f?`Done`:x,C=e.name??``,w=t=>{r(e.id,t)},T=t=>{t.preventDefault(),i(e.id,t)},E=t=>{t.stopPropagation(),a(e.id)},D=`border-r border-divider/40`;function O(n){let r=n.align===`center`?`text-center`:n.align===`right`?`text-right`:`text-left`,i=`px-2 align-middle whitespace-nowrap ${D}`;switch(n.id){case`checkbox`:return(0,b.jsx)(`td`,{className:`px-2 align-middle text-center ${D}`,onMouseDown:E,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>{},className:`w-4 h-4 rounded border-divider-strong bg-surface text-primary focus:ring-primary`})},`checkbox`);case`status_icon`:return(0,b.jsx)(`td`,{className:`px-1 align-middle ${D}`,children:(0,b.jsx)(os,{className:`w-5 h-5`,error:!!l,live:p,finished:f,queued:s?.queue_state===`Queued`})},`status_icon`);case`id`:return(0,b.jsx)(`td`,{className:`${i} text-center text-tertiary font-mono`,children:e.id},`id`);case`name`:return(0,b.jsxs)(`td`,{className:`px-2 align-middle ${r} ${D}`,children:[(0,b.jsx)(`div`,{className:`truncate`,title:C,children:C||`Loading...`}),l&&(0,b.jsx)(`div`,{className:`truncate text-sm text-error`,title:l,children:l})]},`name`);case`size`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:Xo(u)},`size`);case`progress`:return(0,b.jsx)(`td`,{className:`px-2 align-middle text-center ${D}`,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-2 bg-divider rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-500 ${l?`bg-error-bg`:f?`bg-success-bg`:c===`initializing`?`bg-warning-bg`:`bg-accent-download`}`,style:{width:`${m}%`}})}),(0,b.jsxs)(`span`,{className:`text-sm text-secondary w-8 text-right tabular-nums`,children:[m,`%`]})]})},`progress`);case`downloadedBytes`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:Xo(d)},`downloadedBytes`);case`downSpeed`:return(0,b.jsx)(`td`,{className:`${i} ${r} tabular-nums ${(s?.live?.download_speed?.mbps??0)>.01?`text-accent-download font-medium`:`text-secondary`}`,children:h},`downSpeed`);case`upSpeed`:return(0,b.jsx)(`td`,{className:`${i} ${r} tabular-nums ${(s?.live?.upload_speed?.mbps??0)>.01?`text-accent-upload font-medium`:`text-secondary`}`,children:g},`upSpeed`);case`uploadedBytes`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:_>0?Xo(_):``},`uploadedBytes`);case`eta`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:S},`eta`);case`peers`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:y},`peers`);case`state`:{let e=jc(c,f,l,s?.queue_state===`Queued`);return(0,b.jsx)(`td`,{className:`${i} ${r}`,children:(0,b.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.cls}`,children:e.label})},`state`)}case`info_hash`:return(0,b.jsx)(`td`,{className:`px-2 align-middle ${r} font-mono text-xs text-tertiary ${D}`,children:(0,b.jsx)(`div`,{className:`truncate`,title:e.info_hash,children:e.info_hash})},`info_hash`);case`ratio`:{let e=s?.ratio,t=e==null?u>0?(_/u).toFixed(2):`0.00`:e.toFixed(2);return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:t},`ratio`)}case`category`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:(0,b.jsx)(`span`,{className:`truncate`,children:e.category||`—`})},`category`);case`seeding_time`:{let e=s?.seeding_time_secs;return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:e==null?`—`:Qo(e)},`seeding_time`)}case`queue_position`:{let e=s?.queue_state,t=s?.queue_position,n;return n=e===`Queued`&&t!=null?`#${t}`:e===`Active`?`Active`:`—`,(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:n},`queue_position`)}case`sequential`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:s?.sequential?`✓`:`—`},`sequential`);case`availability`:{let e=s?.min_piece_availability;return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:e==null?`—`:e.toFixed(1)},`availability`)}case`added_on`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary tabular-nums`,children:Sc(e.added_on)},`added_on`);case`tracker`:{let t=hs(e);return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,title:t.join(`, `),children:(0,b.jsx)(`span`,{className:`truncate`,children:t.length===0?`—`:t.length===1?t[0]:`${t[0]} +${t.length-1}`})},`tracker`)}default:return(0,b.jsx)(`td`,{className:i},n.id)}}return(0,b.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,b.jsx)(Mc,{columns:o}),(0,b.jsx)(`tbody`,{children:(0,b.jsx)(`tr`,{onMouseDown:w,onContextMenu:T,className:`cursor-pointer border-b border-divider/60 text-sm h-8 transition-colors ${t?`bg-primary/15`:`${n?`bg-surface-sunken/40`:``} hover:bg-primary/5`}`,children:o.map(e=>O(e))})})]})}),Pc=({x:e,y:t,onClose:n})=>{let r=Ac(e=>e.columnVisibility),i=Ac(e=>e.columnOrder),a=Ac(e=>e.toggleColumnVisibility),o=Ac(e=>e.moveColumn),s=Ac(e=>e.resetColumns),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=Math.min(e,window.innerWidth-260-8),u=Math.min(t,window.innerHeight-400-8),d=i.map(e=>wc.find(t=>t.id===e)).filter(e=>e&&e.configurable),f=e=>{let t=r[e];return t===void 0?wc.find(t=>t.id===e)?.defaultVisible??!0:t},p=`p-0.5 text-tertiary hover:text-primary rounded hover:bg-surface-raised disabled:opacity-30 disabled:cursor-not-allowed cursor-pointer`;return(0,b.jsxs)(`div`,{ref:c,className:`fixed z-50 bg-surface-raised border border-divider rounded-lg shadow-lg py-1 overflow-y-auto`,style:{left:l,top:u,width:260,maxHeight:400},children:[(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-semibold text-tertiary uppercase tracking-wider border-b border-divider`,children:`Columns`}),d.map((e,t)=>{let n=f(e.id);return(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 hover:bg-surface`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2 flex-1 cursor-pointer text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>a(e.id),className:`w-3.5 h-3.5 rounded border-divider-strong bg-surface text-primary focus:ring-primary`}),(0,b.jsx)(`span`,{className:n?`text-primary`:`text-tertiary`,children:e.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,b.jsx)(`button`,{className:p,onClick:()=>o(e.id,`up`),disabled:t===0,title:`Move up`,children:(0,b.jsx)(li,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{className:p,onClick:()=>o(e.id,`down`),disabled:t===d.length-1,title:`Move down`,children:(0,b.jsx)(ui,{className:`w-3.5 h-3.5`})})]})]},e.id)}),(0,b.jsx)(`div`,{className:`border-t border-divider mt-1 pt-1`,children:(0,b.jsx)(`button`,{onClick:()=>{s(),n()},className:`w-full text-left px-3 py-1.5 text-xs text-secondary hover:bg-surface cursor-pointer`,children:`Reset to defaults`})})]})},Fc=`id`,Ic=`desc`;function Lc(e,t){switch(t){case`id`:return e.id;case`name`:return(e.name??``).toLowerCase();case`size`:return e.stats?.total_bytes??0;case`progress`:return e.stats?.total_bytes?(e.stats.progress_bytes??0)/e.stats.total_bytes:0;case`downloadedBytes`:return e.stats?.progress_bytes??0;case`downSpeed`:return e.stats?.live?.download_speed?.mbps??0;case`upSpeed`:return e.stats?.live?.upload_speed?.mbps??0;case`uploadedBytes`:return e.stats?.live?.snapshot.uploaded_bytes??0;case`eta`:{if(!e.stats?.live)return 1/0;let t=(e.stats.total_bytes??0)-(e.stats.progress_bytes??0),n=e.stats.live.download_speed?.mbps??0;return n<=0||t<=0?t<=0?0:1/0:t/(n*1024*1024)}case`peers`:return e.stats?.live?.snapshot.peer_stats?.live??0;case`state`:return e.stats?.state??``;case`ratio`:{if(e.stats?.ratio!=null)return e.stats.ratio;let t=e.stats?.live?.snapshot.uploaded_bytes??0,n=e.stats?.total_bytes??1;return n>0?t/n:0}case`category`:return(e.category??``).toLowerCase();case`seeding_time`:return e.stats?.seeding_time_secs??0;case`queue_position`:return e.stats?.queue_position??1/0;case`availability`:return e.stats?.min_piece_availability??0;case`added_on`:return e.added_on??0;case`tracker`:return hs(e)[0]??``}}function Rc({columns:e}){Ac(e=>e.columnWidths);let t=Ac(e=>e.getWidth);return(0,b.jsx)(`colgroup`,{children:e.map(e=>{let n=t(e.id);return(0,b.jsx)(`col`,{style:n>0?{width:`${n}px`}:void 0},e.id)})})}var zc=({torrents:e,loading:t})=>{let n=Q(e=>e.selectedTorrentIds),r=Q(e=>e.selectTorrent),i=Q(e=>e.toggleSelection),a=Q(e=>e.selectRange),o=Q(e=>e.selectRelative),s=Q(e=>e.selectAll),c=Q(e=>e.clearSelection),l=Q(e=>e.searchQuery),u=Q(e=>e.statusFilter),d=Q(e=>e.categoryFilter),f=Q(e=>e.trackerFilter);Ac(e=>e.columnVisibility),Ac(e=>e.columnWidths),Ac(e=>e.columnOrder);let p=Ac(e=>e.getVisibleColumns)(),m=Ac(e=>e.getWidth),h=Ac(e=>e.setColumnWidth),g=l.toLowerCase().trim(),[v,y]=(0,_.useState)(Fc),[x,S]=(0,_.useState)(Ic),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),ee=(0,_.useCallback)(e=>{y(t=>(S(n=>t===e?n===`asc`?`desc`:`asc`:`desc`),e))},[]),te=(0,_.useMemo)(()=>e?[...e].filter(e=>ys(e,g,u,d,f)).sort((e,t)=>{let n=Lc(e,v),r=Lc(t,v),i=typeof n==`string`?n.localeCompare(r):n-r;return x===`asc`?i:-i}):null,[e,g,u,d,f,v,x]),k=(0,_.useMemo)(()=>te?te.map(e=>e.id):[],[te]),ne=!!(k.length>0&&k.every(e=>n.has(e))),A=k.some(e=>n.has(e)),j=()=>{ne?c():s(k)},re=e=>{ee(e)},M=(0,_.useRef)([]);M.current=k,(0,_.useEffect)(()=>{let e=e=>{let t=document.activeElement;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)||(e.key===`ArrowDown`?(e.preventDefault(),o(`down`,M.current)):e.key===`ArrowUp`&&(e.preventDefault(),o(`up`,M.current)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let N=(0,_.useCallback)((e,t)=>{t.button!==2&&(t.shiftKey?(t.preventDefault(),a(e,M.current)):r(e))},[a,r]),P=(0,_.useCallback)((e,t)=>{let i=te?.find(t=>t.id===e);if(!i)return;let a;n.has(e)?a=te.filter(e=>n.has(e.id)):(r(e),a=[i]),O({x:t.clientX,y:t.clientY,torrent:i,selectedTorrents:a})},[te,n,r]);(0,_.useEffect)(()=>{if(!C)return;let e=e=>{let t=e.clientX-C.startX;h(C.colId,C.startWidth+t)},t=()=>{w(null)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.userSelect=``,document.body.style.cursor=``}},[C,h]);let ie=(0,_.useCallback)((e,t)=>{t.preventDefault(),t.stopPropagation();let n=m(e);if(n===0){let e=t.target.closest(`th`);e&&(n=e.getBoundingClientRect().width)}w({colId:e,startX:t.clientX,startWidth:n})},[m]),F=(0,_.useCallback)(e=>{e.preventDefault(),E({x:e.clientX,y:e.clientY})},[]),I=(0,_.useCallback)(e=>{let t=te[e];return(0,b.jsx)(Nc,{torrent:t,isSelected:n.has(t.id),odd:e%2==1,onRowClick:N,onContextMenu:P,onCheckboxChange:i,visibleColumns:p},t.id)},[te,n,N,P,i,p]);return t?(0,b.jsx)(`div`,{className:`flex justify-center items-center h-64`,children:(0,b.jsx)(bi,{})}):!e||e.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-tertiary`,children:[(0,b.jsx)(`p`,{className:`text-lg`,children:`No torrents`}),(0,b.jsx)(`p`,{className:``,children:`Add a torrent to get started`})]}):(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,b.jsx)(Rc,{columns:p}),(0,b.jsx)(`thead`,{className:`bg-surface-raised text-sm`,children:(0,b.jsx)(`tr`,{className:`border-b border-divider`,onContextMenu:F,children:p.map(e=>{if(e.id===`checkbox`)return(0,b.jsx)(`th`,{className:`px-2 py-3 border-r border-divider/40`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:ne,ref:e=>{e&&(e.indeterminate=A&&!ne)},onChange:j,className:`w-4 h-4 rounded border-divider-strong bg-surface text-primary focus:ring-primary`})},`checkbox`);if(e.id===`status_icon`)return(0,b.jsx)(`th`,{className:`px-1 py-3 border-r border-divider/40`},`status_icon`);let t=e.align===`center`?`text-center`:e.align===`right`?`text-right`:`text-left`,n=e.sortable,r=e.configurable;return(0,b.jsxs)(`th`,{className:`relative px-2 py-2 text-secondary select-none whitespace-nowrap border-r border-divider/40 ${t} ${n?`cursor-pointer hover:text-text`:``}`,onClick:n?()=>re(e.id):void 0,children:[e.label,n&&(0,b.jsx)(Ls,{column:e.id,sortColumn:v,sortDirection:x}),r&&(0,b.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/40 z-10`,onMouseDown:t=>ie(e.id,t)})]},e.id)})})})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(or,{totalCount:te?.length??0,itemContent:I})}),T&&(0,b.jsx)(Pc,{x:T.x,y:T.y,onClose:()=>E(null)}),D&&(0,b.jsx)(gc,{menu:D,onClose:()=>O(null)})]})},Bc=100,Vc=600,Hc=256,Uc=({torrents:e,loading:t})=>{bs();let[n,r]=(0,_.useState)(Hc),[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null),s=(0,_.useCallback)(e=>{e.preventDefault(),a(!0)},[]);(0,_.useEffect)(()=>{if(!i)return;let e=e=>{if(!o.current)return;let t=o.current.getBoundingClientRect().bottom-e.clientY;r(Math.max(Bc,Math.min(Vc,t)))},t=()=>{a(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[i]);let c=(e?.length??0)>0;return(0,b.jsxs)(`div`,{ref:o,className:`flex flex-col h-full`,children:[(0,b.jsx)(`div`,{className:`flex-1 overflow-auto min-h-0`,children:(0,b.jsx)(zc,{torrents:e,loading:t})}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{onMouseDown:s,className:`h-1.5 cursor-ns-resize shrink-0 bg-divider hover:bg-primary transition-colors ${i?`bg-primary`:``}`,title:`Drag to resize`,children:(0,b.jsx)(`div`,{className:`h-full w-12 mx-auto flex items-center justify-center`,children:(0,b.jsx)(`div`,{className:`w-8 h-0.5 bg-secondary rounded-full`})})}),(0,b.jsx)(`div`,{style:{height:n},className:`shrink-0`,children:(0,b.jsx)(pc,{})})]})]})},Wc=oa((e,t)=>({status:null,setStatus:t=>e({status:t}),identity:null,setIdentity:t=>e({identity:t}),syncPreferences:null,setSyncPreferences:t=>e({syncPreferences:t}),showSetup:!1,setShowSetup:t=>e({showSetup:t}),searchQuery:``,setSearchQuery:t=>e({searchQuery:t}),searchFilters:{},setSearchFilter:(t,n)=>e(e=>({searchFilters:{...e.searchFilters,[t]:n}})),clearSearchFilters:()=>e({searchFilters:{}}),searchResults:[],searchTotal:0,searchOffset:0,searchLoading:!1,setSearchResults:(t,n,r)=>e({searchResults:t,searchTotal:n,searchOffset:r}),setSearchLoading:t=>e({searchLoading:t}),recentTorrents:[],recentLoading:!1,setRecentTorrents:t=>e({recentTorrents:t}),setRecentLoading:t=>e({recentLoading:t})})),Gc=`rtbit_access_token`,Kc=`rtbit_refresh_token`,qc=`rtbit_token_expiry`,Jc=oa((e,t)=>({state:`loading`,accessToken:localStorage.getItem(Gc),refreshToken:localStorage.getItem(Kc),tokenExpiry:(()=>{let e=localStorage.getItem(qc);return e?parseInt(e,10):null})(),setState:t=>e({state:t}),setTokens:(t,n,r)=>{let i=Date.now()+r*1e3;localStorage.setItem(Gc,t),localStorage.setItem(Kc,n),localStorage.setItem(qc,i.toString()),e({accessToken:t,refreshToken:n,tokenExpiry:i,state:`authenticated`})},clearTokens:()=>{localStorage.removeItem(Gc),localStorage.removeItem(Kc),localStorage.removeItem(qc),e({accessToken:null,refreshToken:null,tokenExpiry:null,state:`login_required`})},getAccessToken:()=>{let{accessToken:e,tokenExpiry:n}=t();return!e||!n||Date.now()>n-3e4?null:e}})),Yc=(()=>{if(window.origin===`null`)return`http://localhost:3030`;let e=new URL(window.location.href);return e.port==`3031`&&(e.pathname===`/`||e.pathname===``)||e.port==`1420`?`${e.protocol}//${e.hostname}:3030`:/(.*?)\/?(\/web\/?)?$/.exec(e.pathname)[1]??``})(),Xc=()=>{let e=Jc.getState().getAccessToken();return e?{Authorization:`Bearer ${e}`}:{}},Zc=async()=>{let{refreshToken:e,setTokens:t,clearTokens:n}=Jc.getState();if(!e)return!1;try{let r=Yc+`/auth/refresh`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:e})});if(!i.ok)return n(),!1;let a=await i.json();return t(a.access_token,a.refresh_token,a.expires_in),!0}catch{return n(),!1}},Qc=async(e,t,n,r)=>{console.log(e,t);let i=Yc+t,a=Xc(),o={method:e,headers:{Accept:`application/json`,...a}};r?(o.headers={Accept:`application/json`,"Content-Type":`application/json`,...a},o.body=JSON.stringify(n)):o.body=n;let s={method:e,path:t,text:``},c;try{c=await fetch(i,o)}catch{return s.text=`network error`,Promise.reject(s)}if(c.status===401){if(await Zc()){let e=Xc(),t={...o,headers:r?{Accept:`application/json`,"Content-Type":`application/json`,...e}:{Accept:`application/json`,...e}};try{c=await fetch(i,t)}catch{return s.text=`network error`,Promise.reject(s)}if(c.ok)return c.json()}return Jc.getState().clearTokens(),s.status=401,s.statusText=`401 Unauthorized`,s.text=`Session expired. Please log in again.`,Promise.reject(s)}if(s.status=c.status,s.statusText=`${c.status} ${c.statusText}`,!c.ok){let e=await c.text();try{let t=JSON.parse(e);s.text=t.human_readable===void 0?JSON.stringify(t,null,2):t.human_readable}catch{s.text=e}return Promise.reject(s)}return await c.json()},$c={getStatus:async()=>{let e=Yc+`/auth/status`,t=await fetch(e);return t.ok?t.json():{auth_enabled:!1,setup_required:!1}},login:async(e,t)=>{let n=Yc+`/auth/login`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});if(!r.ok){let e=await r.text();throw Error(e||`Login failed`)}return r.json()},setup:async(e,t)=>{let n=Yc+`/auth/setup`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});if(!r.ok){let e=await r.text();throw Error(e||`Setup failed`)}return r.json()},logout:async e=>{let t=Yc+`/auth/logout`;await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,...Xc()},body:JSON.stringify({refresh_token:e})})},changeCredentials:async(e,t,n)=>{let r=Yc+`/auth/change_credentials`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,...Xc()},body:JSON.stringify({current_password:e,new_username:t||void 0,new_password:n||void 0})});if(!i.ok){let e=await i.text();throw Error(e||`Failed to change credentials`)}}},el={getStatus:()=>Qc(`GET`,`/indexarr/status`),search:(e,t,n=50,r=0)=>{let i=new URLSearchParams;if(i.set(`q`,e),i.set(`limit`,String(n)),i.set(`offset`,String(r)),t)for(let[e,n]of Object.entries(t))n&&i.set(e,n);return Qc(`GET`,`/indexarr/search?${i.toString()}`)},getRecent:(e=50)=>Qc(`GET`,`/indexarr/recent?limit=${e}`),getTrending:(e=50)=>Qc(`GET`,`/indexarr/trending?limit=${e}`),getIdentityStatus:()=>Qc(`GET`,`/indexarr/identity/status`),acknowledgeIdentity:()=>Qc(`POST`,`/indexarr/identity/acknowledge`),getSyncPreferences:()=>Qc(`GET`,`/indexarr/sync/preferences`),setSyncPreferences:e=>Qc(`POST`,`/indexarr/sync/preferences`,e,!0)},tl={getFeeds:()=>Qc(`GET`,`/rss/feeds`),addFeed:e=>Qc(`POST`,`/rss/feeds`,e,!0),updateFeed:(e,t)=>Qc(`PUT`,`/rss/feeds/${encodeURIComponent(e)}`,t,!0),deleteFeed:e=>Qc(`DELETE`,`/rss/feeds/${encodeURIComponent(e)}`),getItems:(e,t=500)=>{let n=new URLSearchParams;return e&&n.set(`feed`,e),n.set(`limit`,String(t)),Qc(`GET`,`/rss/items?${n.toString()}`)},downloadItem:e=>Qc(`POST`,`/rss/items/${encodeURIComponent(e)}/download`),getRules:()=>Qc(`GET`,`/rss/rules`),addRule:e=>Qc(`POST`,`/rss/rules`,e,!0),updateRule:(e,t)=>Qc(`PUT`,`/rss/rules/${encodeURIComponent(e)}`,t,!0),deleteRule:e=>Qc(`DELETE`,`/rss/rules/${encodeURIComponent(e)}`),getSettings:()=>Qc(`GET`,`/rss/settings`)},nl=()=>{let e=Wc(e=>e.identity),t=Wc(e=>e.setIdentity),n=Wc(e=>e.syncPreferences),r=Wc(e=>e.setSyncPreferences),i=Wc(e=>e.setShowSetup),a=Ko(e=>e.setCloseableError),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(`identity`);(0,_.useEffect)(()=>{(async()=>{try{let[e,n]=await Promise.all([el.getIdentityStatus(),el.getSyncPreferences()]);t(e),r(n),p(n.import_categories),h(n.sync_comments),e.needs_onboarding||v(`categories`)}catch(e){a({text:`Failed to load Indexarr setup`,details:e})}finally{s(!1)}})()},[]);let y=async()=>{if(e?.recovery_key)try{await navigator.clipboard.writeText(e.recovery_key),d(!0),setTimeout(()=>d(!1),2e3)}catch{}},x=async()=>{l(!0);try{await el.acknowledgeIdentity(),t(await el.getIdentityStatus()),v(`categories`)}catch(e){a({text:`Failed to acknowledge identity`,details:e})}finally{l(!1)}},S=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return o?(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,b.jsx)(bi,{label:`Loading setup`})}):(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center p-4`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-lg max-w-lg w-full`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-b border-divider`,children:[e&&!e.needs_onboarding&&(0,b.jsx)(`button`,{onClick:()=>i(!1),className:`p-1 text-secondary hover:text-text cursor-pointer`,children:(0,b.jsx)(Ho,{className:`w-4 h-4`})}),(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Indexarr Setup`})]}),g===`identity`&&(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-sm text-secondary`,children:`Your Indexarr node has generated a unique contributor identity. Save the recovery key below — you will need it to restore your identity if you reinstall.`}),e?.contributor_id&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-secondary mb-1 block`,children:`Contributor ID`}),(0,b.jsx)(`code`,{className:`block text-sm bg-surface px-3 py-2 rounded font-mono`,children:e.contributor_id})]}),e?.recovery_key&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-secondary mb-1 block`,children:`Recovery Key`}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`textarea`,{readOnly:!0,value:e.recovery_key,className:`w-full text-sm bg-surface px-3 py-2 rounded font-mono resize-none h-20 border border-divider`}),(0,b.jsx)(`button`,{onClick:y,className:`absolute top-2 right-2 p-1.5 bg-surface-raised rounded hover:bg-primary/10 cursor-pointer`,title:`Copy to clipboard`,children:u?(0,b.jsx)(Bo,{className:`w-3.5 h-3.5 text-green-500`}):(0,b.jsx)(Ro,{className:`w-3.5 h-3.5 text-secondary`})})]}),(0,b.jsx)(`p`,{className:`text-xs text-tertiary mt-1`,children:`Store this key securely. It cannot be recovered later.`})]}),(0,b.jsx)(`button`,{onClick:x,disabled:c,className:`w-full py-2 rounded bg-primary text-white font-medium hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,children:c?`Saving...`:`I have saved my recovery key`})]}),g===`categories`&&(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-sm text-secondary`,children:`Select which content categories to sync from the network.`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(n?.all_categories||[]).map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-2 bg-surface rounded cursor-pointer hover:bg-surface-raised/50`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:f.includes(e),onChange:()=>S(e),className:`rounded`}),(0,b.jsx)(`span`,{className:`text-sm capitalize`,children:e.replace(`_`,` `)})]},e))}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-2 bg-surface rounded cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),className:`rounded`}),(0,b.jsx)(`span`,{className:`text-sm`,children:`Sync comments`})]}),(0,b.jsx)(`button`,{onClick:async()=>{l(!0);try{r(await el.setSyncPreferences({import_categories:f,sync_comments:m})),i(!1)}catch(e){a({text:`Failed to save sync preferences`,details:e})}finally{l(!1)}},disabled:c||f.length===0,className:`w-full py-2 rounded bg-primary text-white font-medium hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,children:c?`Saving...`:`Save Preferences`})]})]})})},rl=({children:e,label:t,help:n,className:r})=>(0,b.jsxs)(`fieldset`,{className:`mb-4 ${r}`,children:[t&&(0,b.jsx)(`label`,{className:`font-medium mb-3 block pb-1 border-b border-divider`,children:t}),e]}),il=({autoFocus:e,value:t,name:n,disabled:r,onChange:i,onKeyDown:a,label:o,help:s,inputType:c,placeholder:l})=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:n,children:o}),(0,b.jsx)(`input`,{autoFocus:e,type:c,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 focus:ring-0 focus:border-primary sm:leading-6`,id:n,name:n,disabled:r,placeholder:l,value:t,onKeyDown:a,onChange:i}),s&&(0,b.jsx)(`div`,{className:`text-sm text-secondary`,children:s})]}),al=({children:e})=>(0,b.jsx)(`form`,{children:e}),ol=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:i,data:a}=e,[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),g=la(e=>e.refreshTorrents),y=(0,_.useContext)(v);(0,_.useEffect)(()=>{s(new Set(n?.details.files.flatMap((e,t)=>e.attributes.padding?[]:[t]))),h(n?.output_folder||``)},[n]);let x=()=>{t(),s(new Set),d(null),l(!1)};return(0,b.jsxs)(xo,{isOpen:!0,onClose:x,title:`Add Torrent`,children:[(0,b.jsxs)(So,{children:[(()=>{if(i)return(0,b.jsx)(bi,{label:`Loading torrent contents`});if(r)return(0,b.jsx)(ma,{error:r});if(n)return(0,b.jsxs)(al,{children:[(0,b.jsx)(il,{label:`Output folder`,name:`output_folder`,inputType:`text`,placeholder:`Server default`,value:m,onChange:e=>h(e.target.value)}),(0,b.jsx)(rl,{children:(0,b.jsx)(Fs,{selectedFiles:o,setSelectedFiles:s,torrentDetails:n.details,torrentStats:null})})]})})(),(0,b.jsx)(ma,{error:u})]}),(0,b.jsxs)(Co,{children:[c&&(0,b.jsx)(bi,{}),(0,b.jsx)(fa,{onClick:x,variant:`cancel`,children:`Cancel`}),(0,b.jsx)(fa,{onClick:async()=>{if(!n)return;l(!0);let e=n.seen_peers?n.seen_peers.slice(0,32):null,r=new Set(n.details.files.flatMap((e,t)=>e.attributes.padding?[]:[t])),i={overwrite:!0,only_files:o.size===r.size&&[...o].every(e=>r.has(e))?void 0:Array.from(o),initial_peers:e,output_folder:m};f&&(i.peer_opts={connect_timeout:20,read_write_timeout:60}),y.uploadTorrent(a,i).then(()=>{t(),g()},e=>{d({text:`Error starting torrent`,details:e})}).finally(()=>l(!1))},variant:`primary`,disabled:i||c||o.size==0,children:`OK`})]})]})},sl=[`udp://tracker.opentrackr.org:1337/announce`,`udp://open.stealth.si:80/announce`];function cl(e,t,n){return`magnet:?xt=urn:btih:${e}${t?`&dn=${encodeURIComponent(t)}`:``}${(n&&n.length>0?n:sl).map(e=>`&tr=${encodeURIComponent(e)}`).join(``)}`}function ll(e){if(!e)return null;let t={movie:`bg-blue-500/20 text-blue-400`,tv_show:`bg-purple-500/20 text-purple-400`,music:`bg-green-500/20 text-green-400`,ebook:`bg-yellow-500/20 text-yellow-400`,game:`bg-red-500/20 text-red-400`,software:`bg-cyan-500/20 text-cyan-400`,xxx:`bg-pink-500/20 text-pink-400`}[e]||`bg-surface text-secondary`,n=e.replace(`_`,` `);return(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs font-medium ${t}`,children:n})}function ul(e){if(!e)return``;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var dl=[``,`movie`,`tv_show`,`music`,`ebook`,`comic`,`audiobook`,`game`,`software`],fl=()=>{let e=(0,_.useContext)(v),t=Ko(e=>e.setCloseableError),n=Wc(e=>e.status),r=Wc(e=>e.identity),i=Wc(e=>e.setIdentity),a=Wc(e=>e.showSetup),o=Wc(e=>e.setShowSetup),s=Wc(e=>e.searchQuery),c=Wc(e=>e.setSearchQuery),l=Wc(e=>e.searchFilters),u=Wc(e=>e.setSearchFilter),d=Wc(e=>e.searchResults),f=Wc(e=>e.searchTotal),p=Wc(e=>e.searchLoading),m=Wc(e=>e.setSearchResults),h=Wc(e=>e.setSearchLoading),g=Wc(e=>e.recentTorrents),y=Wc(e=>e.recentLoading),x=Wc(e=>e.setRecentTorrents),S=Wc(e=>e.setRecentLoading),[C,w]=(0,_.useState)(s),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(`search`),[ee,te]=(0,_.useState)(null),[k,ne]=(0,_.useState)(null),[A,j]=(0,_.useState)(!1),[re,M]=(0,_.useState)(null),N=(0,_.useRef)(null);(0,_.useEffect)(()=>{el.getIdentityStatus().then(i).catch(()=>{})},[]);let P=(0,_.useCallback)(async()=>{S(!0);try{x((await el.getRecent(50)).results)}catch{}finally{S(!1)}},[]);(0,_.useEffect)(()=>(P(),N.current=setInterval(P,6e4),()=>{N.current&&clearInterval(N.current)}),[P]);let ie=(0,_.useCallback)(async(e,n)=>{h(!0);try{let t=await el.search(e,n);m(t.results,t.total,t.offset)}catch(e){t({text:`Indexarr search failed`,details:e})}finally{h(!1)}},[]),F=(0,_.useCallback)((0,yi.default)((e,t)=>ie(e,t),300),[ie]),I=e=>{let t=e.target.value;w(t),c(t),F(t,l)},L=(e,t)=>{u(e,t),F(s,{...l,[e]:t})},R=()=>{w(``),c(``),m([],0,0)};(0,_.useEffect)(()=>{if(!ee)return;let t=!1;return j(!0),ne(null),M(null),(async()=>{try{let n=await e.uploadTorrent(ee,{list_only:!0});t||ne(n)}catch(e){t||M({text:`Error listing torrent files`,details:e})}finally{t||j(!1)}})(),()=>{t=!0}},[ee]);let z=()=>{te(null),ne(null),M(null),j(!1),E(null)},ae=(e,t,n)=>{E(e),te(cl(e,t,n))};if(n&&!n.enabled)return(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center text-secondary`,children:(0,b.jsx)(`p`,{children:`Indexarr integration is not enabled.`})});if(n&&n.enabled&&!n.reachable)return(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center text-secondary`,children:(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`p`,{className:`text-lg font-semibold mb-2`,children:`Cannot reach Indexarr`}),(0,b.jsx)(`p`,{className:`text-sm`,children:n.error})]})});if(r&&r.needs_onboarding||a)return(0,b.jsx)(nl,{});let B=`px-3 py-2 text-sm font-medium text-secondary text-left`;return(0,b.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-divider bg-surface-raised`,children:[(0,b.jsx)(`button`,{onClick:()=>O(`search`),className:`px-3 py-1 text-sm rounded cursor-pointer ${D===`search`?`bg-primary text-white`:`text-secondary hover:text-text`}`,children:`Search`}),(0,b.jsx)(`button`,{onClick:()=>O(`recent`),className:`px-3 py-1 text-sm rounded cursor-pointer ${D===`recent`?`bg-primary text-white`:`text-secondary hover:text-text`}`,children:`Recent`}),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`button`,{onClick:()=>o(!0),className:`p-1 text-secondary hover:text-text cursor-pointer`,title:`Indexarr Settings`,children:(0,b.jsx)(zo,{className:`w-4 h-4`})})]}),D===`search`&&(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`px-4 py-3 border-b border-divider space-y-2`,children:[(0,b.jsx)(`div`,{className:`flex gap-2`,children:(0,b.jsxs)(`div`,{className:`relative flex-1`,children:[(0,b.jsx)(Mo,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,value:C,onChange:I,placeholder:`Search the torrent index...`,className:`w-full pl-9 pr-8 py-2 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),C&&(0,b.jsx)(`button`,{onClick:R,className:`absolute right-2 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(ci,{className:`w-4 h-4`})})]})}),(0,b.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,b.jsxs)(`select`,{value:l.content_type||``,onChange:e=>L(`content_type`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:``,children:`All types`}),dl.filter(Boolean).map(e=>(0,b.jsx)(`option`,{value:e,children:e.replace(`_`,` `)},e))]}),(0,b.jsxs)(`select`,{value:l.resolution||``,onChange:e=>L(`resolution`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:``,children:`Any resolution`}),[`720p`,`1080p`,`2160p`].map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),(0,b.jsxs)(`select`,{value:l.sort||`relevance`,onChange:e=>L(`sort`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:`relevance`,children:`Sort: Relevance`}),(0,b.jsx)(`option`,{value:`date`,children:`Sort: Date`}),(0,b.jsx)(`option`,{value:`seeders`,children:`Sort: Seeders`}),(0,b.jsx)(`option`,{value:`size`,children:`Sort: Size`}),(0,b.jsx)(`option`,{value:`name`,children:`Sort: Name`})]})]})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:p&&d.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(bi,{label:`Searching`})}):d.length===0&&s?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`No results found`}):d.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`Enter a search query to find torrents`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`px-4 py-1 text-xs text-secondary`,children:[f.toLocaleString(),` results`,p&&` (loading...)`]}),(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:B,children:`Name`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden lg:table-cell`,children:`SE`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden lg:table-cell`,children:`LE`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden md:table-cell`,children:`Age`}),(0,b.jsx)(`th`,{className:`${B} w-20`})]})}),(0,b.jsx)(`tbody`,{children:d.map(e=>(0,b.jsx)(pl,{result:e,downloading:T===e.info_hash,onDownload:()=>ae(e.info_hash,e.name,e.trackers)},e.info_hash))})]})]})})]}),D===`recent`&&(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:y&&g.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(bi,{label:`Loading recent`})}):g.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`No recent torrents`}):(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:B,children:`Name`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden lg:table-cell`,children:`SE`}),(0,b.jsx)(`th`,{className:`${B} text-right hidden md:table-cell`,children:`Age`}),(0,b.jsx)(`th`,{className:`${B} w-20`})]})}),(0,b.jsx)(`tbody`,{children:g.map(e=>(0,b.jsx)(ml,{item:e,downloading:T===e.info_hash,onDownload:()=>ae(e.info_hash,e.name,e.trackers)},e.info_hash))})]})}),ee&&(0,b.jsx)(ol,{onHide:z,listTorrentResponse:k,listTorrentError:re,listTorrentLoading:A,data:ee})]})},pl=({result:e,downloading:t,onDownload:n})=>{let r=`px-3 py-2 text-sm`,i=`${r} text-right whitespace-nowrap`;return(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface-raised/50 transition-colors`,children:[(0,b.jsx)(`td`,{className:`${r} max-w-0`,children:(0,b.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`div`,{className:`truncate text-text`,title:e.name||``,children:e.name||e.info_hash}),(0,b.jsxs)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:[ll(e.content_type),e.resolution&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.resolution}),e.codec&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.codec}),e.year&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.year})]})]})})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:e.size?Xo(e.size):`-`}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-green-500 inline-flex items-center gap-0.5`,children:[(0,b.jsx)(jo,{className:`w-3 h-3`}),e.seed_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-secondary inline-flex items-center gap-0.5`,children:[(0,b.jsx)(To,{className:`w-3 h-3`}),e.peer_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:ul(e.resolved_at)}),(0,b.jsx)(`td`,{className:`${r} text-right`,children:(0,b.jsx)(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded bg-primary text-white hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,title:`Download torrent`,children:t?(0,b.jsx)(`span`,{className:`w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin`}):(0,b.jsx)(Lo,{className:`w-3 h-3`})})})]})},ml=({item:e,downloading:t,onDownload:n})=>{let r=`px-3 py-2 text-sm`,i=`${r} text-right whitespace-nowrap`;return(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface-raised/50 transition-colors`,children:[(0,b.jsx)(`td`,{className:`${r} max-w-0`,children:(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`truncate text-text`,title:e.name||``,children:e.name||e.info_hash}),(0,b.jsxs)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:[ll(e.content_type),e.resolution&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.resolution})]})]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:e.size?Xo(e.size):`-`}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-green-500 inline-flex items-center gap-0.5`,children:[(0,b.jsx)(jo,{className:`w-3 h-3`}),e.seed_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:ul(e.resolved_at)}),(0,b.jsx)(`td`,{className:`${r} text-right`,children:(0,b.jsx)(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded bg-primary text-white hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,title:`Download torrent`,children:t?(0,b.jsx)(`span`,{className:`w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin`}):(0,b.jsx)(Lo,{className:`w-3 h-3`})})})]})};function hl(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),(i>0||a.length===0)&&a.push(`${i}s`),a.join(``)}var gl=oa(e=>({feeds:[],setFeeds:t=>e({feeds:t}),items:[],setItems:t=>e({items:t}),rules:[],setRules:t=>e({rules:t}),selectedFeedFilter:null,setSelectedFeedFilter:t=>e({selectedFeedFilter:t}),loading:!1,setLoading:t=>e({loading:t})})),_l=({isOpen:e,onClose:t,feed:n,onSaved:r})=>{let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(900),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null);if((0,_.useEffect)(()=>{n?(a(n.name),s(n.url),l(n.poll_interval_secs),d(n.category??``),p(n.filter_regex??``),h(n.enabled),v(n.auto_download)):(a(``),s(``),l(900),d(``),p(``),h(!0),v(!1)),C(null)},[n,e]),!e)return null;let w=async()=>{if(!i.trim()||!o.trim()){C(`Name and URL are required`);return}x(!0),C(null);try{let e={name:i.trim(),url:o.trim(),poll_interval_secs:c,category:u.trim()||null,filter_regex:f.trim()||null,enabled:m,auto_download:g};n?await tl.updateFeed(n.name,e):await tl.addFeed(e),r(),t()}catch(e){C(e?.text||e?.message||`Failed to save feed`)}finally{x(!1)}},T=`w-full px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,E=`block text-xs font-medium text-secondary mb-1`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,b.jsx)(`div`,{className:`px-4 py-3 border-b border-divider`,children:(0,b.jsx)(`h3`,{className:`text-base font-semibold`,children:n?`Edit Feed`:`Add Feed`})}),(0,b.jsxs)(`div`,{className:`px-4 py-3 space-y-3`,children:[S&&(0,b.jsx)(`div`,{className:`text-xs text-red-500 bg-red-50 dark:bg-red-900/20 px-2 py-1 rounded`,children:S}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Name`}),(0,b.jsx)(`input`,{className:T,value:i,onChange:e=>a(e.target.value),placeholder:`My Feed`,disabled:!!n})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`URL`}),(0,b.jsx)(`input`,{className:T,value:o,onChange:e=>s(e.target.value),placeholder:`https://example.com/rss`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Poll Interval (sec)`}),(0,b.jsx)(`input`,{type:`number`,className:T,value:c,onChange:e=>l(Number(e.target.value)||900)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Category`}),(0,b.jsx)(`input`,{className:T,value:u,onChange:e=>d(e.target.value),placeholder:`Optional`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Filter Regex`}),(0,b.jsx)(`input`,{className:T,value:f,onChange:e=>p(e.target.value),placeholder:`Optional title filter`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Enabled`]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>v(e.target.checked)}),`Auto-download`]})]})]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3 border-t border-divider`,children:[(0,b.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-sm text-secondary hover:text-text rounded border border-divider cursor-pointer`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:w,disabled:y,className:`px-3 py-1.5 text-sm text-white bg-primary hover:bg-primary/90 rounded disabled:opacity-50 cursor-pointer`,children:y?`Saving...`:`Save`})]})]})})},vl=({isOpen:e,onClose:t,rule:n,feedNames:r,onSaved:i})=>{let[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null);if((0,_.useEffect)(()=>{n?(o(n.name),c(n.feed_names),u(n.category??``),f(n.priority),m(n.match_regex),g(n.enabled)):(o(``),c([]),u(``),f(1),m(``),g(!0)),S(null)},[n,e]),!e)return null;let C=e=>{c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async()=>{if(!a.trim()||!p.trim()){S(`Name and match regex are required`);return}if(s.length===0){S(`Select at least one feed`);return}y(!0),S(null);try{let e={name:a.trim(),feed_names:s,category:l.trim()||null,priority:d,match_regex:p.trim(),enabled:h};n?await tl.updateRule(n.id,e):await tl.addRule(e),i(),t()}catch(e){S(e?.text||e?.message||`Failed to save rule`)}finally{y(!1)}},T=`w-full px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,E=`block text-xs font-medium text-secondary mb-1`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,b.jsx)(`div`,{className:`px-4 py-3 border-b border-divider`,children:(0,b.jsx)(`h3`,{className:`text-base font-semibold`,children:n?`Edit Rule`:`Add Rule`})}),(0,b.jsxs)(`div`,{className:`px-4 py-3 space-y-3`,children:[x&&(0,b.jsx)(`div`,{className:`text-xs text-red-500 bg-red-50 dark:bg-red-900/20 px-2 py-1 rounded`,children:x}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Name`}),(0,b.jsx)(`input`,{className:T,value:a,onChange:e=>o(e.target.value),placeholder:`Rule name`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Match Regex`}),(0,b.jsx)(`input`,{className:T,value:p,onChange:e=>m(e.target.value),placeholder:`e.g. 1080p.*HEVC`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Feeds`}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[r.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1 text-xs bg-surface px-2 py-1 rounded border border-divider`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:s.includes(e),onChange:()=>C(e)}),e]},e)),r.length===0&&(0,b.jsx)(`span`,{className:`text-xs text-tertiary`,children:`No feeds configured`})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Category`}),(0,b.jsx)(`input`,{className:T,value:l,onChange:e=>u(e.target.value),placeholder:`Optional`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Priority`}),(0,b.jsxs)(`select`,{className:T,value:d,onChange:e=>f(Number(e.target.value)),children:[(0,b.jsx)(`option`,{value:0,children:`Low`}),(0,b.jsx)(`option`,{value:1,children:`Normal`}),(0,b.jsx)(`option`,{value:2,children:`High`}),(0,b.jsx)(`option`,{value:3,children:`Force`})]})]})]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),`Enabled`]})]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3 border-t border-divider`,children:[(0,b.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-sm text-secondary hover:text-text rounded border border-divider cursor-pointer`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:w,disabled:v,className:`px-3 py-1.5 text-sm text-white bg-primary hover:bg-primary/90 rounded disabled:opacity-50 cursor-pointer`,children:v?`Saving...`:`Save`})]})]})})},yl=()=>{let e=gl(e=>e.feeds),t=gl(e=>e.setFeeds),n=gl(e=>e.items),r=gl(e=>e.setItems),i=gl(e=>e.rules),a=gl(e=>e.setRules),o=gl(e=>e.selectedFeedFilter),s=gl(e=>e.setSelectedFeedFilter),c=gl(e=>e.loading),l=gl(e=>e.setLoading),u=Ko(e=>e.setCloseableError),[d,f]=(0,_.useState)(`items`),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),T=(0,_.useCallback)(async()=>{l(!0);try{let[e,n,i]=await Promise.all([tl.getFeeds(),tl.getItems(o??void 0),tl.getRules()]);t(e),r(n),a(i)}catch(e){u({text:`Error loading RSS data`,details:e})}finally{l(!1)}},[o]);(0,_.useEffect)(()=>{T();let e=setInterval(T,3e4);return()=>clearInterval(e)},[T]);let E=async e=>{try{await tl.deleteFeed(e),T()}catch(e){u({text:`Error deleting feed`,details:e})}},D=async e=>{try{await tl.deleteRule(e),T()}catch(e){u({text:`Error deleting rule`,details:e})}},O=async e=>{w(e.id);try{await tl.downloadItem(e.id),T()}catch(e){u({text:`Error downloading item`,details:e})}finally{w(null)}},ee=(0,_.useMemo)(()=>e.map(e=>e.name),[e]),te=e=>e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`-`,k=e=>`px-3 py-1.5 text-sm font-medium border-b-2 cursor-pointer transition-colors ${d===e?`border-primary text-primary`:`border-transparent text-secondary hover:text-text hover:border-divider`}`,ne=`p-1 text-secondary hover:text-primary rounded cursor-pointer transition-colors`,A=`px-2 py-1.5 text-left text-xs font-medium text-secondary uppercase tracking-wider`,j=`px-2 py-1.5 text-sm whitespace-nowrap`;return c&&n.length===0?(0,b.jsx)(`div`,{className:`flex justify-center items-center h-full`,children:(0,b.jsx)(bi,{})}):(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-divider`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>f(`items`),className:k(`items`),children:`Items`}),(0,b.jsxs)(`button`,{onClick:()=>f(`feeds`),className:k(`feeds`),children:[`Feeds (`,e.length,`)`]}),(0,b.jsxs)(`button`,{onClick:()=>f(`rules`),className:k(`rules`),children:[`Rules (`,i.length,`)`]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d===`items`&&(0,b.jsxs)(`select`,{className:`text-xs bg-surface border border-divider rounded px-2 py-1 focus:outline-none focus:border-primary`,value:o??``,onChange:e=>s(e.target.value||null),children:[(0,b.jsx)(`option`,{value:``,children:`All feeds`}),ee.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),d===`feeds`&&(0,b.jsxs)(`button`,{onClick:()=>{g(null),m(!0)},className:`flex items-center gap-1 px-2 py-1 text-xs text-white bg-primary rounded hover:bg-primary/90 cursor-pointer`,children:[(0,b.jsx)(ji,{className:`w-4 h-4`}),` Add Feed`]}),d===`rules`&&(0,b.jsxs)(`button`,{onClick:()=>{S(null),y(!0)},className:`flex items-center gap-1 px-2 py-1 text-xs text-white bg-primary rounded hover:bg-primary/90 cursor-pointer`,children:[(0,b.jsx)(ji,{className:`w-4 h-4`}),` Add Rule`]})]})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:[d===`items`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Title`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Feed`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Published`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:40}})]})}),(0,b.jsxs)(`tbody`,{children:[n.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} max-w-xs truncate`,title:e.title,children:e.title}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary`,children:e.feed_name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary`,children:te(e.published_at)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.size_bytes>0?Xo(e.size_bytes):`-`}),(0,b.jsx)(`td`,{className:j,children:e.downloaded?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 text-green-600 dark:text-green-400 text-xs`,children:[(0,b.jsx)(Wi,{className:`w-3 h-3`}),` Done`]}):(0,b.jsx)(`span`,{className:`text-xs text-secondary`,children:`Pending`})}),(0,b.jsx)(`td`,{className:j,children:!e.downloaded&&e.url&&(0,b.jsx)(`button`,{onClick:()=>O(e),disabled:C===e.id,className:ne,title:`Download`,children:C===e.id?(0,b.jsx)(bi,{}):(0,b.jsx)(Ri,{className:`w-3.5 h-3.5`})})})]},e.id)),n.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No RSS items found. Add a feed to get started.`})})]})]}),d===`feeds`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Name`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`URL`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Interval`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Category`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:80}})]})}),(0,b.jsxs)(`tbody`,{children:[e.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} font-medium`,children:e.name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary max-w-xs truncate`,title:e.url,children:e.url}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:hl(e.poll_interval_secs)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.category||`-`}),(0,b.jsx)(`td`,{className:j,children:(0,b.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.enabled?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.enabled?`Active`:`Disabled`})}),(0,b.jsxs)(`td`,{className:`${j} flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>{g(e),m(!0)},className:ne,title:`Edit`,children:(0,b.jsx)(Ni,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{onClick:()=>E(e.name),className:`${ne} hover:text-red-500`,title:`Delete`,children:(0,b.jsx)(Ci,{className:`w-3.5 h-3.5`})})]})]},e.name)),e.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No RSS feeds configured. Click "Add Feed" to add one.`})})]})]}),d===`rules`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Name`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Pattern`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Feeds`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Category`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:80}})]})}),(0,b.jsxs)(`tbody`,{children:[i.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} font-medium`,children:e.name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary font-mono text-xs max-w-xs truncate`,title:e.match_regex,children:e.match_regex}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.feed_names.join(`, `)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.category||`-`}),(0,b.jsx)(`td`,{className:j,children:(0,b.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.enabled?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.enabled?`Active`:`Disabled`})}),(0,b.jsxs)(`td`,{className:`${j} flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>{S(e),y(!0)},className:ne,title:`Edit`,children:(0,b.jsx)(Ni,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{onClick:()=>D(e.id),className:`${ne} hover:text-red-500`,title:`Delete`,children:(0,b.jsx)(Ci,{className:`w-3.5 h-3.5`})})]})]},e.id)),i.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No download rules. Click "Add Rule" to create one.`})})]})]})]}),(0,b.jsx)(_l,{isOpen:p,onClose:()=>m(!1),feed:h,onSaved:T}),(0,b.jsx)(vl,{isOpen:v,onClose:()=>y(!1),rule:x,feedNames:ee,onSaved:T})]})},bl=()=>{let e=Ko(e=>e.closeableError),t=Ko(e=>e.setCloseableError),n=Ko(e=>e.otherError),r=la(e=>e.torrents),i=la(e=>e.torrentsInitiallyLoading),a=Q(e=>e.viewMode),o=Q(e=>e.currentPage),s=xc(),c=a===`compact`&&s;return o===`indexarr`?(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsx)(ma,{error:e,remove:()=>t(null)}),(0,b.jsx)(ma,{error:n}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(fl,{})})]}):o===`rss`?(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsx)(ma,{error:e,remove:()=>t(null)}),(0,b.jsx)(ma,{error:n}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(yl,{})})]}):(0,b.jsxs)(`div`,{className:c?`h-full`:`h-full flex flex-col`,children:[(0,b.jsx)(ma,{error:e,remove:()=>t(null)}),(0,b.jsx)(ma,{error:n}),c?(0,b.jsx)(Uc,{torrents:r,loading:i}):(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(yc,{torrents:r,loading:i})})]})},xl=({show:e,onClose:t})=>{let n=(0,_.useContext)(v).getStreamLogsUrl();return(0,b.jsxs)(xo,{isOpen:e,onClose:t,title:`RustTorrent server logs`,className:`max-w-7xl`,children:[(0,b.jsx)(`div`,{className:`p-3 border-b dark:border-slate-500 h-[70vh]`,children:n?(0,b.jsx)(dc,{url:n}):(0,b.jsx)(ma,{error:{text:`HTTP API not available to stream logs`}})}),(0,b.jsx)(Co,{children:(0,b.jsx)(fa,{variant:`primary`,onClick:t,children:`Close`})})]})};function Sl(e){return Z({tag:`svg`,attr:{fill:`none`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,"aria-hidden":`true`},child:[{tag:`path`,attr:{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M4 6h16M4 12h16M4 18h16`},child:[]}]})(e)}var Cl=e=>(0,b.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 120 120`,width:120,height:120,...e,children:[(0,b.jsxs)(`defs`,{children:[(0,b.jsxs)(`linearGradient`,{id:`bg`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,b.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#4a3728`}}),(0,b.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#3d2e22`}})]}),(0,b.jsxs)(`linearGradient`,{id:`gear`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,b.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#8b6914`}}),(0,b.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#a07818`}})]})]}),(0,b.jsx)(`rect`,{width:120,height:120,rx:24,fill:`url(#bg)`}),(0,b.jsxs)(`g`,{transform:`translate(60,62)`,children:[(0,b.jsx)(`path`,{d:`M-6,-38 L6,-38 L8,-30 L-8,-30Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-6,30 L6,30 L8,38 L-8,38Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-38,-6 L-38,6 L-30,8 L-30,-8Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M30,-6 L30,6 L38,8 L38,-8Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M21,-31 L29,-25 L23,-19 L15,-25Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-29,25 L-21,31 L-15,25 L-23,19Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-29,-25 L-21,-31 L-15,-25 L-23,-19Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M21,31 L29,25 L23,19 L15,25Z`,fill:`url(#gear)`}),(0,b.jsx)(`circle`,{cx:0,cy:0,r:24,fill:`none`,stroke:`url(#gear)`,strokeWidth:6}),(0,b.jsx)(`ellipse`,{cx:-6,cy:-4,rx:12,ry:10,fill:`#e8dcc8`}),(0,b.jsx)(`ellipse`,{cx:8,cy:-2,rx:10,ry:9,fill:`#e8dcc8`}),(0,b.jsx)(`ellipse`,{cx:0,cy:4,rx:14,ry:8,fill:`#e8dcc8`}),(0,b.jsx)(`path`,{d:`M0,-10 L0,2 L-5,-3 M0,2 L5,-3`,fill:`none`,stroke:`#4a3728`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,b.jsx)(`text`,{x:0,y:12,fontFamily:`Arial,Helvetica,sans-serif`,fontSize:14,fontWeight:800,fill:`#4a3728`,textAnchor:`middle`,children:`T`})]})]}),wl=window.matchMedia(`(prefers-color-scheme: dark)`).matches;window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{Tl.setDark(e.matches)});var Tl={isDark:()=>wl,setDark:e=>(wl=e,document.body.classList.toggle(`dark`,wl),wl),toggle:()=>{Tl.setDark(!wl)}};Tl.setDark(wl);function El(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`},child:[{tag:`path`,attr:{d:`M14.8284 12L16.2426 13.4142L19.071 10.5858C20.6331 9.02365 20.6331 6.49099 19.071 4.9289C17.509 3.3668 14.9763 3.3668 13.4142 4.9289L10.5858 7.75732L12 9.17154L14.8284 6.34311C15.6095 5.56206 16.8758 5.56206 17.6568 6.34311C18.4379 7.12416 18.4379 8.39049 17.6568 9.17154L14.8284 12Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{d:`M12 14.8285L13.4142 16.2427L10.5858 19.0711C9.02372 20.6332 6.49106 20.6332 4.92896 19.0711C3.36686 17.509 3.36686 14.9764 4.92896 13.4143L7.75739 10.5858L9.1716 12L6.34317 14.8285C5.56212 15.6095 5.56212 16.8758 6.34317 17.6569C7.12422 18.4379 8.39055 18.4379 9.1716 17.6569L12 14.8285Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{d:`M14.8285 10.5857C15.219 10.1952 15.219 9.56199 14.8285 9.17147C14.4379 8.78094 13.8048 8.78094 13.4142 9.17147L9.1716 13.4141C8.78107 13.8046 8.78107 14.4378 9.1716 14.8283C9.56212 15.2188 10.1953 15.2188 10.5858 14.8283L14.8285 10.5857Z`,fill:`currentColor`},child:[]}]})(e)}function Dl(e){return Z({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`},child:[{tag:`path`,attr:{d:`M10 18V16H8V14H10V12H12V14H14V16H12V18H10Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,clipRule:`evenodd`,d:`M6 2C4.34315 2 3 3.34315 3 5V19C3 20.6569 4.34315 22 6 22H18C19.6569 22 21 20.6569 21 19V9C21 5.13401 17.866 2 14 2H6ZM6 4H13V9H19V19C19 19.5523 18.5523 20 18 20H6C5.44772 20 5 19.5523 5 19V5C5 4.44772 5.44772 4 6 4ZM15 4.10002C16.6113 4.4271 17.9413 5.52906 18.584 7H15V4.10002Z`,fill:`currentColor`},child:[]}]})(e)}var Ol=({onClick:e,data:t,resetData:n,children:r,className:i})=>{let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(0,_.useContext)(v);return(0,_.useEffect)(()=>{if(t===null)return;let e=setTimeout(async()=>{o(!0);try{c(await d.uploadTorrent(t,{list_only:!0}))}catch(e){u({text:`Error listing torrent files`,details:e})}finally{o(!1)}},0);return()=>clearTimeout(e)},[t]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(fa,{onClick:e,className:i,children:r}),t&&(0,b.jsx)(ol,{onHide:()=>{n(),u(null),c(null),o(!1)},listTorrentError:l,listTorrentResponse:s,data:t,listTorrentLoading:a})]})},kl=({className:e})=>{let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>{n(r),i(``),o(!1)},c=()=>{o(!1),n(null)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(Ol,{onClick:()=>{o(!0)},data:t,className:`group ${e}`,resetData:()=>n(null),children:[(0,b.jsx)(El,{className:`text-blue-500 group-hover:text-white dark:text-white`}),(0,b.jsx)(`div`,{children:`Add Torrent from Magnet / URL`})]}),(0,b.jsxs)(xo,{isOpen:a,onClose:c,title:`Add torrent`,children:[(0,b.jsx)(So,{children:(0,b.jsx)(il,{autoFocus:!0,value:r,name:`magnet`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&s()},placeholder:`magnet:?xt=urn:btih:...`,help:`Enter magnet or HTTP(S) URL to the .torrent`})}),(0,b.jsxs)(Co,{children:[(0,b.jsx)(fa,{variant:`cancel`,onClick:c,children:`Cancel`}),(0,b.jsx)(fa,{disabled:!r,variant:`primary`,onClick:s,children:`Add`})]})]})]})},Al=({className:e,onMultiFileSelect:t})=>{let n=(0,_.useRef)(null),[r,i]=(0,_.useState)(null),a=(0,_.useContext)(v),o=la(e=>e.refreshTorrents),s=async()=>{if(n?.current?.files)if(n.current.files.length==1)if(t)t([n.current.files[0]]),c();else{let e=n.current.files[0];i(e)}else if(t)t(Array.from(n.current.files)),c();else{for(let e=0;e{console.log(`uploaded file successfully`),o()},e=>{console.error(`error uploading file`,e)})}c()}},c=()=>{n?.current&&(n.current.value=``,i(null))};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`input`,{type:`file`,ref:n,multiple:!0,accept:`.torrent`,onChange:s,hidden:!0}),(0,b.jsxs)(Ol,{onClick:()=>{n?.current&&n.current.click()},data:r,resetData:c,className:`group ${e}`,children:[(0,b.jsx)(Dl,{className:`text-blue-500 group-hover:text-white dark:text-white`}),(0,b.jsx)(`div`,{children:`Upload .torrent File`})]})]})},jl=({isOpen:e,onClose:t,title:n,tabs:r,initialTab:i,onSave:a,onReset:o,saveButtonText:s=`OK`,showResetButton:c=!1,isSaving:l=!1,error:u})=>{let[d,f]=(0,_.useState)(i||r[0]?.id);return(0,b.jsxs)(xo,{isOpen:e,onClose:t,title:n,className:`sm:max-w-4xl`,children:[(0,b.jsxs)(So,{children:[(0,b.jsx)(ma,{error:u??null}),r.length>1&&(0,b.jsx)(tc,{className:`mb-4`,children:r.map(e=>(0,b.jsx)(ec,{id:e.id,label:e.label,active:e.id===d,onClick:()=>f(e.id)},e.id))}),r.map(e=>(0,b.jsx)(`div`,{className:e.id===d?``:`hidden`,children:e.content},e.id))]}),(0,b.jsxs)(Co,{children:[t&&(0,b.jsx)(fa,{variant:`cancel`,onClick:t,children:`Cancel`}),c&&o&&(0,b.jsx)(fa,{variant:`secondary`,onClick:o,children:`Reset to defaults`}),(0,b.jsx)(fa,{variant:`primary`,onClick:a,disabled:l,children:s})]})]})},Ml=(e,t)=>{let n=e??0;return n>0?`Limit total ${t} speed to this number of bytes per second (current ${Xo(n)} per second)`:`Limit total ${t} speed to this number of bytes per second (currently disabled)`},Nl=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],Pl=[1,2,4,8,16,32,64],Fl=e=>{let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`},Il=e=>{let[t,n]=e.split(`:`).map(Number);return(t||0)*60+(n||0)},Ll=({downloadBps:e,uploadBps:t,peerLimit:n,concurrentInitLimit:r,onDownloadBpsChange:i,onUploadBpsChange:a,onPeerLimitChange:o,onConcurrentInitLimitChange:s})=>{let c=(0,_.useContext)(v),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)({download_rate:null,upload_rate:null}),[p,m]=(0,_.useState)({enabled:!1,start_minutes:0,end_minutes:0,days:0}),[h,g]=(0,_.useState)(!1),[y,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{c.getAltSpeed().then(e=>{u(e.enabled),f(e.config),e.schedule&&m(e.schedule),g(!0)}).catch(()=>{g(!1)})},[c]);let S=async e=>{u(e),x(null);try{await c.toggleAltSpeed(e)}catch{u(!e),x(`Could not update alternative speed limits on the server.`)}},C=async e=>{f(e);try{await c.setAltSpeedConfig(e)}catch{}},w=async e=>{m(e);try{await c.setSpeedSchedule(e)}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(rl,{label:`Speed Limits`,children:[(0,b.jsx)(il,{label:`Download rate limit`,name:`download_bps`,inputType:`number`,value:e?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;i(isNaN(t)||t<=0?null:t)},help:Ml(e,`download`)}),(0,b.jsx)(il,{label:`Upload rate limit`,name:`upload_bps`,inputType:`number`,value:t?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;a(isNaN(t)||t<=0?null:t)},help:Ml(t,`upload`)}),(0,b.jsx)(il,{label:`Peer limit`,name:`peer_limit`,inputType:`number`,value:n?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;o(isNaN(t)||t<=0?null:t)},help:`Maximum number of peers per torrent (current: ${n??`default`})`}),(0,b.jsx)(il,{label:`Concurrent init limit`,name:`concurrent_init_limit`,inputType:`number`,value:r?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;s(isNaN(t)||t<=0?null:t)},help:`Maximum number of torrents initializing concurrently (current: ${r??`default`})`})]}),h&&(0,b.jsxs)(rl,{label:`Alternative Speed Limits`,children:[(0,b.jsx)(ks,{checked:l,label:`Enable alternative speed limits`,name:`alt_speed_enabled`,help:`When enabled, alternative speed limits override the normal limits above.`,onChange:()=>S(!l)}),y&&(0,b.jsx)(`p`,{className:`text-sm text-error mt-1`,children:y}),l&&(0,b.jsxs)(`div`,{className:`mt-3 space-y-2 ml-6`,children:[(0,b.jsx)(il,{label:`Alt download limit (KB/s)`,name:`alt_download_rate`,inputType:`number`,value:d.download_rate==null?``:String(Math.round(d.download_rate/1024)),onChange:e=>{let t=e.target.valueAsNumber;C({...d,download_rate:isNaN(t)||t<=0?null:t*1024})},help:`Alternative download speed limit in KB/s (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Alt upload limit (KB/s)`,name:`alt_upload_rate`,inputType:`number`,value:d.upload_rate==null?``:String(Math.round(d.upload_rate/1024)),onChange:e=>{let t=e.target.valueAsNumber;C({...d,upload_rate:isNaN(t)||t<=0?null:t*1024})},help:`Alternative upload speed limit in KB/s (0 or empty = unlimited)`})]}),(0,b.jsxs)(`div`,{className:`mt-4`,children:[(0,b.jsx)(ks,{checked:p.enabled,label:`Enable schedule`,name:`alt_schedule_enabled`,help:`Automatically enable alternative speed limits during scheduled times.`,onChange:()=>{w({...p,enabled:!p.enabled})}}),p.enabled&&(0,b.jsxs)(`div`,{className:`mt-3 ml-6 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex gap-4 items-center`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`schedule_start`,className:`text-sm text-secondary`,children:`Start time`}),(0,b.jsx)(`input`,{type:`time`,id:`schedule_start`,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 pr-2 focus:ring-0 focus:border-primary sm:leading-6`,value:Fl(p.start_minutes),onChange:e=>{w({...p,start_minutes:Il(e.target.value)})}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`schedule_end`,className:`text-sm text-secondary`,children:`End time`}),(0,b.jsx)(`input`,{type:`time`,id:`schedule_end`,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 pr-2 focus:ring-0 focus:border-primary sm:leading-6`,value:Fl(p.end_minutes),onChange:e=>{w({...p,end_minutes:Il(e.target.value)})}})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-sm text-secondary block mb-2`,children:`Days`}),(0,b.jsx)(`div`,{className:`flex gap-3 flex-wrap`,children:Nl.map((e,t)=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1 text-sm cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:(p.days&Pl[t])!==0,onChange:()=>{w({...p,days:p.days^Pl[t]})}}),e]},e))})]})]})]})]})]})},Rl=oa(e=>({stats:{counters:{fetched_bytes:0,uploaded_bytes:0,blocked_incoming:0,blocked_outgoing:0},peers:{connecting:0,dead:0,live:0,not_needed:0,queued:0,seen:0},download_speed:{human_readable:`N/A`,mbps:0},upload_speed:{human_readable:`N/A`,mbps:0},uptime_seconds:0,connections:{tcp:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}},utp:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}},socks:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}}}},setStats:t=>{e({stats:t})}})),zl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),Bl=({version:e})=>{let t=Rl(e=>e.stats);return(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,b.jsx)(zl,{label:`Version`,value:e}),(0,b.jsx)(zl,{label:`Uptime`,value:Qo(t.uptime_seconds)}),(0,b.jsx)(zl,{label:`Total Downloaded`,value:Xo(t.counters.fetched_bytes)}),(0,b.jsx)(zl,{label:`Total Uploaded`,value:Xo(t.counters.uploaded_bytes)}),(0,b.jsx)(zl,{label:`Live Peers`,value:String(t.peers.live)}),(0,b.jsx)(zl,{label:`Download Speed`,value:t.download_speed.human_readable}),(0,b.jsx)(zl,{label:`Upload Speed`,value:t.upload_speed.human_readable}),(0,b.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-divider`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:`Web Seeds`}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:`Enabled`})]}),(0,b.jsxs)(`div`,{className:`text-secondary text-xs mt-1 ml-0`,children:[`Web seed support is enabled by default. Use`,` `,(0,b.jsx)(`code`,{className:`text-xs bg-surface px-1 py-0.5 rounded`,children:`--disable-webseeds`}),` `,`at startup to disable it.`]})]})]})},Vl=`pb-1 px-2`,Hl=`px-2 text-right text-primary tabular-nums`,Ul=({protocol:e,family:t,stat:n})=>n.attempts===0&&n.successes===0&&n.errors===0?null:(0,b.jsxs)(`tr`,{className:`border-t border-divider`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 text-primary`,children:e}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-primary`,children:t}),(0,b.jsx)(`td`,{className:Hl,children:n.attempts.toLocaleString()}),(0,b.jsx)(`td`,{className:Hl,children:n.successes.toLocaleString()}),(0,b.jsx)(`td`,{className:Hl,children:n.errors.toLocaleString()})]}),Wl=({protocol:e,stats:t})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Ul,{protocol:e,family:`IPv4`,stat:t.v4}),(0,b.jsx)(Ul,{protocol:e,family:`IPv6`,stat:t.v6})]}),Gl=()=>{let e=Rl(e=>e.stats).connections;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(`p`,{className:`text-secondary text-sm mb-3`,children:`Connection statistics from the current session.`}),(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`text-tertiary text-left`,children:[(0,b.jsx)(`th`,{className:Vl,children:`Protocol`}),(0,b.jsx)(`th`,{className:Vl,children:`Family`}),(0,b.jsx)(`th`,{className:`${Vl} text-right`,children:`Attempts`}),(0,b.jsx)(`th`,{className:`${Vl} text-right`,children:`Successes`}),(0,b.jsx)(`th`,{className:`${Vl} text-right`,children:`Errors`})]})}),(0,b.jsxs)(`tbody`,{children:[(0,b.jsx)(Wl,{protocol:`TCP`,stats:e.tcp}),(0,b.jsx)(Wl,{protocol:`uTP`,stats:e.utp}),(0,b.jsx)(Wl,{protocol:`SOCKS`,stats:e.socks})]})]}),(0,b.jsxs)(`div`,{className:`mt-6 mb-3`,children:[(0,b.jsx)(`label`,{className:`font-medium mb-3 block pb-1 border-b border-divider`,children:`Encryption`}),(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsxs)(`select`,{className:`block border border-divider rounded bg-transparent py-1.5 px-2 focus:ring-0 focus:border-primary sm:leading-6 text-primary`,disabled:!0,value:`enabled`,children:[(0,b.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,b.jsx)(`option`,{value:`enabled`,children:`Enabled (prefer encrypted)`}),(0,b.jsx)(`option`,{value:`forced`,children:`Forced (require encrypted)`})]}),(0,b.jsxs)(`div`,{className:`text-sm text-secondary mt-2 space-y-1`,children:[(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Disabled:`}),` No encryption, all connections are plaintext.`]}),(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Enabled:`}),` Prefer encrypted connections but allow plaintext fallback.`]}),(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Forced:`}),` Only allow encrypted connections; reject unencrypted peers.`]})]})]})]}),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`Connection settings (listen port, TCP/uTP, UPnP, SOCKS proxy, encryption mode) are configured via CLI arguments at startup.`})]})},Kl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),ql=e=>e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),Jl=()=>{let e=(0,_.useContext)(v),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null);return(0,_.useEffect)(()=>{e.getDhtStats().then(n).catch(()=>i(`DHT is disabled or unavailable`))},[e]),r?(0,b.jsx)(`div`,{className:`text-secondary py-2`,children:r}):t?(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[Object.entries(t).map(([e,t])=>t==null||typeof t==`object`?null:(0,b.jsx)(Kl,{label:ql(e),value:String(t)},e)),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`DHT settings are configured via CLI arguments at startup.`})]}):(0,b.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,b.jsx)(bi,{})})},Yl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),Xl=()=>(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,b.jsx)(Yl,{label:`API URL`,value:window.location.origin}),(0,b.jsx)(Yl,{label:`Swagger UI`,value:`/swagger/`}),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`HTTP API settings (listen address, read-only mode, basic auth) are configured via CLI arguments at startup.`})]}),Zl=()=>{let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),m=Jc(e=>e.state),h=async()=>{if(l(null),d(null),!e){l(`Current password is required`);return}if(i&&i!==o){l(`New passwords do not match`);return}if(i&&i.length<4){l(`New password must be at least 4 characters`);return}if(!n&&!i){l(`Enter a new username or password to change`);return}p(!0);try{await $c.changeCredentials(e,n||void 0,i||void 0),d(`Credentials updated successfully`),t(``),r(``),a(``),s(``)}catch(e){l(e.message||`Failed to change credentials`)}finally{p(!1)}},g=`w-full px-3 py-2 bg-surface border border-divider rounded text-primary placeholder:text-tertiary focus:outline-none focus:border-primary text-sm`;return m===`no_auth`?(0,b.jsx)(`div`,{className:`space-y-3 py-2`,children:(0,b.jsxs)(`div`,{className:`text-secondary text-sm`,children:[`Authentication is not enabled. Set`,` `,(0,b.jsx)(`code`,{className:`text-xs bg-surface px-1 py-0.5 rounded`,children:`RTBIT_HTTP_BASIC_AUTH_USERPASS`}),` `,`or use the first-boot setup to enable it.`]})}):(0,b.jsxs)(`div`,{className:`space-y-4 py-2`,children:[c&&(0,b.jsx)(`div`,{className:`bg-error-bg/10 border border-error-bg text-error-bg rounded px-3 py-2 text-sm`,children:c}),u&&(0,b.jsx)(`div`,{className:`bg-green-500/10 border border-green-500 text-green-600 dark:text-green-400 rounded px-3 py-2 text-sm`,children:u}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`Current Password`}),(0,b.jsx)(`input`,{type:`password`,value:e,onChange:e=>t(e.target.value),className:g,placeholder:`Enter current password`,autoComplete:`current-password`})]}),(0,b.jsx)(`hr`,{className:`border-divider`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`New Username (optional)`}),(0,b.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),className:g,placeholder:`Leave blank to keep current`,autoComplete:`username`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`New Password (optional)`}),(0,b.jsx)(`input`,{type:`password`,value:i,onChange:e=>a(e.target.value),className:g,placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`Confirm New Password`}),(0,b.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),className:g,placeholder:`Confirm new password`,autoComplete:`new-password`,disabled:!i})]}),(0,b.jsx)(`button`,{onClick:h,disabled:f||!e,className:`w-full py-2 bg-primary-bg text-white rounded font-medium text-sm hover:bg-primary-bg-hover disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed`,children:f?`Saving...`:`Update Credentials`})]})},Ql=()=>{let e=(0,_.useContext)(v),[t,n]=(0,_.useState)({ratio_limit:null,time_limit_secs:null}),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{e.getSeedLimits().then(e=>{n(e)}).catch(()=>{o(`Could not load seed limits`)}).finally(()=>i(!1))},[e]);let s=async t=>{n(t);try{await e.setSeedLimits(t)}catch{}};if(r)return(0,b.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,b.jsx)(bi,{})});if(a)return(0,b.jsx)(`div`,{className:`text-secondary py-2`,children:a});let c=t.ratio_limit!=null,l=t.time_limit_secs!=null,u=t.time_limit_secs==null?``:Math.round(t.time_limit_secs/3600*100)/100;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(rl,{label:`Seed Ratio Limit`,children:[(0,b.jsx)(ks,{checked:c,label:`Limit seed ratio globally`,name:`ratio_limit_enabled`,help:`Stop seeding when the upload/download ratio reaches this value.`,onChange:()=>{s({...t,ratio_limit:c?null:2})}}),c&&(0,b.jsx)(`div`,{className:`mt-2 ml-6`,children:(0,b.jsx)(il,{label:`Ratio limit`,name:`ratio_limit`,inputType:`number`,value:t.ratio_limit==null?``:String(t.ratio_limit),onChange:e=>{let n=e.target.valueAsNumber;s({...t,ratio_limit:isNaN(n)||n<=0?null:n})},help:`e.g. 2.0 means upload 2x the downloaded amount`})})]}),(0,b.jsxs)(rl,{label:`Seed Time Limit`,children:[(0,b.jsx)(ks,{checked:l,label:`Limit seeding time globally`,name:`time_limit_enabled`,help:`Stop seeding after this amount of time.`,onChange:()=>{s({...t,time_limit_secs:l?null:24*3600})}}),l&&(0,b.jsx)(`div`,{className:`mt-2 ml-6`,children:(0,b.jsx)(il,{label:`Time limit (hours)`,name:`time_limit_hours`,inputType:`number`,value:String(u),onChange:e=>{let n=e.target.valueAsNumber;s({...t,time_limit_secs:isNaN(n)||n<=0?null:Math.round(n*3600)})},help:`Seeding time limit in hours`})})]}),(0,b.jsx)(`div`,{className:`text-secondary text-xs mt-4`,children:`Super-seeding can be enabled per-torrent from the torrent context menu.`})]})},$l=({maxActiveDownloads:e,maxActiveUploads:t,maxActiveTotal:n,onMaxActiveDownloadsChange:r,onMaxActiveUploadsChange:i,onMaxActiveTotalChange:a})=>(0,b.jsx)(`div`,{className:`py-2`,children:(0,b.jsxs)(rl,{label:`Queue Limits`,children:[(0,b.jsx)(il,{label:`Max active downloads`,name:`max_active_downloads`,inputType:`number`,value:e?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;r(isNaN(t)||t<0?null:t)},help:`Maximum number of active downloading torrents (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Max active uploads`,name:`max_active_uploads`,inputType:`number`,value:t?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;i(isNaN(t)||t<0?null:t)},help:`Maximum number of active seeding torrents (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Max active total`,name:`max_active_total`,inputType:`number`,value:n?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;a(isNaN(t)||t<0?null:t)},help:`Maximum number of active torrents total (0 or empty = unlimited)`})]})}),eu=({rssHistoryLimit:e,onRssHistoryLimitChange:t})=>{let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{tl.getFeeds().then(e=>r(e.length)).catch(()=>{}),tl.getRules().then(e=>a(e.length)).catch(()=>{}),tl.getItems(void 0,1).then(()=>tl.getItems().then(e=>s(e.length))).catch(()=>{})},[]),(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsxs)(`div`,{className:`border-b border-divider pb-3 mb-3`,children:[(0,b.jsx)(`h4`,{className:`text-xs font-semibold uppercase text-tertiary mb-2`,children:`RSS Status`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:n??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Feeds`})]}),(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Rules`})]}),(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:o??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Items`})]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h4`,{className:`text-xs font-semibold uppercase text-tertiary mb-2`,children:`Settings`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,b.jsx)(`label`,{className:`text-sm text-secondary`,children:`Feed History Limit`}),(0,b.jsx)(`input`,{type:`number`,className:`w-32 px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,value:e??``,onChange:e=>{let n=e.target.value;t(n===``?null:Number(n))},placeholder:`Unlimited`,min:0})]}),(0,b.jsx)(`p`,{className:`text-xs text-tertiary mt-1`,children:`Maximum number of RSS feed items to keep in history. Empty = unlimited. Default: 500.`})]})]})},tu=({isOpen:e,initialPath:t,onSelect:n,onClose:r})=>{let i=(0,_.useContext)(v),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=(0,_.useCallback)(e=>{c(!0),u(null),i.browseDirectory(e).then(e=>{o(e)}).catch(e=>{u(e?.text||`Failed to browse directory`)}).finally(()=>c(!1))},[i]);if((0,_.useEffect)(()=>{e&&d(t||void 0)},[e,t,d]),!e)return null;let f=a?.entries.filter(e=>e.is_dir)??[];return(0,b.jsxs)(`div`,{className:`border border-divider rounded bg-surface mt-1 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-surface border-b border-divider`,children:[(0,b.jsx)(`span`,{className:`text-xs text-secondary truncate flex-1 font-mono`,children:a?.current??`Loading...`}),(0,b.jsx)(`button`,{type:`button`,className:`text-xs px-2 py-1 rounded bg-primary text-white hover:bg-primary/80 cursor-pointer`,onClick:()=>{a&&(n(a.current),r())},disabled:!a,children:`Select`}),(0,b.jsx)(`button`,{type:`button`,className:`text-xs px-2 py-1 rounded bg-surface-raised text-secondary hover:text-text border border-divider cursor-pointer`,onClick:r,children:`Cancel`})]}),(0,b.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[s&&(0,b.jsx)(`div`,{className:`flex justify-center p-3`,children:(0,b.jsx)(bi,{})}),l&&(0,b.jsx)(`div`,{className:`p-3 text-sm text-red-500`,children:l}),!s&&!l&&a&&(0,b.jsxs)(`div`,{className:`divide-y divide-divider/50`,children:[a.parent&&(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface-raised cursor-pointer`,onClick:()=>d(a.parent),children:[(0,b.jsx)(_i,{className:`w-4 h-4 text-secondary flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`..`})]}),f.map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface-raised cursor-pointer`,onClick:()=>d(e.path),children:[(0,b.jsx)(Li,{className:`w-4 h-4 text-yellow-500 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),f.length===0&&!a.parent&&(0,b.jsx)(`div`,{className:`px-3 py-2 text-sm text-secondary`,children:`No subdirectories`})]})]})]})},nu=({label:e,name:t,value:n,help:r,placeholder:i,onChange:a})=>{let[o,s]=(0,_.useState)(!1);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:t,children:e}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,className:`flex-1 block border border-divider rounded bg-transparent py-1.5 pl-2 focus:ring-0 focus:border-primary sm:leading-6`,id:t,name:t,placeholder:i,value:n,onChange:e=>a(e.target.value)}),(0,b.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 px-3 py-1.5 border border-divider rounded hover:bg-surface-raised text-secondary hover:text-text transition-colors cursor-pointer`,onClick:()=>s(!o),title:`Browse directories`,children:(0,b.jsx)(Ii,{className:`w-4 h-4`})})]}),r&&(0,b.jsx)(`div`,{className:`text-sm text-secondary`,children:r}),(0,b.jsx)(tu,{isOpen:o,initialPath:n,onSelect:e=>a(e),onClose:()=>s(!1)})]})},ru=({downloadFolder:e,completedFolder:t,onDownloadFolderChange:n,onCompletedFolderChange:r})=>(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(rl,{label:`Download Location`,children:(0,b.jsx)(nu,{label:`Default download folder`,name:`download_folder`,value:e,onChange:n,help:`New torrents will be saved to this folder by default`,placeholder:`/path/to/downloads`})}),(0,b.jsx)(rl,{label:`Move on Completion`,children:(0,b.jsx)(nu,{label:`Completed folder`,name:`completed_folder`,value:t,onChange:r,help:`Finished torrents will be moved here. Leave empty to disable`,placeholder:`/path/to/completed (optional)`})})]}),iu=({isOpen:e,onClose:t,version:n})=>{let[r,i]=(0,_.useState)({upload_bps:null,download_bps:null,peer_limit:null,concurrent_init_limit:null,max_active_downloads:null,max_active_uploads:null,max_active_total:null}),[a,o]=(0,_.useState)(500),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),y=(0,_.useContext)(v);return(0,_.useEffect)(()=>{e&&(f(!0),g(null),Promise.all([y.getLimits(),y.getFolders()]).then(([e,t])=>{i(e),c(t.download_folder),u(t.completed_folder??``)}).catch(e=>{g({text:`Error loading settings`,details:e})}).finally(()=>f(!1)))},[e,y]),d&&e?(0,b.jsx)(xo,{isOpen:e,onClose:t,title:`Settings`,children:(0,b.jsx)(So,{children:(0,b.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,b.jsx)(bi,{})})})}):(0,b.jsx)(jl,{isOpen:e,onClose:t,title:`Settings`,tabs:[{id:`general`,label:`General`,content:(0,b.jsx)(Bl,{version:n??`unknown`})},{id:`folders`,label:`Folders`,content:(0,b.jsx)(ru,{downloadFolder:s,completedFolder:l,onDownloadFolderChange:c,onCompletedFolderChange:u})},{id:`speed`,label:`Speed`,content:(0,b.jsx)(Ll,{downloadBps:r.download_bps,uploadBps:r.upload_bps,peerLimit:r.peer_limit,concurrentInitLimit:r.concurrent_init_limit,onDownloadBpsChange:e=>i(t=>({...t,download_bps:e})),onUploadBpsChange:e=>i(t=>({...t,upload_bps:e})),onPeerLimitChange:e=>i(t=>({...t,peer_limit:e})),onConcurrentInitLimitChange:e=>i(t=>({...t,concurrent_init_limit:e}))})},{id:`connections`,label:`Connections`,content:(0,b.jsx)(Gl,{})},{id:`queue`,label:`Queue`,content:(0,b.jsx)($l,{maxActiveDownloads:r.max_active_downloads,maxActiveUploads:r.max_active_uploads,maxActiveTotal:r.max_active_total,onMaxActiveDownloadsChange:e=>i(t=>({...t,max_active_downloads:e})),onMaxActiveUploadsChange:e=>i(t=>({...t,max_active_uploads:e})),onMaxActiveTotalChange:e=>i(t=>({...t,max_active_total:e}))})},{id:`seeding`,label:`Seeding`,content:(0,b.jsx)(Ql,{})},{id:`dht`,label:`DHT`,content:(0,b.jsx)(Jl,{})},{id:`security`,label:`Security`,content:(0,b.jsx)(Zl,{})},{id:`http-api`,label:`HTTP API`,content:(0,b.jsx)(Xl,{})},{id:`rss`,label:`RSS`,content:(0,b.jsx)(eu,{rssHistoryLimit:a,onRssHistoryLimitChange:o})}],onSave:async()=>{m(!0),g(null);try{await Promise.all([y.setLimits(r),y.setFolders({download_folder:s,completed_folder:l||null})]),t()}catch(e){g({text:`Error saving settings`,details:e})}finally{m(!1)}},isSaving:p,error:h,showResetButton:!1})},au=({title:e,version:t,onMultiFileSelect:n,onLogsClick:r,menuButtons:i})=>{let a=(0,_.useContext)(v),o=xc(),s=Q(e=>e.selectedTorrentIds),c=Q(e=>e.searchQuery),l=Q(e=>e.setSearchQuery),u=Q(e=>e.setSidebarOpen),d=Q(e=>e.currentPage),f=Q(e=>e.setCurrentPage),p=la(e=>e.torrents),m=la(e=>e.refreshTorrents),h=Ko(e=>e.setCloseableError),g=Wc(e=>e.status?.enabled??!1),y=Wc(e=>e.setStatus);(0,_.useEffect)(()=>{el.getStatus().then(y).catch(()=>y({enabled:!1}))},[]);let[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)([]),[D,O]=(0,_.useState)(c),[ee,te]=(0,_.useState)(Tl.isDark()),[k,ne]=(0,_.useState)(!1),A=Jc(e=>e.state),j=Jc(e=>e.refreshToken),re=Jc(e=>e.clearTokens),M=async()=>{if(j)try{await $c.logout(j)}catch{}re()},N=(0,_.useCallback)((0,yi.default)(e=>l(e),150),[l]),P=e=>{let t=e.target.value;O(t),N(t)},ie=()=>{O(``),l(``)},F=()=>{Tl.toggle(),te(Tl.isDark())},I=s.size,L=I>0,R=e=>p?.find(t=>t.id===e),z=(0,_.useCallback)(()=>{E(Array.from(s).map(e=>({id:e,name:R(e)?.name??null}))),w(!0)},[s,p]);bs((0,_.useMemo)(()=>({onDelete:z}),[z]));let ae=async(e,t,n)=>{S(!0);try{for(let r of s)if(R(r)?.stats?.state!==t)try{await e(r),m()}catch(e){h({text:`Error ${n} torrent id=${r}`,details:e})}}finally{S(!1)}},B=()=>ae(e=>a.pause(e),Zi,`pausing`),V=()=>ae(e=>a.start(e),Qi,`starting`),oe=!i||i.length===0,H=d===`torrents`,se=`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg transition-colors cursor-pointer whitespace-nowrap`,ce=`${se} bg-primary/12 text-primary`,le=`${se} text-secondary hover:text-text hover:bg-surface/50`,U=`p-1.5 text-secondary hover:text-text hover:bg-surface/50 rounded-lg cursor-pointer transition-colors inline-flex items-center justify-center`,ue=`p-1.5 text-tertiary rounded-lg inline-flex items-center justify-center opacity-40 cursor-not-allowed`;return(0,b.jsxs)(`div`,{className:`bg-surface-raised drop-shadow-lg`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[!o&&(0,b.jsx)(`button`,{onClick:()=>{u(!0),f(`torrents`)},className:`p-1.5 text-secondary hover:text-primary cursor-pointer`,title:`Open sidebar`,children:(0,b.jsx)(Sl,{className:`w-5 h-5`})}),(0,b.jsx)(`div`,{className:`flex items-center mr-1`,title:e,children:(0,b.jsx)(Cl,{className:`w-6 h-6`,alt:e})}),o&&(0,b.jsx)(`div`,{className:`w-px h-5 bg-divider mx-1`}),o&&(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,b.jsxs)(`button`,{onClick:()=>f(`torrents`),className:d===`torrents`?ce:le,children:[(0,b.jsx)(zi,{className:`w-3.5 h-3.5`}),`Torrents`]}),g&&(0,b.jsxs)(`button`,{onClick:()=>f(`indexarr`),className:d===`indexarr`?ce:le,children:[(0,b.jsx)(Fi,{className:`w-3.5 h-3.5`}),`Index`]}),(0,b.jsxs)(`button`,{onClick:()=>f(`rss`),className:d===`rss`?ce:le,children:[(0,b.jsx)(Ai,{className:`w-3.5 h-3.5`}),`RSS`]})]}),(0,b.jsx)(`div`,{className:`flex-1`}),H&&(0,b.jsxs)(`div`,{className:`relative hidden lg:block`,children:[(0,b.jsx)(di,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:D,onChange:P,placeholder:`Filter...`,className:`pl-8 pr-7 py-1.5 w-44 text-sm bg-surface/50 border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),D&&(0,b.jsx)(`button`,{onClick:ie,className:`absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(ci,{className:`w-3.5 h-3.5`})})]}),H&&(0,b.jsx)(`div`,{className:`hidden lg:block w-px h-5 bg-divider mx-1`}),H&&(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 bg-surface/30 rounded-lg p-0.5`,children:[(0,b.jsx)(kl,{className:`grow-0 justify-center !px-2.5 !py-1 !text-sm !rounded-lg`}),(0,b.jsx)(Al,{className:`grow-0 justify-center !px-2.5 !py-1 !text-sm !rounded-lg`,onMultiFileSelect:n}),(0,b.jsx)(`div`,{className:`w-px h-5 bg-divider mx-0.5`}),(0,b.jsx)(`button`,{onClick:V,disabled:x||!L,className:x||!L?ue:U,title:`Resume selected`,children:(0,b.jsx)(Po,{className:`w-3 h-3`})}),(0,b.jsx)(`button`,{onClick:B,disabled:x||!L,className:x||!L?ue:U,title:`Pause selected`,children:(0,b.jsx)(Fo,{className:`w-3 h-3`})}),(0,b.jsx)(`button`,{onClick:z,disabled:x||!L,className:x||!L?`p-1.5 text-error rounded-lg inline-flex items-center justify-center opacity-40 cursor-not-allowed`:`p-1.5 text-error hover:text-error hover:bg-error/10 rounded-lg cursor-pointer transition-colors inline-flex items-center justify-center`,title:`Delete selected`,children:(0,b.jsx)(Do,{className:`w-3 h-3`})}),L&&(0,b.jsx)(`span`,{className:`hidden lg:inline text-xs text-secondary ml-0.5 mr-1`,children:I})]}),(0,b.jsx)(`div`,{className:`hidden lg:block w-px h-5 bg-divider mx-1`}),i?.map((e,t)=>(0,b.jsx)(`span`,{children:e},t)),oe&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>ne(!0),className:U,title:`Configure`,children:(0,b.jsx)(ki,{className:`w-4 h-4`})}),(0,b.jsx)(iu,{isOpen:k,onClose:()=>ne(!1),version:t})]}),(0,b.jsx)(`button`,{onClick:r,className:U,title:`View logs`,children:(0,b.jsx)(Ji,{className:`w-4 h-4`})}),(0,b.jsx)(`button`,{onClick:F,className:U,title:`Toggle dark mode`,children:ee?(0,b.jsx)(Ei,{className:`w-4 h-4`}):(0,b.jsx)(Pi,{className:`w-4 h-4`})}),A===`authenticated`&&(0,b.jsx)(`button`,{onClick:M,className:U,title:`Logout`,children:(0,b.jsx)(qi,{className:`w-4 h-4`})})]}),(0,b.jsx)(wo,{show:C,onHide:()=>w(!1),torrents:T})]})},ou=()=>{let e=(0,_.useContext)(v),t=la(e=>e.torrents),n=Q(e=>e.categoryFilter),r=Q(e=>e.setCategoryFilter),i=Q(e=>e.categories),a=Q(e=>e.setCategories),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),u=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=!1;return e.getCategories().then(e=>{t||a(e)}).catch(()=>{}),()=>{t=!0}},[e,a]),(0,_.useEffect)(()=>{o&&u.current&&u.current.focus()},[o]);let d=(0,_.useMemo)(()=>{let e={},n=0,r=0;if(t)for(let i of t)r++,i.category?e[i.category]=(e[i.category]||0)+1:n++;return{counts:e,uncategorized:n,total:r}},[t]),f=(0,_.useMemo)(()=>{let e=new Set;for(let t of Object.keys(i))e.add(t);for(let t of Object.keys(d.counts))e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[i,d.counts]),p=async()=>{let t=c.trim();if(!t){s(!1);return}try{await e.createCategory(t),a(await e.getCategories())}catch{}l(``),s(!1)},m=`bg-primary/10 text-primary font-medium`,h=`text-secondary hover:bg-surface-sunken hover:text-primary`,g=`w-3.5 h-3.5 shrink-0`;return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`px-3 pt-3 pb-1 flex items-center justify-between`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Categories`}),(0,b.jsx)(`button`,{onClick:()=>s(!0),className:`text-tertiary hover:text-primary cursor-pointer`,title:`New category`,children:(0,b.jsx)(ji,{className:`w-4 h-4`})})]}),(0,b.jsxs)(`div`,{className:`px-1.5`,children:[o&&(0,b.jsx)(`div`,{className:`px-2.5 py-1`,children:(0,b.jsx)(`input`,{ref:u,type:`text`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&(l(``),s(!1))},onBlur:p,placeholder:`Category name...`,className:`w-full px-2 py-1 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`})}),(0,b.jsxs)(`button`,{onClick:()=>r(null),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===null?m:h}`,children:[(0,b.jsx)(wi,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:`All`}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===null?`text-primary`:`text-tertiary`}`,children:d.total})]}),(0,b.jsxs)(`button`,{onClick:()=>r(``),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===``?m:h}`,children:[(0,b.jsx)(wi,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:`Uncategorized`}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===``?`text-primary`:`text-tertiary`}`,children:d.uncategorized})]}),f.map(e=>(0,b.jsxs)(`button`,{onClick:()=>r(e),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===e?m:h}`,children:[(0,b.jsx)(Ti,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===e?`text-primary`:`text-tertiary`}`,children:d.counts[e]??0})]},e))]})]})},su=()=>{let e=la(e=>e.torrents),t=Q(e=>e.trackerFilter),n=Q(e=>e.setTrackerFilter),r=(0,_.useMemo)(()=>{let t={},n=0,r=0;if(e)for(let i of e){r++;let e=hs(i);e.length===0&&n++;for(let n of e)t[n]=(t[n]||0)+1}return{counts:t,trackerless:n,total:r}},[e]),i=(0,_.useMemo)(()=>Object.keys(r.counts).sort((e,t)=>e.localeCompare(t)),[r.counts]),a=`w-3.5 h-3.5 shrink-0`,o=(e,r,i,a)=>(0,b.jsxs)(`button`,{onClick:()=>n(e),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${t===e?`bg-primary/10 text-primary font-medium`:`text-secondary hover:bg-surface-sunken hover:text-primary`}`,children:[a,(0,b.jsx)(`span`,{className:`flex-1 text-left truncate`,title:r,children:r}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${t===e?`text-primary`:`text-tertiary`}`,children:i})]},e??`__all__`);return i.length===0&&r.trackerless===0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`px-3 pt-3 pb-1`,children:(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Trackers`})}),(0,b.jsxs)(`div`,{className:`px-1.5 pb-2`,children:[o(null,`All`,r.total,(0,b.jsx)(Gi,{className:a})),r.trackerless>0&&o(``,`Trackerless`,r.trackerless,(0,b.jsx)(Gi,{className:a})),i.map(e=>o(e,e,r.counts[e],(0,b.jsx)(Ki,{className:a})))]})]})},cu=()=>{let e=la(e=>e.torrents),t=Q(e=>e.statusFilter),n=Q(e=>e.setStatusFilter),r=Q(e=>e.setCurrentPage),i=Q(e=>e.sidebarCollapsed),a=Q(e=>e.toggleSidebar),o=e=>{n(e),r(`torrents`)},s=(0,_.useMemo)(()=>e?{all:e.length,downloading:e.filter(e=>e.stats?.state===`live`&&!e.stats?.finished).length,seeding:e.filter(e=>e.stats?.state===`live`&&e.stats?.finished).length,paused:e.filter(e=>e.stats?.state===`paused`).length,queued:e.filter(e=>e.stats?.queue_state===`Queued`).length,initializing:e.filter(e=>e.stats?.state===`initializing`).length,error:e.filter(e=>e.stats?.state===`error`).length}:{all:0,downloading:0,seeding:0,paused:0,queued:0,initializing:0,error:0},[e]),c=`w-3.5 h-3.5 shrink-0`,l=[{key:`all`,label:`All`,icon:(0,b.jsx)(zi,{className:c}),count:s.all},{key:`downloading`,label:`Downloading`,icon:(0,b.jsx)(Lo,{className:c}),count:s.downloading},{key:`seeding`,label:`Seeding`,icon:(0,b.jsx)(Eo,{className:c}),count:s.seeding},{key:`paused`,label:`Paused`,icon:(0,b.jsx)(Fo,{className:c}),count:s.paused},{key:`queued`,label:`Queued`,icon:(0,b.jsx)(ns,{className:c}),count:s.queued},{key:`error`,label:`Error`,icon:(0,b.jsx)(Io,{className:c}),count:s.error}],u=`bg-primary/10 text-primary font-medium`,d=`text-secondary hover:bg-surface-sunken hover:text-primary`;return i?(0,b.jsxs)(`div`,{className:`w-12 bg-surface border-r border-divider flex flex-col shrink-0`,children:[(0,b.jsx)(`div`,{className:`flex-1 pt-2`,children:l.map(e=>(0,b.jsx)(`button`,{onClick:()=>o(e.key),title:`${e.label} (${e.count})`,className:`w-full flex items-center justify-center py-2.5 cursor-pointer transition-colors ${t===e.key?u:d}`,children:e.icon},e.key))}),(0,b.jsx)(`button`,{onClick:a,className:`p-2 text-tertiary hover:text-secondary cursor-pointer border-t border-divider flex items-center justify-center`,title:`Expand sidebar`,children:(0,b.jsx)(Vi,{className:`w-3.5 h-3.5`})})]}):(0,b.jsxs)(`div`,{className:`w-48 bg-surface border-r border-divider flex flex-col shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,b.jsx)(`div`,{className:`px-3 pt-3 pb-1`,children:(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Status`})}),(0,b.jsx)(`div`,{className:`px-1.5`,children:l.map(e=>(0,b.jsxs)(`button`,{onClick:()=>o(e.key),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${t===e.key?u:d}`,children:[e.icon,(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:e.label}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${t===e.key?`text-primary`:`text-tertiary`}`,children:e.count})]},e.key))}),(0,b.jsx)(ou,{}),(0,b.jsx)(su,{})]}),(0,b.jsxs)(`button`,{onClick:a,className:`p-2 text-tertiary hover:text-secondary cursor-pointer border-t border-divider flex items-center justify-center gap-1 text-xs`,title:`Collapse sidebar`,children:[(0,b.jsx)(Hi,{className:`w-3 h-3`}),(0,b.jsx)(`span`,{children:`Collapse`})]})]})},lu=()=>{let e=Ko(e=>e.alert),t=Ko(e=>e.removeAlert);return e?(0,b.jsxs)(xo,{isOpen:!0,onClose:t,title:e.text,children:[(0,b.jsxs)(So,{children:[e.details?.statusText&&(0,b.jsx)(`div`,{className:`pb-2 text-md`,children:e.details?.statusText}),(0,b.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.details?.text})]}),(0,b.jsx)(Co,{children:(0,b.jsx)(fa,{variant:`cancel`,onClick:t,children:`Close`})})]}):(0,b.jsx)(b.Fragment,{})},uu=({className:e})=>(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,b.jsx)(`path`,{d:`M8.5 7.5C9.6 6.1 11.5 5 13.5 5c3.6 0 6.5 2.9 6.5 6.5 0 .5-.1 1-.2 1.5H21c.6 0 1 .4 1 1s-.4 1-1 1h-1.9c-.8 1.2-2 2.1-3.4 2.6l.6 1.2c.2.5 0 1.1-.5 1.3-.5.2-1.1 0-1.3-.5l-.7-1.4c-.1 0-.2 0-.3 0h-3l-.7 1.4c-.2.5-.8.7-1.3.5-.5-.2-.7-.8-.5-1.3l.5-1.1c-.9-.4-1.7-.9-2.3-1.6l-1.4.9c-.5.3-1.1.2-1.4-.3-.3-.5-.2-1.1.3-1.4l1.5-1c-.1-.4-.2-.9-.2-1.3H3c-.6 0-1-.4-1-1s.4-1 1-1h2.1c.2-.9.6-1.7 1.1-2.4l-.9-.9c-.4-.4-.4-1 0-1.4.4-.4 1-.4 1.4 0l.9.9c.3-.2.6-.4.9-.6zm5 .5c-2.5 0-4.5 2-4.5 4.5S11 17 13.5 17s4.5-2 4.5-4.5S16 8 13.5 8z`})}),du=({children:e,title:t})=>(0,b.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 whitespace-nowrap`,title:t,children:e}),fu=()=>{let e=(0,_.useContext)(v),t=Rl(e=>e.stats),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{let t=!1,n=()=>e.getAltSpeed().then(e=>{t||(r(!0),a(e.enabled))}).catch(()=>{t||r(!1)});n();let i=setInterval(n,1e4);return()=>{t=!0,clearInterval(i)}},[e]),(0,b.jsxs)(`div`,{className:`bg-surface-raised border-t border-divider text-sm text-secondary flex items-center flex-wrap gap-x-1 lg:gap-x-3 px-1`,children:[n&&(0,b.jsx)(`button`,{onClick:async()=>{let t=!i;a(t);try{await e.toggleAltSpeed(t)}catch{a(!t)}},className:`p-1 rounded cursor-pointer transition-colors ${i?`text-primary bg-primary/15`:`text-tertiary hover:text-secondary hover:bg-surface-sunken`}`,title:i?`Alternative speed limits are ON — click to disable`:`Alternative speed limits are OFF — click to enable`,children:(0,b.jsx)(uu,{className:`w-4 h-4`})}),(0,b.jsxs)(`div`,{className:`flex-1 flex items-center justify-evenly flex-wrap gap-x-1 lg:gap-x-5`,children:[(0,b.jsxs)(du,{title:`Download speed (session total)`,children:[(0,b.jsx)(Uo,{className:`w-3 h-3 text-accent-download`}),(0,b.jsx)(`span`,{className:`text-accent-download font-medium tabular-nums`,children:t.download_speed.human_readable}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[`(`,Xo(t.counters.fetched_bytes),`)`]})]}),(0,b.jsxs)(du,{title:`Upload speed (session total)`,children:[(0,b.jsx)(Vo,{className:`w-3 h-3 text-accent-upload`}),(0,b.jsx)(`span`,{className:`text-accent-upload font-medium tabular-nums`,children:t.upload_speed.human_readable}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[`(`,Xo(t.counters.uploaded_bytes),`)`]})]}),(0,b.jsxs)(du,{title:`Connected peers`,children:[(0,b.jsx)(Mi,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`span`,{className:`tabular-nums`,children:t.peers.live})]}),(0,b.jsxs)(du,{title:`Session uptime`,children:[(0,b.jsx)(Bi,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`span`,{className:`tabular-nums`,children:Qo(t.uptime_seconds)})]}),(0,b.jsxs)(du,{children:[(0,b.jsx)(Oi,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`a`,{href:`/swagger/`,target:`_blank`,className:`text-primary hover:underline`,children:`API`})]})]})]})},pu=({files:e,onHide:t})=>{let n=(0,_.useContext)(v),r=la(e=>e.refreshTorrents),i=Q(e=>e.categories),a=Q(e=>e.setCategories),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(e.map(e=>({file:e,status:`pending`}))),[m,h]=(0,_.useState)(!1),[g,y]=(0,_.useState)(!1);(0,_.useEffect)(()=>{n.getCategories().then(e=>a(e)).catch(()=>{})},[n,a]);let x=Object.keys(i).sort((e,t)=>e.localeCompare(t)),S=async()=>{h(!0);let e=[...f];for(let t=0;t{switch(e){case`uploading`:return(0,b.jsx)(bi,{className:`w-4 h-4 inline-block`});case`success`:return(0,b.jsx)(Wi,{className:`text-green-500 inline-block`});case`error`:return(0,b.jsx)(Si,{className:`text-red-500 inline-block`});default:return(0,b.jsx)(`span`,{className:`text-secondary`,children:`--`})}};return(0,b.jsxs)(xo,{isOpen:!0,onClose:t,title:`Upload Multiple Torrents`,children:[(0,b.jsxs)(So,{children:[(0,b.jsxs)(al,{children:[(0,b.jsx)(il,{label:`Output folder`,name:`multi_output_folder`,inputType:`text`,placeholder:`Server default`,value:o,onChange:e=>s(e.target.value)}),x.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`multi_category`,className:`text-sm font-medium text-secondary`,children:`Category`}),(0,b.jsxs)(`select`,{id:`multi_category`,value:c,onChange:e=>l(e.target.value),className:`px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:[(0,b.jsx)(`option`,{value:``,children:`None`}),x.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})]}),(0,b.jsx)(ks,{label:`Start torrents after adding`,checked:u,onChange:()=>d(!u),name:`start_torrent`})]}),(0,b.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-divider rounded`,children:f.map((e,t)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-divider last:border-b-0`,children:[(0,b.jsx)(`span`,{className:`w-5 flex-shrink-0`,children:C(e.status)}),(0,b.jsx)(`span`,{className:`truncate min-w-0 flex-1`,children:e.file.name}),e.error&&(0,b.jsx)(`span`,{className:`text-red-500 text-xs truncate max-w-[200px]`,children:e.error})]},t))})]}),(0,b.jsxs)(Co,{children:[m&&(0,b.jsx)(bi,{}),(0,b.jsx)(fa,{onClick:t,variant:`cancel`,children:g?`Close`:`Cancel`}),!g&&(0,b.jsxs)(fa,{onClick:S,variant:`primary`,disabled:m,children:[`Upload All (`,f.length,`)`]})]})]})},mu=e=>{let[t,n]=(0,_.useState)(!1),r=Ko(e=>e.setOtherError),i=(0,_.useContext)(v),a=xc(),o=Q(e=>e.sidebarOpen),s=Q(e=>e.setSidebarOpen),c=Q(e=>e.currentPage),l=la(e=>e.setTorrents),u=la(e=>e.setTorrentsLoading),d=la(e=>e.setRefreshTorrents),f=async()=>{u(!0);try{let e=await i.listTorrents({withStats:!0});return l(e.torrents),r(null),e.torrents.some(e=>e.stats?.state===`live`||e.stats?.state===`initializing`)?1e3:5e3}catch(e){return r({text:`Error refreshing torrents`,details:e}),console.error(e),5e3}finally{u(!1)}},p=Rl(e=>e.setStats);(0,_.useEffect)(()=>{d(f)},[]),(0,_.useEffect)(()=>Cs(async()=>f(),0),[]),(0,_.useEffect)(()=>Cs(async()=>i.stats().then(e=>(p(e),1e3),e=>(console.error(e),5e3)),0),[]);let[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(0),[y,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(y?.type!==`single`)return;let e=y.file;T(!0),C(null),D(null);let t=!1,n=setTimeout(async()=>{try{let n=await i.uploadTorrent(e,{list_only:!0});t||C(n)}catch(e){t||D({text:`Error listing torrent files`,details:e})}finally{t||T(!1)}},0);return()=>{t=!0,clearTimeout(n)}},[y]);let O=()=>{x(null),C(null),D(null),T(!1)},ee=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current++,g.current===1&&h(!0)},[]),te=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current--,g.current===0&&h(!1)},[]),k=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),ne=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current=0,h(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.name.endsWith(`.torrent`));t.length!==0&&(t.length===1?x({type:`single`,file:t[0]}):x({type:`multi`,files:t}))},[]),A=(0,_.useCallback)(e=>{e.length===1?x({type:`single`,file:e[0]}):e.length>1&&x({type:`multi`,files:e})},[]);return(0,b.jsxs)(`div`,{className:`bg-surface h-dvh flex flex-col overflow-hidden`,children:[(0,b.jsx)(au,{title:e.title,version:e.version,onMultiFileSelect:A,onLogsClick:()=>n(!0),menuButtons:e.menuButtons}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-row`,children:[a&&c===`torrents`&&(0,b.jsx)(cu,{}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,onDragEnter:ee,onDragLeave:te,onDragOver:k,onDrop:ne,children:[(0,b.jsx)(bl,{}),m&&(0,b.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-surface/90`,children:(0,b.jsx)(`div`,{className:`border-2 border-dashed border-primary rounded-lg p-8 text-center`,children:(0,b.jsx)(`p`,{className:`text-lg font-semibold text-primary`,children:`Drop .torrent files here`})})})]})]}),!a&&o&&(0,b.jsxs)(`div`,{className:`fixed inset-0 z-40`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:()=>s(!1)}),(0,b.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 bg-surface shadow-xl`,children:(0,b.jsx)(cu,{})})]}),(0,b.jsx)(fu,{}),(0,b.jsx)(xl,{show:t,onClose:()=>n(!1)}),(0,b.jsx)(lu,{}),y?.type===`single`&&(0,b.jsx)(ol,{onHide:O,listTorrentResponse:S,listTorrentError:E,listTorrentLoading:w,data:y.file}),y?.type===`multi`&&(0,b.jsx)(pu,{files:y.files,onHide:()=>x(null)})]})},hu=`NebulaOS-26.07-desktop-x86_64.iso,CopperFinch-Linux-12.4-live-amd64.iso,Atlas.Public.Dataset.2026.07.parquet.zst,Moonbase.Manuals.Collection.v4.2.epub.zip,Open.Orchestra.Sessions.Vol.08.FLAC,Glass.River.2026.Short.Film.1080p.WEB.x264-DEMO,Cinder.Workstation-9.1-arm64.img.xz,Northstar.Game.Assets.CreativeCommons.v3.tar.zst,Pocket.Planetarium.Catalog.2026-07.sqlite.zst,Paper.Kites.Public.Domain.Collection.4K-DEMO,Field.Notes.Quarterly.Issue.42.pdf.zip,LighthouseOS-5.8-server-amd64.iso,Mosaic.Fonts.Open.Collection.2026.1.tar.gz,Signal.Garden.S01E04.1080p.WEB.x265-DEMO,Blue.Hour.Live.Session.2026.FLAC-DEMO,JuniperBSD-14.2-install-amd64.iso,Rookery.Container.Images.airgap-bundle-v7.tar,Cloud.Atlas.Weather.Archive.2026-06.nc.zst,Tiny.Museums.Photo.Archive.Vol.12.zip,Amber.Terminal-3.6.2-source-and-docs.tar.gz,Fable.Engine.Sample.Projects.v2.8.zip,Harbor.Light.2025.Open.Movie.2160p-DEMO,OrchardOS-rolling-2026.07-kde-x86_64.iso,Transit.Map.OpenData.Global.2026Q2.pbf,Night.Train.Radio.Archive.Episodes.101-125.opus,Stonecrop.Rescue.Environment.v5.1.iso,Wildflower.Macro.Photos.CC0.Collection.03.zip,CometDB-8.0.1-offline-documentation.tar.gz,Riverside.Ambience.24bit.96kHz.FLAC-DEMO,SundialOS-2.0-raspberrypi-arm64.img.xz,Workshop.CAD.Models.Open-Pack.2026-07.zip,Morning.Fog.2024.Short.Film.1080p-DEMO,Redwood.Security.Lab.v11.qcow2,Open.Cookbook.Archive.2026.07.epub,Aurora.Language.Corpus.v6.jsonl.zst,Telescope.Raw.Sample.Data.M31.2026.fits.tar`.split(`,`),gu=[`.iso`,`.img`,`.tar.gz`,`.zip`,`.qcow2`],_u=[`udp://tracker.demo-open.example:6969/announce`,`https://announce.publicbits.example:443/announce`,`udp://tr.linuxmirror.example:2710/announce`,`https://tracker.datasets.example/announce`,`udp://open.seedhub.example:6969/announce`];function vu(e){let t=bu(e*6659),n=1+Math.floor(t()*3),r=new Set;for(let e=0;e(e=e*1103515245+12345&2147483647,e/2147483647)}function xu(e){let t=bu(e*31337),n=``;for(let e=0;e<40;e++)n+=`0123456789abcdef`[Math.floor(t()*16)];return n}function Su(e){return hu[e%hu.length]}var Cu=8;function wu(e){if(e.1,attributes:{symlink:!1,hidden:!1,padding:!1,executable:!1}})}return a}function ku(e,t,n){let r=bu(e*8737+Date.now()%1e4),i=n-t,a=Math.random()*50,o=Math.random()*10,s=a*1024*1024/8,c=s>0?i/s:null;return{snapshot:{have_bytes:t,downloaded_and_checked_bytes:t,downloaded_and_checked_pieces:Math.floor(t/n*1e3),fetched_bytes:t,uploaded_bytes:Math.floor(r()*t*.5),initially_needed_bytes:n,remaining_bytes:i,total_bytes:n,total_piece_download_ms:Math.floor(r()*1e5),peer_stats:{queued:Math.floor(r()*50),connecting:Math.floor(r()*10),live:Math.floor(r()*30)+1,seen:Math.floor(r()*200),dead:Math.floor(r()*100),not_needed:Math.floor(r()*20)}},average_piece_download_time:{secs:Math.floor(r()*2),nanos:Math.floor(r()*1e9)},download_speed:{mbps:a,human_readable:`${a.toFixed(1)} MB/s`},upload_speed:{mbps:o,human_readable:`${o.toFixed(1)} MB/s`},all_time_download_speed:{mbps:a*.8,human_readable:`${(a*.8).toFixed(1)} MB/s`},time_remaining:c===null?null:{human_readable:c<60?`${Math.floor(c)}s`:c<3600?`${Math.floor(c/60)}m`:`${Math.floor(c/3600)}h ${Math.floor(c%3600/60)}m`,duration:{secs:Math.floor(c)}}}}function Au(e){let t=Mu.get(e)??wu(e),n=Tu(e),r=Du(e,n,t),i=r>=n,a=bu(e*5501),o=Math.floor(a()*5)+1,s=Array(o).fill(0).map(()=>i?1:a()*(r/n));return{state:i&&t===`live`?`live`:t,error:t===`error`?`Connection timed out`:null,file_progress:s,progress_bytes:r,finished:i,total_bytes:n,live:t===`live`?ku(e,r,n):null}}function ju(e,t){let n=Tu(e),r=Math.ceil(n/(256*1024)),i={id:e,info_hash:xu(e),name:Su(e),output_folder:`/downloads/torrent_${e}`,total_pieces:r,added_on:yu(e),trackers:vu(e)},a=Hu.get(e);return a&&(i.category=a),t&&(i.stats=Au(e)),i}var Mu=new Map,Nu=new Set,Pu={enabled:!1,config:{download_rate:2*1024*1024,upload_rate:512*1024},schedule:{enabled:!1,start_minutes:1320,end_minutes:360,days:127}},Fu=new Map,Iu=new Map;function Lu(e){let t=Fu.get(e);if(!t){let n=bu(e*9371),r=Math.floor(n()*15)+5;t=[];for(let e=0;e.3?`tcp`:`utp`,fetchedBytes:Math.floor(n()*1e7),uploadedBytes:Math.floor(n()*5e6),fetchRate:Math.floor(n()*2e6)+1e5,uploadRate:Math.floor(n()*5e5)+5e4});Fu.set(e,t),Iu.set(e,Date.now())}return t}function Ru(e){let t=Fu.get(e),n=Iu.get(e);if(!t||!n)return;let r=Date.now(),i=(r-n)/1e3;if(Iu.set(e,r),(Mu.get(e)??wu(e))===`live`)for(let e of t){let t=.5+Math.random(),n=.5+Math.random();e.fetchedBytes+=Math.floor(e.fetchRate*i*t),e.uploadedBytes+=Math.floor(e.uploadRate*i*n)}}var zu=hu.length,Bu=[`Linux ISOs`,`Software`,`Documents`,`Media`],Vu={"Linux ISOs":{name:`Linux ISOs`,save_path:`/downloads/linux`},Software:{name:`Software`,save_path:`/downloads/software`},Documents:{name:`Documents`,save_path:`/downloads/docs`},Media:{name:`Media`,save_path:`/downloads/media`}},Hu=new Map;for(let e=0;enew Date(Uu-e*36e5).toISOString(),Gu=[{name:`Open Media Weekly`,url:`https://feeds.example.invalid/open-media.xml`,poll_interval_secs:900,category:`Media`,enabled:!0,auto_download:!1},{name:`Demo Software Releases`,url:`https://feeds.example.invalid/software.xml`,poll_interval_secs:1800,category:`Software`,filter_regex:`(stable|release)`,enabled:!0,auto_download:!0},{name:`Public Data Dispatch`,url:`https://feeds.example.invalid/data.xml`,poll_interval_secs:3600,category:`Documents`,enabled:!0,auto_download:!1}],Ku=[[`rss-01`,`Open Media Weekly`,`Glass River (2026) — Open Short Film 1080p`,24e8,2,!0],[`rss-02`,`Demo Software Releases`,`Amber Terminal 3.6.2 stable source bundle`,184e6,5,!0],[`rss-03`,`Public Data Dispatch`,`Atlas public dataset — July 2026 snapshot`,87e8,9,!0],[`rss-04`,`Open Media Weekly`,`Blue Hour — live session in lossless audio`,11e8,15,!1],[`rss-05`,`Demo Software Releases`,`CometDB 8.0.1 offline documentation`,426e6,21,!0],[`rss-06`,`Open Media Weekly`,`Harbor Light (2025) — open movie 2160p`,68e8,28,!1],[`rss-07`,`Public Data Dispatch`,`Transit map OpenData — 2026 Q2 export`,43e8,37,!0],[`rss-08`,`Demo Software Releases`,`Fable Engine sample projects v2.8 release`,97e7,49,!1],[`rss-09`,`Open Media Weekly`,`Riverside Ambience — 24-bit field recording`,32e8,63,!0],[`rss-10`,`Public Data Dispatch`,`Pocket Planetarium catalog — July update`,74e7,76,!1]].map(([e,t,n,r,i,a])=>({id:e,feed_name:t,title:n,url:`magnet:?xt=urn:btih:${xu(Number(e.slice(-2)))}`,published_at:Wu(i),first_seen_at:Wu(i-.25),downloaded:a,downloaded_at:a?Wu(i-.5):null,category:Gu.find(e=>e.name===t)?.category,size_bytes:r})),qu=[{id:`rule-1`,name:`Stable software`,feed_names:[`Demo Software Releases`],category:`Software`,priority:10,match_regex:`(?i)(stable|release)`,enabled:!0},{id:`rule-2`,name:`Open films`,feed_names:[`Open Media Weekly`],category:`Media`,priority:20,match_regex:`(?i)(open movie|short film)`,enabled:!0}],Ju={getFeeds:async()=>[...Gu],addFeed:async e=>{Gu=[...Gu,e]},updateFeed:async(e,t)=>{Gu=Gu.map(n=>n.name===e?t:n)},deleteFeed:async e=>{Gu=Gu.filter(t=>t.name!==e)},getItems:async e=>Ku.filter(t=>!e||t.feed_name===e),downloadItem:async e=>{Ku=Ku.map(t=>t.id===e?{...t,downloaded:!0,downloaded_at:new Date().toISOString()}:t)},getRules:async()=>[...qu],addRule:async e=>{qu=[...qu,{...e,id:`rule-${qu.length+1}`}]},updateRule:async(e,t)=>{qu=qu.map(n=>n.id===e?{...t,id:e}:n)},deleteRule:async e=>{qu=qu.filter(t=>t.id!==e)},getSettings:async()=>({rss_history_limit:500})},Yu={getStreamLogsUrl:()=>null,listTorrents:async e=>{await new Promise(e=>setTimeout(e,50+Math.random()*100));let t=[];for(let n=0;n{if(await new Promise(e=>setTimeout(e,20+Math.random()*50)),Nu.has(e))throw{text:`Torrent not found`,status:404};let t=Tu(e);return{name:Su(e),info_hash:xu(e),files:Ou(e,t),total_pieces:Math.ceil(t/(256*1024)),output_folder:`/downloads/torrent_${e}`}},getTrackerStatus:async e=>{if(await new Promise(e=>setTimeout(e,20+Math.random()*40)),Nu.has(e))throw{text:`Torrent not found`,status:404};let t=Mu.get(e)??wu(e),n=vu(e),r=bu(e*8447);return{trackers:n.map((e,n)=>{let i=r()<.15;return t===`live`?i?{url:e,state:`error`,seeders:null,leechers:null,peers_returned:null,last_announce_unix:null,interval_secs:null,last_error:`tracker responded with 502 Bad Gateway`}:{url:e,state:`working`,seeders:Math.floor(r()*500)+5,leechers:Math.floor(r()*200),peers_returned:Math.floor(r()*50)+1,last_announce_unix:Math.floor(Date.now()/1e3)-Math.floor(r()*600)-n*30,interval_secs:1800,last_error:null}:{url:e,state:`not_contacted`,seeders:null,leechers:null,peers_returned:null,last_announce_unix:null,interval_secs:null,last_error:null}})}},getTorrentStats:async e=>{if(await new Promise(e=>setTimeout(e,10+Math.random()*30)),Nu.has(e))throw{text:`Torrent not found`,status:404};let t=Mu.get(e),n=Au(e);return t&&(n.state=t,t!==`live`&&(n.live=null)),n},getPeerStats:async e=>{await new Promise(e=>setTimeout(e,20));let t=Lu(e);Ru(e);let n={},r=bu(e*4421);for(let e of t)n[`${e.ip}:${e.port}`]={counters:{incoming_connections:Math.floor(r()*10),fetched_bytes:e.fetchedBytes,uploaded_bytes:e.uploadedBytes,total_time_connecting_ms:Math.floor(r()*1e4)+1e3,connection_attempts:Math.floor(r()*3)+1,connections:1,errors:Math.floor(r()*2),fetched_chunks:Math.floor(e.fetchedBytes/16384),downloaded_and_checked_pieces:Math.floor(e.fetchedBytes/262144),total_piece_download_ms:Math.floor(r()*5e4)+5e3,times_stolen_from_me:0,times_i_stole:0},state:`live`,conn_kind:e.connKind};return{peers:n}},stats:async()=>{await new Promise(e=>setTimeout(e,30));let e=Math.random()*100,t=Math.random()*30;return{counters:{fetched_bytes:Math.floor(Math.random()*1e11),uploaded_bytes:Math.floor(Math.random()*5e10),blocked_incoming:Math.floor(Math.random()*100),blocked_outgoing:Math.floor(Math.random()*50)},peers:{queued:Math.floor(Math.random()*500),connecting:Math.floor(Math.random()*100),live:Math.floor(Math.random()*300)+50,seen:Math.floor(Math.random()*2e3),dead:Math.floor(Math.random()*500),not_needed:Math.floor(Math.random()*200)},connections:{tcp:{v4:{attempts:1e3,successes:800,errors:200},v6:{attempts:200,successes:150,errors:50}},utp:{v4:{attempts:500,successes:300,errors:200},v6:{attempts:100,successes:60,errors:40}},socks:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}}},download_speed:{mbps:e,human_readable:`${e.toFixed(1)} MB/s`},upload_speed:{mbps:t,human_readable:`${t.toFixed(1)} MB/s`},uptime_seconds:Math.floor(Date.now()/1e3)%86400}},uploadTorrent:async()=>{throw{text:`Upload not supported in mock mode`,status:501}},updateOnlyFiles:async()=>{await new Promise(e=>setTimeout(e,100))},pause:async e=>{await new Promise(e=>setTimeout(e,50)),Mu.set(e,`paused`)},start:async e=>{await new Promise(e=>setTimeout(e,50)),Mu.set(e,`live`)},recheck:async e=>{await new Promise(e=>setTimeout(e,50)),Mu.set(e,`initializing`)},addTrackers:async()=>{await new Promise(e=>setTimeout(e,50))},forget:async e=>{await new Promise(e=>setTimeout(e,50)),Nu.add(e)},delete:async e=>{await new Promise(e=>setTimeout(e,100)),Nu.add(e)},getVersion:async()=>`mock-1.0.0`,getTorrentStreamUrl:()=>null,getPlaylistUrl:()=>null,getTorrentHaves:async e=>{let t=Tu(e),n=Math.ceil(t/(256*1024)),r=Math.ceil(n/8),i=new Uint8Array(r),a=bu(e*6173),o=Du(e,t,wu(e))/t;for(let e=0;e({upload_bps:null,download_bps:null}),setLimits:async()=>{await new Promise(e=>setTimeout(e,50))},getDhtStats:async()=>({id:`mock-dht-node-id-abc123def456`,outstanding_requests:5,seen_peers:1234,have_peers:567,inflight_peers:12}),setRustLog:async()=>{await new Promise(e=>setTimeout(e,100))},getMetadata:async()=>new TextEncoder().encode(`d8:announce35:udp://tracker.example.com:6969/announce13:announce-listll35:udp://tracker.example.com:6969/announceel38:https://tracker2.example.org:443/announceee4:infod6:lengthi1024ee8:url-list0:e`),getCategories:async()=>(await new Promise(e=>setTimeout(e,30)),{...Vu}),createCategory:async(e,t)=>{await new Promise(e=>setTimeout(e,50)),Vu[e]={name:e,save_path:t}},deleteCategory:async e=>{await new Promise(e=>setTimeout(e,50)),delete Vu[e];for(let[t,n]of Hu.entries())n===e&&Hu.delete(t)},setTorrentCategory:async(e,t)=>{await new Promise(e=>setTimeout(e,50)),t?Hu.set(e,t):Hu.delete(e)},getAltSpeed:async()=>({enabled:Pu.enabled,config:{...Pu.config},schedule:{...Pu.schedule}}),toggleAltSpeed:async e=>{await new Promise(e=>setTimeout(e,30)),Pu.enabled=e},setAltSpeedConfig:async e=>{Pu.config={...e}},getSpeedSchedule:async()=>({...Pu.schedule}),setSpeedSchedule:async e=>{Pu.schedule={...e}},getSeedLimits:async()=>({ratio_limit:null,time_limit_secs:null}),setSeedLimits:async e=>{},setTorrentSeedLimits:async(e,t)=>{},getTorrentLimits:async e=>({}),setTorrentLimits:async(e,t)=>{},setSequential:async(e,t)=>{},setSuperSeed:async(e,t)=>{},queueMoveTop:async e=>{},queueMoveBottom:async e=>{},queueMoveUp:async e=>{},queueMoveDown:async e=>{},getFolders:async()=>({download_folder:`/downloads`,completed_folder:null}),setFolders:async()=>{},browseDirectory:async e=>({current:e??`/`,parent:e&&e!==`/`?e.split(`/`).slice(0,-1).join(`/`)||`/`:null,entries:[{name:`downloads`,path:(e??`/`)+`/downloads`,is_dir:!0},{name:`completed`,path:(e??`/`)+`/completed`,is_dir:!0},{name:`media`,path:(e??`/`)+`/media`,is_dir:!0}]})};Object.assign(tl,Ju),g.createRoot(document.getElementById(`app`)).render((0,b.jsx)(_.StrictMode,{children:(0,b.jsx)(()=>(0,b.jsx)(v.Provider,{value:Yu,children:(0,b.jsx)(mu,{title:`RustTorrent Demo`,version:`v0.1.0-beta.3`})}),{})})); \ No newline at end of file diff --git a/website/demo/assets/mock-Fgd9Vka6.js b/website/demo/assets/mock-Fgd9Vka6.js deleted file mode 100644 index 0b94795..0000000 --- a/website/demo/assets/mock-Fgd9Vka6.js +++ /dev/null @@ -1,15 +0,0 @@ -var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`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`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function k(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function ne(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function A(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,A(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+k(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),A(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&k(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&k(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function k(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,k(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1F||(e.current=ie[F],ie[F]=null,F--)}function R(e,t){F++,ie[F]=e.current,e.current=t}var z=I(null),B=I(null),V=I(null),H=I(null);function ae(e,t){switch(R(V,t),R(B,e),R(z,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}L(z),R(z,e)}function U(){L(z),L(B),L(V)}function oe(e){e.memoizedState!==null&&R(H,e);var t=z.current,n=Hd(t,e.type);t!==n&&(R(B,e),R(z,n))}function se(e){B.current===e&&(L(z),L(B)),H.current===e&&(L(H),Qf._currentValue=P)}var ce,W;function le(e){if(ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ce=t&&t[1]||``,W=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ue=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?le(n):``}function de(e,t){switch(e.tag){case 26:case 27:case 5:return le(e.type);case 16:return le(`Lazy`);case 13:return e.child!==t&&t!==null?le(`Suspense Fallback`):le(`Suspense`);case 19:return le(`SuspenseList`);case 0:case 15:return G(e.type,!1);case 11:return G(e.type.render,!1);case 1:return G(e.type,!0);case 31:return le(`Activity`);default:return``}}function K(e){try{var t=``,n=null;do t+=de(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var fe=Object.prototype.hasOwnProperty,pe=t.unstable_scheduleCallback,me=t.unstable_cancelCallback,he=t.unstable_shouldYield,ge=t.unstable_requestPaint,q=t.unstable_now,_e=t.unstable_getCurrentPriorityLevel,ve=t.unstable_ImmediatePriority,ye=t.unstable_UserBlockingPriority,be=t.unstable_NormalPriority,xe=t.unstable_LowPriority,Se=t.unstable_IdlePriority,Ce=t.log,we=t.unstable_setDisableYieldValue,Te=null,Ee=null;function De(e){if(typeof Ce==`function`&&we(e),Ee&&typeof Ee.setStrictMode==`function`)try{Ee.setStrictMode(Te,e)}catch{}}var Oe=Math.clz32?Math.clz32:je,ke=Math.log,Ae=Math.LN2;function je(e){return e>>>=0,e===0?32:31-(ke(e)/Ae|0)|0}var Me=256,Ne=262144,Pe=4194304;function Fe(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ie(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Fe(n))):i=Fe(o):i=Fe(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Fe(n))):i=Fe(o)):i=Fe(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Le(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Re(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ze(){var e=Pe;return Pe<<=1,!(Pe&62914560)&&(Pe=4194304),e}function Be(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ve(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function He(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),en=!1;if($t)try{var tn={};Object.defineProperty(tn,"passive",{get:function(){en=!0}}),window.addEventListener(`test`,tn,tn),window.removeEventListener(`test`,tn,tn)}catch{en=!1}var nn=null,rn=null,an=null;function on(){if(an)return an;var e,t=rn,n=t.length,r,i=`value`in nn?nn.value:nn.textContent,a=i.length;for(e=0;e=Rn),Vn=` `,Hn=!1;function Un(e,t){switch(e){case`keyup`:return In.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Wn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Gn=!1;function Kn(e,t){switch(e){case`compositionend`:return Wn(t);case`keypress`:return t.which===32?(Hn=!0,Vn):null;case`textInput`:return e=t.data,e===Vn&&Hn?null:e;default:return null}}function qn(e,t){if(Gn)return e===`compositionend`||!Ln&&Un(e,t)?(e=on(),an=rn=nn=null,Gn=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=mr(n)}}function gr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?gr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _r(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Dt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Dt(e.document)}return t}function vr(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`)}var Y=$t&&`documentMode`in document&&11>=document.documentMode,yr=null,br=null,xr=null,Sr=!1;function Cr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Sr||yr==null||yr!==Dt(r)||(r=yr,`selectionStart`in r&&vr(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}),xr&&pr(xr,r)||(xr=r,r=Td(br,`onSelect`),0>=o,i-=o,mi=1<<32-Oe(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ci&&gi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ci&&gi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ci&&gi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ci&&gi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&ga(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ca(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=ni(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=ti(o.type,o.key,o.props,null,e.mode,c),Ca(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ai(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=ga(o),b(e,r,o,c)}if(re(o))return h(e,r,o,c);if(ne(o)){if(l=ne(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Sa(o),c);if(o.$$typeof===C)return b(e,r,Gi(e,o),c);wa(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ri(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{xa=0;var i=b(e,t,n,r);return ba=null,i}catch(t){if(t===da||t===Z)throw t;var a=Zr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ea=Ta(!0),Da=Ta(!1),Oa=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Aa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ma(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ml&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Jr(e),qr(e,null,n),t}return Wr(e,r,t,n),Jr(e)}function Na(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,We(e,n)}}function Pa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Fa=!1;function Ia(){if(Fa){var e=na;if(e!==null)throw e}}function La(e,t,n,r){Fa=!1;var i=e.updateQueue;Oa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Pl&f)===f:(r&f)===f){f!==0&&f===ta&&(Fa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Oa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Hl|=o,e.lanes=o,e.memoizedState=d}}function Ra(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function za(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=M.T,s={};M.T=s,Ts(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ws(e,t,aa(c,r),uu(e)):ws(e,t,r,uu(e))}catch(n){ws(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function ms(){}function hs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=gs(e).queue;ps(e,a,t,P,n===null?ms:function(){return _s(e),n(r)})}function gs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:P,baseState:P,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:P},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function _s(e){var t=gs(e);t.next===null&&(t=e.alternate.memoizedState),ws(e,t.next.queue,{},uu())}function vs(){return Wi(Qf)}function ys(){return xo().memoizedState}function bs(){return xo().memoizedState}function xs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=ja(n);var r=Ma(t,e,n);r!==null&&(fu(r,t,n),Na(r,t,n)),t={cache:Zi()},e.payload=t;return}t=t.return}}function Ss(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Es(e)?Ds(t,n):(n=Gr(e,t,n,r),n!==null&&(fu(n,e,r),Os(n,t,r)))}function Cs(e,t,n){ws(e,t,n,uu())}function ws(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Es(e))Ds(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,fr(s,o))return Wr(e,t,i,0),Nl===null&&Ur(),!1}catch{}if(n=Gr(e,t,i,r),n!==null)return fu(n,e,r),Os(n,t,r),!0}return!1}function Ts(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Es(e)){if(t)throw Error(i(479))}else t=Gr(e,n,r,2),t!==null&&fu(t,e,2)}function Es(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Ds(e,t){io=ro=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Os(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,We(e,n)}}var ks={readContext:Wi,use:wo,useCallback:uo,useContext:uo,useEffect:uo,useImperativeHandle:uo,useLayoutEffect:uo,useInsertionEffect:uo,useMemo:uo,useReducer:uo,useRef:uo,useState:uo,useDebugValue:uo,useDeferredValue:uo,useTransition:uo,useSyncExternalStore:uo,useId:uo,useHostTransitionStatus:uo,useFormState:uo,useActionState:uo,useOptimistic:uo,useMemoCache:uo,useCacheRefresh:uo};ks.useEffectEvent=uo;var As={readContext:Wi,use:wo,useCallback:function(e,t){return bo().memoizedState=[e,t===void 0?null:t],e},useContext:Wi,useEffect:es,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Qo(4194308,4,os.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qo(4194308,4,e,t)},useInsertionEffect:function(e,t){Qo(4,2,e,t)},useMemo:function(e,t){var n=bo();t=t===void 0?null:t;var r=e();if(ao){De(!0);try{e()}finally{De(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=bo();if(n!==void 0){var i=n(t);if(ao){De(!0);try{n(t)}finally{De(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ss.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=bo();return e={current:e},t.memoizedState=e},useState:function(e){e=Io(e);var t=e.queue,n=Cs.bind(null,Q,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:cs,useDeferredValue:function(e,t){return ds(bo(),e,t)},useTransition:function(){var e=Io(!1);return e=ps.bind(null,Q,e.queue,!0,!1),bo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Q,a=bo();if(Ci){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Nl===null)throw Error(i(349));Pl&127||jo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,es(No.bind(null,r,o,e),[e]),r.flags|=2048,Xo(9,{destroy:void 0},Mo.bind(null,r,o,n,t),null),n},useId:function(){var e=bo(),t=Nl.identifierPrefix;if(Ci){var n=hi,r=mi;n=(r&~(1<<32-Oe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=oo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Ze]=t,o[Qe]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&wc(t)}}return kc(t),Tc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=V.current,Ai(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=xi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Ze]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Di(t,!0)}else e=Bd(e).createTextNode(r),e[Ze]=t,t.stateNode=e}return kc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ai(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Ze]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),e=!1}else n=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Za(t),t):(Za(t),null);if(t.flags&128)throw Error(i(558))}return kc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ai(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Ze]=t}else ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),a=!1}else a=Mi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Za(t),t):(Za(t),null)}return Za(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Dc(t,t.updateQueue),kc(t),null);case 4:return U(),e===null&&xd(t.stateNode.containerInfo),kc(t),null;case 10:return Ri(t.type),kc(t),null;case 19:if(L(Qa),r=t.memoizedState,r===null)return kc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Oc(r,!1);else{if(Vl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=$a(e),o!==null){for(t.flags|=128,Oc(r,!1),e=o.updateQueue,t.updateQueue=e,Dc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ei(n,e),n=n.sibling;return R(Qa,Qa.current&1|2),Ci&&gi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&q()>Ql&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304)}else{if(!a)if(e=$a(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Dc(t,e),Oc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ci)return kc(t),null}else 2*q()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(kc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=q(),e.sibling=null,n=Qa.current,R(Qa,a?n&1|2:n&1),Ci&&gi(t,r.treeForkCount),e);case 22:case 23:return Za(t),Wa(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(kc(t),t.subtreeFlags&6&&(t.flags|=8192)):kc(t),n=t.updateQueue,n!==null&&Dc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&L(sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ri(Xi),kc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function jc(e,t){switch(yi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ri(Xi),U(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return se(t),null;case 31:if(t.memoizedState!==null){if(Za(t),t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Za(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(Qa),null;case 4:return U(),null;case 10:return Ri(t.type),null;case 22:case 23:return Za(t),Wa(),e!==null&&L(sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ri(Xi),null;case 25:return null;default:return null}}function Mc(e,t){switch(yi(t),t.tag){case 3:Ri(Xi),U();break;case 26:case 27:case 5:se(t);break;case 4:U();break;case 31:t.memoizedState!==null&&Za(t);break;case 13:Za(t);break;case 19:L(Qa);break;case 10:Ri(t.type);break;case 22:case 23:Za(t),Wa(),e!==null&&L(sa);break;case 24:Ri(Xi)}}function Nc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Pc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Fc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{za(t,n)}catch(t){Hu(e,e.return,t)}}}function Ic(e,t,n){n.props=Ls(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Lc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Rc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}function zc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function Bc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[Qe]=t}catch(t){Hu(e,e.return,t)}}function Vc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Hc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Vc(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.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Uc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Wt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(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&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Ze]=e,t[Qe]=n}catch(t){Hu(e,e.return,t)}}var Kc=!1,qc=!1,Jc=!1,Yc=typeof WeakSet==`function`?WeakSet:Set,Xc=null;function Zc(e,t){if(e=e.containerInfo,Rd=sp,e=_r(e),vr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Xc=t;Xc!==null;)if(t=Xc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Xc=e;else for(;Xc!==null;){switch(t=Xc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(o,r,n),o[Ze]=e,ut(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=hr(s,h),v=hr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,M.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,Ml&6)throw Error(i(331));var c=Ml;if(Ml|=4,Dl(o.current),yl(o,o.current,s,n),Ml=c,nd(0,!1),Ee&&typeof Ee.onPostCommitFiberRoot==`function`)try{Ee.onPostCommitFiberRoot(Te,o)}catch{}return!0}finally{N.p=a,M.T=r,Ru(e,t)}}function Vu(e,t,n){t=si(n,t),t=Us(e.stateNode,t,2),e=Ma(e,t,2),e!==null&&(Ve(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=si(n,e),n=Ws(2),r=Ma(t,n,2),r!==null&&(Gs(n,r,t,e),Ve(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new jl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(zl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Nl===e&&(Pl&n)===n&&(Vl===4||Vl===3&&(Pl&62914560)===Pl&&300>q()-Xl?!(Ml&2)&&yu(e,0):Wl|=n,Kl===Pl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=ze()),e=Kr(e,t),e!==null&&(Ve(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return pe(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Oe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Pl,a=Ie(r,r===Nl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Le(r,a)||(n=!0,sd(r,a));r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=q(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=kt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),ut(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+kt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+kt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+kt(n.imageSizes)+`"]`)):i+=`[href="`+kt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),ut(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+kt(r)+`"][href="`+kt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),ut(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=lt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);ut(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),ut(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),ut(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=V.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=lt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=lt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+kt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),ut(t),e.head.appendChild(t))}function Pf(e){return`[src="`+kt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+kt(n.href)+`"]`);if(r)return t.instance=r,ut(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ut(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,ut(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),ut(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,ut(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),ut(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ut(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()}))(),1),_=c(u(),1),v=(0,_.createContext)({listTorrents:()=>{throw Error(`Function not implemented.`)},getTorrentDetails:()=>{throw Error(`Function not implemented.`)},getTorrentStats:()=>{throw Error(`Function not implemented.`)},getTrackerStatus:()=>{throw Error(`Function not implemented.`)},getPeerStats:()=>{throw Error(`Function not implemented.`)},uploadTorrent:()=>{throw Error(`Function not implemented.`)},updateOnlyFiles:()=>{throw Error(`Function not implemented.`)},pause:()=>{throw Error(`Function not implemented.`)},start:()=>{throw Error(`Function not implemented.`)},forget:()=>{throw Error(`Function not implemented.`)},delete:()=>{throw Error(`Function not implemented.`)},getTorrentStreamUrl:()=>{throw Error(`Function not implemented.`)},getStreamLogsUrl:function(){throw Error(`Function not implemented.`)},getPlaylistUrl:function(e){throw Error(`Function not implemented.`)},stats:function(){throw Error(`Function not implemented.`)},getTorrentHaves:function(e){throw Error(`Function not implemented.`)},getLimits:function(){throw Error(`Function not implemented.`)},setLimits:function(e){throw Error(`Function not implemented.`)},getDhtStats:function(){throw Error(`Function not implemented.`)},setRustLog:function(e){throw Error(`Function not implemented.`)},getMetadata:function(e){throw Error(`Function not implemented.`)},getCategories:function(){throw Error(`Function not implemented.`)},createCategory:function(e,t){throw Error(`Function not implemented.`)},deleteCategory:function(e){throw Error(`Function not implemented.`)},setTorrentCategory:function(e,t){throw Error(`Function not implemented.`)},getAltSpeed:function(){throw Error(`Function not implemented.`)},toggleAltSpeed:function(e){throw Error(`Function not implemented.`)},setAltSpeedConfig:function(e){throw Error(`Function not implemented.`)},getSpeedSchedule:function(){throw Error(`Function not implemented.`)},setSpeedSchedule:function(e){throw Error(`Function not implemented.`)},getSeedLimits:function(){throw Error(`Function not implemented.`)},setSeedLimits:function(e){throw Error(`Function not implemented.`)},setTorrentSeedLimits:function(e,t){throw Error(`Function not implemented.`)},getTorrentLimits:function(e){throw Error(`Function not implemented.`)},setTorrentLimits:function(e,t){throw Error(`Function not implemented.`)},setSequential:function(e,t){throw Error(`Function not implemented.`)},setSuperSeed:function(e,t){throw Error(`Function not implemented.`)},queueMoveTop:function(e){throw Error(`Function not implemented.`)},queueMoveBottom:function(e){throw Error(`Function not implemented.`)},queueMoveUp:function(e){throw Error(`Function not implemented.`)},queueMoveDown:function(e){throw Error(`Function not implemented.`)},getFolders:function(){throw Error(`Function not implemented.`)},setFolders:function(e){throw Error(`Function not implemented.`)},browseDirectory:function(e){throw Error(`Function not implemented.`)}}),y=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),b=o(((e,t)=>{t.exports=y()}))(),x=c(m(),1),S=0,C=1,w=2,T=4;function E(e){return()=>e}function D(e){e()}function O(e,t){return n=>e(t(n))}function ee(e,t){return()=>e(t)}function te(e,t){return n=>e(t,n)}function k(e){return e!==void 0}function ne(...e){return()=>{e.map(D)}}function A(){}function j(e,t){return t(e),e}function re(e,t){return t(e)}function M(...e){return e}function N(e,t){return e(C,t)}function P(e,t){e(S,t)}function ie(e){e(w)}function F(e){return e(T)}function I(e,t){return N(e,te(t,S))}function L(e,t){let n=e(C,e=>{n(),t(e)});return n}function R(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function z(e,t){return e===t}function B(e=z){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function V(e){return t=>n=>{e(n)&&t(n)}}function H(e){return t=>O(t,e)}function ae(e){return t=>()=>{t(e)}}function U(e,...t){let n=le(...t);return((t,r)=>{switch(t){case w:ie(e);return;case C:return N(e,n(r))}})}function oe(e,t){return n=>r=>{n(t=e(t,r))}}function se(e){return t=>n=>{e>0?e--:t(n)}}function ce(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function W(...e){let t=Array(e.length),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;N(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function le(...e){return t=>e.reduceRight(re,t)}function ue(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case C:return a?n===a?void 0:(r(),n=a,t=N(e,a),t):(r(),A);case w:r(),n=null;return}}}function G(e){let t=e,n=K();return((e,r)=>{switch(e){case S:t=r;break;case C:r(t);break;case T:return t}return n(e,r)})}function de(e,t){return j(G(t),t=>I(e,t))}function K(){let e=[];return((t,n)=>{switch(t){case S:e.slice().forEach(e=>{e(n)});return;case w:e.splice(0,e.length);return;case C:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function fe(e){return j(K(),t=>I(e,t))}function pe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:me(),singleton:n}}var me=()=>Symbol();function he(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function ge(...e){let t=K(),n=Array(e.length),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;N(e,e=>{n[a]=e,r|=o,r===i&&P(t,n)})}),function(e,a){switch(e){case w:ie(t);return;case C:return r===i&&a(n),N(t,a)}}}function q(e,t=z){return U(e,B(t))}function _e(...e){return function(t,n){switch(t){case w:return;case C:return ne(...e.map(e=>N(e,n)))}}}var ve={DEBUG:0,INFO:1,WARN:2,ERROR:3},ye={[ve.DEBUG]:`debug`,[ve.ERROR]:`error`,[ve.INFO]:`log`,[ve.WARN]:`warn`},be=()=>typeof globalThis>`u`?window:globalThis,xe=pe(()=>{let e=G(ve.ERROR);return{log:G((t,n,r=ve.INFO)=>{r>=(be().VIRTUOSO_LOG_LEVEL??F(e))&&console[ye[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0}),Se=new WeakMap;function Ce(e){return`self`in e?e.document.documentElement:e}function we(e){let t=Ce(e),n=Se.get(t);if(n!==void 0)return n;let r=t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`;return Se.set(t,r),r}function Te(e){Se.delete(Ce(e))}function Ee(e,t){return we(e)?-t:t}var De=Ee;function Oe(e,t){return Ee(e,t)}function ke(e,t,n){return Ae(e,t,n).callbackRef}function Ae(e,t,n){let r=_.useRef(null),i=e=>{},a=_.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function je(e,t,n,r,i,a,o,s,c){return Ae(_.useCallback(n=>{let c=Me(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?De(o,o.scrollLeft):o.scrollTop:u?s?De(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?De(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?Ne(`column-gap`,getComputedStyle(n).columnGap,i):Ne(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function Me(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=Ae(i,!0,n),s=_.useCallback(()=>{i(o.current)},[i,o]);return _.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var Fe=pe(()=>{let e=K(),t=K(),n=G(0),r=K(),i=G(0),a=K(),o=K(),s=G(0),c=G(0),l=G(0),u=G(0),d=K(),f=K(),p=G(!1),m=G(!1),h=G(!1);return I(U(e,H(({scrollTop:e})=>e)),t),I(U(e,H(({scrollHeight:e})=>e)),o),I(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),Ie={lvl:0};function Le(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;ot&&(s=s.concat(Ke(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(Ke(a,t,n))),s}function qe(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(Xe(t))return et(Je(e,{lvl:n-1}));if(!Re(t)&&!Re(t.r))return Je(t.r,{l:Je(t,{r:t.r.l}),lvl:n,r:Je(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(Xe(e))return tt(Je(e,{lvl:n-1}));if(!Re(r)&&!Re(r.l)){let t=r.l,i=Xe(t)?r.lvl-1:r.lvl;return Je(t,{l:Je(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:tt(Je(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function Je(e,t){return Qe(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function Ye(e){return Re(e.r)?e.l:qe(Je(e,{r:Ye(e.r)}))}function Xe(e){return Re(e)||e.lvl>e.r.lvl}function Ze(e){return Re(e.r)?[e.k,e.v]:Ze(e.r)}function Qe(e,t,n,r=Ie,i=Ie){return{k:e,l:r,lvl:n,r:i,v:t}}function $e(e){return tt(et(e))}function et(e){let{l:t}=e;return!Re(t)&&t.lvl===e.lvl?Je(t,{r:Je(e,{l:t.r})}):e}function tt(e){let{lvl:t,r:n}=e;return!Re(n)&&!Re(n.r)&&n.lvl===t&&n.r.lvl===t?Je(n,{l:Je(e,{r:n.l}),lvl:t+1}):e}function nt(e){return Le(e,({k:e,v:t})=>({index:e,value:t}))}function rt(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function it(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var at=pe(()=>({recalcInProgress:G(!1)}),[],{singleton:!0});function ot(e,t,n){return e[st(e,t,n)]}function st(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function ct(e,t,n,r){let i=st(e,t,r),a=st(e,n,r,i);return e.slice(i,a+1)}function lt(e,t){return Math.round(e.getBoundingClientRect()[t])}function ut(e){return!Re(e.groupOffsetTree)}function dt({index:e},t){return t===e?0:t=r||i===a)&&(e=We(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=Ve(e,t+1,a));c&&(e=Ve(e,a,i))}return[e,n]}function mt(e){return typeof e.groupIndex<`u`}function ht({offset:e},t){return t===e?0:t0?s+n:s}function _t(e,t){if(!ut(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function vt(e,t,n){if(mt(e))return t.groupIndices[e.groupIndex]+1;let r=_t(e.index===`LAST`?n:e.index,t);return r=Math.max(0,r,Math.min(n,r)),r}function yt(e,t,n,r=0){return r>0&&(t=Math.max(t,ot(e,r,dt).offset)),Le(ct(e,t,n,ht),wt)}function bt(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,ve.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&Re(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>Ve(Ve(t,n,e),n+1,r),o)}else [o,s]=pt(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=Ct(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>Ve(e,t,gt(t,d,i)),He()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function xt(e){return Ge(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function St(e,t){let n=0,r=0;for(;ne.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var Et={offsetHeight:`height`,offsetWidth:`width`},Dt=pe(([{log:e},{recalcInProgress:t}])=>{let n=K(),r=K(),i=de(r,0),a=K(),o=K(),s=G(0),c=G([]),l=G(void 0),u=G(void 0),d=G(void 0),f=G(void 0),p=G((e,t)=>lt(e,Et[t])),m=G(void 0),h=G(0),g=ft(),_=de(U(n,W(c,e,h),oe(bt,g),B()),g),v=de(U(c,B(),oe((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),H(({prev:e})=>e)),[]);I(U(c,V(e=>e.length>0),W(_,h),H(([e,t,n])=>{let r=e.reduce((e,r,i)=>Ve(e,r,gt(r,t.offsetTree,n)||i),He());return{...t,groupIndices:e,groupOffsetTree:r}})),_),I(U(r,W(_),V(([e,{lastIndex:t}])=>e[{endIndex:t,size:n,startIndex:e}])),n),I(l,u);let y=de(U(l,H(e=>e===void 0)),!0);I(U(u,V(e=>e!==void 0&&Re(F(_).sizeTree)),H(e=>{let t=F(d),n=F(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),I(U(f,V(e=>e!==void 0&&e.length>0&&Re(F(_).sizeTree)),H(e=>{let t=[],n=e[0],r=0;for(let i=1;ie!==void 0&&t!==void 0),H(([e,t,n])=>{let r=[];for(let i=0;i({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),H(e=>e.changed)));N(U(s,oe((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),H(e=>e.diff)),e=>{let{groupIndices:n}=F(_);if(e>0)P(t,!0),P(a,e+St(e,n));else if(e<0){let t=F(v);t.length>0&&(e-=St(-e,t)),P(o,e)}}),N(U(s,W(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},ve.ERROR)});let x=fe(a);I(U(a,W(_),H(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=ze(t.sizeTree,0),a=0,o=0;for(;a{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return Ge(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=fe(U(o,W(_,h),H(([e,{offsetTree:t},n])=>gt(-e,t,n))));return I(U(o,W(_,h),H(([e,t,n])=>{if(t.groupIndices.length>0){if(Re(t.sizeTree))return t;let r=He(),i=F(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=Ge(t.sizeTree).reduce((t,{k:n,v:r})=>Ve(t,Math.max(0,n+e),r),r),a!==-e){let n=ze(t.sizeTree,s);r=Ve(r,0,n);let i=Be(t.sizeTree,-e+1)[1];r=Ve(r,1,i)}return{...t,sizeTree:r,...Ct(t.offsetTree,0,r,n)}}let r=Ge(t.sizeTree).reduce((t,{k:n,v:r})=>Ve(t,Math.max(0,n+e),r),He());return{...t,sizeTree:r,...Ct(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},M(xe,at),{singleton:!0});function Ot(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var kt=pe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=K(),o=K(),s=fe(U(a,H(Ot)));return I(U(s,H(e=>e.totalCount)),n),I(U(s,H(e=>e.groupIndices)),e),I(U(ge(i,t,r),V(([e,t])=>ut(t)),H(([e,t,n])=>Be(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),B(),H(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},M(Dt,Fe)),At=pe(([{log:e}])=>{let t=G(!1),n=fe(U(t,V(e=>e),B()));return N(t,t=>{t&&F(e)(`props updated`,{},ve.DEBUG)}),{didMount:n,propsReady:t}},M(xe),{singleton:!0}),jt=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function Mt(e){let t=typeof e==`number`?{index:e}:e;return t.align||=`start`,(!t.behavior||!jt)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var Nt=pe(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=K(),m=K(),h=G(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),P(c,!1)}return I(U(p,W(n,d,r,h,s,o,f),W(e,a,i),H(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=Mt(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=vt(b,n,w),E=gt(T,n.offsetTree,d)+o;x===`end`?(E+=f+Be(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+Be(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},ve.DEBUG),P(p,e)):(P(m,!0),l(`list did not change, scroll successful`,{},ve.DEBUG))};if(y(),S===`smooth`){let e=!1;v=N(t,t=>{e||=t}),g=L(u,()=>{D(e)})}else g=L(U(t,Pt(150)),D);return _=setTimeout(()=>{y()},1200),P(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},ve.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},M(Dt,Fe,xe),{singleton:!0});function Pt(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function Ft(e,t){e===0?t():requestAnimationFrame(()=>{Ft(e-1,t)})}function It(e,t){let n=t-1;return typeof e==`number`?e:e.index===`LAST`?n:e.index}var Lt=pe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=G(!0),c=G(0),l=G(!0);return I(U(o,W(c),V(([e,t])=>t!==0),ae(!1)),s),I(U(o,W(c),V(([e,t])=>t!==0),ae(!1)),l),N(U(ge(t,o),W(s,n,e,l),V(([[,e],t,{sizeTree:n},r,i])=>e&&(!Re(n)||k(r))&&!t&&!i),W(c)),([,e])=>{L(i,()=>{P(l,!0)}),Ft(4,()=>{L(r,()=>{P(s,!0)}),P(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},M(Dt,Fe,Nt,At),{singleton:!0});function Rt(e,t){return Math.abs(e-t)<1.01}var zt=`up`,Bt=`down`,Vt=`none`,Ht={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Ut=0,Wt=pe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=G(!1),s=G(!0),c=K(),l=K(),u=G(4),d=G(Ut),f=de(U(_e(U(q(i),se(1),ae(!0)),U(q(i),se(1),ae(!1),R(100))),B()),!1),p=de(U(_e(U(n,ae(!0)),U(n,ae(!1),R(200))),B()),!1);I(U(ge(q(i),q(d)),H(([e,t])=>e<=t),B()),s),I(U(s,ce(50)),l);let m=fe(U(ge(r,q(a),q(t),q(e),q(u)),oe((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:re!==void 0&&e.atBottom===t.atBottom))),h=de(U(r,oe((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!Rt(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),V(e=>e.changed),H(e=>e.jump)),0);I(U(m,H(e=>e.atBottom)),o),I(U(o,ce(50)),c);let g=G(Bt);I(U(r,H(({scrollTop:e})=>e),B(),oe((e,t)=>F(p)?{direction:e.direction,prevScrollTop:t}:{direction:te.direction)),g),I(U(r,ce(50),ae(Vt)),g);let _=G(0);return I(U(f,V(e=>!e),ae(0)),_),I(U(i,ce(100),W(f),V(([e,t])=>t),oe(([e,t],[n])=>[t,n],[0,0]),H(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},M(Fe)),Gt=`top`,Kt=`bottom`,qt=`none`;function Jt(e,t,n){return typeof e==`number`?n===zt&&t===Gt||n===Bt&&t===Kt?e:0:n===zt?t===Gt?e.main:e.reverse:t===Kt?e.main:e.reverse}function Yt(e,t){return typeof e==`number`?e:e[t]??0}var Xt=pe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=K(),o=G(0),s=G(0),c=G(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:de(U(ge(q(r),q(i),q(n),q(a,it),q(c),q(o),q(t),q(e),q(s)),H(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=qt,m=Yt(l,Gt),h=Yt(l,Kt);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=zt),ie!==null),B(it)),[0,0])}},M(Fe),{singleton:!0});function Zt(e,t,n){if(ut(t)){let r=_t(e,t);return[{index:Be(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var Qt={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function $t(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:tn(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:tn(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function en(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=It(t,s);return $t(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function tn(e,t,n){if(e.length===0)return[];if(!ut(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=Ue(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end{let h=G([]),g=G(0),_=K(),v=G(0);I(a.topItemsIndexes,h);let y=de(U(ge(p,m,q(c,it),q(i),q(r),q(l),u,q(h),q(t),q(n),q(v),e),V(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),H(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=F(g);if(n===0)return{...Qt,totalCount:n};if(e===0&&t===0)return m===0?{...Qt,totalCount:n}:en(m,i,r,s,c,u||[]);if(Re(p))return m>0?null:$t(Zt(It(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of Ue(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return $t([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=yt(f,e,t,_);if(v.length===0)return null;let y=n-1,b=j([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=nn(l,Gt),S=nn(l,Kt);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=Ue(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.indexe!==null),B()),Qt);I(U(e,V(k),H(e=>e?.length)),i),I(U(y,H(e=>e.topListHeight)),d),I(d,s),I(U(y,H(e=>[e.top,e.bottom])),o),I(U(y,H(e=>e.items)),_);let b=fe(U(y,V(({items:e})=>e.length>0),W(i,e),V(([{items:e},t])=>e[e.length-1].originalIndex===t-1),H(([,e,t])=>[e-1,t]),B(it),H(([e])=>e))),x=fe(U(y,ce(200),V(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),H(({items:e})=>e[0].index),B()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:fe(U(y,V(({items:e})=>e.length>0),H(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&tt;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),B(rt))),startReached:x,topItemsIndexes:h,...f}},M(Dt,kt,Xt,Lt,Nt,Wt,At,at),{singleton:!0}),an=pe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=K(),o=de(U(ge(n,e,r,t,i),H(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return I(q(o),a),{totalListHeight:o,totalListHeightChanged:a}},M(Fe,rn),{singleton:!0}),on=pe(([{viewportHeight:e},{totalListHeight:t}])=>{let n=G(!1);return{alignToBottom:n,paddingTopAddition:de(U(ge(n,e,t),V(([e])=>e),H(([,e,t])=>Math.max(0,e-t)),ce(0),B()),0)}},M(Fe,an),{singleton:!0}),sn=pe(()=>({context:G(null)})),cn=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>ta?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,ln=pe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=K();return I(U(u,W(t,c,n,a,i,r,s),W(e),H(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=cn,done:d,...f}=e,p=vt(e,t,r-1),m=gt(p,t.offsetTree,l)+i+a,h=m+Be(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&L(U(o,V(e=>!e),se(F(o)?1:2)),d),_}),V(e=>e!==null)),l),{scrollIntoView:u}},M(Dt,Fe,Nt,rn,xe),{singleton:!0});function un(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var dn=(e,t)=>typeof e==`function`?un(e(t)):t&&un(e),fn=pe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=G(!1),h=K(),g=null;function _(e){P(o,{align:`end`,behavior:e,index:`LAST`})}N(U(ge(U(q(t),se(1)),c),W(q(m),a,s,d),H(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=dn(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),V(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),F(n)===void 0?g=L(e,()=>{F(u)(`following output to `,{totalCount:r},ve.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{F(u)(`following output to `,{totalCount:r},ve.DEBUG),_(t)})});function v(e){let t=L(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(F(u)(`scrolling to bottom due to increased size`,{},ve.DEBUG),_(`auto`))});setTimeout(t,100)}N(U(ge(q(m),t,l),V(([e,,t])=>e!==!1&&t),oe(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),V(({refreshed:e})=>e),W(m,t)),([,e])=>{F(s)&&v(e!==!1)}),N(h,()=>{v(F(m)!==!1)}),N(ge(q(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=G(null),b=K();return I(_e(U(q(r),H(e=>e?.length??0)),U(q(t))),b),N(U(ge(U(b,se(1)),c),W(q(y),s,d,f),H(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),V(e=>!!e),ce(0)),t=>{g!==null&&(g(),g=null),F(n)===void 0?g=L(e,()=>{F(u)(`scrolling into view`,{}),P(p,t),g=null}):requestAnimationFrame(()=>{F(u)(`scrolling into view`,{}),P(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},M(Dt,Wt,Nt,Lt,At,xe,Fe,sn,ln)),pn=pe(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(I(U(s,W(a),V(([,e])=>e!==0),W(i,r,t,n,e),H(([[,e],t,n,r,i,a=[]])=>en(e,t,n,r,i,a))),o),{}),M(Dt,Lt,rn,At),{singleton:!0}),mn=pe(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=G(0);return N(U(e,W(r),V(([,e])=>e!==0),H(([,e])=>({top:e}))),e=>{L(U(n,se(1),V(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{P(t,e)})})}),{initialScrollTop:r}},M(At,Fe,rn),{singleton:!0}),hn=pe(([{scrollVelocity:e}])=>{let t=G(!1),n=K(),r=G(!1);return I(U(e,W(r,t,n),V(([e,t])=>t!==!1&&t!==void 0),H(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),B()),t),N(U(ge(t,e,n),W(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},M(Wt),{singleton:!0}),gn=pe(([{scrollContainerState:e,scrollTo:t}])=>{let n=K(),r=K(),i=K(),a=G(!1),o=G(void 0);return I(U(ge(n,r),H(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),I(U(t,W(r),H(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},M(Fe)),_n=pe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=K(),u=G(void 0),d=G(null),f=G(null);return I(s,d),I(c,f),N(U(l,W(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=xt(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),I(U(u,V(k),H(vn)),i),I(U(a,W(u),V(([,e])=>e!==void 0),B(),H(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},M(Dt,Fe,Lt,At,gn));function vn(e){return{align:`start`,index:0,offset:e.scrollTop}}var yn=pe(([{topItemsIndexes:e}])=>{let t=G(0);return I(U(t,V(e=>e>=0),H(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},M(rn));function bn(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var xn=bn(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Sn=pe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:ee,...te}=b;return I(ee,T.scrollSeekRangeChanged),I(U(T.windowViewportRect,H(e=>e.visibleHeight)),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:ee,...te,...T,..._,sizes:u,...v}},M(Dt,Lt,Fe,_n,fn,rn,Nt,pe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=fe(U(c,W(o),oe(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),V(([e])=>e!==0),W(r,s,n,i,p,m),V(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===zt),H(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},ve.DEBUG),e))));function g(n){n>0?(P(t,{behavior:`auto`,top:-n}),P(e,0)):(P(e,0),P(t,{behavior:`auto`,top:-n}))}return N(U(h,W(e,a)),([t,n,r])=>{r&&xn()?P(e,n-t):g(-t)}),N(U(ge(de(a,!1),e,m),V(([e,t,n])=>!e&&!n&&t!==0),H(([e,t])=>t),ce(1)),g),I(U(d,H(e=>({top:-e}))),t),N(U(l,W(f,u),H(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=ze(r,0),c=0,l=0;for(;ce&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{P(e,n),requestAnimationFrame(()=>{P(t,{top:n}),requestAnimationFrame(()=>{P(e,0),P(m,!1)})})}),{deviation:e}},M(Fe,Wt,rn,Dt,xe,at)),yn,kt,pe(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),M(Xt,pn,At,hn,an,mn,on,gn,ln,xe,sn))));function Cn(e,t){let n={},r={},i=0,a=e.length;for(;i(n[r]=n=>{let i=e[t.methods[r]];P(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=ue(e[t.events[r]]),n),{})}return{Component:_.forwardRef(function(t,a){let{children:d,...f}=t,[p]=_.useState(()=>j(he(e),e=>{c(e,f)})),[m]=_.useState(ee(u,p));wn(()=>{for(let e of o)e in f&&N(m[e],f[e]);return()=>{Object.values(m).map(ie)}},[f,m,p]),wn(()=>{c(p,f)}),_.useImperativeHandle(a,E(l(p)));let h=n;return(0,b.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,b.jsx)(h,{...Cn([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=_.useContext(s)[e];wn(()=>N(n,t),[t,n])},useEmitterValue:e=>{let t=_.useContext(s)[e],n=_.useCallback(e=>N(t,e),[t]);return _.useSyncExternalStore(n,()=>F(t),()=>F(t))},usePublisher:e=>{let t=_.useContext(s);return _.useCallback(n=>{P(t[e],n)},[t,e])}}}var En=_.createContext(void 0),Dn=_.createContext(void 0),On=`-webkit-sticky`,kn=`sticky`,An=bn(()=>{if(typeof document>`u`)return kn;let e=document.createElement(`div`);return e.style.position=On,e.style.position===On?On:kn}),jn=typeof document<`u`?_.useLayoutEffect:_.useEffect;function Mn(e){return`self`in e}function Nn(e){return`body`in e}function Pn(e,t,n,r=A,i,a){let o=_.useRef(null),s=_.useRef(null),c=_.useRef(null),l=_.useCallback(n=>{let r,i,o,l=n.target;if(Nn(l)||Mn(l)){let e=Mn(l)?l:l.defaultView;o=a===!0?De(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?De(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():x.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);_.useEffect(()=>{let e=i||o.current;return Te(e),r(i||o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{Te(e),r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;Mn(r)?(u=Math.max(lt(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?De(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=lt(r,a===!0?`width`:`height`),d=a===!0?De(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,Rt(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:Oe(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:Oe(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function Fn(e){return e}var In=pe(([e,t])=>({...e,...t}),M(Sn,pe(()=>{let e=G(e=>`Item ${e}`),t=G(e=>`Group ${e}`),n=G({}),r=G(Fn),i=G(`div`),a=G(A),o=(e,t=null)=>de(U(n,H(t=>t[e]),B()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),Ln=({height:e})=>(0,b.jsx)(`div`,{style:{height:e}}),Rn={overflowAnchor:`none`,position:An(),zIndex:1},zn={overflowAnchor:`none`},Bn={...zn,display:`inline-block`,height:`100%`},Vn=_.memo(function({showTopList:e=!1}){let t=J(`listState`),n=ir(`sizeRanges`),r=J(`useWindowScroll`),i=J(`customScrollParent`),a=ir(`windowScrollContainerState`),o=ir(`scrollContainerState`),s=i||r?a:o,c=J(`itemContent`),l=J(`context`),u=J(`groupContent`),d=J(`trackItemSizes`),f=J(`itemSize`),p=J(`log`),m=ir(`gap`),h=J(`horizontalDirection`),{callbackRef:g}=je(n,f,d,e?A:s,p,m,i,h,J(`skipAnimationFrameInResizeObserver`)),[v,y]=_.useState(0);rr(`deviation`,e=>{v!==e&&y(e)});let x=J(`EmptyPlaceholder`),S=J(`ScrollSeekPlaceholder`)??Ln,C=J(`ListComponent`),w=J(`ItemComponent`),T=J(`GroupComponent`),E=J(`computeItemKey`),D=J(`isSeeking`),O=J(`groupIndices`).length>0,ee=J(`alignToBottom`),te=J(`initialItemFinalLocationReached`),k=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:v===0?ee?`auto`:0:v,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:v===0?ee?`auto`:0:v,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...te?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&x!=null?(0,b.jsx)(x,{...qn(x,l)}):(0,b.jsx)(C,{...qn(C,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:k,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=E(n+t.firstItemIndex,e.data,l);return D?(0,_.createElement)(S,{...qn(S,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,_.createElement)(T,{...qn(T,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:Rn},u(e.index,l)):(0,_.createElement)(w,{...qn(w,l),...Jn(w,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?Bn:zn},O?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),Hn={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},Un={outline:`none`,overflowX:`auto`,position:`relative`},Wn=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),Gn=(e,t,n=0)=>({...Wn(e),position:t?`relative`:`absolute`,top:t?-n:0}),Kn={position:An(),top:0,width:`100%`,zIndex:1};function qn(e,t){if(typeof e!=`string`)return{context:t}}function Jn(e,t){return{item:typeof e==`string`?void 0:t}}var Yn=_.memo(function(){let e=J(`HeaderComponent`),t=ir(`headerHeight`),n=J(`HeaderFooterTag`),r=ke(_.useMemo(()=>e=>{t(lt(e,`height`))},[t]),!0,J(`skipAnimationFrameInResizeObserver`)),i=J(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...qn(e,i)})})}),Xn=_.memo(function(){let e=J(`FooterComponent`),t=ir(`footerHeight`),n=J(`HeaderFooterTag`),r=ke(_.useMemo(()=>e=>{t(lt(e,`height`))},[t]),!0,J(`skipAnimationFrameInResizeObserver`)),i=J(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...qn(e,i)})})});function Zn({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=Pn(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,b.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?Un:Hn,...i},tabIndex:0,...o,...qn(c,a),children:r})})}function Qn({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=_.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=Pn(s,l,c,t(`scrollerRef`),f);return jn(()=>(h.current=f||p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,b.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...qn(c,a),children:r})})}var $n=({children:e})=>{let t=_.useContext(En),n=ir(`viewportHeight`),r=ir(`fixedItemHeight`),i=J(`alignToBottom`),a=J(`horizontalDirection`),o=ke(_.useMemo(()=>O(n,e=>lt(e,a?`width`:`height`)),[n,a]),!0,J(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:Wn(i),children:e})},er=({children:e})=>{let t=_.useContext(En),n=ir(`windowViewportRect`),r=ir(`fixedItemHeight`),i=J(`customScrollParent`),a=J(`useWindowScroll`),o=J(`topListHeight`),s=Pe(n,i,J(`skipAnimationFrameInResizeObserver`)),c=J(`alignToBottom`);return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:Gn(c,a,o),children:e})},tr=({children:e})=>{let t=J(`TopItemListComponent`)??`div`,n=J(`headerHeight`);return(0,b.jsx)(t,{style:{...Kn,marginTop:`${n}px`},...qn(t,J(`context`)),children:e})},{Component:nr,useEmitter:rr,useEmitterValue:J,usePublisher:ir}=Tn(In,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=J(`useWindowScroll`),n=J(`topItemsIndexes`).length>0,r=J(`customScrollParent`),i=J(`context`);return(0,b.jsxs)(r||t?or:ar,{...e,context:i,children:[n&&(0,b.jsx)(tr,{children:(0,b.jsx)(Vn,{showTopList:!0})}),(0,b.jsxs)(r||t?er:$n,{children:[(0,b.jsx)(Yn,{}),(0,b.jsx)(Vn,{}),(0,b.jsx)(Xn,{})]})]})})),ar=Zn({useEmitter:rr,useEmitterValue:J,usePublisher:ir}),or=Qn({useEmitter:rr,useEmitterValue:J,usePublisher:ir}),sr=nr,cr=pe(([e,t])=>({...e,...t}),M(Sn,pe(()=>{let e=G(e=>(0,b.jsxs)(`td`,{children:[`Item $`,e]})),t=G(null),n=G(e=>(0,b.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=G(null),i=G(null),a=G({}),o=G(Fn),s=G(A),c=(e,t=null)=>de(U(a,H(t=>t[e]),B()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),lr=({height:e})=>(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{style:{height:e}})}),ur=({height:e})=>(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),dr={overflowAnchor:`none`},fr={position:An(),zIndex:2,overflowAnchor:`none`},pr=_.memo(function({showTopList:e=!1}){let t=Y(`listState`),n=Y(`computeItemKey`),r=Y(`firstItemIndex`),i=Y(`context`),a=Y(`isSeeking`),o=Y(`fixedHeaderHeight`),s=Y(`groupIndices`).length>0,c=Y(`itemContent`),l=Y(`groupContent`),u=Y(`ScrollSeekPlaceholder`)??lr,d=Y(`GroupComponent`),f=Y(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,_.createElement)(u,{...qn(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,_.createElement)(d,{...qn(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...fr,top:o}},l(t.index,i)):(0,_.createElement)(f,{...qn(f,i),...Jn(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...fr,top:o+g}:dr},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),mr=_.memo(function(){let e=Y(`listState`),t=Y(`topItemsIndexes`).length>0,n=yr(`sizeRanges`),r=Y(`useWindowScroll`),i=Y(`customScrollParent`),a=yr(`windowScrollContainerState`),o=yr(`scrollContainerState`),s=i||r?a:o,c=Y(`trackItemSizes`),{callbackRef:l,ref:u}=je(n,Y(`itemSize`),c,s,Y(`log`),void 0,i,!1,Y(`skipAnimationFrameInResizeObserver`)),[d,f]=_.useState(0);vr(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=Y(`EmptyPlaceholder`),m=Y(`FillerRow`)??ur,h=Y(`TableBodyComponent`),g=Y(`paddingTopAddition`),v=Y(`statefulTotalCount`),y=Y(`context`);if(v===0&&p!=null)return(0,b.jsx)(p,{...qn(p,y)});let x=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),S=e.offsetTop+g+d-x,C=e.offsetBottom,w=S>0?(0,b.jsx)(m,{context:y,height:S},`padding-top`):null,T=C>0?(0,b.jsx)(m,{context:y,height:C},`padding-bottom`):null;return(0,b.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...qn(h,y),children:[w,t&&(0,b.jsx)(pr,{showTopList:!0}),(0,b.jsx)(pr,{}),T]})}),hr=({children:e})=>{let t=_.useContext(En),n=yr(`viewportHeight`),r=yr(`fixedItemHeight`),i=ke(_.useMemo(()=>O(n,e=>lt(e,`height`)),[n]),!0,Y(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:Wn(!1),children:e})},gr=({children:e})=>{let t=_.useContext(En),n=yr(`windowViewportRect`),r=yr(`fixedItemHeight`),i=Y(`customScrollParent`),a=Y(`useWindowScroll`),o=Pe(n,i,Y(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,b.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:Gn(!1,a),children:e})},{Component:_r,useEmitter:vr,useEmitterValue:Y,usePublisher:yr}=Tn(cr,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=Y(`useWindowScroll`),n=Y(`customScrollParent`),r=yr(`fixedHeaderHeight`),i=yr(`fixedFooterHeight`),a=Y(`fixedHeaderContent`),o=Y(`fixedFooterContent`),s=Y(`context`),c=ke(_.useMemo(()=>O(r,e=>lt(e,`height`)),[r]),!0,Y(`skipAnimationFrameInResizeObserver`)),l=ke(_.useMemo(()=>O(i,e=>lt(e,`height`)),[i]),!0,Y(`skipAnimationFrameInResizeObserver`)),u=n||t?xr:br,d=n||t?gr:hr,f=Y(`TableComponent`),p=Y(`TableHeadComponent`),m=Y(`TableFooterComponent`),h=a?(0,b.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...qn(p,s),children:a()},`TableHead`):null,g=o?(0,b.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...qn(m,s),children:o()},`TableFoot`):null;return(0,b.jsx)(u,{...e,...qn(u,s),children:(0,b.jsx)(d,{children:(0,b.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...qn(f,s),children:[h,(0,b.jsx)(mr,{},`TableBody`),g]})})})})),br=Zn({useEmitter:vr,useEmitterValue:Y,usePublisher:yr}),xr=Qn({useEmitter:vr,useEmitterValue:Y,usePublisher:yr}),Sr={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Cr={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:wr,floor:Tr,max:Er,min:Dr,round:Or}=Math;function kr(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function Ar(e){return{...Cr,items:e}}function jr(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function Mr(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var Nr=pe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=G(0),C=G(0),w=G(Sr),T=G({height:0,width:0}),E=G({height:0,width:0}),D=K(),O=K(),ee=G(0),te=G(null),k=G({column:0,row:0}),ne=K(),A=K(),j=G(!1),re=G(0),M=G(!0),ie=G(!1),F=G(!1);N(U(m,W(re),V(([e,t])=>t!==0)),()=>{P(M,!1)}),N(U(ge(m,M,E,T,re,ie),V(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{P(ie,!0),Ft(1,()=>{P(D,e)}),L(U(l),()=>{P(t,[0,0]),P(M,!0)})}),I(U(A,V(e=>e!=null&&e.scrollTop>0),ae(0)),C),N(U(m,W(A),V(([,e])=>e!=null)),([,e])=>{e&&(P(T,e.viewport),P(E,e.item),P(k,e.gap),e.scrollTop>0&&(P(j,!0),L(U(l,se(1)),e=>{P(j,!1)}),P(c,{top:e.scrollTop})))}),I(U(T,H(({height:e})=>e)),d),I(U(ge(q(T,jr),q(E,jr),q(k,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),q(l)),H(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),ne),I(U(ge(q(S),r,q(k,Mr),q(E,jr),q(T,jr),q(te),q(C),q(j),q(M),q(re)),V(([,,,,,,,e])=>!e),H(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return Sr;if(p===0){let t=It(l,e);return Ar(kr(t,t+Math.max(s-1,0),o))}let h=Pr(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*Tr((t+d)/(f+d)),_=h*wr((n+d)/(f+d))-1,_=Dr(e-1,Er(_,h-1)),g=Dr(_,Er(0,g))):(g=0,_=-1);let v=kr(g,_,o),{bottom:y,top:b}=Fr(a,r,i,v),x=wr(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),I(U(te,V(e=>e!==null),H(e=>e.length)),S),I(U(ge(T,E,w,k),V(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),H(([e,t,{items:n},r])=>{let{bottom:i,top:a}=Fr(e,r,t,n);return[a,i]}),B(it)),t);let R=G(!1);I(U(l,W(R),H(([e,t])=>t||e!==0)),R);let z=fe(U(ge(w,S),V(([{items:e}])=>e.length>0),W(R),V(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),H(([[,e]])=>e-1),B())),oe=fe(U(q(w),V(({items:e})=>e.length>0&&e[0].index===0),ae(0),B())),le=fe(U(q(w),W(j),V(([{items:e},t])=>e.length>0&&!t),H(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),B(rt),ce(0)));I(le,p.scrollSeekRangeChanged),I(U(D,W(T,E,S,k),H(([e,t,n,r,i])=>{let a=Mt(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=Er(0,l,Dr(r-1,l));let u=Ir(t,i,n,l);return o===`end`?u=Or(u-t.height+n.height):o===`center`&&(u=Or(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let ue=de(U(w,H(e=>e.offsetBottom+e.bottom)),0);return I(U(b,H(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:te,deviation:ee,footerHeight:i,gap:k,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:A,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:F,initialTopMostItemIndex:re,totalListHeight:ue,...f,endReached:z,propsReady:h,rangeChanged:le,startReached:oe,stateChanged:ne,stateRestoreInProgress:j,...x}},M(Xt,Fe,Wt,hn,At,gn,xe));function Pr(e,t,n){return Er(1,Tr((e+n)/(Tr(t)+n)))}function Fr(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=Ir(e,t,n,r[0].index);return{bottom:Ir(e,t,n,r[r.length-1].index)+i,top:a}}function Ir(e,t,n,r){let i=Tr(r/Pr(e.width,n.width,t.column)),a=i*n.height+Er(0,i-1)*t.row;return a>0?a+t.row:a}var Lr=pe(([e,t])=>({...e,...t}),M(Nr,pe(()=>{let e=G(e=>`Item ${e}`),t=G({}),n=G(null),r=G(`virtuoso-grid-item`),i=G(`virtuoso-grid-list`),a=G(Fn),o=G(`div`),s=G(A),c=(e,n=null)=>de(U(t,H(t=>t[e]),B()),n),l=G(!1),u=G(!1);return I(q(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),Rr=_.memo(function(){let e=Gr(`gridState`),t=Gr(`listClassName`),n=Gr(`itemClassName`),r=Gr(`itemContent`),i=Gr(`computeItemKey`),a=Gr(`isSeeking`),o=Kr(`scrollHeight`),s=Gr(`ItemComponent`),c=Gr(`ListComponent`),l=Gr(`ScrollSeekPlaceholder`),u=Gr(`context`),d=Kr(`itemDimensions`),f=Kr(`gap`),p=Gr(`log`),m=Gr(`stateRestoreInProgress`),h=Kr(`reportReadyState`),g=ke(_.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:Yr(`column-gap`,getComputedStyle(e).columnGap,p),row:Yr(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return jn(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,b.jsx)(c,{className:t,ref:g,...qn(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,b.jsx)(l,{...qn(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,_.createElement)(s,{...qn(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),zr=_.memo(function(){let e=Gr(`HeaderComponent`),t=Kr(`headerHeight`),n=Gr(`headerFooterTag`),r=ke(_.useMemo(()=>e=>{t(lt(e,`height`))},[t]),!0,!1),i=Gr(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...qn(e,i)})})}),Br=_.memo(function(){let e=Gr(`FooterComponent`),t=Kr(`footerHeight`),n=Gr(`headerFooterTag`),r=ke(_.useMemo(()=>e=>{t(lt(e,`height`))},[t]),!0,!1),i=Gr(`context`);return e==null?null:(0,b.jsx)(n,{ref:r,children:(0,b.jsx)(e,{...qn(e,i)})})}),Vr=({children:e})=>{let t=_.useContext(Dn),n=Kr(`itemDimensions`),r=Kr(`viewportDimensions`),i=ke(_.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return _.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,b.jsx)(`div`,{ref:i,style:Wn(!1),children:e})},Hr=({children:e})=>{let t=_.useContext(Dn),n=Kr(`windowViewportRect`),r=Kr(`itemDimensions`),i=Gr(`customScrollParent`),a=Gr(`useWindowScroll`),o=Pe(n,i,!1);return _.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,b.jsx)(`div`,{ref:o,style:Gn(!1,a),children:e})},{Component:Ur,useEmitter:Wr,useEmitterValue:Gr,usePublisher:Kr}=Tn(Lr,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},_.memo(function({...e}){let t=Gr(`useWindowScroll`),n=Gr(`customScrollParent`),r=n||t?Jr:qr,i=n||t?Hr:Vr,a=Gr(`context`);return(0,b.jsx)(r,{...e,...qn(r,a),children:(0,b.jsxs)(i,{children:[(0,b.jsx)(zr,{}),(0,b.jsx)(Rr,{}),(0,b.jsx)(Br,{})]})})})),qr=Zn({useEmitter:Wr,useEmitterValue:Gr,usePublisher:Kr}),Jr=Qn({useEmitter:Wr,useEmitterValue:Gr,usePublisher:Kr});function Yr(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,ve.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Xr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Zr=_.createContext&&_.createContext(Xr),Qr=[`attr`,`size`,`title`];function $r(e,t){if(e==null)return{};var n,r,i=ei(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r_.createElement(e.tag,ri({key:t},e.attr),si(e.child)))}function X(e){return t=>_.createElement(ci,ti({attr:ri({},e.attr)},t),si(e.child))}function ci(e){var t=t=>{var{attr:n,size:r,title:i}=e,a=$r(e,Qr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),_.createElement(`svg`,ti({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ri(ri({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&_.createElement(`title`,null,i),e.children)};return Zr===void 0?t(Xr):_.createElement(Zr.Consumer,null,e=>t(e))}function li(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.72 5.72a.75.75 0 0 1 1.06 0L12 10.94l5.22-5.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L13.06 12l5.22 5.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L12 13.06l-5.22 5.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L10.94 12 5.72 6.78a.75.75 0 0 1 0-1.06Z`},child:[]}]})(e)}function ui(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`m12.354 8.854 5.792 5.792a.5.5 0 0 1-.353.854H6.207a.5.5 0 0 1-.353-.854l5.792-5.792a.5.5 0 0 1 .708 0Z`},child:[]}]})(e)}function di(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M11.646 15.146 5.854 9.354a.5.5 0 0 1 .353-.854h11.586a.5.5 0 0 1 .353.854l-5.793 5.792a.5.5 0 0 1-.707 0Z`},child:[]}]})(e)}function fi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M10.25 2a8.25 8.25 0 0 1 6.34 13.53l5.69 5.69a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-5.69-5.69A8.25 8.25 0 1 1 10.25 2ZM3.5 10.25a6.75 6.75 0 1 0 13.5 0 6.75 6.75 0 0 0-13.5 0Z`},child:[]}]})(e)}function pi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M3.5 8a5.5 5.5 0 1 1 8.596 4.547 9.005 9.005 0 0 1 5.9 8.18.751.751 0 0 1-1.5.045 7.5 7.5 0 0 0-14.993 0 .75.75 0 0 1-1.499-.044 9.005 9.005 0 0 1 5.9-8.181A5.496 5.496 0 0 1 3.5 8ZM9 4a4 4 0 1 0 0 8 4 4 0 0 0 0-8Zm8.29 4c-.148 0-.292.01-.434.03a.75.75 0 1 1-.212-1.484 4.53 4.53 0 0 1 3.38 8.097 6.69 6.69 0 0 1 3.956 6.107.75.75 0 0 1-1.5 0 5.193 5.193 0 0 0-3.696-4.972l-.534-.16v-1.676l.41-.209A3.03 3.03 0 0 0 17.29 8Z`},child:[]}]})(e)}function mi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M3 3a2 2 0 0 1 2-2h9.982a2 2 0 0 1 1.414.586l4.018 4.018A2 2 0 0 1 21 7.018V21a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2Zm2-.5a.5.5 0 0 0-.5.5v18a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V8.5h-4a2 2 0 0 1-2-2v-4Zm10 0v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 0-.146-.336l-4.018-4.018A.5.5 0 0 0 15 2.5Z`},child:[]}]})(e)}function hi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M12.5 7.25a.75.75 0 0 0-1.5 0v5.5c0 .27.144.518.378.651l3.5 2a.75.75 0 0 0 .744-1.302L12.5 12.315V7.25Z`},child:[]},{tag:`path`,attr:{d:`M12 1c6.075 0 11 4.925 11 11s-4.925 11-11 11S1 18.075 1 12 5.925 1 12 1ZM2.5 12a9.5 9.5 0 0 0 9.5 9.5 9.5 9.5 0 0 0 9.5-9.5A9.5 9.5 0 0 0 12 2.5 9.5 9.5 0 0 0 2.5 12Z`},child:[]}]})(e)}function gi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M18.78 15.78a.749.749 0 0 1-1.06 0L12 10.061 6.28 15.78a.749.749 0 1 1-1.06-1.06l6.25-6.25a.749.749 0 0 1 1.06 0l6.25 6.25a.749.749 0 0 1 0 1.06Z`},child:[]}]})(e)}function _i(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M5.22 8.22a.749.749 0 0 0 0 1.06l6.25 6.25a.749.749 0 0 0 1.06 0l6.25-6.25a.749.749 0 1 0-1.06-1.06L12 13.939 6.28 8.22a.749.749 0 0 0-1.06 0Z`},child:[]}]})(e)}function vi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M18.655 10.405a.75.75 0 0 1-1.06 0l-4.97-4.97v14.44a.75.75 0 0 1-1.5 0V5.435l-4.97 4.97a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734l6.25-6.25a.75.75 0 0 1 1.06 0l6.25 6.25a.75.75 0 0 1 0 1.06Z`},child:[]}]})(e)}function yi(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{d:`M7.72 21.78a.75.75 0 0 0 1.06-1.06L5.56 17.5h14.69a.75.75 0 0 0 0-1.5H5.56l3.22-3.22a.75.75 0 1 0-1.06-1.06l-4.5 4.5a.75.75 0 0 0 0 1.06l4.5 4.5Zm8.56-9.5a.75.75 0 1 1-1.06-1.06L18.44 8H3.75a.75.75 0 0 1 0-1.5h14.69l-3.22-3.22a.75.75 0 0 1 1.06-1.06l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5Z`},child:[]}]})(e)}var bi=c(o(((e,t)=>{var n=`Expected a function`,r=NaN,i=`[object Symbol]`,a=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt,u=typeof global==`object`&&global&&global.Object===Object&&global,d=typeof self==`object`&&self&&self.Object===Object&&self,f=u||d||Function(`return this`)(),p=Object.prototype.toString,m=Math.max,h=Math.min,g=function(){return f.Date.now()};function _(e,t,r){var i,a,o,s,c,l,u=0,d=!1,f=!1,p=!0;if(typeof e!=`function`)throw TypeError(n);t=x(t)||0,v(r)&&(d=!!r.leading,f=`maxWait`in r,o=f?m(x(r.maxWait)||0,t):o,p=`trailing`in r?!!r.trailing:p);function _(t){var n=i,r=a;return i=a=void 0,u=t,s=e.apply(r,n),s}function y(e){return u=e,c=setTimeout(C,t),d?_(e):s}function b(e){var n=e-l,r=e-u,i=t-n;return f?h(i,o-r):i}function S(e){var n=e-l,r=e-u;return l===void 0||n>=t||n<0||f&&r>=o}function C(){var e=g();if(S(e))return w(e);c=setTimeout(C,b(e))}function w(e){return c=void 0,p&&i?_(e):(i=a=void 0,s)}function T(){c!==void 0&&clearTimeout(c),u=0,i=l=a=c=void 0}function E(){return c===void 0?s:w(g())}function D(){var e=g(),n=S(e);if(i=arguments,a=this,l=e,n){if(c===void 0)return y(l);if(f)return c=setTimeout(C,t),_(l)}return c===void 0&&(c=setTimeout(C,t)),s}return D.cancel=T,D.flush=E,D}function v(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function y(e){return!!e&&typeof e==`object`}function b(e){return typeof e==`symbol`||y(e)&&p.call(e)==i}function x(e){if(typeof e==`number`)return e;if(b(e))return r;if(v(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=v(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=e.replace(a,``);var n=s.test(e);return n||c.test(e)?l(e.slice(2),n?2:8):o.test(e)?r:+e}t.exports=_}))(),1),xi=({label:e,className:t})=>(0,b.jsxs)(`div`,{className:`flex gap-2 items-center ${t}`,children:[(0,b.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border animate-spin fill-primary`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,b.jsx)(`path`,{d:`M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z`,fill:`currentColor`}),(0,b.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z`,fill:`currentFill`})]}),e?(0,b.jsxs)(`span`,{children:[e,` ...`]}):(0,b.jsx)(`span`,{className:`sr-only`,children:`Loading...`})]});function Si(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708`},child:[]}]})(e)}function Ci(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293z`},child:[]}]})(e)}function wi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5m3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0z`},child:[]},{tag:`path`,attr:{d:`M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4zM2.5 3h11V2h-11z`},child:[]}]})(e)}function Ti(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0`},child:[]},{tag:`path`,attr:{d:`M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1m0 5.586 7 7L13.586 9l-7-7H2z`},child:[]}]})(e)}function Ei(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2 1a1 1 0 0 0-1 1v4.586a1 1 0 0 0 .293.707l7 7a1 1 0 0 0 1.414 0l4.586-4.586a1 1 0 0 0 0-1.414l-7-7A1 1 0 0 0 6.586 1zm4 3.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0`},child:[]}]})(e)}function Di(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 11a3 3 0 1 1 0-6 3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8 4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708`},child:[]}]})(e)}function Oi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z`},child:[]}]})(e)}function ki(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 4a.5.5 0 0 1 .5.5V6a.5.5 0 0 1-1 0V4.5A.5.5 0 0 1 8 4M3.732 5.732a.5.5 0 0 1 .707 0l.915.914a.5.5 0 1 1-.708.708l-.914-.915a.5.5 0 0 1 0-.707M2 10a.5.5 0 0 1 .5-.5h1.586a.5.5 0 0 1 0 1H2.5A.5.5 0 0 1 2 10m9.5 0a.5.5 0 0 1 .5-.5h1.5a.5.5 0 0 1 0 1H12a.5.5 0 0 1-.5-.5m.754-4.246a.39.39 0 0 0-.527-.02L7.547 9.31a.91.91 0 1 0 1.302 1.258l3.434-4.297a.39.39 0 0 0-.029-.518z`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M0 10a8 8 0 1 1 15.547 2.661c-.442 1.253-1.845 1.602-2.932 1.25C11.309 13.488 9.475 13 8 13c-1.474 0-3.31.488-4.615.911-1.087.352-2.49.003-2.932-1.25A8 8 0 0 1 0 10m8-7a7 7 0 0 0-6.603 9.329c.203.575.923.876 1.68.63C4.397 12.533 6.358 12 8 12s3.604.532 4.923.96c.757.245 1.477-.056 1.68-.631A7 7 0 0 0 8 3`},child:[]}]})(e)}function Ai(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M10.5 1a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V4H1.5a.5.5 0 0 1 0-1H10V1.5a.5.5 0 0 1 .5-.5M12 3.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5m-6.5 2A.5.5 0 0 1 6 6v1.5h8.5a.5.5 0 0 1 0 1H6V10a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5M1 8a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2A.5.5 0 0 1 1 8m9.5 2a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0V13H1.5a.5.5 0 0 1 0-1H10v-1.5a.5.5 0 0 1 .5-.5m1.5 2.5a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5`},child:[]}]})(e)}function ji(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2z`},child:[]},{tag:`path`,attr:{d:`M5.5 12a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-3-8.5a1 1 0 0 1 1-1c5.523 0 10 4.477 10 10a1 1 0 1 1-2 0 8 8 0 0 0-8-8 1 1 0 0 1-1-1m0 4a1 1 0 0 1 1-1 6 6 0 0 1 6 6 1 1 0 1 1-2 0 4 4 0 0 0-4-4 1 1 0 0 1-1-1`},child:[]}]})(e)}function Mi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4`},child:[]}]})(e)}function Ni(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1zm-7.978-1L7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002-.014.002zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4m3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0M6.936 9.28a6 6 0 0 0-1.23-.247A7 7 0 0 0 5 9c-4 0-5 3-5 4q0 1 1 1h4.216A2.24 2.24 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816M4.92 10A5.5 5.5 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275ZM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0m3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4`},child:[]}]})(e)}function Pi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M12.146.146a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1 0 .708l-10 10a.5.5 0 0 1-.168.11l-5 2a.5.5 0 0 1-.65-.65l2-5a.5.5 0 0 1 .11-.168zM11.207 2.5 13.5 4.793 14.793 3.5 12.5 1.207zm1.586 3L10.5 3.207 4 9.707V10h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.293zm-9.761 5.175-.106.106-1.528 3.821 3.821-1.528.106-.106A.5.5 0 0 1 5 12.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.468-.325`},child:[]}]})(e)}function Fi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278M4.858 1.311A7.27 7.27 0 0 0 1.025 7.71c0 4.02 3.279 7.276 7.319 7.276a7.32 7.32 0 0 0 5.205-2.162q-.506.063-1.029.063c-4.61 0-8.343-3.714-8.343-8.29 0-1.167.242-2.278.681-3.286`},child:[]}]})(e)}function Ii(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8m7.5-6.923c-.67.204-1.335.82-1.887 1.855q-.215.403-.395.872c.705.157 1.472.257 2.282.287zM4.249 3.539q.214-.577.481-1.078a7 7 0 0 1 .597-.933A7 7 0 0 0 3.051 3.05q.544.277 1.198.49zM3.509 7.5c.036-1.07.188-2.087.436-3.008a9 9 0 0 1-1.565-.667A6.96 6.96 0 0 0 1.018 7.5zm1.4-2.741a12.3 12.3 0 0 0-.4 2.741H7.5V5.091c-.91-.03-1.783-.145-2.591-.332M8.5 5.09V7.5h2.99a12.3 12.3 0 0 0-.399-2.741c-.808.187-1.681.301-2.591.332zM4.51 8.5c.035.987.176 1.914.399 2.741A13.6 13.6 0 0 1 7.5 10.91V8.5zm3.99 0v2.409c.91.03 1.783.145 2.591.332.223-.827.364-1.754.4-2.741zm-3.282 3.696q.18.469.395.872c.552 1.035 1.218 1.65 1.887 1.855V11.91c-.81.03-1.577.13-2.282.287zm.11 2.276a7 7 0 0 1-.598-.933 9 9 0 0 1-.481-1.079 8.4 8.4 0 0 0-1.198.49 7 7 0 0 0 2.276 1.522zm-1.383-2.964A13.4 13.4 0 0 1 3.508 8.5h-2.49a6.96 6.96 0 0 0 1.362 3.675c.47-.258.995-.482 1.565-.667m6.728 2.964a7 7 0 0 0 2.275-1.521 8.4 8.4 0 0 0-1.197-.49 9 9 0 0 1-.481 1.078 7 7 0 0 1-.597.933M8.5 11.909v3.014c.67-.204 1.335-.82 1.887-1.855q.216-.403.395-.872A12.6 12.6 0 0 0 8.5 11.91zm3.555-.401c.57.185 1.095.409 1.565.667A6.96 6.96 0 0 0 14.982 8.5h-2.49a13.4 13.4 0 0 1-.437 3.008M14.982 7.5a6.96 6.96 0 0 0-1.362-3.675c-.47.258-.995.482-1.565.667.248.92.4 1.938.437 3.008zM11.27 2.461q.266.502.482 1.078a8.4 8.4 0 0 0 1.196-.49 7 7 0 0 0-2.275-1.52c.218.283.418.597.597.932m-.488 1.343a8 8 0 0 0-.395-.872C9.835 1.897 9.17 1.282 8.5 1.077V4.09c.81-.03 1.577-.13 2.282-.287z`},child:[]}]})(e)}function Li(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M1 3.5A1.5 1.5 0 0 1 2.5 2h2.764c.958 0 1.76.56 2.311 1.184C7.985 3.648 8.48 4 9 4h4.5A1.5 1.5 0 0 1 15 5.5v.64c.57.265.94.876.856 1.546l-.64 5.124A2.5 2.5 0 0 1 12.733 15H3.266a2.5 2.5 0 0 1-2.481-2.19l-.64-5.124A1.5 1.5 0 0 1 1 6.14zM2 6h12v-.5a.5.5 0 0 0-.5-.5H9c-.964 0-1.71-.629-2.174-1.154C6.374 3.334 5.82 3 5.264 3H2.5a.5.5 0 0 0-.5.5zm-.367 1a.5.5 0 0 0-.496.562l.64 5.124A1.5 1.5 0 0 0 3.266 14h9.468a1.5 1.5 0 0 0 1.489-1.314l.64-5.124A.5.5 0 0 0 14.367 7z`},child:[]}]})(e)}function Ri(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.825a2 2 0 0 1-1.991-1.819l-.637-7a2 2 0 0 1 .342-1.31L.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3m-8.322.12q.322-.119.684-.12h5.396l-.707-.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981z`},child:[]}]})(e)}function zi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5`},child:[]},{tag:`path`,attr:{d:`M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708z`},child:[]}]})(e)}function Bi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2.5 3.5a.5.5 0 0 1 0-1h11a.5.5 0 0 1 0 1zm2-2a.5.5 0 0 1 0-1h7a.5.5 0 0 1 0 1zM0 13a1.5 1.5 0 0 0 1.5 1.5h13A1.5 1.5 0 0 0 16 13V6a1.5 1.5 0 0 0-1.5-1.5h-13A1.5 1.5 0 0 0 0 6zm1.5.5A.5.5 0 0 1 1 13V6a.5.5 0 0 1 .5-.5h13a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-.5.5z`},child:[]}]})(e)}function Vi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71z`},child:[]},{tag:`path`,attr:{d:`M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0`},child:[]}]})(e)}function Hi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708`},child:[]}]})(e)}function Ui(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0`},child:[]}]})(e)}function Wi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm10.03 4.97a.75.75 0 0 1 .011 1.05l-3.992 4.99a.75.75 0 0 1-1.08.02L4.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093 3.473-4.425a.75.75 0 0 1 1.08-.022z`},child:[]}]})(e)}function Gi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z`},child:[]}]})(e)}function Ki(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707m2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708m5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708m2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM10 8a2 2 0 1 1-4 0 2 2 0 0 1 4 0`},child:[]}]})(e)}function qi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M3.05 3.05a7 7 0 0 0 0 9.9.5.5 0 0 1-.707.707 8 8 0 0 1 0-11.314.5.5 0 0 1 .707.707m2.122 2.122a4 4 0 0 0 0 5.656.5.5 0 1 1-.708.708 5 5 0 0 1 0-7.072.5.5 0 0 1 .708.708m5.656-.708a.5.5 0 0 1 .708 0 5 5 0 0 1 0 7.072.5.5 0 1 1-.708-.708 4 4 0 0 0 0-5.656.5.5 0 0 1 0-.708m2.122-2.12a.5.5 0 0 1 .707 0 8 8 0 0 1 0 11.313.5.5 0 0 1-.707-.707 7 7 0 0 0 0-9.9.5.5 0 0 1 0-.707zM6 8a2 2 0 1 1 2.5 1.937V15.5a.5.5 0 0 1-1 0V9.937A2 2 0 0 1 6 8`},child:[]}]})(e)}function Ji(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M10 12.5a.5.5 0 0 1-.5.5h-8a.5.5 0 0 1-.5-.5v-9a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 .5.5v2a.5.5 0 0 0 1 0v-2A1.5 1.5 0 0 0 9.5 2h-8A1.5 1.5 0 0 0 0 3.5v9A1.5 1.5 0 0 0 1.5 14h8a1.5 1.5 0 0 0 1.5-1.5v-2a.5.5 0 0 0-1 0z`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M15.854 8.354a.5.5 0 0 0 0-.708l-3-3a.5.5 0 0 0-.708.708L14.293 7.5H5.5a.5.5 0 0 0 0 1h8.793l-2.147 2.146a.5.5 0 0 0 .708.708z`},child:[]}]})(e)}function Yi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{fillRule:`evenodd`,d:`M0 .5A.5.5 0 0 1 .5 0h4a.5.5 0 0 1 0 1h-4A.5.5 0 0 1 0 .5m0 2A.5.5 0 0 1 .5 2h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m9 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-9 2A.5.5 0 0 1 .5 4h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5m5 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m7 0a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5m-12 2A.5.5 0 0 1 .5 6h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5m8 0a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m-8 2A.5.5 0 0 1 .5 8h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5m7 0a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5m-7 2a.5.5 0 0 1 .5-.5h8a.5.5 0 0 1 0 1h-8a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h2a.5.5 0 0 1 0 1h-2a.5.5 0 0 1-.5-.5`},child:[]}]})(e)}function Xi(e){return X({tag:`svg`,attr:{fill:`currentColor`,viewBox:`0 0 16 16`},child:[{tag:`path`,attr:{d:`M11.534 7h3.932a.25.25 0 0 1 .192.41l-1.966 2.36a.25.25 0 0 1-.384 0l-1.966-2.36a.25.25 0 0 1 .192-.41m-11 2h3.932a.25.25 0 0 0 .192-.41L2.692 6.23a.25.25 0 0 0-.384 0L.342 8.59A.25.25 0 0 0 .534 9`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,d:`M8 3c-1.552 0-2.94.707-3.857 1.818a.5.5 0 1 1-.771-.636A6.002 6.002 0 0 1 13.917 7H12.9A5 5 0 0 0 8 3M3.1 9a5.002 5.002 0 0 0 8.757 2.182.5.5 0 1 1 .771.636A6.002 6.002 0 0 1 2.083 9z`},child:[]}]})(e)}var Zi=`initializing`,Qi=`paused`,$i=`live`,ea=`error`,ta=e=>{let{onClick:t,disabled:n,color:r,children:i,className:a,href:o,title:s,...c}=e;return(0,b.jsx)(`a`,{className:`p-1 text-blue-500 flex items-center justify-center cursor-pointer ${r?`text-${r}`:``} ${a}`,onClick:e=>{e.stopPropagation(),e.preventDefault(),!n&&t()},href:o??`#`,title:s,...c,children:i})},na=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},ra=(e=>e?na(e):na),ia=e=>e;function aa(e,t=ia){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var oa=e=>{let t=ra(e),n=e=>aa(t,e);return Object.assign(n,t),n},sa=(e=>e?oa(e):oa);function ca(e,t){if(e===t)return!0;if(e===null||t===null||typeof e!=`object`||typeof t!=`object`||Array.isArray(e)!==Array.isArray(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i of n)if(!r.includes(i)||!ca(e[i],t[i]))return!1;return!0}function la(e,t){return ca(e,t)}var ua=sa((e,t)=>({torrents:null,torrentsLoading:!1,torrentsInitiallyLoading:!1,setTorrentsLoading:t=>e(e=>e.torrents==null?{torrentsInitiallyLoading:t,torrentsLoading:t}:{torrentsInitiallyLoading:!1,torrentsLoading:t}),setTorrents:t=>e(e=>{if(!e.torrents)return{torrents:t};let n=new Map(e.torrents.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&la(t,e)?t:e});return r.length!==e.torrents.length||r.some((t,n)=>t!==e.torrents[n])?{torrents:r}:{}}),refreshTorrents:()=>{},setRefreshTorrents:t=>e({refreshTorrents:t}),detailsCache:new Map,getDetails:e=>t().detailsCache.get(e)??null,setDetails:(t,n)=>e(e=>({detailsCache:new Map(e.detailsCache).set(t,n)}))})),da=1024;function fa(){return window.innerWidth>=da?`compact`:`full`}var Z=sa((e,t)=>({currentPage:`torrents`,setCurrentPage:t=>e({currentPage:t}),viewMode:fa(),setViewMode:t=>{e({viewMode:t})},toggleViewMode:()=>{e({viewMode:t().viewMode===`compact`?`full`:`compact`})},searchQuery:``,setSearchQuery:t=>e({searchQuery:t}),statusFilter:`all`,setStatusFilter:t=>{e({statusFilter:t})},selectedTorrentIds:new Set,lastSelectedId:null,selectTorrent:t=>{e({selectedTorrentIds:new Set([t]),lastSelectedId:t})},toggleSelection:n=>{let r=t().selectedTorrentIds,i=new Set(r);i.has(n)?i.delete(n):i.add(n),e({selectedTorrentIds:i,lastSelectedId:n})},selectRange:(n,r)=>{let{lastSelectedId:i,selectedTorrentIds:a}=t();if(i===null){e({selectedTorrentIds:new Set([n]),lastSelectedId:n});return}if(a.has(n)){let t=new Set(a);t.delete(n),e({selectedTorrentIds:t});return}let o=r.indexOf(i),s=r.indexOf(n);if(o===-1||s===-1){e({selectedTorrentIds:new Set([n]),lastSelectedId:n});return}let c=Math.min(o,s),l=Math.max(o,s),u=r.slice(c,l+1),d=new Set(a);for(let e of u)d.add(e);e({selectedTorrentIds:d})},deselectTorrent:n=>{let r=t().selectedTorrentIds;if(r.has(n)){let t=new Set(r);t.delete(n),e({selectedTorrentIds:t})}},clearSelection:()=>{e({selectedTorrentIds:new Set,lastSelectedId:null})},selectAll:t=>{e({selectedTorrentIds:new Set(t)})},selectRelative:(n,r)=>{let{selectedTorrentIds:i,lastSelectedId:a}=t();if(r.length===0)return;let o;if(i.size===0){let t=n===`down`?r[0]:r[r.length-1];e({selectedTorrentIds:new Set([t]),lastSelectedId:t});return}if(i.size===1){let e=Array.from(i)[0];o=r.indexOf(e)}else o=a!==null&&r.includes(a)?r.indexOf(a):r.findIndex(e=>i.has(e));if(o===-1){let t=r[0];e({selectedTorrentIds:new Set([t]),lastSelectedId:t});return}let s=r[n===`down`?Math.min(o+1,r.length-1):Math.max(o-1,0)];e({selectedTorrentIds:new Set([s]),lastSelectedId:s})},sidebarCollapsed:!1,sidebarOpen:!1,trackerFilter:null,categoryFilter:null,toggleSidebar:()=>e(e=>({sidebarCollapsed:!e.sidebarCollapsed})),setSidebarOpen:t=>e({sidebarOpen:t}),setTrackerFilter:t=>e({trackerFilter:t}),setCategoryFilter:t=>e({categoryFilter:t}),categories:{},setCategories:t=>e({categories:t}),detailsModalTorrentId:null,openDetailsModal:t=>e({detailsModalTorrentId:t,selectedTorrentIds:new Set([t]),lastSelectedId:t}),closeDetailsModal:()=>e({detailsModalTorrentId:null}),detailPaneRequestedTab:null,setDetailPaneTab:t=>e({detailPaneRequestedTab:t})})),pa=({onClick:e,children:t,className:n,disabled:r,variant:i,size:a})=>{let o={sm:`text-sm px-2 py-1`,default:`px-3 py-1.5`}[a??`default`],s={secondary:`bg-surface-raised border-divider hover:bg-primary hover:text-white transition-colors`,danger:`bg-error-bg text-white border-transparent hover:bg-red-600 transition-colors`,primary:`bg-primary-bg text-white border-transparent hover:bg-primary-bg-hover disabled:opacity-50 transition-colors`,cancel:`bg-surface-raised text-secondary border-divider hover:bg-surface-sunken transition-colors`,none:``}[i??`secondary`];return(0,b.jsx)(`button`,{disabled:r,onClick:t=>{t.preventDefault(),e()},className:`inline-flex items-center gap-1 border rounded font-medium cursor-pointer disabled:cursor-not-allowed ${o} ${s} ${n??``}`,children:t})},ma=({title:e,children:t,onClose:n})=>(0,b.jsxs)(`div`,{className:`bg-error/10 p-3 rounded-md mb-3`,children:[(0,b.jsxs)(`div`,{className:`flex justify-between mb-2`,children:[(0,b.jsx)(`h2`,{className:`text-lg font-semibold text-error`,children:e}),n&&(0,b.jsx)(`button`,{onClick:n,className:`text-error hover:text-error/80 transition-colors cursor-pointer`,children:(0,b.jsx)(Si,{})})]}),t]}),ha=e=>{let{error:t,remove:n}=e;return t==null?null:(0,b.jsxs)(ma,{onClose:n,title:t.text,children:[t.details?.statusText&&(0,b.jsx)(`div`,{className:`pb-2 text-md`,children:t.details?.statusText}),(0,b.jsx)(`div`,{className:`whitespace-pre-wrap text-secondary`,children:t.details?.text})]})};function ga(e){return e&&e.ownerDocument||document}function _a(e){e===void 0&&(e=ga());try{var t=e.activeElement;return!t||!t.nodeName?null:t}catch{return e.body}}function va(e,t){if(e.contains)return e.contains(t);if(e.compareDocumentPosition)return e===t||!!(e.compareDocumentPosition(t)&16)}var ya=!!(typeof window<`u`&&window.document&&window.document.createElement),ba=!1,xa=!1;try{var Sa={get passive(){return ba=!0},get once(){return xa=ba=!0}};ya&&(window.addEventListener(`test`,Sa,Sa),window.removeEventListener(`test`,Sa,!0))}catch{}function Ca(e,t,n,r){if(r&&typeof r!=`boolean`&&!xa){var i=r.once,a=r.capture,o=n;!xa&&i&&(o=n.__once||function e(r){this.removeEventListener(t,e,a),n.call(this,r)},n.__once=o),e.addEventListener(t,o,ba?r:a)}e.addEventListener(t,n,r)}function wa(e,t,n,r){var i=r&&typeof r!=`boolean`?r.capture:r;e.removeEventListener(t,n,i),n.__once&&e.removeEventListener(t,n.__once,i)}function Ta(e,t,n,r){return Ca(e,t,n,r),function(){wa(e,t,n,r)}}function Ea(){let e=(0,_.useRef)(!0),t=(0,_.useRef)(()=>e.current);return(0,_.useEffect)(()=>(e.current=!0,()=>{e.current=!1}),[]),t.current}function Da(e){let t=(0,_.useRef)(e);return t.current=e,t}function Oa(e){let t=Da(e);(0,_.useEffect)(()=>()=>t.current(),[])}function ka(e){let t=(0,_.useRef)(null);return(0,_.useEffect)(()=>{t.current=e}),t.current}function Aa(e){let t=(0,_.useRef)(e);return(0,_.useEffect)(()=>{t.current=e},[e]),t}function ja(e){let t=Aa(e);return(0,_.useCallback)(function(...e){return t.current&&t.current(...e)},[t])}function Ma(e){var t=ga(e);return t&&t.defaultView||window}function Na(e,t){return Ma(e).getComputedStyle(e,t)}var Pa=/([A-Z])/g;function Fa(e){return e.replace(Pa,`-$1`).toLowerCase()}var Ia=/^ms-/;function La(e){return Fa(e).replace(Ia,`-ms-`)}var Ra=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;function za(e){return!!(e&&Ra.test(e))}function Ba(e,t){var n=``,r=``;if(typeof t==`string`)return e.style.getPropertyValue(La(t))||Na(e).getPropertyValue(La(t));Object.keys(t).forEach(function(i){var a=t[i];!a&&a!==0?e.style.removeProperty(La(i)):za(i)?r+=i+`(`+a+`) `:n+=La(i)+`: `+a+`;`}),r&&(n+=`transform: `+r+`;`),e.style.cssText+=`;`+n}var Va=`data-rr-ui-`;function Ha(e){return`${Va}${e}`}function Ua(e=document){let t=e.defaultView;return Math.abs(t.innerWidth-e.documentElement.clientWidth)}var Wa=Ha(`modal-open`),Ga=class{constructor({ownerDocument:e,handleContainerOverflow:t=!0,isRTL:n=!1}={}){this.handleContainerOverflow=t,this.isRTL=n,this.modals=[],this.ownerDocument=e}getScrollbarWidth(){return Ua(this.ownerDocument)}getElement(){return(this.ownerDocument||document).body}setModalAttributes(e){}removeModalAttributes(e){}setContainerStyle(e){let t={overflow:`hidden`},n=this.isRTL?`paddingLeft`:`paddingRight`,r=this.getElement();e.style={overflow:r.style.overflow,[n]:r.style[n]},e.scrollBarWidth&&(t[n]=`${parseInt(Ba(r,n)||`0`,10)+e.scrollBarWidth}px`),r.setAttribute(Wa,``),Ba(r,t)}reset(){[...this.modals].forEach(e=>this.remove(e))}removeContainerStyle(e){let t=this.getElement();t.removeAttribute(Wa),Object.assign(t.style,e.style)}add(e){let t=this.modals.indexOf(e);return t!==-1||(t=this.modals.length,this.modals.push(e),this.setModalAttributes(e),t!==0)?t:(this.state={scrollBarWidth:this.getScrollbarWidth(),style:{}},this.handleContainerOverflow&&this.setContainerStyle(this.state),t)}remove(e){let t=this.modals.indexOf(e);t!==-1&&(this.modals.splice(t,1),!this.modals.length&&this.handleContainerOverflow&&this.removeContainerStyle(this.state),this.removeModalAttributes(e))}isTopModal(e){return!!this.modals.length&&this.modals[this.modals.length-1]===e}},Ka=(0,_.createContext)(ya?window:void 0);Ka.Provider;function qa(){return(0,_.useContext)(Ka)}var Ja=(e,t)=>ya?e==null?(t||ga()).body:(typeof e==`function`&&(e=e()),e&&`current`in e&&(e=e.current),e&&(`nodeType`in e||e.getBoundingClientRect)?e:null):null;function Ya(e,t){let n=qa(),[r,i]=(0,_.useState)(()=>Ja(e,n?.document));if(!r){let t=Ja(e);t&&i(t)}return(0,_.useEffect)(()=>{t&&r&&t(r)},[t,r]),(0,_.useEffect)(()=>{let t=Ja(e);t!==r&&i(t)},[e,r]),r}var Xa=e=>!e||typeof e==`function`?e:t=>{e.current=t};function Za(e,t){let n=Xa(e),r=Xa(t);return e=>{n&&n(e),r&&r(e)}}function Qa(e,t){return(0,_.useMemo)(()=>Za(e,t),[e,t])}var $a=typeof global<`u`&&global.navigator&&global.navigator.product===`ReactNative`,eo=typeof document<`u`||$a?_.useLayoutEffect:_.useEffect;function Q(e){return e.code===`Escape`||e.keyCode===27}function to(){let e=`19.2.7`.split(`.`);return{major:+e[0],minor:+e[1],patch:+e[2]}}function no(e){if(!e||typeof e==`function`)return null;let{major:t}=to();return t>=19?e.props.ref:e.ref}function ro({children:e,in:t,onExited:n,mountOnEnter:r,unmountOnExit:i}){let a=(0,_.useRef)(null),o=(0,_.useRef)(t),s=ja(n);(0,_.useEffect)(()=>{t?o.current=!0:s(a.current)},[t,s]);let c=(0,_.cloneElement)(e,{ref:Qa(a,no(e))});return t?c:i||!o.current&&r?null:c}var io=[`onEnter`,`onEntering`,`onEntered`,`onExit`,`onExiting`,`onExited`,`addEndListener`,`children`];function ao(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function oo(e){let{onEnter:t,onEntering:n,onEntered:r,onExit:i,onExiting:a,onExited:o,addEndListener:s,children:c}=e,l=ao(e,io),u=(0,_.useRef)(null),d=Qa(u,no(c)),f=e=>t=>{e&&u.current&&e(u.current,t)},p=(0,_.useCallback)(f(t),[t]),m=(0,_.useCallback)(f(n),[n]),h=(0,_.useCallback)(f(r),[r]),g=(0,_.useCallback)(f(i),[i]),v=(0,_.useCallback)(f(a),[a]),y=(0,_.useCallback)(f(o),[o]),b=(0,_.useCallback)(f(s),[s]);return Object.assign({},l,{nodeRef:u},t&&{onEnter:p},n&&{onEntering:m},r&&{onEntered:h},i&&{onExit:g},a&&{onExiting:v},o&&{onExited:y},s&&{addEndListener:b},{children:typeof c==`function`?(e,t)=>c(e,Object.assign({},t,{ref:d})):(0,_.cloneElement)(c,{ref:d})})}var so=[`component`];function co(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var lo=_.forwardRef((e,t)=>{let{component:n}=e,r=oo(co(e,so));return(0,b.jsx)(n,Object.assign({ref:t},r))});function uo({in:e,onTransition:t}){let n=(0,_.useRef)(null),r=(0,_.useRef)(!0),i=ja(t);return eo(()=>{if(!n.current)return;let t=!1;return i({in:e,element:n.current,initial:r.current,isStale:()=>t}),()=>{t=!0}},[e,i]),eo(()=>(r.current=!1,()=>{r.current=!0}),[]),n}function fo({children:e,in:t,onExited:n,onEntered:r,transition:i}){let[a,o]=(0,_.useState)(!t);t&&a&&o(!1);let s=Qa(uo({in:!!t,onTransition:e=>{Promise.resolve(i(e)).then(()=>{e.isStale()||(e.in?r?.(e.element,e.initial):(o(!0),n?.(e.element)))},t=>{throw e.in||o(!0),t})}}),no(e));return a&&!t?null:(0,_.cloneElement)(e,{ref:s})}function po(e,t,n){return e?(0,b.jsx)(lo,Object.assign({},n,{component:e})):t?(0,b.jsx)(fo,Object.assign({},n,{transition:t})):(0,b.jsx)(ro,Object.assign({},n))}var mo=`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`.split(`.`);function ho(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var go;function _o(e){return go||=new Ga({ownerDocument:e?.document}),go}function vo(e){let t=qa(),n=e||_o(t),r=(0,_.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:(0,_.useCallback)(e=>{r.current.dialog=e},[]),setBackdropRef:(0,_.useCallback)(e=>{r.current.backdrop=e},[])})}var yo=(0,_.forwardRef)((e,t)=>{let{show:n=!1,role:r=`dialog`,className:i,style:a,children:o,backdrop:s=!0,keyboard:c=!0,onBackdropClick:l,onEscapeKeyDown:u,transition:d,runTransition:f,backdropTransition:p,runBackdropTransition:m,autoFocus:h=!0,enforceFocus:g=!0,restoreFocus:v=!0,restoreFocusOptions:y,renderDialog:S,renderBackdrop:C=e=>(0,b.jsx)(`div`,Object.assign({},e)),manager:w,container:T,onShow:E,onHide:D=()=>{},onExit:O,onExited:ee,onExiting:te,onEnter:k,onEntering:ne,onEntered:A}=e,j=ho(e,mo),re=qa(),M=Ya(T),N=vo(w),P=Ea(),ie=ka(n),[F,I]=(0,_.useState)(!n),L=(0,_.useRef)(null);(0,_.useImperativeHandle)(t,()=>N,[N]),ya&&!ie&&n&&(L.current=_a(re?.document)),n&&F&&I(!1);let R=ja(()=>{if(N.add(),U.current=Ta(document,`keydown`,H),ae.current=Ta(document,`focus`,()=>setTimeout(B),!0),E&&E(),h){let e=_a(N.dialog?.ownerDocument??re?.document);N.dialog&&e&&!va(N.dialog,e)&&(L.current=e,N.dialog.focus())}}),z=ja(()=>{if(N.remove(),U.current==null||U.current(),ae.current==null||ae.current(),v){var e;(e=L.current)==null||e.focus==null||e.focus(y),L.current=null}});(0,_.useEffect)(()=>{!n||!M||R()},[n,M,R]),(0,_.useEffect)(()=>{F&&z()},[F,z]),Oa(()=>{z()});let B=ja(()=>{if(!g||!P()||!N.isTopModal())return;let e=_a(re?.document);N.dialog&&e&&!va(N.dialog,e)&&N.dialog.focus()}),V=ja(e=>{e.target===e.currentTarget&&(l?.(e),s===!0&&D())}),H=ja(e=>{c&&Q(e)&&N.isTopModal()&&(u?.(e),e.defaultPrevented||D())}),ae=(0,_.useRef)(),U=(0,_.useRef)(),oe=(...e)=>{I(!0),ee?.(...e)};if(!M)return null;let se=Object.assign({role:r,ref:N.setDialogRef,"aria-modal":r===`dialog`?!0:void 0},j,{style:a,className:i,tabIndex:-1}),ce=S?S(se):(0,b.jsx)(`div`,Object.assign({},se,{children:_.cloneElement(o,{role:`document`})}));ce=po(d,f,{unmountOnExit:!0,mountOnEnter:!0,appear:!0,in:!!n,onExit:O,onExiting:te,onExited:oe,onEnter:k,onEntering:ne,onEntered:A,children:ce});let W=null;return s&&(W=C({ref:N.setBackdropRef,onClick:V}),W=po(p,m,{in:!!n,appear:!0,mountOnEnter:!0,unmountOnExit:!0,children:W})),(0,b.jsx)(b.Fragment,{children:x.createPortal((0,b.jsxs)(b.Fragment,{children:[W,ce]}),M)})});yo.displayName=`Modal`;var bo=Object.assign(yo,{Manager:Ga}),xo=({onClose:e,title:t})=>(0,b.jsxs)(`div`,{className:`flex p-3 justify-between items-center border-b border-divider gap-2`,children:[(0,b.jsx)(`h2`,{className:`text-xl font-semibold truncate min-w-0`,children:t}),e&&(0,b.jsx)(`button`,{className:`flex-shrink-0 p-1 -m-1 text-secondary hover:text-text transition-colors cursor-pointer`,onClick:e,"aria-label":`Close modal`,children:(0,b.jsx)(Si,{className:`w-6 h-6`})})]}),So=({isOpen:e,onClose:t,title:n,children:r,className:i})=>(0,b.jsx)(bo,{show:e,onHide:t,renderBackdrop:()=>(0,b.jsx)(`div`,{className:`fixed inset-0 bg-black/50 z-300 dark:bg-black/70`}),className:`fixed z-301 top-0 left-0 w-full h-full block overflow-x-hidden overflow-y-auto`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised shadow-lg my-4 mx-4 sm:my-8 sm:mx-auto sm:max-w-2xl rounded ${i}`,children:[(0,b.jsx)(xo,{onClose:t,title:n}),r]})}),Co=({children:e})=>(0,b.jsx)(`div`,{className:`p-3 border-b dark:border-slate-500`,children:e}),wo=({children:e,className:t})=>(0,b.jsx)(`div`,{className:`p-3 flex justify-end gap-2 ${t}`,children:e}),To=({show:e,onHide:t,torrents:n})=>{let[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),l=(0,_.useContext)(v),u=ua(e=>e.refreshTorrents),d=Z(e=>e.clearSelection);if(!e||n.length===0)return null;let f=()=>{i(!1),o(null),c(!1),t()},p=async()=>{c(!0),o(null);let e=r?l.delete:l.forget,t=[];for(let r of n)try{await e(r.id)}catch(e){let n=r.name||`id=${r.id}`;t.push(`${n}: ${e}`)}t.length>0?(o({text:`Failed to delete ${t.length} torrent${t.length>1?`s`:``}`,details:{text:t.join(` -`)}}),c(!1)):(d(),u(),f())},m=n.length>1;return(0,b.jsxs)(So,{isOpen:e,onClose:t,title:m?`Delete ${n.length} torrents`:`Delete torrent`,children:[(0,b.jsxs)(Co,{children:[(0,b.jsx)(`p`,{className:`text-gray-700 dark:text-slate-300 mb-3`,children:m?`Are you sure you want to delete the following torrents?`:`Are you sure you want to delete this torrent?`}),(0,b.jsx)(`div`,{className:`rounded-md bg-gray-50 dark:bg-slate-700/50 p-3 ${m?`max-h-48 overflow-y-auto`:``}`,children:(0,b.jsx)(`ul`,{className:`space-y-1`,children:n.map(e=>(0,b.jsx)(`li`,{className:`text-gray-800 dark:text-slate-200 truncate`,title:e.name??void 0,children:(0,b.jsx)(`span`,{className:`font-medium`,children:e.name||`Torrent #${e.id}`})},e.id))})}),(0,b.jsxs)(`div`,{className:`mt-4 flex items-center`,children:[(0,b.jsx)(`input`,{type:`checkbox`,id:`deleteFiles`,className:`form-checkbox h-4 w-4 text-blue-500 rounded border-gray-300 dark:border-slate-600`,onChange:()=>i(!r),checked:r}),(0,b.jsx)(`label`,{htmlFor:`deleteFiles`,className:`ml-2 text-gray-700 dark:text-slate-300`,children:`Also delete downloaded files`})]}),a&&(0,b.jsx)(ha,{error:a})]}),(0,b.jsxs)(wo,{children:[s&&(0,b.jsx)(xi,{}),(0,b.jsx)(pa,{variant:`cancel`,onClick:f,children:`Cancel`}),(0,b.jsx)(pa,{variant:`danger`,onClick:p,disabled:s,children:m?`Delete ${n.length} Torrents`:`Delete Torrent`})]})]})};function Eo(e){return X({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M96 224c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm448 0c35.3 0 64-28.7 64-64s-28.7-64-64-64-64 28.7-64 64 28.7 64 64 64zm32 32h-64c-17.6 0-33.5 7.1-45.1 18.6 40.3 22.1 68.9 62 75.1 109.4h66c17.7 0 32-14.3 32-32v-32c0-35.3-28.7-64-64-64zm-256 0c61.9 0 112-50.1 112-112S381.9 32 320 32 208 82.1 208 144s50.1 112 112 112zm76.8 32h-8.3c-20.8 10-43.9 16-68.5 16s-47.6-6-68.5-16h-8.3C179.6 288 128 339.6 128 403.2V432c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48v-28.8c0-63.6-51.6-115.2-115.2-115.2zm-223.7-13.4C161.5 263.1 145.6 256 128 256H64c-35.3 0-64 28.7-64 64v32c0 17.7 14.3 32 32 32h65.9c6.3-47.4 34.9-87.3 75.2-109.4z`},child:[]}]})(e)}function Do(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M296 384h-80c-13.3 0-24-10.7-24-24V192h-87.7c-17.8 0-26.7-21.5-14.1-34.1L242.3 5.7c7.5-7.5 19.8-7.5 27.3 0l152.2 152.2c12.6 12.6 3.7 34.1-14.1 34.1H320v168c0 13.3-10.7 24-24 24zm216-8v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h136v8c0 30.9 25.1 56 56 56h80c30.9 0 56-25.1 56-56v-8h136c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z`},child:[]}]})(e)}function Oo(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z`},child:[]}]})(e)}function ko(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M0 252.118V48C0 21.49 21.49 0 48 0h204.118a48 48 0 0 1 33.941 14.059l211.882 211.882c18.745 18.745 18.745 49.137 0 67.882L293.823 497.941c-18.745 18.745-49.137 18.745-67.882 0L14.059 286.059A48 48 0 0 1 0 252.118zM112 64c-26.51 0-48 21.49-48 48s21.49 48 48 48 48-21.49 48-48-21.49-48-48-48z`},child:[]}]})(e)}function Ao(e){return X({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M288 32C128.94 32 0 160.94 0 320c0 52.8 14.25 102.26 39.06 144.8 5.61 9.62 16.3 15.2 27.44 15.2h443c11.14 0 21.83-5.58 27.44-15.2C561.75 422.26 576 372.8 576 320c0-159.06-128.94-288-288-288zm0 64c14.71 0 26.58 10.13 30.32 23.65-1.11 2.26-2.64 4.23-3.45 6.67l-9.22 27.67c-5.13 3.49-10.97 6.01-17.64 6.01-17.67 0-32-14.33-32-32S270.33 96 288 96zM96 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm48-160c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32zm246.77-72.41l-61.33 184C343.13 347.33 352 364.54 352 384c0 11.72-3.38 22.55-8.88 32H232.88c-5.5-9.45-8.88-20.28-8.88-32 0-33.94 26.5-61.43 59.9-63.59l61.34-184.01c4.17-12.56 17.73-19.45 30.36-15.17 12.57 4.19 19.35 17.79 15.17 30.36zm14.66 57.2l15.52-46.55c3.47-1.29 7.13-2.23 11.05-2.23 17.67 0 32 14.33 32 32s-14.33 32-32 32c-11.38-.01-20.89-6.28-26.57-15.22zM480 384c-17.67 0-32-14.33-32-32s14.33-32 32-32 32 14.33 32 32-14.33 32-32 32z`},child:[]}]})(e)}function jo(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M64 96H0c0 123.7 100.3 224 224 224v144c0 8.8 7.2 16 16 16h32c8.8 0 16-7.2 16-16V320C288 196.3 187.7 96 64 96zm384-64c-84.2 0-157.4 46.5-195.7 115.2 27.7 30.2 48.2 66.9 59 107.6C424 243.1 512 147.9 512 32h-64z`},child:[]}]})(e)}function Mo(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z`},child:[]}]})(e)}function No(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z`},child:[]}]})(e)}function Po(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z`},child:[]}]})(e)}function Fo(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M144 479H48c-26.5 0-48-21.5-48-48V79c0-26.5 21.5-48 48-48h96c26.5 0 48 21.5 48 48v352c0 26.5-21.5 48-48 48zm304-48V79c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h96c26.5 0 48-21.5 48-48z`},child:[]}]})(e)}function Io(e){return X({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z`},child:[]}]})(e)}function Lo(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z`},child:[]}]})(e)}function Ro(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M320 448v40c0 13.255-10.745 24-24 24H24c-13.255 0-24-10.745-24-24V120c0-13.255 10.745-24 24-24h72v296c0 30.879 25.121 56 56 56h168zm0-344V0H152c-13.255 0-24 10.745-24 24v368c0 13.255 10.745 24 24 24h272c13.255 0 24-10.745 24-24V128H344c-13.2 0-24-10.8-24-24zm120.971-31.029L375.029 7.029A24 24 0 0 0 358.059 0H352v96h96v-6.059a24 24 0 0 0-7.029-16.97z`},child:[]}]})(e)}function zo(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z`},child:[]}]})(e)}function Bo(e){return X({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z`},child:[]}]})(e)}function Vo(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`},child:[]}]})(e)}function Ho(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M257.5 445.1l-22.2 22.2c-9.4 9.4-24.6 9.4-33.9 0L7 273c-9.4-9.4-9.4-24.6 0-33.9L201.4 44.7c9.4-9.4 24.6-9.4 33.9 0l22.2 22.2c9.5 9.5 9.3 25-.4 34.3L136.6 216H424c13.3 0 24 10.7 24 24v32c0 13.3-10.7 24-24 24H136.6l120.5 114.8c9.8 9.3 10 24.8.4 34.3z`},child:[]}]})(e)}function Uo(e){return X({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`},child:[]}]})(e)}function Wo(e){return X({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M177 255.7l136 136c9.4 9.4 9.4 24.6 0 33.9l-22.6 22.6c-9.4 9.4-24.6 9.4-33.9 0L160 351.9l-96.4 96.4c-9.4 9.4-24.6 9.4-33.9 0L7 425.7c-9.4-9.4-9.4-24.6 0-33.9l136-136c9.4-9.5 24.6-9.5 34-.1zm-34-192L7 199.7c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l96.4-96.4 96.4 96.4c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9l-136-136c-9.2-9.4-24.4-9.4-33.8 0z`},child:[]}]})(e)}function Go(e){return X({tag:`svg`,attr:{viewBox:`0 0 320 512`},child:[{tag:`path`,attr:{d:`M143 256.3L7 120.3c-9.4-9.4-9.4-24.6 0-33.9l22.6-22.6c9.4-9.4 24.6-9.4 33.9 0l96.4 96.4 96.4-96.4c9.4-9.4 24.6-9.4 33.9 0L313 86.3c9.4 9.4 9.4 24.6 0 33.9l-136 136c-9.4 9.5-24.6 9.5-34 .1zm34 192l136-136c9.4-9.4 9.4-24.6 0-33.9l-22.6-22.6c-9.4-9.4-24.6-9.4-33.9 0L160 352.1l-96.4-96.4c-9.4-9.4-24.6-9.4-33.9 0L7 278.3c-9.4 9.4-9.4 24.6 0 33.9l136 136c9.4 9.5 24.6 9.5 34 .1z`},child:[]}]})(e)}var Ko=sa(e=>({closeableError:null,setCloseableError:t=>e(()=>({closeableError:t})),otherError:null,setOtherError:t=>e(()=>({otherError:t})),alert:null,setAlert:t=>e(()=>({alert:t})),removeAlert:()=>e(()=>({alert:null}))})),qo=({torrent:e})=>{let{id:t,name:n,stats:r}=e,i=r.state,[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),l=ua(e=>e.refreshTorrents),u=Z(e=>e.openDetailsModal),d=i==`live`,f=i==`paused`||i==`error`,p=i==`paused`||i==`live`,m=Ko(e=>e.setCloseableError),h=(0,_.useContext)(v);return(0,b.jsxs)(`div`,{className:`flex w-full justify-center gap-1 sm:gap-2 dark:text-slate-300`,children:[f&&(0,b.jsx)(ta,{onClick:()=>{o(!0),h.start(t).then(()=>{l()},e=>{m({text:`Error starting torrent id=${t}`,details:e})}).finally(()=>o(!1))},disabled:a,children:(0,b.jsx)(Po,{className:`hover:text-green-600`})}),d&&(0,b.jsx)(ta,{onClick:()=>{o(!0),h.pause(t).then(()=>{l()},e=>{m({text:`Error pausing torrent id=${t}`,details:e})}).finally(()=>o(!1))},disabled:a,children:(0,b.jsx)(Fo,{className:`hover:text-amber-500`})}),p&&(0,b.jsx)(ta,{onClick:()=>u(t),disabled:a,children:(0,b.jsx)(zo,{className:`hover:text-green-600`})}),(0,b.jsx)(ta,{onClick:()=>{o(!0),c(!0)},disabled:a,children:(0,b.jsx)(Oo,{className:`hover:text-red-500`})}),(0,b.jsx)(To,{show:s,onHide:()=>{o(!1),c(!1)},torrents:[{id:t,name:n}]})]})},Jo={warn:`bg-warning-bg text-white`,info:`bg-primary-bg text-white`,success:`bg-success-bg text-white`,error:`bg-error-bg text-white`},Yo=({now:e,variant:t,label:n,classNames:r})=>{let i=n??`${e.toFixed(2)}%`,a=Jo[t??`info`]??Jo.info;return(0,b.jsx)(`div`,{className:`w-full bg-divider rounded-full mb-1 ${r}`,children:(0,b.jsx)(`div`,{className:`text-sm font-medium transition-all text-center leading-none py-0.5 px-2 rounded-full ${a} ${e<1&&`bg-transparent`}`,style:{width:`${e}%`},children:i})})};function Xo(e){if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`,`TB`,`PB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(2))+` `+n[r]}var Zo=({statsResponse:e})=>{switch(e.state){case Qi:return(0,b.jsx)(`span`,{className:`text-secondary`,children:`Paused`});case Zi:return(0,b.jsx)(`span`,{className:`text-warning`,children:`Checking files`});case ea:return(0,b.jsx)(`span`,{className:`text-error`,children:`Error`})}return e.state!=`live`||e.live===null?(0,b.jsx)(`span`,{className:`text-secondary`,children:e.state}):(0,b.jsxs)(b.Fragment,{children:[!e.finished&&(0,b.jsxs)(`span`,{className:`text-success`,children:[`↓ `,e.live.download_speed?.human_readable]}),(0,b.jsxs)(`span`,{className:`text-primary`,children:[`↑ `,e.live.upload_speed?.human_readable,e.live.snapshot.uploaded_bytes>0&&(0,b.jsxs)(`span`,{className:`text-secondary`,children:[`(`,Xo(e.live.snapshot.uploaded_bytes),`)`]})]})]})};function Qo(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60),i=e%60,a=(e,t)=>e>0?`${e}${t}`:``;return t>0?`${a(t,`d`)} ${a(n,`h`)} ${a(r,`m`)}`.trim():n>0?`${a(n,`h`)} ${a(r,`m`)}`.trim():r>0?`${a(r,`m`)} ${a(i,`s`)}`.trim():`${a(i,`s`)}`.trim()}function $o(e){let t=e?.live?.time_remaining?.duration?.secs;return t==null?`N/A`:Qo(t)}function es(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M5 20h14v-2H5v2zM19 9h-4V3H9v6H5l7 7 7-7z`},child:[]}]})(e)}function ts(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z`},child:[]}]})(e)}function ns(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M4 6H2v14c0 1.1.9 2 2 2h14v-2H4V6zm16-4H8c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-1 9h-4v4h-2v-4H9V9h4V5h2v4h4v2z`},child:[]}]})(e)}function rs(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z`},child:[]}]})(e)}function is(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0V0z`},child:[]},{tag:`path`,attr:{d:`M9 16h6v-6h4l-7-7-7 7h4v6zm3-10.17L14.17 8H13v6h-2V8H9.83L12 5.83zM5 18h14v2H5z`},child:[]}]})(e)}function as(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`path`,attr:{fill:`none`,d:`M0 0h24v24H0z`},child:[]},{tag:`path`,attr:{d:`M22 12c0 5.52-4.48 10-10 10S2 17.52 2 12c0-1.19.22-2.32.6-3.38l1.88.68C4.17 10.14 4 11.05 4 12c0 4.41 3.59 8 8 8s8-3.59 8-8-3.59-8-8-8c-.95 0-1.85.17-2.69.48l-.68-1.89C9.69 2.22 10.82 2 12 2c5.52 0 10 4.48 10 10zM5.5 4C4.67 4 4 4.67 4 5.5S4.67 7 5.5 7 7 6.33 7 5.5 6.33 4 5.5 4zM11 16V8H9v8h2zm4 0V8h-2v8h2z`},child:[]}]})(e)}var os=({className:e,finished:t,live:n,error:r,queued:i})=>r?(0,b.jsx)(ts,{className:`text-error ${e}`}):i?(0,b.jsx)(ns,{className:`text-warning ${e}`}):t&&n?(0,b.jsx)(is,{className:`text-success ${e}`}):t?(0,b.jsx)(rs,{className:`text-success ${e}`}):n?(0,b.jsx)(es,{className:`text-primary ${e}`}):(0,b.jsx)(as,{className:`text-secondary ${e}`}),ss=({torrent:e})=>{e.id;let t=e.stats??null,n=t?.state??``,r=t?.error??null,i=t?.total_bytes??1,a=t?.progress_bytes??0,o=t?.finished||!1,s=r||i==0?100:a/i*100,c=()=>{let e=t?.live?.snapshot.peer_stats;return e?`${e.live} / ${e.seen}`:``},l=t?.live?.snapshot.uploaded_bytes??0,u=t?.ratio,d=t?.queue_position,f=t?.sequential,p=e=>(0,b.jsx)(os,{className:e,error:!!r,live:!!t?.live,finished:o});return(0,b.jsx)(`div`,{className:`flex flex-col border p-1.5 sm:p-2 border-divider rounded-xl shadow-xs hover:drop-shadow-sm bg-surface-raised`,children:(0,b.jsxs)(`section`,{className:`flex flex-col lg:flex-row items-center gap-1.5 sm:gap-2`,children:[(0,b.jsx)(`div`,{className:`hidden md:block`,children:p(`w-10 h-10`)}),(0,b.jsxs)(`div`,{className:`w-full flex flex-col gap-1 sm:gap-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2`,children:[(0,b.jsx)(`div`,{className:`md:hidden`,children:p(`w-4 h-4 sm:w-5 sm:h-5`)}),(0,b.jsx)(`div`,{className:`text-left text-sm sm:text-base lg:text-lg text-ellipsis break-all line-clamp-2 sm:line-clamp-none`,children:e.name})]}),r?(0,b.jsxs)(`p`,{className:`text-error`,children:[(0,b.jsx)(`strong`,{children:`Error:`}),` `,r]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{children:(0,b.jsx)(Yo,{now:s,label:r,variant:n==`initializing`?`warn`:o?`success`:`info`})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 sm:gap-x-4 sm:gap-y-1 items-center text-nowrap text-xs sm:text-sm font-medium text-secondary`,children:[(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(pi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),` `,c().toString()]}),(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(mi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),(0,b.jsxs)(`div`,{children:[Xo(a),`/`,Xo(i)]})]}),t&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(hi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),$o(t)]}),(0,b.jsx)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:(0,b.jsx)(Zo,{statsResponse:t})}),(l>0||u!=null)&&(0,b.jsxs)(`div`,{className:`flex gap-1 sm:gap-2 items-center`,children:[(0,b.jsx)(yi,{className:`w-3 h-3 sm:w-4 sm:h-4`}),(0,b.jsxs)(`span`,{children:[Xo(l),u!=null&&(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(ratio: `,u.toFixed(2),`)`]})]})]}),d!=null&&(0,b.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-surface border border-divider rounded`,children:[`Q: `,d]}),f&&(0,b.jsx)(`span`,{className:`inline-flex items-center`,title:`Sequential download`,children:(0,b.jsx)(Xi,{className:`w-3 h-3 sm:w-4 sm:h-4 text-primary`})})]})]})]})]}),t&&(0,b.jsx)(`div`,{className:``,children:(0,b.jsx)(qo,{torrent:{...e,stats:t}})})]})})},cs=({torrent:e,hidden:t})=>(0,b.jsx)(`div`,{className:t?`hidden`:``,children:(0,b.jsx)(ss,{torrent:e})}),ls={id:`ID`,name:`Name`,size:`Size`,progress:`Progress`,downSpeed:`Down Speed`,upSpeed:`Up Speed`,eta:`ETA`,category:`Category`},us={all:`All`,downloading:`Downloading`,seeding:`Seeding`,paused:`Paused`,queued:`Queued`,error:`Error`};function ds(e,t){switch(t){case`id`:return e.id;case`name`:return(e.name??``).toLowerCase();case`size`:return e.stats?.total_bytes??0;case`progress`:return e.stats?.total_bytes?(e.stats.progress_bytes??0)/e.stats.total_bytes:0;case`downSpeed`:return e.stats?.live?.download_speed?.mbps??0;case`upSpeed`:return e.stats?.live?.upload_speed?.mbps??0;case`eta`:{if(!e.stats?.live)return 1/0;let t=(e.stats.total_bytes??0)-(e.stats.progress_bytes??0),n=e.stats.live.download_speed?.mbps??0;return n<=0||t<=0?t<=0?0:1/0:t/(n*1024*1024)}case`category`:return(e.category??``).toLowerCase()}}function fs(e,t,n,r){let i=ds(e,n),a=ds(t,n),o=typeof i==`string`?i.localeCompare(a):i-a;return r===`asc`?o:-o}function ps(e,t){return t?(e??``).toLowerCase().includes(t):!0}function ms(e){let t=/^[a-z+]+:\/\/([^/:?#]+)/i.exec(e);return t?t[1].toLowerCase():null}function hs(e){let t=new Set;for(let n of e.trackers??[]){let e=ms(n);e&&t.add(e)}return Array.from(t)}function gs(e,t){if(t===null)return!0;let n=hs(e);return t===``?n.length===0:n.includes(t)}function _s(e,t){return t===null?!0:t===``?!e.category:e.category===t}function vs(e,t){if(t===`all`)return!0;let n=e.stats?.state,r=e.stats?.finished;switch(t){case`downloading`:return n===`live`&&!r;case`seeding`:return n===`live`&&!!r;case`paused`:return n===`paused`;case`queued`:return e.stats?.queue_state===`Queued`;case`error`:return n===`error`}}function ys(e,t,n,r,i){return ps(e.name,t)&&vs(e,n)&&_s(e,r??null)&&gs(e,i??null)}function bs(e){let t=ua(e=>e.torrents),n=Z(e=>e.searchQuery),r=Z(e=>e.statusFilter),i=Z(e=>e.categoryFilter),a=Z(e=>e.selectAll),o=Z(e=>e.clearSelection),s=Z(e=>e.selectedTorrentIds);(0,_.useEffect)(()=>{let c=c=>{let l=c.target;if(l.tagName===`INPUT`||l.tagName===`TEXTAREA`||l.isContentEditable||document.querySelector(`[role="dialog"]`))return;let u=c.metaKey||c.ctrlKey;if(u&&c.key===`a`){if(c.preventDefault(),t){let e=n.toLowerCase();a(t.filter(t=>ys(t,e,r,i)).map(e=>e.id))}return}if(u&&c.key===`f`){c.preventDefault();let e=document.querySelector(`[data-search-input]`);e?.focus(),e?.select();return}if(c.key===`Escape`){c.preventDefault(),o();return}if((c.key===`Delete`||c.key===`Backspace`)&&s.size>0){c.preventDefault(),e?.onDelete?.();return}if(c.key===`b`||c.key===`B`){c.preventDefault(),e?.onToggleSidebar?.();return}if(u&&c.key===`,`){c.preventDefault(),e?.onOpenSettings?.();return}if(u&&c.key===`l`){c.preventDefault(),e?.onOpenLogs?.();return}};return window.addEventListener(`keydown`,c),()=>window.removeEventListener(`keydown`,c)},[t,n,r,i,a,o,s,e])}var xs=({hideFilters:e})=>{let t=Z(e=>e.selectedTorrentIds),n=Z(e=>e.searchQuery),r=Z(e=>e.setSearchQuery),i=Z(e=>e.statusFilter),a=Z(e=>e.setStatusFilter),o=ua(e=>e.torrents),s=ua(e=>e.refreshTorrents),c=Ko(e=>e.setCloseableError),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(n),y=(0,_.useCallback)((0,bi.default)(e=>r(e),150),[r]),x=e=>{let t=e.target.value;g(t),y(t)},S=()=>{g(``),r(``)},C=(0,_.useContext)(v),w=t.size,T=w>0,E=e=>o?.find(t=>t.id===e),D=(0,_.useCallback)(()=>{m(Array.from(t).map(e=>({id:e,name:E(e)?.name??null}))),f(!0)},[t,o]);bs((0,_.useMemo)(()=>({onDelete:D}),[D]));let O=async(e,n,r)=>{u(!0);try{for(let i of t)if(E(i)?.stats?.state!==n)try{await e(i),s()}catch(e){c({text:`Error ${r} torrent id=${i}`,details:e})}}finally{u(!1)}};return(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 bg-surface-raised border-b border-divider`,children:[(0,b.jsxs)(pa,{onClick:()=>O(e=>C.start(e),$i,`starting`),disabled:l||!T,variant:`secondary`,children:[(0,b.jsx)(Po,{className:`w-2.5 h-2.5`}),`Resume`]}),(0,b.jsxs)(pa,{onClick:()=>O(e=>C.pause(e),Qi,`pausing`),disabled:l||!T,variant:`secondary`,children:[(0,b.jsx)(Fo,{className:`w-2.5 h-2.5`}),`Pause`]}),(0,b.jsxs)(pa,{onClick:D,disabled:l||!T,variant:`danger`,children:[(0,b.jsx)(Oo,{className:`w-2.5 h-2.5`}),`Delete`]}),(0,b.jsx)(pa,{onClick:async()=>{u(!0);try{for(let e of t)try{await C.queueMoveUp(e)}catch(t){c({text:`Error moving torrent id=${e} up in queue`,details:t})}s()}finally{u(!1)}},disabled:l||!T,variant:`secondary`,children:(0,b.jsx)(Vo,{className:`w-2.5 h-2.5`})}),(0,b.jsx)(pa,{onClick:async()=>{u(!0);try{for(let e of t)try{await C.queueMoveDown(e)}catch(t){c({text:`Error moving torrent id=${e} down in queue`,details:t})}s()}finally{u(!1)}},disabled:l||!T,variant:`secondary`,children:(0,b.jsx)(Uo,{className:`w-2.5 h-2.5`})}),!e&&(0,b.jsxs)(b.Fragment,{children:[T&&(0,b.jsxs)(`span`,{className:`ml-1.5 text-secondary`,children:[w,` selected`]}),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`select`,{value:i,onChange:e=>a(e.target.value),className:`py-1 px-2 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:Object.keys(us).map(e=>(0,b.jsx)(`option`,{value:e,children:us[e]},e))}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(fi,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:h,onChange:x,placeholder:`Search...`,className:`pl-7 pr-7 py-1 w-48 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`}),h&&(0,b.jsx)(`button`,{onClick:S,className:`absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(li,{className:`w-3.5 h-3.5`})})]})]}),(0,b.jsx)(To,{show:d,onHide:()=>f(!1),torrents:p})]})};function Ss(e,t){let n,r=async()=>{await e().then(()=>!1,()=>!0)&&i()},i=e=>{n=setTimeout(r,e===void 0?t:e)};return i(0),()=>clearTimeout(n)}function Cs(e,t){let n,r=t,i=async()=>{if(r=await e(),r==null)throw`asyncCallback returned null or undefined`;a()},a=()=>{n=setTimeout(i,r)};return a(),()=>{clearTimeout(n)}}var ws=12,Ts=({torrentId:e,totalPieces:t,stats:n})=>{let r=(0,_.useRef)(null),i=(0,_.useRef)(null),a=(0,_.useContext)(v),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{if(t!==0)return Cs(async()=>{try{s(await a.getTorrentHaves(e))}catch(e){console.error(`Failed to fetch haves:`,e)}let t=n?.state===`live`||n?.state===`initializing`,r=n?.finished??!1;return t&&!r?2e3:3e4},0)},[e,t,n?.state,n?.finished]),(0,_.useEffect)(()=>{let e=r.current,n=i.current;if(!e||!n||!o||t===0)return;let a=e.getContext(`2d`);if(!a)return;let s=n.clientWidth,c=Math.max(s,100);e.width=c,e.height=ws;let l=getComputedStyle(document.body),u=l.getPropertyValue(`--color-success-bg`).trim()||`#22c55e`;a.fillStyle=l.getPropertyValue(`--color-divider`).trim()||`#374151`,a.fillRect(0,0,c,ws);let d=e=>{let t=Math.floor(e/8),n=7-e%8;return t>n&1)==1},f=c/t;a.fillStyle=u;let p=-1;for(let e=0;e{if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m ${e%60}s`;let n=Math.floor(t/60);return n<24?`${n}h ${t%60}m`:`${Math.floor(n/24)}d ${n%24}h`},Ds=({label:e,value:t,mono:n})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[e,` `]}),(0,b.jsx)(`span`,{className:n?`font-mono`:``,children:t})]}),Os=({torrent:e})=>{let t=(0,_.useContext)(v),n=Z(e=>e.categories),r=Z(e=>e.setCategories),i=ua(e=>e.refreshTorrents),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(``),l=e?.stats??null,u=(0,_.useRef)(!1);if((0,_.useEffect)(()=>{u.current||(u.current=!0,t.getCategories().then(e=>r(e)).catch(()=>{}))},[t,r]),!e||!l)return(0,b.jsx)(`div`,{className:`p-3 text-tertiary`,children:`Loading...`});let d=e.name??``,f=e.info_hash,p=l.state,m=l.error,h=l.total_bytes??1,g=l.progress_bytes??0,y=l.finished||!1,x=e.total_pieces??0,S=l.live?.snapshot.downloaded_and_checked_pieces??0,C=x>0?h/x:0,w=l.live?.snapshot.uploaded_bytes??0,T=m||h===0?100:g/h*100,E=l.live?.download_speed?.human_readable??`-`,D=l.live?.upload_speed?.human_readable??`-`,O=$o(l),ee=l.live?.snapshot.peer_stats,te=m?{text:`Error`,color:`text-error`}:p===`initializing`?{text:`Initializing`,color:`text-warning`}:p===`paused`?{text:`Paused`,color:`text-secondary`}:p===`live`&&y?{text:`Seeding`,color:`text-success`}:p===`live`?{text:`Downloading`,color:`text-primary`}:{text:p,color:`text-secondary`};return(0,b.jsxs)(`div`,{className:`p-3 flex flex-col gap-3 text-sm`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(`span`,{className:`truncate font-medium flex-1`,title:d,children:d}),(0,b.jsx)(`span`,{className:`shrink-0 ${te.color}`,children:te.text})]}),x>0&&(0,b.jsx)(`div`,{children:(0,b.jsx)(Ts,{torrentId:e.id,totalPieces:x,stats:l})}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Progress`,value:`${T.toFixed(1)}%`}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(g),`/`,Xo(h),`)`]})]}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Down`,value:E})}),(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Up`,value:D}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(w),` total)`]})]}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`ETA`,value:y?`Complete`:O})}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Ratio`,value:l.ratio?.toFixed(2)??`N/A`})})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[x>0&&(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Pieces`,value:`${S.toLocaleString()}/${x.toLocaleString()}`}),C>0&&(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[` `,`(`,Xo(C),` each)`]})]}),ee&&(0,b.jsxs)(`span`,{children:[(0,b.jsx)(Ds,{label:`Peers`,value:``}),(0,b.jsx)(`span`,{className:`text-success`,children:ee.live}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` live, `}),(0,b.jsx)(`span`,{className:`text-primary`,children:ee.connecting}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` connecting, `}),(0,b.jsx)(`span`,{className:`text-warning`,children:ee.queued}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` queued, `}),(0,b.jsx)(`span`,{children:ee.seen}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` seen, `}),(0,b.jsx)(`span`,{className:`text-error`,children:ee.dead}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:` dead`})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`div`,{className:`truncate`,children:(0,b.jsx)(Ds,{label:`Hash`,value:f,mono:!0})}),(0,b.jsx)(`div`,{className:`truncate`,children:(0,b.jsx)(Ds,{label:`Output`,value:e.output_folder,mono:!0})}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(Ds,{label:`Category`,value:``}),a?(0,b.jsxs)(`select`,{value:s,onChange:n=>{let r=n.target.value;c(r),t.setTorrentCategory(e.id,r||null).then(()=>i()).catch(()=>{}),o(!1)},onBlur:()=>o(!1),autoFocus:!0,className:`px-1 py-0.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:[(0,b.jsx)(`option`,{value:``,children:`None`}),Object.keys(n).sort((e,t)=>e.localeCompare(t)).map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}):(0,b.jsx)(`button`,{onClick:()=>{c(e.category??``),o(!0)},className:`text-sm text-primary hover:underline cursor-pointer`,children:e.category||`None`})]})]}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1`,children:[l.seeding_time_secs!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Seeding Time`,value:Es(l.seeding_time_secs)})}),l.queue_state!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Queue State`,value:l.queue_state})}),l.queue_position!=null&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Queue Position`,value:l.queue_position})}),(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Sequential`,value:l.sequential?`Yes`:`No`})}),y&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Super-seeding`,value:l.super_seeding?`Yes`:`No`})}),(l.min_piece_availability!=null||l.avg_piece_availability!=null)&&(0,b.jsx)(`span`,{children:(0,b.jsx)(Ds,{label:`Availability`,value:`${l.min_piece_availability?.toFixed(2)??`?`} min / ${l.avg_piece_availability?.toFixed(2)??`?`} avg`})})]}),m&&(0,b.jsx)(`div`,{className:`text-error`,children:m})]})},ks=({checked:e,name:t,disabled:n,onChange:r,label:i,help:a,inputType:o,children:s,labelLink:c})=>(0,b.jsxs)(`div`,{className:`flex gap-3 items-start`,children:[(0,b.jsx)(`div`,{className:`flex`,children:(0,b.jsx)(`input`,{type:o||`checkbox`,className:`block mt-1`,id:t,name:t,disabled:n,checked:e,onChange:r})}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[c?(0,b.jsx)(`a`,{href:c,target:`_blank`,className:`text-blue-600 dark:text-blue-500 hover:underline`,children:i}):(0,b.jsx)(`label`,{htmlFor:t,children:i}),a&&(0,b.jsx)(`div`,{className:`text-sm text-slate-500 dark:text-slate-300 mb-3`,children:a})]}),s]});function As(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`g`,attr:{id:`Square_Plus`},child:[{tag:`g`,attr:{},child:[{tag:`path`,attr:{d:`M18.438,20.938H5.563a2.5,2.5,0,0,1-2.5-2.5V5.564a2.5,2.5,0,0,1,2.5-2.5H18.438a2.5,2.5,0,0,1,2.5,2.5V18.438A2.5,2.5,0,0,1,18.438,20.938ZM5.563,4.064a1.5,1.5,0,0,0-1.5,1.5V18.438a1.5,1.5,0,0,0,1.5,1.5H18.438a1.5,1.5,0,0,0,1.5-1.5V5.564a1.5,1.5,0,0,0-1.5-1.5Z`},child:[]},{tag:`path`,attr:{d:`M15,12.5H12.5V15a.5.5,0,0,1-1,0V12.5H9a.5.5,0,0,1,0-1h2.5V9a.5.5,0,0,1,1,0v2.5H15A.5.5,0,0,1,15,12.5Z`},child:[]}]}]}]})(e)}function js(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`},child:[{tag:`g`,attr:{id:`Square_Minus`},child:[{tag:`g`,attr:{},child:[{tag:`path`,attr:{d:`M18.438,20.938H5.564a2.5,2.5,0,0,1-2.5-2.5V5.564a2.5,2.5,0,0,1,2.5-2.5H18.438a2.5,2.5,0,0,1,2.5,2.5V18.438A2.5,2.5,0,0,1,18.438,20.938ZM5.564,4.064a1.5,1.5,0,0,0-1.5,1.5V18.438a1.5,1.5,0,0,0,1.5,1.5H18.438a1.5,1.5,0,0,0,1.5-1.5V5.564a1.5,1.5,0,0,0-1.5-1.5Z`},child:[]},{tag:`path`,attr:{d:`M9,12.5a.5.5,0,0,1,0-1h6a.5.5,0,0,1,0,1Z`},child:[]}]}]}]})(e)}var Ms=c(o(((e,t)=>{var n=200,r=`Expected a function`,i=`__lodash_hash_undefined__`,a=1,o=2,s=1/0,c=9007199254740991,l=`[object Arguments]`,u=`[object Array]`,d=`[object Boolean]`,f=`[object Date]`,p=`[object Error]`,m=`[object Function]`,h=`[object GeneratorFunction]`,g=`[object Map]`,_=`[object Number]`,v=`[object Object]`,y=`[object Promise]`,b=`[object RegExp]`,x=`[object Set]`,S=`[object String]`,C=`[object Symbol]`,w=`[object WeakMap]`,T=`[object ArrayBuffer]`,E=`[object DataView]`,D=`[object Float32Array]`,O=`[object Float64Array]`,ee=`[object Int8Array]`,te=`[object Int16Array]`,k=`[object Int32Array]`,ne=`[object Uint8Array]`,A=`[object Uint8ClampedArray]`,j=`[object Uint16Array]`,re=`[object Uint32Array]`,M=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,N=/^\w*$/,P=/^\./,ie=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,F=/[\\^$.*+?()[\]{}|]/g,I=/\\(\\)?/g,L=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,z={};z[D]=z[O]=z[ee]=z[te]=z[k]=z[ne]=z[A]=z[j]=z[re]=!0,z[l]=z[u]=z[T]=z[d]=z[E]=z[f]=z[p]=z[m]=z[g]=z[_]=z[v]=z[b]=z[x]=z[S]=z[w]=!1;var B=typeof global==`object`&&global&&global.Object===Object&&global,V=typeof self==`object`&&self&&self.Object===Object&&self,H=B||V||Function(`return this`)(),ae=typeof e==`object`&&e&&!e.nodeType&&e,U=ae&&typeof t==`object`&&t&&!t.nodeType&&t,oe=U&&U.exports===ae&&B.process,se=function(){try{return oe&&oe.binding(`util`)}catch{}}(),ce=se&&se.isTypedArray;function W(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function le(e,t){for(var n=-1,r=e?e.length:0,i=Array(r);++n-1}function at(e,t){var n=this.__data__,r=St(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}et.prototype.clear=tt,et.prototype.delete=nt,et.prototype.get=rt,et.prototype.has=it,et.prototype.set=at;function ot(e){var t=-1,n=e?e.length:0;for(this.clear();++t0&&n(s)?t>1?wt(s,t-1,n,r,i):ue(i,s):r||(i[i.length]=s)}return i}var Tt=Jt();function Et(e,t){return e&&Tt(e,t,Mn)}function Dt(e,t){t=sn(t,e)?[t]:Wt(t);for(var n=0,r=t.length;e!=null&&nt||a&&o&&c&&!s&&!l||r&&o&&c||!n&&c||!i)return 1;if(!r&&!a&&!l&&e=s?c:c*(n[r]==`desc`?-1:1)}return e.index-t.index}function qt(e,t){return function(n,r){if(n==null)return n;if(!xn(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++al))return!1;var d=s.get(e);if(d&&s.get(t))return d==t;var f=-1,p=!0,m=i&a?new ft:void 0;for(s.set(e,t),s.set(t,e);++f-1&&e%1==0&&e1&&on(e,t[0],t[1])?t=[]:n>2&&on(t[0],t[1],t[2])&&(t=[t[0]]),Bt(e,wt(t,1),[])});function _n(e,t){if(typeof e!=`function`||t&&typeof t!=`function`)throw TypeError(r);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o),o};return n.cache=new(_n.Cache||ot),n}_n.Cache=ot;function vn(e,t){return e===t||e!==e&&t!==t}function yn(e){return Sn(e)&&we.call(e,`callee`)&&(!ke.call(e,`callee`)||Te.call(e)==l)}var bn=Array.isArray;function xn(e){return e!=null&&wn(e.length)&&!Cn(e)}function Sn(e){return En(e)&&xn(e)}function Cn(e){var t=Tn(e)?Te.call(e):``;return t==m||t==h}function wn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=c}function Tn(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function En(e){return!!e&&typeof e==`object`}function Dn(e){return typeof e==`symbol`||En(e)&&Te.call(e)==C}var On=ce?pe(ce):Pt;function kn(e){return e==null?``:Ut(e)}function An(e,t,n){var r=e==null?void 0:Dt(e,t);return r===void 0?n:r}function jn(e,t){return e!=null&&nn(e,t,kt)}function Mn(e){return xn(e)?xt(e):It(e)}function Nn(e){return e}function Pn(e){return sn(e)?de(mn(e)):Vt(e)}t.exports=gn}))(),1),Ns=(e,t)=>{let n=(e,t,r,i)=>{let a=[],o=[],s={},c=e=>(s[e]=s[e]||[],s[e]);r.forEach(e=>{if(i==e.pathComponents.length-1){a.push(e);return}c(e.pathComponents[i]).push(e)}),a=(0,Ms.default)(a,e=>e.filename);let l=(0,Ms.default)(Object.entries(s),([e,t])=>e),u=0;for(let[e,r]of l)o.push(n(e,t+`.`+u,r,i+1)),u+=1;return{name:e,id:t,dirs:o,files:a}};return n(``,`filetree-root`,e.files.map((e,n)=>e.attributes.padding?null:{id:n,filename:e.components[e.components.length-1],pathComponents:e.components,length:e.length,have_bytes:t?t.file_progress[n]??0:0}).filter(e=>e!==null),0)},Ps=({torrentId:e,tree:t,selectedFiles:n,setSelectedFiles:r,initialExpanded:i,torrentDetails:a,torrentStats:o,showProgressBar:s,disabled:c,allowStream:l})=>{let u=(0,_.useContext)(v),[d,f]=(0,_.useState)(i),p=(0,_.useMemo)(()=>{let e=t=>{let n=t.dirs.flatMap(e);return n.push(...t.files.map(e=>e.id)),n};return e(t)},[t]),m=e=>{if(e.target.checked){let e=new Set(n);p.forEach(t=>e.add(t)),r(e)}else{let e=new Set(n);p.forEach(t=>e.delete(t)),r(e)}},h=e=>{if(n.has(e)){let t=new Set(n);t.delete(e),r(t)}else{let t=new Set(n);t.add(e),r(t)}},g=()=>p.filter(e=>n.has(e)).length,y=()=>p.filter(e=>n.has(e)).map(e=>a.files[e].length).reduce((e,t)=>e+t,0),x=t=>{if(l&&e!=null)return u.getTorrentStreamUrl(e,t.id,t.filename)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(ta,{onClick:()=>f(!d),children:d?(0,b.jsx)(js,{}):(0,b.jsx)(As,{})}),(0,b.jsx)(ks,{checked:p.every(e=>n.has(e)),label:`${t.name?t.name+`, `:``} ${g()} files, ${Xo(y())}`,name:t.id,onChange:m})]}),(0,b.jsxs)(`div`,{className:`pl-5`,hidden:!d,children:[t.dirs.map(t=>(0,b.jsx)(Ps,{torrentId:e,torrentDetails:a,torrentStats:o,tree:t,selectedFiles:n,setSelectedFiles:r,initialExpanded:!1,showProgressBar:s,disabled:c,allowStream:l},t.name)),(0,b.jsx)(`div`,{className:`pl-1`,children:t.files.map(t=>(0,b.jsxs)(`div`,{className:`${s?`grid grid-cols-1 gap-1 items-start lg:grid-cols-2 mb-2 lg:mb-0`:``}`,children:[(0,b.jsx)(ks,{checked:n.has(t.id),label:`${t.filename} (${Xo(t.length)})`,name:`torrent-${e}-file-${t.id}`,disabled:c,onChange:()=>h(t.id),labelLink:x(t)}),s&&(0,b.jsx)(Yo,{now:t.have_bytes/t.length*100,variant:t.have_bytes==t.length?`success`:`info`})]},t.id))})]})]})},Fs=({torrentId:e,torrentDetails:t,selectedFiles:n,setSelectedFiles:r,torrentStats:i,showProgressBar:a,disabled:o,allowStream:s})=>(0,b.jsx)(Ps,{torrentId:e,torrentDetails:t,torrentStats:i,tree:(0,_.useMemo)(()=>Ns(t,i),[t,i]),selectedFiles:n,setSelectedFiles:r,initialExpanded:!0,showProgressBar:a,disabled:o,allowStream:s}),Is=({torrentId:e,detailsResponse:t,statsResponse:n,onRefresh:r})=>{let[i,a]=(0,_.useState)(new Set),[o,s]=(0,_.useState)(!1),c=(0,_.useContext)(v),l=Ko(e=>e.setCloseableError);return(0,_.useEffect)(()=>{a(new Set(t?.files.map((e,t)=>({f:e,id:t})).filter(({f:e})=>e.included).map(({id:e})=>e)??[]))},[t]),t?(0,b.jsx)(`div`,{className:`p-2 text-sm`,children:(0,b.jsx)(Fs,{torrentId:e,torrentDetails:t,torrentStats:n,selectedFiles:i,setSelectedFiles:t=>{s(!0),c.updateOnlyFiles(e,Array.from(t)).then(()=>{r?.(),l(null)},e=>{l({text:`Error configuring torrent`,details:e})}).finally(()=>s(!1))},disabled:o,allowStream:!0,showProgressBar:!0})}):(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`Loading...`})};function Ls({column:e,sortColumn:t,sortDirection:n}){return e===t?n===`asc`?(0,b.jsx)(gi,{className:`inline ml-0.5 w-4 h-4`}):(0,b.jsx)(_i,{className:`inline ml-0.5 w-4 h-4`}):null}var Rs=5e3,zs=e=>e===0?`-`:Xo(e)+`/s`,Bs=({torrent:e})=>{let t=e?.id,n=e?.stats??null,r=(0,_.useContext)(v),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)([]),[c,l]=(0,_.useState)(`downloadSpeed`),[u,d]=(0,_.useState)(`desc`),f=(0,_.useRef)(null),p=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{if(!(t==null||!n?.live))return Cs(()=>r.getPeerStats(t).then(e=>(a(e),1e3),e=>(console.error(e),5e3)),0)},[t,!!n?.live]),(0,_.useEffect)(()=>{if(!i){s([]);return}let e=Date.now(),t=f.current,n=p.current,r=Object.entries(i.peers).map(([r,i])=>{let a=0,o=0;if(t&&t.snapshot.peers[r]){let n=(e-t.timestamp)/1e3;if(n>0){let e=t.snapshot.peers[r],s=i.counters.fetched_bytes-e.counters.fetched_bytes,c=i.counters.uploaded_bytes-e.counters.uploaded_bytes;a=Math.max(0,s/n),o=Math.max(0,c/n)}}let s=n.get(r)??[];s.push({downloadSpeed:a,uploadSpeed:o,timestamp:e}),s=s.filter(t=>e-t.timestamp<=Rs),n.set(r,s);let c=0,l=0;return s.length>0&&(c=s.reduce((e,t)=>e+t.downloadSpeed,0)/s.length,l=s.reduce((e,t)=>e+t.uploadSpeed,0)/s.length),{addr:r,stats:i,downloadSpeed:c,uploadSpeed:l}});for(let e of n.keys())i.peers[e]||n.delete(e);s(r),f.current={snapshot:i,timestamp:e}},[i]);let m=(0,_.useCallback)(e=>{l(t=>t===e?(d(e=>e===`asc`?`desc`:`asc`),e):(d(`desc`),e))},[]),h=(0,_.useMemo)(()=>[...o].sort((e,t)=>{let n=0;switch(c){case`addr`:n=e.addr.localeCompare(t.addr);break;case`connKind`:n=(e.stats.conn_kind??``).localeCompare(t.stats.conn_kind??``);break;case`downloadSpeed`:n=e.downloadSpeed-t.downloadSpeed;break;case`uploadSpeed`:n=e.uploadSpeed-t.uploadSpeed;break;case`downloaded`:n=e.stats.counters.fetched_bytes-t.stats.counters.fetched_bytes;break;case`uploaded`:n=e.stats.counters.uploaded_bytes-t.stats.counters.uploaded_bytes;break}return u===`asc`?n:-n}),[o,c,u]);if(!n)return(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`Loading...`});if(!n.live)return(0,b.jsx)(`div`,{className:`p-4 text-tertiary`,children:`No live peer information available (torrent is not live)`});let g=`px-2 py-1.5 text-left text-sm text-secondary cursor-pointer hover:text-text select-none`;return(0,b.jsx)(`div`,{className:`p-3`,children:(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`min-w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`addr`),children:[`IP Address`,(0,b.jsx)(Ls,{column:`addr`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`connKind`),children:[`Type`,(0,b.jsx)(Ls,{column:`connKind`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`downloadSpeed`),children:[`Down Speed`,(0,b.jsx)(Ls,{column:`downloadSpeed`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`uploadSpeed`),children:[`Up Speed`,(0,b.jsx)(Ls,{column:`uploadSpeed`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`downloaded`),children:[`Downloaded`,(0,b.jsx)(Ls,{column:`downloaded`,sortColumn:c,sortDirection:u})]}),(0,b.jsxs)(`th`,{className:g,onClick:()=>m(`uploaded`),children:[`Uploaded`,(0,b.jsx)(Ls,{column:`uploaded`,sortColumn:c,sortDirection:u})]})]})}),(0,b.jsx)(`tbody`,{children:h.length===0?(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-2 py-3 text-center text-sm text-tertiary`,children:i===null?`Loading peer list...`:`No connected peers`})}):h.map(e=>(0,b.jsxs)(`tr`,{className:`hover:bg-surface-raised`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm font-mono`,children:e.addr}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:e.stats.conn_kind??`-`}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-success`,children:zs(e.downloadSpeed)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-primary`,children:zs(e.uploadSpeed)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:Xo(e.stats.counters.fetched_bytes)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-sm text-secondary`,children:Xo(e.stats.counters.uploaded_bytes)})]},e.addr))})]})})})};function Vs(e,t){let n=t;for(;n=48&&e[n]<=57;)n++;if(n===t||e[n]!==58)return null;let r=parseInt(new TextDecoder().decode(e.slice(t,n)),10);return n++,n+r>e.length?null:[new TextDecoder().decode(e.slice(n,n+r)),n+r]}function Hs(e,t){if(e[t]!==105)return null;let n=t+1;for(;n=e.length?null:[parseInt(new TextDecoder().decode(e.slice(t+1,n)),10),n+1]}function Us(e,t){if(t>=e.length)return null;let n=e[t];if(n>=48&&n<=57)return Vs(e,t);if(n===105)return Hs(e,t);if(n===108){let n=[],r=t+1;for(;rtypeof e==`string`);t.length>0&&i.push(t)}}return{announce:r,announceList:i}}var Gs={not_contacted:`Not contacted`,updating:`Updating...`,working:`Working`,error:`Error`,disabled:`Disabled`},Ks={not_contacted:`bg-surface-sunken text-tertiary`,updating:`bg-warning/15 text-warning`,working:`bg-success/15 text-success`,error:`bg-error/15 text-error`,disabled:`bg-surface-sunken text-tertiary`},qs=({state:e})=>(0,b.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium whitespace-nowrap ${Ks[e]}`,children:Gs[e]});function Js(e){if(!e)return`—`;let t=Math.max(0,Math.floor(Date.now()/1e3)-e);return t<5?`just now`:t<60?`${t}s ago`:t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}var Ys=`px-2 py-1.5 text-left text-xs font-semibold text-tertiary uppercase tracking-wide whitespace-nowrap`,Xs=`px-2 py-1 text-center text-secondary tabular-nums`,Zs=({torrent:e})=>{let t=(0,_.useContext)(v),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(null),u=e?.id;return(0,_.useEffect)(()=>{if(u!=null)return r(null),a(!0),s(!1),l(null),Cs(async()=>{try{return r((await t.getTrackerStatus(u)).trackers),a(!1),5e3}catch{return a(!1),s(!0),6e4}},0)},[u,t]),(0,_.useEffect)(()=>{u==null||!o||t.getMetadata(u).then(e=>{let t=Ws(e),n=new Set;t.announce&&n.add(t.announce);for(let e of t.announceList)for(let t of e)n.add(t);l(Array.from(n))}).catch(()=>l([]))},[u,o,t]),e?(0,b.jsxs)(`div`,{className:`p-3 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,b.jsx)(`span`,{className:`text-secondary font-medium`,children:`Info Hash:`}),(0,b.jsx)(`code`,{className:`bg-surface-sunken px-1.5 py-0.5 rounded text-xs font-mono`,children:e.info_hash})]}),i&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-tertiary`,children:[(0,b.jsx)(xi,{}),(0,b.jsx)(`span`,{children:`Loading tracker status...`})]}),!i&&n&&n.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-tertiary`,children:`No trackers configured (DHT/PEX only)`}),!i&&n&&n.length>0&&(0,b.jsx)(`div`,{className:`overflow-x-auto`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:Ys,children:`Tracker`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Status`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Seeds`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Peers`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Received`}),(0,b.jsx)(`th`,{className:`${Ys} text-center`,children:`Last Announce`}),(0,b.jsx)(`th`,{className:Ys,children:`Message`})]})}),(0,b.jsx)(`tbody`,{children:n.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider/50 hover:bg-surface-raised`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 font-mono text-xs max-w-[26rem] truncate`,title:e.url,children:e.url}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-center`,children:(0,b.jsx)(qs,{state:e.state})}),(0,b.jsx)(`td`,{className:Xs,children:e.seeders??`—`}),(0,b.jsx)(`td`,{className:Xs,children:e.leechers??`—`}),(0,b.jsx)(`td`,{className:Xs,children:e.peers_returned??`—`}),(0,b.jsx)(`td`,{className:Xs,children:Js(e.last_announce_unix)}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-xs text-tertiary max-w-[18rem] truncate`,title:e.last_error??void 0,children:e.last_error??``})]},e.url))})]})}),o&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`p`,{className:`text-xs text-tertiary mb-2`,children:`Live tracker status not available on this server; showing configured trackers.`}),c===null&&(0,b.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-tertiary`,children:[(0,b.jsx)(xi,{}),(0,b.jsx)(`span`,{children:`Loading tracker info...`})]}),c&&c.length===0&&(0,b.jsx)(`p`,{className:`text-sm text-tertiary`,children:`No trackers found (DHT/PEX only)`}),c&&c.length>0&&(0,b.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>(0,b.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-mono bg-surface-sunken px-2 py-1 rounded`,children:(0,b.jsx)(`span`,{className:`truncate text-primary`,title:e,children:e})},e))})]})]}):null},Qs=300,$s=({torrent:e})=>{let t=(0,_.useRef)(null),[n,r]=(0,_.useState)([]),i=(0,_.useContext)(v);(0,_.useEffect)(()=>{r([])},[e?.id]),(0,_.useEffect)(()=>{if(!e||e.stats?.state!==`live`)return;let t=setInterval(async()=>{try{let t=await i.getTorrentStats(e.id);t.live&&r(e=>[...e,{timestamp:Date.now(),downloadSpeed:t.live.download_speed.mbps*1024*1024/8,uploadSpeed:t.live.upload_speed.mbps*1024*1024/8}].slice(-300))}catch{}},1e3);return()=>clearInterval(t)},[e?.id,e?.stats?.state,i]);let a=(0,_.useCallback)(()=>{let e=t.current;if(!e||n.length<2)return;let r=e.getContext(`2d`);if(!r)return;let i=window.devicePixelRatio||1,a=e.clientWidth,o=e.clientHeight;e.width=a*i,e.height=o*i,r.scale(i,i),r.clearRect(0,0,a,o);let s=Math.max(...n.map(e=>Math.max(e.downloadSpeed,e.uploadSpeed)),1024),c=document.documentElement.classList.contains(`dark`);r.strokeStyle=c?`rgba(255,255,255,0.1)`:`rgba(0,0,0,0.1)`,r.lineWidth=1;for(let e=0;e<5;e++){let t=e/4*o;r.beginPath(),r.moveTo(0,t),r.lineTo(a,t),r.stroke()}let l=(e,t,n)=>{r.beginPath(),r.strokeStyle=n,r.lineWidth=2,e.forEach((e,n)=>{let i=n/(Qs-1)*a,c=o-t(e)/s*o;n===0?r.moveTo(i,c):r.lineTo(i,c)}),r.stroke()};l(n,e=>e.downloadSpeed,c?`#60a5fa`:`#2563eb`),l(n,e=>e.uploadSpeed,c?`#34d399`:`#059669`),r.fillStyle=c?`rgba(255,255,255,0.5)`:`rgba(0,0,0,0.5)`,r.font=`10px monospace`,r.textAlign=`right`;for(let e=0;e<=4;e++){let t=s*(1-e/4),n=e/4*o+10;r.fillText(`${Xo(t)}/s`,a-4,n)}},[n]);return(0,_.useEffect)(()=>{a()},[a]),e?e.stats?.state===`live`?(0,b.jsxs)(`div`,{className:`p-3 h-full flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-4 mb-2 text-xs`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`w-3 h-0.5 bg-accent-download inline-block rounded`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`Download`}),e.stats?.live&&(0,b.jsx)(`span`,{className:`text-primary font-medium`,children:e.stats.live.download_speed.human_readable})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`w-3 h-0.5 bg-accent-upload inline-block rounded`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`Upload`}),e.stats?.live&&(0,b.jsx)(`span`,{className:`text-primary font-medium`,children:e.stats.live.upload_speed.human_readable})]})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(`canvas`,{ref:t,className:`w-full h-full bg-surface-sunken rounded`,style:{minHeight:`120px`}})})]}):(0,b.jsx)(`div`,{className:`p-3 text-tertiary text-sm`,children:`Speed chart is only available for active torrents.`}):null},ec=({label:e,active:t,onClick:n})=>(0,b.jsx)(`button`,{onClick:n,className:`px-3 py-1.5 font-medium transition-colors cursor-pointer ${t?`border-b-2 border-primary text-primary -mb-px`:`text-tertiary hover:text-secondary`}`,children:e}),tc=({children:e,className:t})=>(0,b.jsx)(`div`,{className:`flex border-b border-divider ${t??``}`,children:e}),nc=({span:e})=>{let t=Object.entries(e).filter(([e,t])=>e!=`name`);return t.length==0?null:(0,b.jsxs)(b.Fragment,{children:[`{`,t.map(([e,t])=>(0,b.jsxs)(`span`,{children:[e,` = `,t]},e)).reduce((e,t)=>(0,b.jsxs)(b.Fragment,{children:[e,`, `,t]})),`}`]})},rc=({span:e})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`span`,{className:`font-bold`,children:e.name}),(0,b.jsx)(nc,{span:e}),(0,b.jsx)(`span`,{className:`font-bold`,children:`:`})]}),ic=({fields:e})=>(0,b.jsxs)(`span`,{className:`m-1 ${e.message.match(/error|fail/g)?`text-red-500`:`text-slate-500 dark:text-slate-200`}`,children:[e.message,Object.entries(e).filter(([e,t])=>e!=`message`).map(([e,t])=>(0,b.jsxs)(`span`,{className:`m-1`,children:[(0,b.jsx)(`span`,{className:`italic font-bold`,children:e}),`=`,t]},e))]}),ac=_.memo(({line:e})=>{let t=e;return(0,b.jsxs)(`p`,{className:`font-mono m-0 text-break text-[10px]`,children:[(0,b.jsx)(`span`,{className:`m-1 text-slate-500 dark:text-slate-400`,children:t.timestamp}),(0,b.jsx)(`span`,{className:`m-1 ${(e=>{switch(e){case`TRACE`:return`text-slate-400 dark:text-slate-500`;case`DEBUG`:return`text-blue-500`;case`INFO`:return`text-green-500`;case`WARN`:return`text-amber-500`;case`ERROR`:return`text-red-500`;default:return`text-slate-500`}})(t.level)}`,children:t.level}),(0,b.jsx)(`span`,{className:`m-1`,children:t.spans?.map((e,t)=>(0,b.jsx)(rc,{span:e},t))}),(0,b.jsx)(`span`,{className:`m-1 text-slate-500 dark:text-slate-400`,children:t.target}),(0,b.jsx)(ic,{fields:t.fields})]})}),oc=(e,t,n)=>{let r=[...e.spans??[],...e.span?[e.span]:[]];for(let e of r)if(e.name===`torrent`&&Number(e.id)===n.id)return!0;return n.infoHash.length>0&&t.toLowerCase().includes(n.infoHash.toLowerCase())},sc=[`TRACE`,`DEBUG`,`INFO`,`WARN`,`ERROR`],cc=e=>{switch(e){case`TRACE`:return`bg-slate-200 dark:bg-slate-700 text-slate-700 dark:text-slate-300`;case`DEBUG`:return`bg-blue-100 dark:bg-blue-900/50 text-blue-600 dark:text-blue-400`;case`INFO`:return`bg-green-100 dark:bg-green-900/50 text-green-600 dark:text-green-400`;case`WARN`:return`bg-amber-100 dark:bg-amber-900/50 text-amber-600 dark:text-amber-400`;case`ERROR`:return`bg-red-100 dark:bg-red-900/50 text-red-600 dark:text-red-400`;default:return`bg-surface-sunken text-tertiary`}},lc=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n},uc=(e,t,n)=>{let r=new AbortController,i=r.signal,a=!1,o=()=>{console.log(`cancelling fetch`),a=!0,r.abort()},s=async()=>{let r=await fetch(e,{signal:i});if(!r.ok){let e=await r.text();throw n({text:`error fetching logs`,details:{statusText:r.statusText,text:e}}),null}if(!r.body){n({text:`error fetching logs: ReadableStream not supported.`});return}n(null);let a=r.body.getReader(),o=new Uint8Array;for(;;){let{done:e,value:r}=await a.read();if(e)throw n({text:`log stream terminated`}),null;o=lc(o,r);for(let e;(e=o.indexOf(10))!==-1;){let n=o.slice(0,e);t(new TextDecoder().decode(n)),o=o.slice(e+1)}}},c=Ss(()=>s().then(()=>{},e=>{if(!a&&e!==null)throw n({text:`error streaming logs`,details:{text:e.toString()}}),e}),1e3);return()=>{o(),c()}},dc=({url:e,maxLines:t,torrentFilter:n})=>{let[r,i]=(0,_.useState)([]),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(``),l=(0,_.useRef)(null),[u,d]=(0,_.useState)(new Set([`TRACE`,`DEBUG`,`INFO`,`WARN`,`ERROR`])),f=t??1e3,p=(0,_.useCallback)(e=>{d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),m=(0,_.useCallback)(e=>{i(t=>{let n=t.length==0?0:t[0].id+1,r=l.current;return[{id:n,content:e,parsed:JSON.parse(e),show:r?!!e.match(r):!0},...t.slice(0,f-1)]})},[t]),h=(0,_.useRef)(m);h.current=m;let g=(0,bi.default)(e=>{let t=null;try{t=new RegExp(e)}catch{return}l.current=t,i(e=>{let n=[...e];for(let e of n)e.show=!!e.content.match(t);return n})},200),v=e=>{c(e),g(e)};(0,_.useEffect)(()=>g.cancel,[]),(0,_.useEffect)(()=>uc(e,e=>h.current(e),o),[e]);let y=(0,_.useMemo)(()=>r.filter(e=>e.show&&u.has(e.parsed.level)&&(!n||oc(e.parsed,e.content,n))),[r,u,n]),x=(0,_.useCallback)(()=>{let e=y.map(e=>e.content).join(` -`);navigator.clipboard.writeText(e)},[y]),S=(0,_.useCallback)(()=>{let e=y.map(e=>e.content).join(` -`),t=new Blob([e],{type:`text/plain`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`rusttorrent-logs-${new Date().toISOString().slice(0,19)}.log`,r.click(),URL.revokeObjectURL(n)},[y]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsx)(ha,{error:a}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2 mb-2 flex-wrap`,children:[sc.map(e=>(0,b.jsx)(`button`,{onClick:()=>p(e),className:`px-2 py-0.5 text-xs font-mono rounded cursor-pointer ${u.has(e)?cc(e):`bg-surface-sunken text-tertiary`}`,children:e},e)),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`button`,{onClick:x,className:`text-xs text-secondary hover:text-primary cursor-pointer`,children:`Copy`}),(0,b.jsx)(`button`,{onClick:S,className:`text-xs text-secondary hover:text-primary cursor-pointer`,children:`Download`})]}),(0,b.jsx)(`div`,{className:`mb-2`,children:(0,b.jsx)(`input`,{value:s,onChange:e=>v(e.target.value),placeholder:`Filter (regex)...`,className:`w-full px-3 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`})}),(0,b.jsxs)(`div`,{className:`text-xs text-tertiary mb-1`,children:[`Showing `,y.length,` of `,r.length,` lines (last `,f,` `,`since window opened)`]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,style:{minHeight:`300px`},children:(0,b.jsx)(sr,{data:y,followOutput:`smooth`,itemContent:(e,t)=>(0,b.jsx)(ac,{line:t.parsed})})})]})},fc=[`overview`,`files`,`peers`,`trackers`,`speed`,`logs`],pc=()=>{let e=Z(e=>e.selectedTorrentIds),t=Z(e=>e.detailPaneRequestedTab),n=Z(e=>e.setDetailPaneTab),[r,i]=(0,_.useState)(`overview`);(0,_.useEffect)(()=>{t&&fc.includes(t)&&(i(t),n(null))},[t,n]);let a=Array.from(e),o=a.length;if(o===0)return(0,b.jsx)(`div`,{className:`h-full border-t border-divider bg-surface-raised flex items-center justify-center`,children:(0,b.jsx)(`p`,{className:`text-tertiary`,children:`Select a torrent to view details`})});if(o>1)return(0,b.jsx)(`div`,{className:`h-full border-t border-divider bg-surface-raised flex items-center justify-center`,children:(0,b.jsxs)(`p`,{className:`text-tertiary`,children:[o,` torrents selected`]})});let s=a[0];return(0,b.jsxs)(`div`,{className:`h-full border-t border-divider flex flex-col bg-surface`,children:[(0,b.jsxs)(tc,{className:`bg-surface-raised`,children:[(0,b.jsx)(ec,{id:`overview`,label:`Overview`,active:r===`overview`,onClick:()=>i(`overview`)}),(0,b.jsx)(ec,{id:`files`,label:`Files`,active:r===`files`,onClick:()=>i(`files`)}),(0,b.jsx)(ec,{id:`peers`,label:`Peers`,active:r===`peers`,onClick:()=>i(`peers`)}),(0,b.jsx)(ec,{id:`trackers`,label:`Trackers`,active:r===`trackers`,onClick:()=>i(`trackers`)}),(0,b.jsx)(ec,{id:`speed`,label:`Speed`,active:r===`speed`,onClick:()=>i(`speed`)}),(0,b.jsx)(ec,{id:`logs`,label:`Logs`,active:r===`logs`,onClick:()=>i(`logs`)})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,b.jsx)(mc,{torrentId:s,activeTab:r})})]})},mc=({torrentId:e,activeTab:t})=>{let n=(0,_.useContext)(v),[r,i]=(0,_.useState)(!1),a=ua(t=>t.torrents?.find(t=>t.id===e)),o=ua(t=>t.getDetails(e)),s=ua(e=>e.setDetails),c=ua(e=>e.refreshTorrents);(0,_.useEffect)(()=>{t===`files`&&(o||i(!0))},[t,e,o]),(0,_.useEffect)(()=>{if(r)return Ss(async()=>{s(e,await n.getTorrentDetails(e)),i(!1)},1e3)},[r,e]);let l=()=>{c(),i(!0)},u=a?.stats??null,d=n.getStreamLogsUrl(),f=a?.info_hash??``,p=(0,_.useMemo)(()=>({id:e,infoHash:f}),[e,f]);return(0,b.jsxs)(b.Fragment,{children:[t===`overview`&&(0,b.jsx)(Os,{torrent:a??null}),t===`files`&&(0,b.jsx)(Is,{torrentId:e,detailsResponse:o,statsResponse:u,onRefresh:l}),t===`peers`&&(0,b.jsx)(Bs,{torrent:a??null}),t===`trackers`&&(0,b.jsx)(Zs,{torrent:a??null}),t===`speed`&&(0,b.jsx)($s,{torrent:a??null}),t===`logs`&&(0,b.jsx)(`div`,{className:`h-full p-2`,children:d?(0,b.jsx)(dc,{url:d,maxLines:500,torrentFilter:p}):(0,b.jsx)(`p`,{className:`text-tertiary p-3`,children:`Log streaming not available`})})]})},hc=({torrentId:e,isOpen:t,onClose:n})=>(0,b.jsxs)(So,{isOpen:t,onClose:n,title:ua(t=>t.torrents?.find(t=>t.id===e))?.name??`Torrent #${e}`,className:`sm:max-w-4xl flex flex-col max-h-[calc(100vh-2rem)] sm:max-h-[calc(100vh-4rem)]`,children:[(0,b.jsx)(xs,{hideFilters:!0}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(pc,{})})]}),gc=({menu:e,onClose:t})=>{let{x:n,y:r}=e,i=(0,_.useRef)(null),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(``),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(``),[w,T]=(0,_.useState)(``),[E,D]=(0,_.useState)(``),[O,ee]=(0,_.useState)(``),te=(0,_.useRef)(null),k=(0,_.useContext)(v),ne=Ko(e=>e.setCloseableError),A=ua(e=>e.refreshTorrents),j=Z(e=>e.openDetailsModal),re=Z(e=>e.setDetailPaneTab),M=Z(e=>e.categories),N=Z(e=>e.setCategories),P=e.selectedTorrents,ie=P.length>1,F=P.some(e=>e.stats?.state===`live`),I=P.some(e=>e.stats?.state===`paused`||e.stats?.state===`error`),L=P.length===1?P[0]:null,R=L&&(L.stats?.state===`paused`||L.stats?.state===`live`),z=P.some(e=>e.stats?.finished),B=P.some(e=>e.stats?.queue_state!=null),V=L?.stats?.sequential??!1,H=L?.stats?.super_seeding??!1,ae=(0,_.useRef)(!1);(0,_.useEffect)(()=>{ae.current||(ae.current=!0,k.getCategories().then(e=>N(e)).catch(()=>{}))},[k,N]),(0,_.useEffect)(()=>{h&&L&&k.getTorrentLimits(L.id).then(e=>{C(e.download_rate?.toString()??``),T(e.upload_rate?.toString()??``)}).catch(()=>{})},[h,L,k]),(0,_.useEffect)(()=>{if(y&&L){let e=L.stats;D(e?.seed_ratio_limit==null?``:e.seed_ratio_limit.toString()),ee(e?.seed_time_limit_secs==null?``:e.seed_time_limit_secs.toString())}},[y,L]),(0,_.useEffect)(()=>{let e=e=>{e.button!==2&&i.current&&!i.current.contains(e.target)&&t()},n=e=>{e.key===`Escape`&&t()},r=()=>t();return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,n),window.addEventListener(`scroll`,r,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,n),window.removeEventListener(`scroll`,r,!0)}},[t]);let U=Math.min(n,window.innerWidth-220-8),oe=Math.min(r,window.innerHeight-500-8),se=async()=>{m(!0);for(let e of P)if(e.stats?.state===`paused`||e.stats?.state===`error`)try{await k.start(e.id)}catch(t){ne({text:`Error starting torrent "${e.name??e.id}"`,details:t})}A(),t()},ce=async()=>{m(!0);for(let e of P)if(e.stats?.state===`live`)try{await k.pause(e.id)}catch(t){ne({text:`Error pausing torrent "${e.name??e.id}"`,details:t})}A(),t()},W=()=>{let e=P.map(e=>e.name??``).filter(Boolean).join(` -`);navigator.clipboard.writeText(e),t()},le=()=>{let e=P.map(e=>e.info_hash).join(` -`);navigator.clipboard.writeText(e),t()},ue=()=>{let e=P.map(e=>{let t=`magnet:?xt=urn:btih:${e.info_hash}`;return e.name&&(t+=`&dn=${encodeURIComponent(e.name)}`),t});navigator.clipboard.writeText(e.join(` -`)),t()},G=()=>{L&&(j(L.id),re(`files`)),t()},de=async e=>{m(!0);for(let t of P)try{await k.setTorrentCategory(t.id,e)}catch(e){ne({text:`Error setting category for "${t.name??t.id}"`,details:e})}A(),t()},K=async()=>{let e=d.trim();if(!e){u(!1);return}m(!0);try{await k.createCategory(e),N(await k.getCategories())}catch{}for(let t of P)try{await k.setTorrentCategory(t.id,e)}catch(e){ne({text:`Error setting category for "${t.name??t.id}"`,details:e})}A(),t()},fe=async()=>{m(!0);for(let e of P)try{let t=e.stats?.sequential??!1;await k.setSequential(e.id,!t)}catch(t){ne({text:`Error toggling sequential for "${e.name??e.id}"`,details:t})}A(),t()},pe=async()=>{m(!0);for(let e of P)try{let t=e.stats?.super_seeding??!1;await k.setSuperSeed(e.id,!t)}catch(t){ne({text:`Error toggling super-seed for "${e.name??e.id}"`,details:t})}A(),t()},me=async(e,n)=>{m(!0);for(let t of P)try{await e(t.id)}catch(e){ne({text:`Error ${n} for "${t.name??t.id}"`,details:e})}A(),t()},he=async()=>{if(L){m(!0);try{await k.setTorrentLimits(L.id,{download_rate:S?Number(S):void 0,upload_rate:w?Number(w):void 0})}catch(e){ne({text:`Error setting speed limits`,details:e})}A(),t()}},ge=async()=>{if(L){m(!0);try{await k.setTorrentSeedLimits(L.id,{ratio_limit:E?Number(E):null,time_limit_secs:O?Number(O):null})}catch(e){ne({text:`Error setting seed limits`,details:e})}A(),t()}},q=`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,_e=`w-3.5 h-3.5 shrink-0`,ve=(0,b.jsx)(`div`,{className:`border-t border-divider my-1`}),ye=`w-full px-2 py-1 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`,be=Object.keys(M).sort((e,t)=>e.localeCompare(t)),xe=({checked:e})=>e?(0,b.jsx)(Wi,{className:`${_e} text-primary`}):(0,b.jsx)(Oi,{className:`${_e} text-secondary`});return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{ref:i,className:`fixed z-50 bg-surface-raised border border-divider rounded-lg shadow-lg py-1 overflow-y-auto`,style:{left:U,top:oe,width:220,maxHeight:500},children:[I&&(0,b.jsxs)(`button`,{className:q,onClick:se,disabled:p,children:[(0,b.jsx)(Po,{className:`${_e} text-green-600`}),ie?`Resume Selected`:`Resume`]}),F&&(0,b.jsxs)(`button`,{className:q,onClick:ce,disabled:p,children:[(0,b.jsx)(Fo,{className:`${_e} text-amber-500`}),ie?`Pause Selected`:`Pause`]}),(I||F)&&ve,R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:q,onClick:G,children:[(0,b.jsx)(zo,{className:`${_e} text-secondary`}),`Configure Files`]}),ve]}),(0,b.jsxs)(`button`,{className:q,onClick:fe,disabled:p,children:[(0,b.jsx)(xe,{checked:ie?!1:V}),`Sequential Download`]}),z&&(0,b.jsxs)(`button`,{className:q,onClick:pe,disabled:p,children:[(0,b.jsx)(xe,{checked:ie?!1:H}),`Super-Seed`]}),ve,B&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:q,onClick:()=>me(e=>k.queueMoveTop(e),`moving to top`),disabled:p,children:[(0,b.jsx)(Wo,{className:`${_e} text-secondary`}),`Move to Top`]}),(0,b.jsxs)(`button`,{className:q,onClick:()=>me(e=>k.queueMoveUp(e),`moving up`),disabled:p,children:[(0,b.jsx)(Vo,{className:`${_e} text-secondary`}),`Move Up`]}),(0,b.jsxs)(`button`,{className:q,onClick:()=>me(e=>k.queueMoveDown(e),`moving down`),disabled:p,children:[(0,b.jsx)(Uo,{className:`${_e} text-secondary`}),`Move Down`]}),(0,b.jsxs)(`button`,{className:q,onClick:()=>me(e=>k.queueMoveBottom(e),`moving to bottom`),disabled:p,children:[(0,b.jsx)(Go,{className:`${_e} text-secondary`}),`Move to Bottom`]}),ve]}),L&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`button`,{className:q,onClick:()=>g(e=>!e),disabled:p,children:[(0,b.jsx)(Ao,{className:`${_e} text-secondary`}),`Set Speed Limits...`]}),h&&(0,b.jsxs)(`div`,{className:`px-3 py-1.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`input`,{type:`number`,value:S,onChange:e=>C(e.target.value),placeholder:`Download (bytes/s)`,className:ye,min:`0`}),(0,b.jsx)(`input`,{type:`number`,value:w,onChange:e=>T(e.target.value),placeholder:`Upload (bytes/s)`,className:ye,min:`0`}),(0,b.jsx)(`button`,{className:`px-2 py-1 text-sm bg-primary-bg text-white rounded hover:bg-primary-bg-hover cursor-pointer`,onClick:he,children:`Apply`})]}),(0,b.jsxs)(`button`,{className:q,onClick:()=>x(e=>!e),disabled:p,children:[(0,b.jsx)(jo,{className:`${_e} text-secondary`}),`Set Seed Limits...`]}),y&&(0,b.jsxs)(`div`,{className:`px-3 py-1.5 flex flex-col gap-1.5`,children:[(0,b.jsx)(`input`,{type:`number`,value:E,onChange:e=>D(e.target.value),placeholder:`Ratio limit (e.g. 2.0)`,className:ye,min:`0`,step:`0.1`}),(0,b.jsx)(`input`,{type:`number`,value:O,onChange:e=>ee(e.target.value),placeholder:`Time limit (seconds)`,className:ye,min:`0`}),(0,b.jsx)(`button`,{className:`px-2 py-1 text-sm bg-primary-bg text-white rounded hover:bg-primary-bg-hover cursor-pointer`,onClick:ge,children:`Apply`})]}),ve]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsxs)(`button`,{className:q,onClick:()=>c(e=>!e),disabled:p,children:[(0,b.jsx)(ko,{className:`${_e} text-secondary`}),`Set Category...`]}),s&&(0,b.jsxs)(`div`,{className:`border-t border-divider bg-surface-raised`,children:[(0,b.jsx)(`button`,{className:`${q} text-tertiary`,onClick:()=>de(null),children:`None`}),be.map(e=>(0,b.jsx)(`button`,{className:q,onClick:()=>de(e),children:e},e)),l?(0,b.jsx)(`div`,{className:`px-3 py-1`,children:(0,b.jsx)(`input`,{ref:te,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&K(),e.key===`Escape`&&(f(``),u(!1))},onBlur:K,placeholder:`Category name...`,autoFocus:!0,className:ye})}):(0,b.jsxs)(`button`,{className:q,onClick:()=>u(!0),children:[(0,b.jsx)(No,{className:`${_e} text-tertiary`}),(0,b.jsx)(`span`,{className:`text-tertiary`,children:`New Category...`})]})]})]}),ve,(0,b.jsxs)(`button`,{className:q,onClick:W,children:[(0,b.jsx)(Ro,{className:`${_e} text-secondary`}),`Copy Name`]}),(0,b.jsxs)(`button`,{className:q,onClick:le,children:[(0,b.jsx)(Ro,{className:`${_e} text-secondary`}),`Copy Info Hash`]}),(0,b.jsxs)(`button`,{className:q,onClick:ue,children:[(0,b.jsx)(Ro,{className:`${_e} text-secondary`}),`Copy Magnet Link`]}),ve,(0,b.jsxs)(`button`,{className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left text-error hover:bg-error/10 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed`,onClick:()=>o(!0),disabled:p,children:[(0,b.jsx)(Oo,{className:`${_e}`}),ie?`Delete ${P.length} Torrents...`:`Delete...`]})]}),(0,b.jsx)(To,{show:a,onHide:()=>{o(!1),t()},torrents:P.map(e=>({id:e.id,name:e.name}))})]})},_c=`id`,vc=`desc`,yc=e=>{let t=Z(e=>e.searchQuery),n=Z(e=>e.setSearchQuery),r=Z(e=>e.statusFilter),i=Z(e=>e.setStatusFilter);bs();let a=Z(e=>e.detailsModalTorrentId),o=Z(e=>e.closeDetailsModal),[s,c]=(0,_.useState)(t),[l,u]=(0,_.useState)(_c),[d,f]=(0,_.useState)(vc),[p,m]=(0,_.useState)(null),h=(0,_.useCallback)((0,bi.default)(e=>n(e),150),[n]),g=e=>{let t=e.target.value;c(t),h(t)},v=()=>{c(``),n(``)},y=e=>{let[t,n]=e.target.value.split(`:`);u(t),f(n)},x=t.toLowerCase().trim(),S=(0,_.useMemo)(()=>e.torrents?[...e.torrents].filter(e=>ys(e,x,r)).sort((e,t)=>fs(e,t,l,d)):null,[e.torrents,x,r,l,d]),C=(0,_.useCallback)(e=>{let t=S[e];return(0,b.jsx)(`div`,{className:`pb-1.5 sm:pb-2 px-2 sm:px-7 max-w-4xl mx-auto w-full`,onContextMenu:e=>{e.preventDefault(),m({x:e.clientX,y:e.clientY,torrent:t,selectedTorrents:[t]})},children:(0,b.jsx)(cs,{torrent:t},t.id)})},[S]);return(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 w-full max-w-2xl mx-auto mb-2 mt-3 px-2 sm:px-7`,children:[(0,b.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,b.jsx)(fi,{className:`absolute left-2.5 sm:left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:s,onChange:g,placeholder:`Search...`,className:`w-full pl-8 sm:pl-9 pr-8 sm:pr-9 py-1.5 sm:py-2 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),s&&(0,b.jsx)(`button`,{onClick:v,className:`absolute right-1.5 sm:right-2 top-1/2 -translate-y-1/2 p-1 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(li,{className:`w-4 h-4`})})]}),(0,b.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),className:`py-1.5 sm:py-2 px-2 sm:px-3 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary`,children:Object.keys(us).map(e=>(0,b.jsx)(`option`,{value:e,children:us[e]},e))}),(0,b.jsx)(`select`,{value:`${l}:${d}`,onChange:y,className:`py-1.5 sm:py-2 px-2 sm:px-3 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary`,children:Object.keys(ls).flatMap(e=>[(0,b.jsxs)(`option`,{value:`${e}:desc`,children:[ls[e],` ↓`]},`${e}:desc`),(0,b.jsxs)(`option`,{value:`${e}:asc`,children:[ls[e],` ↑`]},`${e}:asc`)])})]}),S===null?e.loading?(0,b.jsx)(xi,{className:`justify-center m-5`,label:`Loading torrent list`}):null:S.length===0?(0,b.jsx)(`p`,{className:`text-center`,children:`No existing torrents found.`}):(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(sr,{totalCount:S.length,itemContent:C})}),a!==null&&(0,b.jsx)(hc,{torrentId:a,isOpen:!0,onClose:o}),p&&(0,b.jsx)(gc,{menu:p,onClose:()=>m(null)})]})},bc=1024;function xc(){let[e,t]=(0,_.useState)(()=>window.innerWidth>=bc);return(0,_.useEffect)(()=>{let e=()=>{t(window.innerWidth>=bc)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function Sc(e){if(!e)return`—`;let t=new Date(e*1e3);return`${t.toLocaleDateString(void 0,{year:`2-digit`,month:`2-digit`,day:`2-digit`})} ${t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`}var Cc=[`id`,`name`,`size`,`progress`,`downloadedBytes`,`downSpeed`,`upSpeed`,`uploadedBytes`,`eta`,`peers`,`state`,`info_hash`,`ratio`,`category`,`seeding_time`,`queue_position`,`sequential`,`availability`,`added_on`,`tracker`],wc=[{id:`checkbox`,label:``,defaultWidth:32,minWidth:32,align:`center`,defaultVisible:!0,configurable:!1,sortable:!1},{id:`status_icon`,label:``,defaultWidth:32,minWidth:32,align:`center`,defaultVisible:!0,configurable:!1,sortable:!1},{id:`id`,label:`ID`,defaultWidth:48,minWidth:36,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`name`,label:`Name`,defaultWidth:0,minWidth:100,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`size`,label:`Size`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`progress`,label:`Progress`,defaultWidth:120,minWidth:80,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`downloadedBytes`,label:`Recv`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`downSpeed`,label:`↓ Speed`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`upSpeed`,label:`↑ Speed`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`uploadedBytes`,label:`Sent`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`eta`,label:`ETA`,defaultWidth:80,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`peers`,label:`Peers`,defaultWidth:64,minWidth:50,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`state`,label:`State`,defaultWidth:100,minWidth:60,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`info_hash`,label:`Info Hash`,defaultWidth:150,minWidth:80,align:`center`,defaultVisible:!1,configurable:!0,sortable:!1},{id:`ratio`,label:`Ratio`,defaultWidth:80,minWidth:50,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`category`,label:`Category`,defaultWidth:120,minWidth:60,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`seeding_time`,label:`Seed Time`,defaultWidth:100,minWidth:60,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`queue_position`,label:`Queue`,defaultWidth:60,minWidth:40,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`sequential`,label:`Seq`,defaultWidth:50,minWidth:36,align:`center`,defaultVisible:!1,configurable:!0,sortable:!1},{id:`availability`,label:`Avail`,defaultWidth:70,minWidth:50,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0},{id:`added_on`,label:`Added On`,defaultWidth:140,minWidth:90,align:`center`,defaultVisible:!0,configurable:!0,sortable:!0},{id:`tracker`,label:`Tracker`,defaultWidth:150,minWidth:80,align:`center`,defaultVisible:!1,configurable:!0,sortable:!0}],Tc=`rtbit-column-widths`,Ec=`rtbit-column-visible`,Dc=`rtbit-column-order`;function Oc(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):{}}catch{return{}}}function kc(){try{let e=localStorage.getItem(Dc);if(e){let t=JSON.parse(e),n=Cc.filter(e=>!t.includes(e));return[...t,...n]}}catch{}return[...Cc]}var Ac=sa((e,t)=>({columnWidths:Oc(Tc),columnVisibility:Oc(Ec),columnOrder:kc(),getWidth:e=>{let n=t().columnWidths[e];return n===void 0?wc.find(t=>t.id===e)?.defaultWidth??80:n},isVisible:e=>{let n=t().columnVisibility[e];return n===void 0?wc.find(t=>t.id===e)?.defaultVisible??!0:n},getVisibleColumns:()=>{let{isVisible:e,columnOrder:n}=t(),r=wc.filter(t=>!t.configurable&&e(t.id)),i=n.map(e=>wc.find(t=>t.id===e)).filter(t=>t&&e(t.id));return[...r,...i]},setColumnWidth:(t,n)=>{let r=wc.find(e=>e.id===t)?.minWidth??30,i=Math.max(r,n);e(e=>{let n={...e.columnWidths,[t]:i};return localStorage.setItem(Tc,JSON.stringify(n)),{columnWidths:n}})},toggleColumnVisibility:t=>{let n=wc.find(e=>e.id===t);n?.configurable&&e(e=>{let r=e.columnVisibility[t]??n.defaultVisible,i={...e.columnVisibility,[t]:!r};return localStorage.setItem(Ec,JSON.stringify(i)),{columnVisibility:i}})},moveColumn:(t,n)=>{e(e=>{let r=[...e.columnOrder],i=r.indexOf(t);if(i===-1)return e;let a=n===`up`?i-1:i+1;return a<0||a>=r.length?e:([r[i],r[a]]=[r[a],r[i]],localStorage.setItem(Dc,JSON.stringify(r)),{columnOrder:r})})},resetColumns:()=>{localStorage.removeItem(Tc),localStorage.removeItem(Ec),localStorage.removeItem(Dc),e({columnWidths:{},columnVisibility:{},columnOrder:[...Cc]})}}));function jc(e,t,n,r){return n||e===`error`?{label:`Error`,cls:`bg-error/15 text-error`}:r?{label:`Queued`,cls:`bg-surface-sunken text-secondary`}:e===`initializing`?{label:`Checking`,cls:`bg-warning/15 text-warning`}:e===`paused`?{label:`Paused`,cls:`bg-surface-sunken text-tertiary`}:e===`live`&&t?{label:`Seeding`,cls:`bg-success/15 text-success`}:e===`live`?{label:`Downloading`,cls:`bg-accent-download/15 text-accent-download`}:{label:e||`—`,cls:`bg-surface-sunken text-tertiary`}}function Mc({columns:e}){let t=Ac(e=>e.getWidth);return(0,b.jsx)(`colgroup`,{children:e.map(e=>{let n=t(e.id);return(0,b.jsx)(`col`,{style:n>0?{width:`${n}px`}:void 0},e.id)})})}var Nc=(0,_.memo)(({torrent:e,isSelected:t,odd:n,onRowClick:r,onContextMenu:i,onCheckboxChange:a,visibleColumns:o})=>{let s=e.stats,c=s?.state??``,l=s?.error??null,u=s?.total_bytes??1,d=s?.progress_bytes??0,f=s?.finished||!1,p=!!s?.live,m=l||u===0?100:Math.round(d/u*100),h=s?.live?.download_speed?.human_readable??`-`,g=s?.live?.upload_speed?.human_readable??`-`,_=s?.live?.snapshot.uploaded_bytes??0,v=s?.live?.snapshot.peer_stats,y=v?`${v.live}/${v.seen}`:`-`,x=s?$o(s):`-`,S=f?`Done`:x,C=e.name??``,w=t=>{r(e.id,t)},T=t=>{t.preventDefault(),i(e.id,t)},E=t=>{t.stopPropagation(),a(e.id)},D=`border-r border-divider/40`;function O(n){let r=n.align===`center`?`text-center`:n.align===`right`?`text-right`:`text-left`,i=`px-2 align-middle whitespace-nowrap ${D}`;switch(n.id){case`checkbox`:return(0,b.jsx)(`td`,{className:`px-2 align-middle text-center ${D}`,onMouseDown:E,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>{},className:`w-4 h-4 rounded border-divider-strong bg-surface text-primary focus:ring-primary`})},`checkbox`);case`status_icon`:return(0,b.jsx)(`td`,{className:`px-1 align-middle ${D}`,children:(0,b.jsx)(os,{className:`w-5 h-5`,error:!!l,live:p,finished:f,queued:s?.queue_state===`Queued`})},`status_icon`);case`id`:return(0,b.jsx)(`td`,{className:`${i} text-center text-tertiary font-mono`,children:e.id},`id`);case`name`:return(0,b.jsxs)(`td`,{className:`px-2 align-middle ${r} ${D}`,children:[(0,b.jsx)(`div`,{className:`truncate`,title:C,children:C||`Loading...`}),l&&(0,b.jsx)(`div`,{className:`truncate text-sm text-error`,title:l,children:l})]},`name`);case`size`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:Xo(u)},`size`);case`progress`:return(0,b.jsx)(`td`,{className:`px-2 align-middle text-center ${D}`,children:(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`div`,{className:`flex-1 h-2 bg-divider rounded-full overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-500 ${l?`bg-error-bg`:f?`bg-success-bg`:c===`initializing`?`bg-warning-bg`:`bg-accent-download`}`,style:{width:`${m}%`}})}),(0,b.jsxs)(`span`,{className:`text-sm text-secondary w-8 text-right tabular-nums`,children:[m,`%`]})]})},`progress`);case`downloadedBytes`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:Xo(d)},`downloadedBytes`);case`downSpeed`:return(0,b.jsx)(`td`,{className:`${i} ${r} tabular-nums ${(s?.live?.download_speed?.mbps??0)>.01?`text-accent-download font-medium`:`text-secondary`}`,children:h},`downSpeed`);case`upSpeed`:return(0,b.jsx)(`td`,{className:`${i} ${r} tabular-nums ${(s?.live?.upload_speed?.mbps??0)>.01?`text-accent-upload font-medium`:`text-secondary`}`,children:g},`upSpeed`);case`uploadedBytes`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:_>0?Xo(_):``},`uploadedBytes`);case`eta`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:S},`eta`);case`peers`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:y},`peers`);case`state`:{let e=jc(c,f,l,s?.queue_state===`Queued`);return(0,b.jsx)(`td`,{className:`${i} ${r}`,children:(0,b.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.cls}`,children:e.label})},`state`)}case`info_hash`:return(0,b.jsx)(`td`,{className:`px-2 align-middle ${r} font-mono text-xs text-tertiary ${D}`,children:(0,b.jsx)(`div`,{className:`truncate`,title:e.info_hash,children:e.info_hash})},`info_hash`);case`ratio`:{let e=s?.ratio,t=e==null?u>0?(_/u).toFixed(2):`0.00`:e.toFixed(2);return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:t},`ratio`)}case`category`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:(0,b.jsx)(`span`,{className:`truncate`,children:e.category||`—`})},`category`);case`seeding_time`:{let e=s?.seeding_time_secs;return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:e==null?`—`:Qo(e)},`seeding_time`)}case`queue_position`:{let e=s?.queue_state,t=s?.queue_position,n;return n=e===`Queued`&&t!=null?`#${t}`:e===`Active`?`Active`:`—`,(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:n},`queue_position`)}case`sequential`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:s?.sequential?`✓`:`—`},`sequential`);case`availability`:{let e=s?.min_piece_availability;return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,children:e==null?`—`:e.toFixed(1)},`availability`)}case`added_on`:return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary tabular-nums`,children:Sc(e.added_on)},`added_on`);case`tracker`:{let t=hs(e);return(0,b.jsx)(`td`,{className:`${i} ${r} text-secondary`,title:t.join(`, `),children:(0,b.jsx)(`span`,{className:`truncate`,children:t.length===0?`—`:t.length===1?t[0]:`${t[0]} +${t.length-1}`})},`tracker`)}default:return(0,b.jsx)(`td`,{className:i},n.id)}}return(0,b.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,b.jsx)(Mc,{columns:o}),(0,b.jsx)(`tbody`,{children:(0,b.jsx)(`tr`,{onMouseDown:w,onContextMenu:T,className:`cursor-pointer border-b border-divider/60 text-sm h-8 transition-colors ${t?`bg-primary/15`:`${n?`bg-surface-sunken/40`:``} hover:bg-primary/5`}`,children:o.map(e=>O(e))})})]})}),Pc=({x:e,y:t,onClose:n})=>{let r=Ac(e=>e.columnVisibility),i=Ac(e=>e.columnOrder),a=Ac(e=>e.toggleColumnVisibility),o=Ac(e=>e.moveColumn),s=Ac(e=>e.resetColumns),c=(0,_.useRef)(null);(0,_.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&n()},t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=Math.min(e,window.innerWidth-260-8),u=Math.min(t,window.innerHeight-400-8),d=i.map(e=>wc.find(t=>t.id===e)).filter(e=>e&&e.configurable),f=e=>{let t=r[e];return t===void 0?wc.find(t=>t.id===e)?.defaultVisible??!0:t},p=`p-0.5 text-tertiary hover:text-primary rounded hover:bg-surface-raised disabled:opacity-30 disabled:cursor-not-allowed cursor-pointer`;return(0,b.jsxs)(`div`,{ref:c,className:`fixed z-50 bg-surface-raised border border-divider rounded-lg shadow-lg py-1 overflow-y-auto`,style:{left:l,top:u,width:260,maxHeight:400},children:[(0,b.jsx)(`div`,{className:`px-3 py-1.5 text-xs font-semibold text-tertiary uppercase tracking-wider border-b border-divider`,children:`Columns`}),d.map((e,t)=>{let n=f(e.id);return(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1 hover:bg-surface`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-2 flex-1 cursor-pointer text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>a(e.id),className:`w-3.5 h-3.5 rounded border-divider-strong bg-surface text-primary focus:ring-primary`}),(0,b.jsx)(`span`,{className:n?`text-primary`:`text-tertiary`,children:e.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[(0,b.jsx)(`button`,{className:p,onClick:()=>o(e.id,`up`),disabled:t===0,title:`Move up`,children:(0,b.jsx)(ui,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{className:p,onClick:()=>o(e.id,`down`),disabled:t===d.length-1,title:`Move down`,children:(0,b.jsx)(di,{className:`w-3.5 h-3.5`})})]})]},e.id)}),(0,b.jsx)(`div`,{className:`border-t border-divider mt-1 pt-1`,children:(0,b.jsx)(`button`,{onClick:()=>{s(),n()},className:`w-full text-left px-3 py-1.5 text-xs text-secondary hover:bg-surface cursor-pointer`,children:`Reset to defaults`})})]})},Fc=`id`,Ic=`desc`;function Lc(e,t){switch(t){case`id`:return e.id;case`name`:return(e.name??``).toLowerCase();case`size`:return e.stats?.total_bytes??0;case`progress`:return e.stats?.total_bytes?(e.stats.progress_bytes??0)/e.stats.total_bytes:0;case`downloadedBytes`:return e.stats?.progress_bytes??0;case`downSpeed`:return e.stats?.live?.download_speed?.mbps??0;case`upSpeed`:return e.stats?.live?.upload_speed?.mbps??0;case`uploadedBytes`:return e.stats?.live?.snapshot.uploaded_bytes??0;case`eta`:{if(!e.stats?.live)return 1/0;let t=(e.stats.total_bytes??0)-(e.stats.progress_bytes??0),n=e.stats.live.download_speed?.mbps??0;return n<=0||t<=0?t<=0?0:1/0:t/(n*1024*1024)}case`peers`:return e.stats?.live?.snapshot.peer_stats?.live??0;case`state`:return e.stats?.state??``;case`ratio`:{if(e.stats?.ratio!=null)return e.stats.ratio;let t=e.stats?.live?.snapshot.uploaded_bytes??0,n=e.stats?.total_bytes??1;return n>0?t/n:0}case`category`:return(e.category??``).toLowerCase();case`seeding_time`:return e.stats?.seeding_time_secs??0;case`queue_position`:return e.stats?.queue_position??1/0;case`availability`:return e.stats?.min_piece_availability??0;case`added_on`:return e.added_on??0;case`tracker`:return hs(e)[0]??``}}function Rc({columns:e}){Ac(e=>e.columnWidths);let t=Ac(e=>e.getWidth);return(0,b.jsx)(`colgroup`,{children:e.map(e=>{let n=t(e.id);return(0,b.jsx)(`col`,{style:n>0?{width:`${n}px`}:void 0},e.id)})})}var zc=({torrents:e,loading:t})=>{let n=Z(e=>e.selectedTorrentIds),r=Z(e=>e.selectTorrent),i=Z(e=>e.toggleSelection),a=Z(e=>e.selectRange),o=Z(e=>e.selectRelative),s=Z(e=>e.selectAll),c=Z(e=>e.clearSelection),l=Z(e=>e.searchQuery),u=Z(e=>e.statusFilter),d=Z(e=>e.categoryFilter),f=Z(e=>e.trackerFilter);Ac(e=>e.columnVisibility),Ac(e=>e.columnWidths),Ac(e=>e.columnOrder);let p=Ac(e=>e.getVisibleColumns)(),m=Ac(e=>e.getWidth),h=Ac(e=>e.setColumnWidth),g=l.toLowerCase().trim(),[v,y]=(0,_.useState)(Fc),[x,S]=(0,_.useState)(Ic),[C,w]=(0,_.useState)(null),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(null),ee=(0,_.useCallback)(e=>{y(t=>(S(n=>t===e?n===`asc`?`desc`:`asc`:`desc`),e))},[]),te=(0,_.useMemo)(()=>e?[...e].filter(e=>ys(e,g,u,d,f)).sort((e,t)=>{let n=Lc(e,v),r=Lc(t,v),i=typeof n==`string`?n.localeCompare(r):n-r;return x===`asc`?i:-i}):null,[e,g,u,d,f,v,x]),k=(0,_.useMemo)(()=>te?te.map(e=>e.id):[],[te]),ne=!!(k.length>0&&k.every(e=>n.has(e))),A=k.some(e=>n.has(e)),j=()=>{ne?c():s(k)},re=e=>{ee(e)},M=(0,_.useRef)([]);M.current=k,(0,_.useEffect)(()=>{let e=e=>{let t=document.activeElement;t&&(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.tagName===`SELECT`)||(e.key===`ArrowDown`?(e.preventDefault(),o(`down`,M.current)):e.key===`ArrowUp`&&(e.preventDefault(),o(`up`,M.current)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let N=(0,_.useCallback)((e,t)=>{t.button!==2&&(t.shiftKey?(t.preventDefault(),a(e,M.current)):r(e))},[a,r]),P=(0,_.useCallback)((e,t)=>{let i=te?.find(t=>t.id===e);if(!i)return;let a;n.has(e)?a=te.filter(e=>n.has(e.id)):(r(e),a=[i]),O({x:t.clientX,y:t.clientY,torrent:i,selectedTorrents:a})},[te,n,r]);(0,_.useEffect)(()=>{if(!C)return;let e=e=>{let t=e.clientX-C.startX;h(C.colId,C.startWidth+t)},t=()=>{w(null)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.userSelect=``,document.body.style.cursor=``}},[C,h]);let ie=(0,_.useCallback)((e,t)=>{t.preventDefault(),t.stopPropagation();let n=m(e);if(n===0){let e=t.target.closest(`th`);e&&(n=e.getBoundingClientRect().width)}w({colId:e,startX:t.clientX,startWidth:n})},[m]),F=(0,_.useCallback)(e=>{e.preventDefault(),E({x:e.clientX,y:e.clientY})},[]),I=(0,_.useCallback)(e=>{let t=te[e];return(0,b.jsx)(Nc,{torrent:t,isSelected:n.has(t.id),odd:e%2==1,onRowClick:N,onContextMenu:P,onCheckboxChange:i,visibleColumns:p},t.id)},[te,n,N,P,i,p]);return t?(0,b.jsx)(`div`,{className:`flex justify-center items-center h-64`,children:(0,b.jsx)(xi,{})}):!e||e.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-64 text-tertiary`,children:[(0,b.jsx)(`p`,{className:`text-lg`,children:`No torrents`}),(0,b.jsx)(`p`,{className:``,children:`Add a torrent to get started`})]}):(0,b.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,b.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,b.jsx)(Rc,{columns:p}),(0,b.jsx)(`thead`,{className:`bg-surface-raised text-sm`,children:(0,b.jsx)(`tr`,{className:`border-b border-divider`,onContextMenu:F,children:p.map(e=>{if(e.id===`checkbox`)return(0,b.jsx)(`th`,{className:`px-2 py-3 border-r border-divider/40`,children:(0,b.jsx)(`input`,{type:`checkbox`,checked:ne,ref:e=>{e&&(e.indeterminate=A&&!ne)},onChange:j,className:`w-4 h-4 rounded border-divider-strong bg-surface text-primary focus:ring-primary`})},`checkbox`);if(e.id===`status_icon`)return(0,b.jsx)(`th`,{className:`px-1 py-3 border-r border-divider/40`},`status_icon`);let t=e.align===`center`?`text-center`:e.align===`right`?`text-right`:`text-left`,n=e.sortable,r=e.configurable;return(0,b.jsxs)(`th`,{className:`relative px-2 py-2 text-secondary select-none whitespace-nowrap border-r border-divider/40 ${t} ${n?`cursor-pointer hover:text-text`:``}`,onClick:n?()=>re(e.id):void 0,children:[e.label,n&&(0,b.jsx)(Ls,{column:e.id,sortColumn:v,sortDirection:x}),r&&(0,b.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize hover:bg-primary/40 z-10`,onMouseDown:t=>ie(e.id,t)})]},e.id)})})})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(sr,{totalCount:te?.length??0,itemContent:I})}),T&&(0,b.jsx)(Pc,{x:T.x,y:T.y,onClose:()=>E(null)}),D&&(0,b.jsx)(gc,{menu:D,onClose:()=>O(null)})]})},Bc=100,Vc=600,Hc=256,Uc=({torrents:e,loading:t})=>{bs();let[n,r]=(0,_.useState)(Hc),[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null),s=(0,_.useCallback)(e=>{e.preventDefault(),a(!0)},[]);(0,_.useEffect)(()=>{if(!i)return;let e=e=>{if(!o.current)return;let t=o.current.getBoundingClientRect().bottom-e.clientY;r(Math.max(Bc,Math.min(Vc,t)))},t=()=>{a(!1)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[i]);let c=(e?.length??0)>0;return(0,b.jsxs)(`div`,{ref:o,className:`flex flex-col h-full`,children:[(0,b.jsx)(`div`,{className:`flex-1 overflow-auto min-h-0`,children:(0,b.jsx)(zc,{torrents:e,loading:t})}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`div`,{onMouseDown:s,className:`h-1.5 cursor-ns-resize shrink-0 bg-divider hover:bg-primary transition-colors ${i?`bg-primary`:``}`,title:`Drag to resize`,children:(0,b.jsx)(`div`,{className:`h-full w-12 mx-auto flex items-center justify-center`,children:(0,b.jsx)(`div`,{className:`w-8 h-0.5 bg-secondary rounded-full`})})}),(0,b.jsx)(`div`,{style:{height:n},className:`shrink-0`,children:(0,b.jsx)(pc,{})})]})]})},Wc=sa((e,t)=>({status:null,setStatus:t=>e({status:t}),identity:null,setIdentity:t=>e({identity:t}),syncPreferences:null,setSyncPreferences:t=>e({syncPreferences:t}),showSetup:!1,setShowSetup:t=>e({showSetup:t}),searchQuery:``,setSearchQuery:t=>e({searchQuery:t}),searchFilters:{},setSearchFilter:(t,n)=>e(e=>({searchFilters:{...e.searchFilters,[t]:n}})),clearSearchFilters:()=>e({searchFilters:{}}),searchResults:[],searchTotal:0,searchOffset:0,searchLoading:!1,setSearchResults:(t,n,r)=>e({searchResults:t,searchTotal:n,searchOffset:r}),setSearchLoading:t=>e({searchLoading:t}),recentTorrents:[],recentLoading:!1,setRecentTorrents:t=>e({recentTorrents:t}),setRecentLoading:t=>e({recentLoading:t})})),Gc=`rtbit_access_token`,Kc=`rtbit_refresh_token`,qc=`rtbit_token_expiry`,Jc=sa((e,t)=>({state:`loading`,accessToken:localStorage.getItem(Gc),refreshToken:localStorage.getItem(Kc),tokenExpiry:(()=>{let e=localStorage.getItem(qc);return e?parseInt(e,10):null})(),setState:t=>e({state:t}),setTokens:(t,n,r)=>{let i=Date.now()+r*1e3;localStorage.setItem(Gc,t),localStorage.setItem(Kc,n),localStorage.setItem(qc,i.toString()),e({accessToken:t,refreshToken:n,tokenExpiry:i,state:`authenticated`})},clearTokens:()=>{localStorage.removeItem(Gc),localStorage.removeItem(Kc),localStorage.removeItem(qc),e({accessToken:null,refreshToken:null,tokenExpiry:null,state:`login_required`})},getAccessToken:()=>{let{accessToken:e,tokenExpiry:n}=t();return!e||!n||Date.now()>n-3e4?null:e}})),Yc=(()=>{if(window.origin===`null`)return`http://localhost:3030`;let e=new URL(window.location.href);return e.port==`3031`||e.port==`1420`?`${e.protocol}//${e.hostname}:3030`:/(.*?)\/?(\/web\/?)?$/.exec(e.pathname)[1]??``})(),Xc=()=>{let e=Jc.getState().getAccessToken();return e?{Authorization:`Bearer ${e}`}:{}},Zc=async()=>{let{refreshToken:e,setTokens:t,clearTokens:n}=Jc.getState();if(!e)return!1;try{let r=Yc+`/auth/refresh`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:e})});if(!i.ok)return n(),!1;let a=await i.json();return t(a.access_token,a.refresh_token,a.expires_in),!0}catch{return n(),!1}},Qc=async(e,t,n,r)=>{console.log(e,t);let i=Yc+t,a=Xc(),o={method:e,headers:{Accept:`application/json`,...a}};r?(o.headers={Accept:`application/json`,"Content-Type":`application/json`,...a},o.body=JSON.stringify(n)):o.body=n;let s={method:e,path:t,text:``},c;try{c=await fetch(i,o)}catch{return s.text=`network error`,Promise.reject(s)}if(c.status===401){if(await Zc()){let e=Xc(),t={...o,headers:r?{Accept:`application/json`,"Content-Type":`application/json`,...e}:{Accept:`application/json`,...e}};try{c=await fetch(i,t)}catch{return s.text=`network error`,Promise.reject(s)}if(c.ok)return c.json()}return Jc.getState().clearTokens(),s.status=401,s.statusText=`401 Unauthorized`,s.text=`Session expired. Please log in again.`,Promise.reject(s)}if(s.status=c.status,s.statusText=`${c.status} ${c.statusText}`,!c.ok){let e=await c.text();try{let t=JSON.parse(e);s.text=t.human_readable===void 0?JSON.stringify(t,null,2):t.human_readable}catch{s.text=e}return Promise.reject(s)}return await c.json()},$c={getStatus:async()=>{let e=Yc+`/auth/status`,t=await fetch(e);return t.ok?t.json():{auth_enabled:!1,setup_required:!1}},login:async(e,t)=>{let n=Yc+`/auth/login`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});if(!r.ok){let e=await r.text();throw Error(e||`Login failed`)}return r.json()},setup:async(e,t)=>{let n=Yc+`/auth/setup`,r=await fetch(n,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({username:e,password:t})});if(!r.ok){let e=await r.text();throw Error(e||`Setup failed`)}return r.json()},logout:async e=>{let t=Yc+`/auth/logout`;await fetch(t,{method:`POST`,headers:{"Content-Type":`application/json`,...Xc()},body:JSON.stringify({refresh_token:e})})},changeCredentials:async(e,t,n)=>{let r=Yc+`/auth/change_credentials`,i=await fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`,...Xc()},body:JSON.stringify({current_password:e,new_username:t||void 0,new_password:n||void 0})});if(!i.ok){let e=await i.text();throw Error(e||`Failed to change credentials`)}}},el={getStatus:()=>Qc(`GET`,`/indexarr/status`),search:(e,t,n=50,r=0)=>{let i=new URLSearchParams;if(i.set(`q`,e),i.set(`limit`,String(n)),i.set(`offset`,String(r)),t)for(let[e,n]of Object.entries(t))n&&i.set(e,n);return Qc(`GET`,`/indexarr/search?${i.toString()}`)},getRecent:(e=50)=>Qc(`GET`,`/indexarr/recent?limit=${e}`),getTrending:(e=50)=>Qc(`GET`,`/indexarr/trending?limit=${e}`),getIdentityStatus:()=>Qc(`GET`,`/indexarr/identity/status`),acknowledgeIdentity:()=>Qc(`POST`,`/indexarr/identity/acknowledge`),getSyncPreferences:()=>Qc(`GET`,`/indexarr/sync/preferences`),setSyncPreferences:e=>Qc(`POST`,`/indexarr/sync/preferences`,e,!0)},tl={getFeeds:()=>Qc(`GET`,`/rss/feeds`),addFeed:e=>Qc(`POST`,`/rss/feeds`,e,!0),updateFeed:(e,t)=>Qc(`PUT`,`/rss/feeds/${encodeURIComponent(e)}`,t,!0),deleteFeed:e=>Qc(`DELETE`,`/rss/feeds/${encodeURIComponent(e)}`),getItems:(e,t=500)=>{let n=new URLSearchParams;return e&&n.set(`feed`,e),n.set(`limit`,String(t)),Qc(`GET`,`/rss/items?${n.toString()}`)},downloadItem:e=>Qc(`POST`,`/rss/items/${encodeURIComponent(e)}/download`),getRules:()=>Qc(`GET`,`/rss/rules`),addRule:e=>Qc(`POST`,`/rss/rules`,e,!0),updateRule:(e,t)=>Qc(`PUT`,`/rss/rules/${encodeURIComponent(e)}`,t,!0),deleteRule:e=>Qc(`DELETE`,`/rss/rules/${encodeURIComponent(e)}`),getSettings:()=>Qc(`GET`,`/rss/settings`)},nl=()=>{let e=Wc(e=>e.identity),t=Wc(e=>e.setIdentity),n=Wc(e=>e.syncPreferences),r=Wc(e=>e.setSyncPreferences),i=Wc(e=>e.setShowSetup),a=Ko(e=>e.setCloseableError),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(!1),[f,p]=(0,_.useState)([]),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(`identity`);(0,_.useEffect)(()=>{(async()=>{try{let[e,n]=await Promise.all([el.getIdentityStatus(),el.getSyncPreferences()]);t(e),r(n),p(n.import_categories),h(n.sync_comments),e.needs_onboarding||v(`categories`)}catch(e){a({text:`Failed to load Indexarr setup`,details:e})}finally{s(!1)}})()},[]);let y=async()=>{if(e?.recovery_key)try{await navigator.clipboard.writeText(e.recovery_key),d(!0),setTimeout(()=>d(!1),2e3)}catch{}},x=async()=>{l(!0);try{await el.acknowledgeIdentity(),t(await el.getIdentityStatus()),v(`categories`)}catch(e){a({text:`Failed to acknowledge identity`,details:e})}finally{l(!1)}},S=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return o?(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,b.jsx)(xi,{label:`Loading setup`})}):(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center p-4`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-lg max-w-lg w-full`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-b border-divider`,children:[e&&!e.needs_onboarding&&(0,b.jsx)(`button`,{onClick:()=>i(!1),className:`p-1 text-secondary hover:text-text cursor-pointer`,children:(0,b.jsx)(Ho,{className:`w-4 h-4`})}),(0,b.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Indexarr Setup`})]}),g===`identity`&&(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-sm text-secondary`,children:`Your Indexarr node has generated a unique contributor identity. Save the recovery key below — you will need it to restore your identity if you reinstall.`}),e?.contributor_id&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-secondary mb-1 block`,children:`Contributor ID`}),(0,b.jsx)(`code`,{className:`block text-sm bg-surface px-3 py-2 rounded font-mono`,children:e.contributor_id})]}),e?.recovery_key&&(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-xs font-medium text-secondary mb-1 block`,children:`Recovery Key`}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`textarea`,{readOnly:!0,value:e.recovery_key,className:`w-full text-sm bg-surface px-3 py-2 rounded font-mono resize-none h-20 border border-divider`}),(0,b.jsx)(`button`,{onClick:y,className:`absolute top-2 right-2 p-1.5 bg-surface-raised rounded hover:bg-primary/10 cursor-pointer`,title:`Copy to clipboard`,children:u?(0,b.jsx)(Bo,{className:`w-3.5 h-3.5 text-green-500`}):(0,b.jsx)(Ro,{className:`w-3.5 h-3.5 text-secondary`})})]}),(0,b.jsx)(`p`,{className:`text-xs text-tertiary mt-1`,children:`Store this key securely. It cannot be recovered later.`})]}),(0,b.jsx)(`button`,{onClick:x,disabled:c,className:`w-full py-2 rounded bg-primary text-white font-medium hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,children:c?`Saving...`:`I have saved my recovery key`})]}),g===`categories`&&(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsx)(`p`,{className:`text-sm text-secondary`,children:`Select which content categories to sync from the network.`}),(0,b.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:(n?.all_categories||[]).map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-2 bg-surface rounded cursor-pointer hover:bg-surface-raised/50`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:f.includes(e),onChange:()=>S(e),className:`rounded`}),(0,b.jsx)(`span`,{className:`text-sm capitalize`,children:e.replace(`_`,` `)})]},e))}),(0,b.jsxs)(`label`,{className:`flex items-center gap-2 px-3 py-2 bg-surface rounded cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),className:`rounded`}),(0,b.jsx)(`span`,{className:`text-sm`,children:`Sync comments`})]}),(0,b.jsx)(`button`,{onClick:async()=>{l(!0);try{r(await el.setSyncPreferences({import_categories:f,sync_comments:m})),i(!1)}catch(e){a({text:`Failed to save sync preferences`,details:e})}finally{l(!1)}},disabled:c||f.length===0,className:`w-full py-2 rounded bg-primary text-white font-medium hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,children:c?`Saving...`:`Save Preferences`})]})]})})},rl=({children:e,label:t,help:n,className:r})=>(0,b.jsxs)(`fieldset`,{className:`mb-4 ${r}`,children:[t&&(0,b.jsx)(`label`,{className:`font-medium mb-3 block pb-1 border-b border-divider`,children:t}),e]}),il=({autoFocus:e,value:t,name:n,disabled:r,onChange:i,onKeyDown:a,label:o,help:s,inputType:c,placeholder:l})=>(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:n,children:o}),(0,b.jsx)(`input`,{autoFocus:e,type:c,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 focus:ring-0 focus:border-primary sm:leading-6`,id:n,name:n,disabled:r,placeholder:l,value:t,onKeyDown:a,onChange:i}),s&&(0,b.jsx)(`div`,{className:`text-sm text-secondary`,children:s})]}),al=({children:e})=>(0,b.jsx)(`form`,{children:e}),ol=e=>{let{onHide:t,listTorrentResponse:n,listTorrentError:r,listTorrentLoading:i,data:a}=e,[o,s]=(0,_.useState)(new Set),[c,l]=(0,_.useState)(!1),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),[m,h]=(0,_.useState)(``),g=ua(e=>e.refreshTorrents),y=(0,_.useContext)(v);(0,_.useEffect)(()=>{s(new Set(n?.details.files.flatMap((e,t)=>e.attributes.padding?[]:[t]))),h(n?.output_folder||``)},[n]);let x=()=>{t(),s(new Set),d(null),l(!1)};return(0,b.jsxs)(So,{isOpen:!0,onClose:x,title:`Add Torrent`,children:[(0,b.jsxs)(Co,{children:[(()=>{if(i)return(0,b.jsx)(xi,{label:`Loading torrent contents`});if(r)return(0,b.jsx)(ha,{error:r});if(n)return(0,b.jsxs)(al,{children:[(0,b.jsx)(il,{label:`Output folder`,name:`output_folder`,inputType:`text`,placeholder:`Server default`,value:m,onChange:e=>h(e.target.value)}),(0,b.jsx)(rl,{children:(0,b.jsx)(Fs,{selectedFiles:o,setSelectedFiles:s,torrentDetails:n.details,torrentStats:null})})]})})(),(0,b.jsx)(ha,{error:u})]}),(0,b.jsxs)(wo,{children:[c&&(0,b.jsx)(xi,{}),(0,b.jsx)(pa,{onClick:x,variant:`cancel`,children:`Cancel`}),(0,b.jsx)(pa,{onClick:async()=>{if(!n)return;l(!0);let e=n.seen_peers?n.seen_peers.slice(0,32):null,r=new Set(n.details.files.flatMap((e,t)=>e.attributes.padding?[]:[t])),i={overwrite:!0,only_files:o.size===r.size&&[...o].every(e=>r.has(e))?void 0:Array.from(o),initial_peers:e,output_folder:m};f&&(i.peer_opts={connect_timeout:20,read_write_timeout:60}),y.uploadTorrent(a,i).then(()=>{t(),g()},e=>{d({text:`Error starting torrent`,details:e})}).finally(()=>l(!1))},variant:`primary`,disabled:i||c||o.size==0,children:`OK`})]})]})},sl=[`udp://tracker.opentrackr.org:1337/announce`,`udp://open.stealth.si:80/announce`];function cl(e,t,n){return`magnet:?xt=urn:btih:${e}${t?`&dn=${encodeURIComponent(t)}`:``}${(n&&n.length>0?n:sl).map(e=>`&tr=${encodeURIComponent(e)}`).join(``)}`}function ll(e){if(!e)return null;let t={movie:`bg-blue-500/20 text-blue-400`,tv_show:`bg-purple-500/20 text-purple-400`,music:`bg-green-500/20 text-green-400`,ebook:`bg-yellow-500/20 text-yellow-400`,game:`bg-red-500/20 text-red-400`,software:`bg-cyan-500/20 text-cyan-400`,xxx:`bg-pink-500/20 text-pink-400`}[e]||`bg-surface text-secondary`,n=e.replace(`_`,` `);return(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs font-medium ${t}`,children:n})}function ul(e){if(!e)return``;let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}var dl=[``,`movie`,`tv_show`,`music`,`ebook`,`comic`,`audiobook`,`game`,`software`],fl=()=>{let e=(0,_.useContext)(v),t=Ko(e=>e.setCloseableError),n=Wc(e=>e.status),r=Wc(e=>e.identity),i=Wc(e=>e.setIdentity),a=Wc(e=>e.showSetup),o=Wc(e=>e.setShowSetup),s=Wc(e=>e.searchQuery),c=Wc(e=>e.setSearchQuery),l=Wc(e=>e.searchFilters),u=Wc(e=>e.setSearchFilter),d=Wc(e=>e.searchResults),f=Wc(e=>e.searchTotal),p=Wc(e=>e.searchLoading),m=Wc(e=>e.setSearchResults),h=Wc(e=>e.setSearchLoading),g=Wc(e=>e.recentTorrents),y=Wc(e=>e.recentLoading),x=Wc(e=>e.setRecentTorrents),S=Wc(e=>e.setRecentLoading),[C,w]=(0,_.useState)(s),[T,E]=(0,_.useState)(null),[D,O]=(0,_.useState)(`search`),[ee,te]=(0,_.useState)(null),[k,ne]=(0,_.useState)(null),[A,j]=(0,_.useState)(!1),[re,M]=(0,_.useState)(null),N=(0,_.useRef)(null);(0,_.useEffect)(()=>{el.getIdentityStatus().then(i).catch(()=>{})},[]);let P=(0,_.useCallback)(async()=>{S(!0);try{x((await el.getRecent(50)).results)}catch{}finally{S(!1)}},[]);(0,_.useEffect)(()=>(P(),N.current=setInterval(P,6e4),()=>{N.current&&clearInterval(N.current)}),[P]);let ie=(0,_.useCallback)(async(e,n)=>{h(!0);try{let t=await el.search(e,n);m(t.results,t.total,t.offset)}catch(e){t({text:`Indexarr search failed`,details:e})}finally{h(!1)}},[]),F=(0,_.useCallback)((0,bi.default)((e,t)=>ie(e,t),300),[ie]),I=e=>{let t=e.target.value;w(t),c(t),F(t,l)},L=(e,t)=>{u(e,t),F(s,{...l,[e]:t})},R=()=>{w(``),c(``),m([],0,0)};(0,_.useEffect)(()=>{if(!ee)return;let t=!1;return j(!0),ne(null),M(null),(async()=>{try{let n=await e.uploadTorrent(ee,{list_only:!0});t||ne(n)}catch(e){t||M({text:`Error listing torrent files`,details:e})}finally{t||j(!1)}})(),()=>{t=!0}},[ee]);let z=()=>{te(null),ne(null),M(null),j(!1),E(null)},B=(e,t,n)=>{E(e),te(cl(e,t,n))};if(n&&!n.enabled)return(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center text-secondary`,children:(0,b.jsx)(`p`,{children:`Indexarr integration is not enabled.`})});if(n&&n.enabled&&!n.reachable)return(0,b.jsx)(`div`,{className:`h-full flex items-center justify-center text-secondary`,children:(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`p`,{className:`text-lg font-semibold mb-2`,children:`Cannot reach Indexarr`}),(0,b.jsx)(`p`,{className:`text-sm`,children:n.error})]})});if(r&&r.needs_onboarding||a)return(0,b.jsx)(nl,{});let V=`px-3 py-2 text-sm font-medium text-secondary text-left`;return(0,b.jsxs)(`div`,{className:`h-full flex flex-col overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-divider bg-surface-raised`,children:[(0,b.jsx)(`button`,{onClick:()=>O(`search`),className:`px-3 py-1 text-sm rounded cursor-pointer ${D===`search`?`bg-primary text-white`:`text-secondary hover:text-text`}`,children:`Search`}),(0,b.jsx)(`button`,{onClick:()=>O(`recent`),className:`px-3 py-1 text-sm rounded cursor-pointer ${D===`recent`?`bg-primary text-white`:`text-secondary hover:text-text`}`,children:`Recent`}),(0,b.jsx)(`div`,{className:`flex-1`}),(0,b.jsx)(`button`,{onClick:()=>o(!0),className:`p-1 text-secondary hover:text-text cursor-pointer`,title:`Indexarr Settings`,children:(0,b.jsx)(zo,{className:`w-4 h-4`})})]}),D===`search`&&(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`px-4 py-3 border-b border-divider space-y-2`,children:[(0,b.jsx)(`div`,{className:`flex gap-2`,children:(0,b.jsxs)(`div`,{className:`relative flex-1`,children:[(0,b.jsx)(Mo,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,value:C,onChange:I,placeholder:`Search the torrent index...`,className:`w-full pl-9 pr-8 py-2 text-sm bg-surface border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),C&&(0,b.jsx)(`button`,{onClick:R,className:`absolute right-2 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(li,{className:`w-4 h-4`})})]})}),(0,b.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,b.jsxs)(`select`,{value:l.content_type||``,onChange:e=>L(`content_type`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:``,children:`All types`}),dl.filter(Boolean).map(e=>(0,b.jsx)(`option`,{value:e,children:e.replace(`_`,` `)},e))]}),(0,b.jsxs)(`select`,{value:l.resolution||``,onChange:e=>L(`resolution`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:``,children:`Any resolution`}),[`720p`,`1080p`,`2160p`].map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),(0,b.jsxs)(`select`,{value:l.sort||`relevance`,onChange:e=>L(`sort`,e.target.value),className:`text-xs px-2 py-1 bg-surface border border-divider rounded cursor-pointer`,children:[(0,b.jsx)(`option`,{value:`relevance`,children:`Sort: Relevance`}),(0,b.jsx)(`option`,{value:`date`,children:`Sort: Date`}),(0,b.jsx)(`option`,{value:`seeders`,children:`Sort: Seeders`}),(0,b.jsx)(`option`,{value:`size`,children:`Sort: Size`}),(0,b.jsx)(`option`,{value:`name`,children:`Sort: Name`})]})]})]}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:p&&d.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(xi,{label:`Searching`})}):d.length===0&&s?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`No results found`}):d.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`Enter a search query to find torrents`}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`px-4 py-1 text-xs text-secondary`,children:[f.toLocaleString(),` results`,p&&` (loading...)`]}),(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:V,children:`Name`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden lg:table-cell`,children:`SE`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden lg:table-cell`,children:`LE`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden md:table-cell`,children:`Age`}),(0,b.jsx)(`th`,{className:`${V} w-20`})]})}),(0,b.jsx)(`tbody`,{children:d.map(e=>(0,b.jsx)(pl,{result:e,downloading:T===e.info_hash,onDownload:()=>B(e.info_hash,e.name,e.trackers)},e.info_hash))})]})]})})]}),D===`recent`&&(0,b.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:y&&g.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,b.jsx)(xi,{label:`Loading recent`})}):g.length===0?(0,b.jsx)(`div`,{className:`flex items-center justify-center py-12 text-secondary`,children:`No recent torrents`}):(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:V,children:`Name`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden lg:table-cell`,children:`SE`}),(0,b.jsx)(`th`,{className:`${V} text-right hidden md:table-cell`,children:`Age`}),(0,b.jsx)(`th`,{className:`${V} w-20`})]})}),(0,b.jsx)(`tbody`,{children:g.map(e=>(0,b.jsx)(ml,{item:e,downloading:T===e.info_hash,onDownload:()=>B(e.info_hash,e.name,e.trackers)},e.info_hash))})]})}),ee&&(0,b.jsx)(ol,{onHide:z,listTorrentResponse:k,listTorrentError:re,listTorrentLoading:A,data:ee})]})},pl=({result:e,downloading:t,onDownload:n})=>{let r=`px-3 py-2 text-sm`,i=`${r} text-right whitespace-nowrap`;return(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface-raised/50 transition-colors`,children:[(0,b.jsx)(`td`,{className:`${r} max-w-0`,children:(0,b.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,b.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,b.jsx)(`div`,{className:`truncate text-text`,title:e.name||``,children:e.name||e.info_hash}),(0,b.jsxs)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:[ll(e.content_type),e.resolution&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.resolution}),e.codec&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.codec}),e.year&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.year})]})]})})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:e.size?Xo(e.size):`-`}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-green-500 inline-flex items-center gap-0.5`,children:[(0,b.jsx)(jo,{className:`w-3 h-3`}),e.seed_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-secondary inline-flex items-center gap-0.5`,children:[(0,b.jsx)(Eo,{className:`w-3 h-3`}),e.peer_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:ul(e.resolved_at)}),(0,b.jsx)(`td`,{className:`${r} text-right`,children:(0,b.jsx)(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded bg-primary text-white hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,title:`Download torrent`,children:t?(0,b.jsx)(`span`,{className:`w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin`}):(0,b.jsx)(Lo,{className:`w-3 h-3`})})})]})},ml=({item:e,downloading:t,onDownload:n})=>{let r=`px-3 py-2 text-sm`,i=`${r} text-right whitespace-nowrap`;return(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface-raised/50 transition-colors`,children:[(0,b.jsx)(`td`,{className:`${r} max-w-0`,children:(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`truncate text-text`,title:e.name||``,children:e.name||e.info_hash}),(0,b.jsxs)(`div`,{className:`flex gap-1 mt-0.5 flex-wrap`,children:[ll(e.content_type),e.resolution&&(0,b.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-xs bg-surface text-secondary`,children:e.resolution})]})]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:e.size?Xo(e.size):`-`}),(0,b.jsx)(`td`,{className:`${i} hidden lg:table-cell`,children:(0,b.jsxs)(`span`,{className:`text-green-500 inline-flex items-center gap-0.5`,children:[(0,b.jsx)(jo,{className:`w-3 h-3`}),e.seed_count]})}),(0,b.jsx)(`td`,{className:`${i} hidden md:table-cell text-secondary`,children:ul(e.resolved_at)}),(0,b.jsx)(`td`,{className:`${r} text-right`,children:(0,b.jsx)(`button`,{onClick:n,disabled:t,className:`inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded bg-primary text-white hover:bg-primary/80 disabled:opacity-50 cursor-pointer`,title:`Download torrent`,children:t?(0,b.jsx)(`span`,{className:`w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin`}):(0,b.jsx)(Lo,{className:`w-3 h-3`})})})]})};function hl(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=[];return n>0&&a.push(`${n}h`),r>0&&a.push(`${r}m`),(i>0||a.length===0)&&a.push(`${i}s`),a.join(``)}var gl=sa(e=>({feeds:[],setFeeds:t=>e({feeds:t}),items:[],setItems:t=>e({items:t}),rules:[],setRules:t=>e({rules:t}),selectedFeedFilter:null,setSelectedFeedFilter:t=>e({selectedFeedFilter:t}),loading:!1,setLoading:t=>e({loading:t})})),_l=({isOpen:e,onClose:t,feed:n,onSaved:r})=>{let[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(900),[u,d]=(0,_.useState)(``),[f,p]=(0,_.useState)(``),[m,h]=(0,_.useState)(!0),[g,v]=(0,_.useState)(!1),[y,x]=(0,_.useState)(!1),[S,C]=(0,_.useState)(null);if((0,_.useEffect)(()=>{n?(a(n.name),s(n.url),l(n.poll_interval_secs),d(n.category??``),p(n.filter_regex??``),h(n.enabled),v(n.auto_download)):(a(``),s(``),l(900),d(``),p(``),h(!0),v(!1)),C(null)},[n,e]),!e)return null;let w=async()=>{if(!i.trim()||!o.trim()){C(`Name and URL are required`);return}x(!0),C(null);try{let e={name:i.trim(),url:o.trim(),poll_interval_secs:c,category:u.trim()||null,filter_regex:f.trim()||null,enabled:m,auto_download:g};n?await tl.updateFeed(n.name,e):await tl.addFeed(e),r(),t()}catch(e){C(e?.text||e?.message||`Failed to save feed`)}finally{x(!1)}},T=`w-full px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,E=`block text-xs font-medium text-secondary mb-1`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,b.jsx)(`div`,{className:`px-4 py-3 border-b border-divider`,children:(0,b.jsx)(`h3`,{className:`text-base font-semibold`,children:n?`Edit Feed`:`Add Feed`})}),(0,b.jsxs)(`div`,{className:`px-4 py-3 space-y-3`,children:[S&&(0,b.jsx)(`div`,{className:`text-xs text-red-500 bg-red-50 dark:bg-red-900/20 px-2 py-1 rounded`,children:S}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Name`}),(0,b.jsx)(`input`,{className:T,value:i,onChange:e=>a(e.target.value),placeholder:`My Feed`,disabled:!!n})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`URL`}),(0,b.jsx)(`input`,{className:T,value:o,onChange:e=>s(e.target.value),placeholder:`https://example.com/rss`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Poll Interval (sec)`}),(0,b.jsx)(`input`,{type:`number`,className:T,value:c,onChange:e=>l(Number(e.target.value)||900)})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Category`}),(0,b.jsx)(`input`,{className:T,value:u,onChange:e=>d(e.target.value),placeholder:`Optional`})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Filter Regex`}),(0,b.jsx)(`input`,{className:T,value:f,onChange:e=>p(e.target.value),placeholder:`Optional title filter`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked)}),`Enabled`]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>v(e.target.checked)}),`Auto-download`]})]})]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3 border-t border-divider`,children:[(0,b.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-sm text-secondary hover:text-text rounded border border-divider cursor-pointer`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:w,disabled:y,className:`px-3 py-1.5 text-sm text-white bg-primary hover:bg-primary/90 rounded disabled:opacity-50 cursor-pointer`,children:y?`Saving...`:`Save`})]})]})})},vl=({isOpen:e,onClose:t,rule:n,feedNames:r,onSaved:i})=>{let[a,o]=(0,_.useState)(``),[s,c]=(0,_.useState)([]),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(1),[p,m]=(0,_.useState)(``),[h,g]=(0,_.useState)(!0),[v,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null);if((0,_.useEffect)(()=>{n?(o(n.name),c(n.feed_names),u(n.category??``),f(n.priority),m(n.match_regex),g(n.enabled)):(o(``),c([]),u(``),f(1),m(``),g(!0)),S(null)},[n,e]),!e)return null;let C=e=>{c(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},w=async()=>{if(!a.trim()||!p.trim()){S(`Name and match regex are required`);return}if(s.length===0){S(`Select at least one feed`);return}y(!0),S(null);try{let e={name:a.trim(),feed_names:s,category:l.trim()||null,priority:d,match_regex:p.trim(),enabled:h};n?await tl.updateRule(n.id,e):await tl.addRule(e),i(),t()}catch(e){S(e?.text||e?.message||`Failed to save rule`)}finally{y(!1)}},T=`w-full px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,E=`block text-xs font-medium text-secondary mb-1`;return(0,b.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,b.jsxs)(`div`,{className:`bg-surface-raised rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,b.jsx)(`div`,{className:`px-4 py-3 border-b border-divider`,children:(0,b.jsx)(`h3`,{className:`text-base font-semibold`,children:n?`Edit Rule`:`Add Rule`})}),(0,b.jsxs)(`div`,{className:`px-4 py-3 space-y-3`,children:[x&&(0,b.jsx)(`div`,{className:`text-xs text-red-500 bg-red-50 dark:bg-red-900/20 px-2 py-1 rounded`,children:x}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Name`}),(0,b.jsx)(`input`,{className:T,value:a,onChange:e=>o(e.target.value),placeholder:`Rule name`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Match Regex`}),(0,b.jsx)(`input`,{className:T,value:p,onChange:e=>m(e.target.value),placeholder:`e.g. 1080p.*HEVC`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Feeds`}),(0,b.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[r.map(e=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1 text-xs bg-surface px-2 py-1 rounded border border-divider`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:s.includes(e),onChange:()=>C(e)}),e]},e)),r.length===0&&(0,b.jsx)(`span`,{className:`text-xs text-tertiary`,children:`No feeds configured`})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Category`}),(0,b.jsx)(`input`,{className:T,value:l,onChange:e=>u(e.target.value),placeholder:`Optional`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:E,children:`Priority`}),(0,b.jsxs)(`select`,{className:T,value:d,onChange:e=>f(Number(e.target.value)),children:[(0,b.jsx)(`option`,{value:0,children:`Low`}),(0,b.jsx)(`option`,{value:1,children:`Normal`}),(0,b.jsx)(`option`,{value:2,children:`High`}),(0,b.jsx)(`option`,{value:3,children:`Force`})]})]})]}),(0,b.jsxs)(`label`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked)}),`Enabled`]})]}),(0,b.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3 border-t border-divider`,children:[(0,b.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-sm text-secondary hover:text-text rounded border border-divider cursor-pointer`,children:`Cancel`}),(0,b.jsx)(`button`,{onClick:w,disabled:v,className:`px-3 py-1.5 text-sm text-white bg-primary hover:bg-primary/90 rounded disabled:opacity-50 cursor-pointer`,children:v?`Saving...`:`Save`})]})]})})},yl=()=>{let e=gl(e=>e.feeds),t=gl(e=>e.setFeeds),n=gl(e=>e.items),r=gl(e=>e.setItems),i=gl(e=>e.rules),a=gl(e=>e.setRules),o=gl(e=>e.selectedFeedFilter),s=gl(e=>e.setSelectedFeedFilter),c=gl(e=>e.loading),l=gl(e=>e.setLoading),u=Ko(e=>e.setCloseableError),[d,f]=(0,_.useState)(`items`),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(!1),[x,S]=(0,_.useState)(null),[C,w]=(0,_.useState)(null),T=(0,_.useCallback)(async()=>{l(!0);try{let[e,n,i]=await Promise.all([tl.getFeeds(),tl.getItems(o??void 0),tl.getRules()]);t(e),r(n),a(i)}catch(e){u({text:`Error loading RSS data`,details:e})}finally{l(!1)}},[o]);(0,_.useEffect)(()=>{T();let e=setInterval(T,3e4);return()=>clearInterval(e)},[T]);let E=async e=>{try{await tl.deleteFeed(e),T()}catch(e){u({text:`Error deleting feed`,details:e})}},D=async e=>{try{await tl.deleteRule(e),T()}catch(e){u({text:`Error deleting rule`,details:e})}},O=async e=>{w(e.id);try{await tl.downloadItem(e.id),T()}catch(e){u({text:`Error downloading item`,details:e})}finally{w(null)}},ee=(0,_.useMemo)(()=>e.map(e=>e.name),[e]),te=e=>e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`-`,k=e=>`px-3 py-1.5 text-sm font-medium border-b-2 cursor-pointer transition-colors ${d===e?`border-primary text-primary`:`border-transparent text-secondary hover:text-text hover:border-divider`}`,ne=`p-1 text-secondary hover:text-primary rounded cursor-pointer transition-colors`,A=`px-2 py-1.5 text-left text-xs font-medium text-secondary uppercase tracking-wider`,j=`px-2 py-1.5 text-sm whitespace-nowrap`;return c&&n.length===0?(0,b.jsx)(`div`,{className:`flex justify-center items-center h-full`,children:(0,b.jsx)(xi,{})}):(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-divider`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>f(`items`),className:k(`items`),children:`Items`}),(0,b.jsxs)(`button`,{onClick:()=>f(`feeds`),className:k(`feeds`),children:[`Feeds (`,e.length,`)`]}),(0,b.jsxs)(`button`,{onClick:()=>f(`rules`),className:k(`rules`),children:[`Rules (`,i.length,`)`]})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d===`items`&&(0,b.jsxs)(`select`,{className:`text-xs bg-surface border border-divider rounded px-2 py-1 focus:outline-none focus:border-primary`,value:o??``,onChange:e=>s(e.target.value||null),children:[(0,b.jsx)(`option`,{value:``,children:`All feeds`}),ee.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]}),d===`feeds`&&(0,b.jsxs)(`button`,{onClick:()=>{g(null),m(!0)},className:`flex items-center gap-1 px-2 py-1 text-xs text-white bg-primary rounded hover:bg-primary/90 cursor-pointer`,children:[(0,b.jsx)(Mi,{className:`w-4 h-4`}),` Add Feed`]}),d===`rules`&&(0,b.jsxs)(`button`,{onClick:()=>{S(null),y(!0)},className:`flex items-center gap-1 px-2 py-1 text-xs text-white bg-primary rounded hover:bg-primary/90 cursor-pointer`,children:[(0,b.jsx)(Mi,{className:`w-4 h-4`}),` Add Rule`]})]})]}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:[d===`items`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Title`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Feed`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Published`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Size`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:40}})]})}),(0,b.jsxs)(`tbody`,{children:[n.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} max-w-xs truncate`,title:e.title,children:e.title}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary`,children:e.feed_name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary`,children:te(e.published_at)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.size_bytes>0?Xo(e.size_bytes):`-`}),(0,b.jsx)(`td`,{className:j,children:e.downloaded?(0,b.jsxs)(`span`,{className:`flex items-center gap-1 text-green-600 dark:text-green-400 text-xs`,children:[(0,b.jsx)(Gi,{className:`w-3 h-3`}),` Done`]}):(0,b.jsx)(`span`,{className:`text-xs text-secondary`,children:`Pending`})}),(0,b.jsx)(`td`,{className:j,children:!e.downloaded&&e.url&&(0,b.jsx)(`button`,{onClick:()=>O(e),disabled:C===e.id,className:ne,title:`Download`,children:C===e.id?(0,b.jsx)(xi,{}):(0,b.jsx)(zi,{className:`w-3.5 h-3.5`})})})]},e.id)),n.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No RSS items found. Add a feed to get started.`})})]})]}),d===`feeds`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Name`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`URL`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Interval`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Category`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:80}})]})}),(0,b.jsxs)(`tbody`,{children:[e.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} font-medium`,children:e.name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary max-w-xs truncate`,title:e.url,children:e.url}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:hl(e.poll_interval_secs)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.category||`-`}),(0,b.jsx)(`td`,{className:j,children:(0,b.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.enabled?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.enabled?`Active`:`Disabled`})}),(0,b.jsxs)(`td`,{className:`${j} flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>{g(e),m(!0)},className:ne,title:`Edit`,children:(0,b.jsx)(Pi,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{onClick:()=>E(e.name),className:`${ne} hover:text-red-500`,title:`Delete`,children:(0,b.jsx)(wi,{className:`w-3.5 h-3.5`})})]})]},e.name)),e.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No RSS feeds configured. Click "Add Feed" to add one.`})})]})]}),d===`rules`&&(0,b.jsxs)(`table`,{className:`w-full`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 bg-surface-raised z-10`,children:(0,b.jsxs)(`tr`,{className:`border-b border-divider`,children:[(0,b.jsx)(`th`,{className:A,children:`Name`}),(0,b.jsx)(`th`,{className:`${A} hidden lg:table-cell`,children:`Pattern`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Feeds`}),(0,b.jsx)(`th`,{className:`${A} hidden md:table-cell`,children:`Category`}),(0,b.jsx)(`th`,{className:A,children:`Status`}),(0,b.jsx)(`th`,{className:A,style:{width:80}})]})}),(0,b.jsxs)(`tbody`,{children:[i.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-divider hover:bg-surface/50`,children:[(0,b.jsx)(`td`,{className:`${j} font-medium`,children:e.name}),(0,b.jsx)(`td`,{className:`${j} hidden lg:table-cell text-secondary font-mono text-xs max-w-xs truncate`,title:e.match_regex,children:e.match_regex}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.feed_names.join(`, `)}),(0,b.jsx)(`td`,{className:`${j} hidden md:table-cell text-secondary`,children:e.category||`-`}),(0,b.jsx)(`td`,{className:j,children:(0,b.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${e.enabled?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400`}`,children:e.enabled?`Active`:`Disabled`})}),(0,b.jsxs)(`td`,{className:`${j} flex gap-1`,children:[(0,b.jsx)(`button`,{onClick:()=>{S(e),y(!0)},className:ne,title:`Edit`,children:(0,b.jsx)(Pi,{className:`w-3.5 h-3.5`})}),(0,b.jsx)(`button`,{onClick:()=>D(e.id),className:`${ne} hover:text-red-500`,title:`Delete`,children:(0,b.jsx)(wi,{className:`w-3.5 h-3.5`})})]})]},e.id)),i.length===0&&(0,b.jsx)(`tr`,{children:(0,b.jsx)(`td`,{colSpan:6,className:`px-4 py-8 text-center text-secondary text-sm`,children:`No download rules. Click "Add Rule" to create one.`})})]})]})]}),(0,b.jsx)(_l,{isOpen:p,onClose:()=>m(!1),feed:h,onSaved:T}),(0,b.jsx)(vl,{isOpen:v,onClose:()=>y(!1),rule:x,feedNames:ee,onSaved:T})]})},bl=()=>{let e=Ko(e=>e.closeableError),t=Ko(e=>e.setCloseableError),n=Ko(e=>e.otherError),r=ua(e=>e.torrents),i=ua(e=>e.torrentsInitiallyLoading),a=Z(e=>e.viewMode),o=Z(e=>e.currentPage),s=xc(),c=a===`compact`&&s;return o===`indexarr`?(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsx)(ha,{error:e,remove:()=>t(null)}),(0,b.jsx)(ha,{error:n}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(fl,{})})]}):o===`rss`?(0,b.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,b.jsx)(ha,{error:e,remove:()=>t(null)}),(0,b.jsx)(ha,{error:n}),(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(yl,{})})]}):(0,b.jsxs)(`div`,{className:c?`h-full`:`h-full flex flex-col`,children:[(0,b.jsx)(ha,{error:e,remove:()=>t(null)}),(0,b.jsx)(ha,{error:n}),c?(0,b.jsx)(Uc,{torrents:r,loading:i}):(0,b.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,b.jsx)(yc,{torrents:r,loading:i})})]})},xl=({show:e,onClose:t})=>{let n=(0,_.useContext)(v).getStreamLogsUrl();return(0,b.jsxs)(So,{isOpen:e,onClose:t,title:`RustTorrent server logs`,className:`max-w-7xl`,children:[(0,b.jsx)(`div`,{className:`p-3 border-b dark:border-slate-500 h-[70vh]`,children:n?(0,b.jsx)(dc,{url:n}):(0,b.jsx)(ha,{error:{text:`HTTP API not available to stream logs`}})}),(0,b.jsx)(wo,{children:(0,b.jsx)(pa,{variant:`primary`,onClick:t,children:`Close`})})]})};function Sl(e){return X({tag:`svg`,attr:{fill:`none`,viewBox:`0 0 24 24`,strokeWidth:`2`,stroke:`currentColor`,"aria-hidden":`true`},child:[{tag:`path`,attr:{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M4 6h16M4 12h16M4 18h16`},child:[]}]})(e)}var Cl=e=>(0,b.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 120 120`,width:120,height:120,...e,children:[(0,b.jsxs)(`defs`,{children:[(0,b.jsxs)(`linearGradient`,{id:`bg`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,b.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#4a3728`}}),(0,b.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#3d2e22`}})]}),(0,b.jsxs)(`linearGradient`,{id:`gear`,x1:`0%`,y1:`0%`,x2:`100%`,y2:`100%`,children:[(0,b.jsx)(`stop`,{offset:`0%`,style:{stopColor:`#8b6914`}}),(0,b.jsx)(`stop`,{offset:`100%`,style:{stopColor:`#a07818`}})]})]}),(0,b.jsx)(`rect`,{width:120,height:120,rx:24,fill:`url(#bg)`}),(0,b.jsxs)(`g`,{transform:`translate(60,62)`,children:[(0,b.jsx)(`path`,{d:`M-6,-38 L6,-38 L8,-30 L-8,-30Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-6,30 L6,30 L8,38 L-8,38Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-38,-6 L-38,6 L-30,8 L-30,-8Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M30,-6 L30,6 L38,8 L38,-8Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M21,-31 L29,-25 L23,-19 L15,-25Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-29,25 L-21,31 L-15,25 L-23,19Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M-29,-25 L-21,-31 L-15,-25 L-23,-19Z`,fill:`url(#gear)`}),(0,b.jsx)(`path`,{d:`M21,31 L29,25 L23,19 L15,25Z`,fill:`url(#gear)`}),(0,b.jsx)(`circle`,{cx:0,cy:0,r:24,fill:`none`,stroke:`url(#gear)`,strokeWidth:6}),(0,b.jsx)(`ellipse`,{cx:-6,cy:-4,rx:12,ry:10,fill:`#e8dcc8`}),(0,b.jsx)(`ellipse`,{cx:8,cy:-2,rx:10,ry:9,fill:`#e8dcc8`}),(0,b.jsx)(`ellipse`,{cx:0,cy:4,rx:14,ry:8,fill:`#e8dcc8`}),(0,b.jsx)(`path`,{d:`M0,-10 L0,2 L-5,-3 M0,2 L5,-3`,fill:`none`,stroke:`#4a3728`,strokeWidth:2.5,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,b.jsx)(`text`,{x:0,y:12,fontFamily:`Arial,Helvetica,sans-serif`,fontSize:14,fontWeight:800,fill:`#4a3728`,textAnchor:`middle`,children:`T`})]})]}),wl=window.matchMedia(`(prefers-color-scheme: dark)`).matches;window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{Tl.setDark(e.matches)});var Tl={isDark:()=>wl,setDark:e=>(wl=e,document.body.classList.toggle(`dark`,wl),wl),toggle:()=>{Tl.setDark(!wl)}};Tl.setDark(wl);function El(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`},child:[{tag:`path`,attr:{d:`M14.8284 12L16.2426 13.4142L19.071 10.5858C20.6331 9.02365 20.6331 6.49099 19.071 4.9289C17.509 3.3668 14.9763 3.3668 13.4142 4.9289L10.5858 7.75732L12 9.17154L14.8284 6.34311C15.6095 5.56206 16.8758 5.56206 17.6568 6.34311C18.4379 7.12416 18.4379 8.39049 17.6568 9.17154L14.8284 12Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{d:`M12 14.8285L13.4142 16.2427L10.5858 19.0711C9.02372 20.6332 6.49106 20.6332 4.92896 19.0711C3.36686 17.509 3.36686 14.9764 4.92896 13.4143L7.75739 10.5858L9.1716 12L6.34317 14.8285C5.56212 15.6095 5.56212 16.8758 6.34317 17.6569C7.12422 18.4379 8.39055 18.4379 9.1716 17.6569L12 14.8285Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{d:`M14.8285 10.5857C15.219 10.1952 15.219 9.56199 14.8285 9.17147C14.4379 8.78094 13.8048 8.78094 13.4142 9.17147L9.1716 13.4141C8.78107 13.8046 8.78107 14.4378 9.1716 14.8283C9.56212 15.2188 10.1953 15.2188 10.5858 14.8283L14.8285 10.5857Z`,fill:`currentColor`},child:[]}]})(e)}function Dl(e){return X({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`},child:[{tag:`path`,attr:{d:`M10 18V16H8V14H10V12H12V14H14V16H12V18H10Z`,fill:`currentColor`},child:[]},{tag:`path`,attr:{fillRule:`evenodd`,clipRule:`evenodd`,d:`M6 2C4.34315 2 3 3.34315 3 5V19C3 20.6569 4.34315 22 6 22H18C19.6569 22 21 20.6569 21 19V9C21 5.13401 17.866 2 14 2H6ZM6 4H13V9H19V19C19 19.5523 18.5523 20 18 20H6C5.44772 20 5 19.5523 5 19V5C5 4.44772 5.44772 4 6 4ZM15 4.10002C16.6113 4.4271 17.9413 5.52906 18.584 7H15V4.10002Z`,fill:`currentColor`},child:[]}]})(e)}var Ol=({onClick:e,data:t,resetData:n,children:r,className:i})=>{let[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),d=(0,_.useContext)(v);return(0,_.useEffect)(()=>{if(t===null)return;let e=setTimeout(async()=>{o(!0);try{c(await d.uploadTorrent(t,{list_only:!0}))}catch(e){u({text:`Error listing torrent files`,details:e})}finally{o(!1)}},0);return()=>clearTimeout(e)},[t]),(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(pa,{onClick:e,className:i,children:r}),t&&(0,b.jsx)(ol,{onHide:()=>{n(),u(null),c(null),o(!1)},listTorrentError:l,listTorrentResponse:s,data:t,listTorrentLoading:a})]})},kl=({className:e})=>{let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(``),[a,o]=(0,_.useState)(!1),s=()=>{n(r),i(``),o(!1)},c=()=>{o(!1),n(null)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(Ol,{onClick:()=>{o(!0)},data:t,className:`group ${e}`,resetData:()=>n(null),children:[(0,b.jsx)(El,{className:`text-blue-500 group-hover:text-white dark:text-white`}),(0,b.jsx)(`div`,{children:`Add Torrent from Magnet / URL`})]}),(0,b.jsxs)(So,{isOpen:a,onClose:c,title:`Add torrent`,children:[(0,b.jsx)(Co,{children:(0,b.jsx)(il,{autoFocus:!0,value:r,name:`magnet`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r&&s()},placeholder:`magnet:?xt=urn:btih:...`,help:`Enter magnet or HTTP(S) URL to the .torrent`})}),(0,b.jsxs)(wo,{children:[(0,b.jsx)(pa,{variant:`cancel`,onClick:c,children:`Cancel`}),(0,b.jsx)(pa,{disabled:!r,variant:`primary`,onClick:s,children:`Add`})]})]})]})},Al=({className:e,onMultiFileSelect:t})=>{let n=(0,_.useRef)(null),[r,i]=(0,_.useState)(null),a=(0,_.useContext)(v),o=ua(e=>e.refreshTorrents),s=async()=>{if(n?.current?.files)if(n.current.files.length==1)if(t)t([n.current.files[0]]),c();else{let e=n.current.files[0];i(e)}else if(t)t(Array.from(n.current.files)),c();else{for(let e=0;e{console.log(`uploaded file successfully`),o()},e=>{console.error(`error uploading file`,e)})}c()}},c=()=>{n?.current&&(n.current.value=``,i(null))};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`input`,{type:`file`,ref:n,multiple:!0,accept:`.torrent`,onChange:s,hidden:!0}),(0,b.jsxs)(Ol,{onClick:()=>{n?.current&&n.current.click()},data:r,resetData:c,className:`group ${e}`,children:[(0,b.jsx)(Dl,{className:`text-blue-500 group-hover:text-white dark:text-white`}),(0,b.jsx)(`div`,{children:`Upload .torrent File`})]})]})},jl=({isOpen:e,onClose:t,title:n,tabs:r,initialTab:i,onSave:a,onReset:o,saveButtonText:s=`OK`,showResetButton:c=!1,isSaving:l=!1,error:u})=>{let[d,f]=(0,_.useState)(i||r[0]?.id);return(0,b.jsxs)(So,{isOpen:e,onClose:t,title:n,className:`sm:max-w-4xl`,children:[(0,b.jsxs)(Co,{children:[(0,b.jsx)(ha,{error:u??null}),r.length>1&&(0,b.jsx)(tc,{className:`mb-4`,children:r.map(e=>(0,b.jsx)(ec,{id:e.id,label:e.label,active:e.id===d,onClick:()=>f(e.id)},e.id))}),r.map(e=>(0,b.jsx)(`div`,{className:e.id===d?``:`hidden`,children:e.content},e.id))]}),(0,b.jsxs)(wo,{children:[t&&(0,b.jsx)(pa,{variant:`cancel`,onClick:t,children:`Cancel`}),c&&o&&(0,b.jsx)(pa,{variant:`secondary`,onClick:o,children:`Reset to defaults`}),(0,b.jsx)(pa,{variant:`primary`,onClick:a,disabled:l,children:s})]})]})},Ml=(e,t)=>{let n=e??0;return n>0?`Limit total ${t} speed to this number of bytes per second (current ${Xo(n)} per second)`:`Limit total ${t} speed to this number of bytes per second (currently disabled)`},Nl=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],$=[1,2,4,8,16,32,64],Pl=e=>{let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`},Fl=e=>{let[t,n]=e.split(`:`).map(Number);return(t||0)*60+(n||0)},Il=({downloadBps:e,uploadBps:t,peerLimit:n,concurrentInitLimit:r,onDownloadBpsChange:i,onUploadBpsChange:a,onPeerLimitChange:o,onConcurrentInitLimitChange:s})=>{let c=(0,_.useContext)(v),[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)({download_rate:null,upload_rate:null}),[p,m]=(0,_.useState)({enabled:!1,start_minutes:0,end_minutes:0,days:0}),[h,g]=(0,_.useState)(!1),[y,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{c.getAltSpeed().then(e=>{u(e.enabled),f(e.config),e.schedule&&m(e.schedule),g(!0)}).catch(()=>{g(!1)})},[c]);let S=async e=>{u(e),x(null);try{await c.toggleAltSpeed(e)}catch{u(!e),x(`Could not update alternative speed limits on the server.`)}},C=async e=>{f(e);try{await c.setAltSpeedConfig(e)}catch{}},w=async e=>{m(e);try{await c.setSpeedSchedule(e)}catch{}};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(rl,{label:`Speed Limits`,children:[(0,b.jsx)(il,{label:`Download rate limit`,name:`download_bps`,inputType:`number`,value:e?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;i(isNaN(t)||t<=0?null:t)},help:Ml(e,`download`)}),(0,b.jsx)(il,{label:`Upload rate limit`,name:`upload_bps`,inputType:`number`,value:t?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;a(isNaN(t)||t<=0?null:t)},help:Ml(t,`upload`)}),(0,b.jsx)(il,{label:`Peer limit`,name:`peer_limit`,inputType:`number`,value:n?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;o(isNaN(t)||t<=0?null:t)},help:`Maximum number of peers per torrent (current: ${n??`default`})`}),(0,b.jsx)(il,{label:`Concurrent init limit`,name:`concurrent_init_limit`,inputType:`number`,value:r?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;s(isNaN(t)||t<=0?null:t)},help:`Maximum number of torrents initializing concurrently (current: ${r??`default`})`})]}),h&&(0,b.jsxs)(rl,{label:`Alternative Speed Limits`,children:[(0,b.jsx)(ks,{checked:l,label:`Enable alternative speed limits`,name:`alt_speed_enabled`,help:`When enabled, alternative speed limits override the normal limits above.`,onChange:()=>S(!l)}),y&&(0,b.jsx)(`p`,{className:`text-sm text-error mt-1`,children:y}),l&&(0,b.jsxs)(`div`,{className:`mt-3 space-y-2 ml-6`,children:[(0,b.jsx)(il,{label:`Alt download limit (KB/s)`,name:`alt_download_rate`,inputType:`number`,value:d.download_rate==null?``:String(Math.round(d.download_rate/1024)),onChange:e=>{let t=e.target.valueAsNumber;C({...d,download_rate:isNaN(t)||t<=0?null:t*1024})},help:`Alternative download speed limit in KB/s (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Alt upload limit (KB/s)`,name:`alt_upload_rate`,inputType:`number`,value:d.upload_rate==null?``:String(Math.round(d.upload_rate/1024)),onChange:e=>{let t=e.target.valueAsNumber;C({...d,upload_rate:isNaN(t)||t<=0?null:t*1024})},help:`Alternative upload speed limit in KB/s (0 or empty = unlimited)`})]}),(0,b.jsxs)(`div`,{className:`mt-4`,children:[(0,b.jsx)(ks,{checked:p.enabled,label:`Enable schedule`,name:`alt_schedule_enabled`,help:`Automatically enable alternative speed limits during scheduled times.`,onChange:()=>{w({...p,enabled:!p.enabled})}}),p.enabled&&(0,b.jsxs)(`div`,{className:`mt-3 ml-6 space-y-3`,children:[(0,b.jsxs)(`div`,{className:`flex gap-4 items-center`,children:[(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`schedule_start`,className:`text-sm text-secondary`,children:`Start time`}),(0,b.jsx)(`input`,{type:`time`,id:`schedule_start`,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 pr-2 focus:ring-0 focus:border-primary sm:leading-6`,value:Pl(p.start_minutes),onChange:e=>{w({...p,start_minutes:Fl(e.target.value)})}})]}),(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`schedule_end`,className:`text-sm text-secondary`,children:`End time`}),(0,b.jsx)(`input`,{type:`time`,id:`schedule_end`,className:`block border border-divider rounded bg-transparent py-1.5 pl-2 pr-2 focus:ring-0 focus:border-primary sm:leading-6`,value:Pl(p.end_minutes),onChange:e=>{w({...p,end_minutes:Fl(e.target.value)})}})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`text-sm text-secondary block mb-2`,children:`Days`}),(0,b.jsx)(`div`,{className:`flex gap-3 flex-wrap`,children:Nl.map((e,t)=>(0,b.jsxs)(`label`,{className:`flex items-center gap-1 text-sm cursor-pointer`,children:[(0,b.jsx)(`input`,{type:`checkbox`,checked:(p.days&$[t])!==0,onChange:()=>{w({...p,days:p.days^$[t]})}}),e]},e))})]})]})]})]})]})},Ll=sa(e=>({stats:{counters:{fetched_bytes:0,uploaded_bytes:0,blocked_incoming:0,blocked_outgoing:0},peers:{connecting:0,dead:0,live:0,not_needed:0,queued:0,seen:0},download_speed:{human_readable:`N/A`,mbps:0},upload_speed:{human_readable:`N/A`,mbps:0},uptime_seconds:0,connections:{tcp:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}},utp:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}},socks:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}}}},setStats:t=>{e({stats:t})}})),Rl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),zl=({version:e})=>{let t=Ll(e=>e.stats);return(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,b.jsx)(Rl,{label:`Version`,value:e}),(0,b.jsx)(Rl,{label:`Uptime`,value:Qo(t.uptime_seconds)}),(0,b.jsx)(Rl,{label:`Total Downloaded`,value:Xo(t.counters.fetched_bytes)}),(0,b.jsx)(Rl,{label:`Total Uploaded`,value:Xo(t.counters.uploaded_bytes)}),(0,b.jsx)(Rl,{label:`Live Peers`,value:String(t.peers.live)}),(0,b.jsx)(Rl,{label:`Download Speed`,value:t.download_speed.human_readable}),(0,b.jsx)(Rl,{label:`Upload Speed`,value:t.upload_speed.human_readable}),(0,b.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-divider`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:`Web Seeds`}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:`Enabled`})]}),(0,b.jsxs)(`div`,{className:`text-secondary text-xs mt-1 ml-0`,children:[`Web seed support is enabled by default. Use`,` `,(0,b.jsx)(`code`,{className:`text-xs bg-surface px-1 py-0.5 rounded`,children:`--disable-webseeds`}),` `,`at startup to disable it.`]})]})]})},Bl=`pb-1 px-2`,Vl=`px-2 text-right text-primary tabular-nums`,Hl=({protocol:e,family:t,stat:n})=>n.attempts===0&&n.successes===0&&n.errors===0?null:(0,b.jsxs)(`tr`,{className:`border-t border-divider`,children:[(0,b.jsx)(`td`,{className:`px-2 py-1 text-primary`,children:e}),(0,b.jsx)(`td`,{className:`px-2 py-1 text-primary`,children:t}),(0,b.jsx)(`td`,{className:Vl,children:n.attempts.toLocaleString()}),(0,b.jsx)(`td`,{className:Vl,children:n.successes.toLocaleString()}),(0,b.jsx)(`td`,{className:Vl,children:n.errors.toLocaleString()})]}),Ul=({protocol:e,stats:t})=>(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Hl,{protocol:e,family:`IPv4`,stat:t.v4}),(0,b.jsx)(Hl,{protocol:e,family:`IPv6`,stat:t.v6})]}),Wl=()=>{let e=Ll(e=>e.stats).connections;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(`p`,{className:`text-secondary text-sm mb-3`,children:`Connection statistics from the current session.`}),(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`text-tertiary text-left`,children:[(0,b.jsx)(`th`,{className:Bl,children:`Protocol`}),(0,b.jsx)(`th`,{className:Bl,children:`Family`}),(0,b.jsx)(`th`,{className:`${Bl} text-right`,children:`Attempts`}),(0,b.jsx)(`th`,{className:`${Bl} text-right`,children:`Successes`}),(0,b.jsx)(`th`,{className:`${Bl} text-right`,children:`Errors`})]})}),(0,b.jsxs)(`tbody`,{children:[(0,b.jsx)(Ul,{protocol:`TCP`,stats:e.tcp}),(0,b.jsx)(Ul,{protocol:`uTP`,stats:e.utp}),(0,b.jsx)(Ul,{protocol:`SOCKS`,stats:e.socks})]})]}),(0,b.jsxs)(`div`,{className:`mt-6 mb-3`,children:[(0,b.jsx)(`label`,{className:`font-medium mb-3 block pb-1 border-b border-divider`,children:`Encryption`}),(0,b.jsxs)(`div`,{className:`mt-2`,children:[(0,b.jsxs)(`select`,{className:`block border border-divider rounded bg-transparent py-1.5 px-2 focus:ring-0 focus:border-primary sm:leading-6 text-primary`,disabled:!0,value:`enabled`,children:[(0,b.jsx)(`option`,{value:`disabled`,children:`Disabled`}),(0,b.jsx)(`option`,{value:`enabled`,children:`Enabled (prefer encrypted)`}),(0,b.jsx)(`option`,{value:`forced`,children:`Forced (require encrypted)`})]}),(0,b.jsxs)(`div`,{className:`text-sm text-secondary mt-2 space-y-1`,children:[(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Disabled:`}),` No encryption, all connections are plaintext.`]}),(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Enabled:`}),` Prefer encrypted connections but allow plaintext fallback.`]}),(0,b.jsxs)(`p`,{children:[(0,b.jsx)(`strong`,{children:`Forced:`}),` Only allow encrypted connections; reject unencrypted peers.`]})]})]})]}),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`Connection settings (listen port, TCP/uTP, UPnP, SOCKS proxy, encryption mode) are configured via CLI arguments at startup.`})]})},Gl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),Kl=e=>e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),ql=()=>{let e=(0,_.useContext)(v),[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null);return(0,_.useEffect)(()=>{e.getDhtStats().then(n).catch(()=>i(`DHT is disabled or unavailable`))},[e]),r?(0,b.jsx)(`div`,{className:`text-secondary py-2`,children:r}):t?(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[Object.entries(t).map(([e,t])=>t==null||typeof t==`object`?null:(0,b.jsx)(Gl,{label:Kl(e),value:String(t)},e)),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`DHT settings are configured via CLI arguments at startup.`})]}):(0,b.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,b.jsx)(xi,{})})},Jl=({label:e,value:t})=>(0,b.jsxs)(`div`,{className:`flex items-center`,children:[(0,b.jsx)(`span`,{className:`w-40 text-secondary text-sm`,children:e}),(0,b.jsx)(`span`,{className:`text-primary text-sm font-medium`,children:t})]}),Yl=()=>(0,b.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,b.jsx)(Jl,{label:`API URL`,value:window.location.origin}),(0,b.jsx)(Jl,{label:`Swagger UI`,value:`/swagger/`}),(0,b.jsx)(`div`,{className:`mt-4 text-secondary text-xs`,children:`HTTP API settings (listen address, read-only mode, basic auth) are configured via CLI arguments at startup.`})]}),Xl=()=>{let[e,t]=(0,_.useState)(``),[n,r]=(0,_.useState)(``),[i,a]=(0,_.useState)(``),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(!1),m=Jc(e=>e.state),h=async()=>{if(l(null),d(null),!e){l(`Current password is required`);return}if(i&&i!==o){l(`New passwords do not match`);return}if(i&&i.length<4){l(`New password must be at least 4 characters`);return}if(!n&&!i){l(`Enter a new username or password to change`);return}p(!0);try{await $c.changeCredentials(e,n||void 0,i||void 0),d(`Credentials updated successfully`),t(``),r(``),a(``),s(``)}catch(e){l(e.message||`Failed to change credentials`)}finally{p(!1)}},g=`w-full px-3 py-2 bg-surface border border-divider rounded text-primary placeholder:text-tertiary focus:outline-none focus:border-primary text-sm`;return m===`no_auth`?(0,b.jsx)(`div`,{className:`space-y-3 py-2`,children:(0,b.jsxs)(`div`,{className:`text-secondary text-sm`,children:[`Authentication is not enabled. Set`,` `,(0,b.jsx)(`code`,{className:`text-xs bg-surface px-1 py-0.5 rounded`,children:`RTBIT_HTTP_BASIC_AUTH_USERPASS`}),` `,`or use the first-boot setup to enable it.`]})}):(0,b.jsxs)(`div`,{className:`space-y-4 py-2`,children:[c&&(0,b.jsx)(`div`,{className:`bg-error-bg/10 border border-error-bg text-error-bg rounded px-3 py-2 text-sm`,children:c}),u&&(0,b.jsx)(`div`,{className:`bg-green-500/10 border border-green-500 text-green-600 dark:text-green-400 rounded px-3 py-2 text-sm`,children:u}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`Current Password`}),(0,b.jsx)(`input`,{type:`password`,value:e,onChange:e=>t(e.target.value),className:g,placeholder:`Enter current password`,autoComplete:`current-password`})]}),(0,b.jsx)(`hr`,{className:`border-divider`}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`New Username (optional)`}),(0,b.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),className:g,placeholder:`Leave blank to keep current`,autoComplete:`username`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`New Password (optional)`}),(0,b.jsx)(`input`,{type:`password`,value:i,onChange:e=>a(e.target.value),className:g,placeholder:`Leave blank to keep current`,autoComplete:`new-password`})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`label`,{className:`block text-sm font-medium text-secondary mb-1`,children:`Confirm New Password`}),(0,b.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),className:g,placeholder:`Confirm new password`,autoComplete:`new-password`,disabled:!i})]}),(0,b.jsx)(`button`,{onClick:h,disabled:f||!e,className:`w-full py-2 bg-primary-bg text-white rounded font-medium text-sm hover:bg-primary-bg-hover disabled:opacity-50 transition-colors cursor-pointer disabled:cursor-not-allowed`,children:f?`Saving...`:`Update Credentials`})]})},Zl=()=>{let e=(0,_.useContext)(v),[t,n]=(0,_.useState)({ratio_limit:null,time_limit_secs:null}),[r,i]=(0,_.useState)(!0),[a,o]=(0,_.useState)(null);(0,_.useEffect)(()=>{e.getSeedLimits().then(e=>{n(e)}).catch(()=>{o(`Could not load seed limits`)}).finally(()=>i(!1))},[e]);let s=async t=>{n(t);try{await e.setSeedLimits(t)}catch{}};if(r)return(0,b.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,b.jsx)(xi,{})});if(a)return(0,b.jsx)(`div`,{className:`text-secondary py-2`,children:a});let c=t.ratio_limit!=null,l=t.time_limit_secs!=null,u=t.time_limit_secs==null?``:Math.round(t.time_limit_secs/3600*100)/100;return(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsxs)(rl,{label:`Seed Ratio Limit`,children:[(0,b.jsx)(ks,{checked:c,label:`Limit seed ratio globally`,name:`ratio_limit_enabled`,help:`Stop seeding when the upload/download ratio reaches this value.`,onChange:()=>{s({...t,ratio_limit:c?null:2})}}),c&&(0,b.jsx)(`div`,{className:`mt-2 ml-6`,children:(0,b.jsx)(il,{label:`Ratio limit`,name:`ratio_limit`,inputType:`number`,value:t.ratio_limit==null?``:String(t.ratio_limit),onChange:e=>{let n=e.target.valueAsNumber;s({...t,ratio_limit:isNaN(n)||n<=0?null:n})},help:`e.g. 2.0 means upload 2x the downloaded amount`})})]}),(0,b.jsxs)(rl,{label:`Seed Time Limit`,children:[(0,b.jsx)(ks,{checked:l,label:`Limit seeding time globally`,name:`time_limit_enabled`,help:`Stop seeding after this amount of time.`,onChange:()=>{s({...t,time_limit_secs:l?null:24*3600})}}),l&&(0,b.jsx)(`div`,{className:`mt-2 ml-6`,children:(0,b.jsx)(il,{label:`Time limit (hours)`,name:`time_limit_hours`,inputType:`number`,value:String(u),onChange:e=>{let n=e.target.valueAsNumber;s({...t,time_limit_secs:isNaN(n)||n<=0?null:Math.round(n*3600)})},help:`Seeding time limit in hours`})})]}),(0,b.jsx)(`div`,{className:`text-secondary text-xs mt-4`,children:`Super-seeding can be enabled per-torrent from the torrent context menu.`})]})},Ql=({maxActiveDownloads:e,maxActiveUploads:t,maxActiveTotal:n,onMaxActiveDownloadsChange:r,onMaxActiveUploadsChange:i,onMaxActiveTotalChange:a})=>(0,b.jsx)(`div`,{className:`py-2`,children:(0,b.jsxs)(rl,{label:`Queue Limits`,children:[(0,b.jsx)(il,{label:`Max active downloads`,name:`max_active_downloads`,inputType:`number`,value:e?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;r(isNaN(t)||t<0?null:t)},help:`Maximum number of active downloading torrents (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Max active uploads`,name:`max_active_uploads`,inputType:`number`,value:t?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;i(isNaN(t)||t<0?null:t)},help:`Maximum number of active seeding torrents (0 or empty = unlimited)`}),(0,b.jsx)(il,{label:`Max active total`,name:`max_active_total`,inputType:`number`,value:n?.toString()??``,onChange:e=>{let t=e.target.valueAsNumber;a(isNaN(t)||t<0?null:t)},help:`Maximum number of active torrents total (0 or empty = unlimited)`})]})}),$l=({rssHistoryLimit:e,onRssHistoryLimitChange:t})=>{let[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null);return(0,_.useEffect)(()=>{tl.getFeeds().then(e=>r(e.length)).catch(()=>{}),tl.getRules().then(e=>a(e.length)).catch(()=>{}),tl.getItems(void 0,1).then(()=>tl.getItems().then(e=>s(e.length))).catch(()=>{})},[]),(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsxs)(`div`,{className:`border-b border-divider pb-3 mb-3`,children:[(0,b.jsx)(`h4`,{className:`text-xs font-semibold uppercase text-tertiary mb-2`,children:`RSS Status`}),(0,b.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:n??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Feeds`})]}),(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:i??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Rules`})]}),(0,b.jsxs)(`div`,{className:`text-center`,children:[(0,b.jsx)(`div`,{className:`text-lg font-semibold`,children:o??`-`}),(0,b.jsx)(`div`,{className:`text-xs text-secondary`,children:`Items`})]})]})]}),(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`h4`,{className:`text-xs font-semibold uppercase text-tertiary mb-2`,children:`Settings`}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,b.jsx)(`label`,{className:`text-sm text-secondary`,children:`Feed History Limit`}),(0,b.jsx)(`input`,{type:`number`,className:`w-32 px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,value:e??``,onChange:e=>{let n=e.target.value;t(n===``?null:Number(n))},placeholder:`Unlimited`,min:0})]}),(0,b.jsx)(`p`,{className:`text-xs text-tertiary mt-1`,children:`Maximum number of RSS feed items to keep in history. Empty = unlimited. Default: 500.`})]})]})},eu=({isOpen:e,initialPath:t,onSelect:n,onClose:r})=>{let i=(0,_.useContext)(v),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(null),d=(0,_.useCallback)(e=>{c(!0),u(null),i.browseDirectory(e).then(e=>{o(e)}).catch(e=>{u(e?.text||`Failed to browse directory`)}).finally(()=>c(!1))},[i]);if((0,_.useEffect)(()=>{e&&d(t||void 0)},[e,t,d]),!e)return null;let f=a?.entries.filter(e=>e.is_dir)??[];return(0,b.jsxs)(`div`,{className:`border border-divider rounded bg-surface mt-1 overflow-hidden`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-surface border-b border-divider`,children:[(0,b.jsx)(`span`,{className:`text-xs text-secondary truncate flex-1 font-mono`,children:a?.current??`Loading...`}),(0,b.jsx)(`button`,{type:`button`,className:`text-xs px-2 py-1 rounded bg-primary text-white hover:bg-primary/80 cursor-pointer`,onClick:()=>{a&&(n(a.current),r())},disabled:!a,children:`Select`}),(0,b.jsx)(`button`,{type:`button`,className:`text-xs px-2 py-1 rounded bg-surface-raised text-secondary hover:text-text border border-divider cursor-pointer`,onClick:r,children:`Cancel`})]}),(0,b.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[s&&(0,b.jsx)(`div`,{className:`flex justify-center p-3`,children:(0,b.jsx)(xi,{})}),l&&(0,b.jsx)(`div`,{className:`p-3 text-sm text-red-500`,children:l}),!s&&!l&&a&&(0,b.jsxs)(`div`,{className:`divide-y divide-divider/50`,children:[a.parent&&(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface-raised cursor-pointer`,onClick:()=>d(a.parent),children:[(0,b.jsx)(vi,{className:`w-4 h-4 text-secondary flex-shrink-0`}),(0,b.jsx)(`span`,{className:`text-secondary`,children:`..`})]}),f.map(e=>(0,b.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 w-full px-3 py-1.5 text-sm text-left hover:bg-surface-raised cursor-pointer`,onClick:()=>d(e.path),children:[(0,b.jsx)(Ri,{className:`w-4 h-4 text-yellow-500 flex-shrink-0`}),(0,b.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path)),f.length===0&&!a.parent&&(0,b.jsx)(`div`,{className:`px-3 py-2 text-sm text-secondary`,children:`No subdirectories`})]})]})]})},tu=({label:e,name:t,value:n,help:r,placeholder:i,onChange:a})=>{let[o,s]=(0,_.useState)(!1);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 mb-2`,children:[(0,b.jsx)(`label`,{htmlFor:t,children:e}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsx)(`input`,{type:`text`,className:`flex-1 block border border-divider rounded bg-transparent py-1.5 pl-2 focus:ring-0 focus:border-primary sm:leading-6`,id:t,name:t,placeholder:i,value:n,onChange:e=>a(e.target.value)}),(0,b.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 px-3 py-1.5 border border-divider rounded hover:bg-surface-raised text-secondary hover:text-text transition-colors cursor-pointer`,onClick:()=>s(!o),title:`Browse directories`,children:(0,b.jsx)(Li,{className:`w-4 h-4`})})]}),r&&(0,b.jsx)(`div`,{className:`text-sm text-secondary`,children:r}),(0,b.jsx)(eu,{isOpen:o,initialPath:n,onSelect:e=>a(e),onClose:()=>s(!1)})]})},nu=({downloadFolder:e,completedFolder:t,onDownloadFolderChange:n,onCompletedFolderChange:r})=>(0,b.jsxs)(`div`,{className:`py-2`,children:[(0,b.jsx)(rl,{label:`Download Location`,children:(0,b.jsx)(tu,{label:`Default download folder`,name:`download_folder`,value:e,onChange:n,help:`New torrents will be saved to this folder by default`,placeholder:`/path/to/downloads`})}),(0,b.jsx)(rl,{label:`Move on Completion`,children:(0,b.jsx)(tu,{label:`Completed folder`,name:`completed_folder`,value:t,onChange:r,help:`Finished torrents will be moved here. Leave empty to disable`,placeholder:`/path/to/completed (optional)`})})]}),ru=({isOpen:e,onClose:t,version:n})=>{let[r,i]=(0,_.useState)({upload_bps:null,download_bps:null,peer_limit:null,concurrent_init_limit:null,max_active_downloads:null,max_active_uploads:null,max_active_total:null}),[a,o]=(0,_.useState)(500),[s,c]=(0,_.useState)(``),[l,u]=(0,_.useState)(``),[d,f]=(0,_.useState)(!0),[p,m]=(0,_.useState)(!1),[h,g]=(0,_.useState)(null),y=(0,_.useContext)(v);return(0,_.useEffect)(()=>{e&&(f(!0),g(null),Promise.all([y.getLimits(),y.getFolders()]).then(([e,t])=>{i(e),c(t.download_folder),u(t.completed_folder??``)}).catch(e=>{g({text:`Error loading settings`,details:e})}).finally(()=>f(!1)))},[e,y]),d&&e?(0,b.jsx)(So,{isOpen:e,onClose:t,title:`Settings`,children:(0,b.jsx)(Co,{children:(0,b.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,b.jsx)(xi,{})})})}):(0,b.jsx)(jl,{isOpen:e,onClose:t,title:`Settings`,tabs:[{id:`general`,label:`General`,content:(0,b.jsx)(zl,{version:n??`unknown`})},{id:`folders`,label:`Folders`,content:(0,b.jsx)(nu,{downloadFolder:s,completedFolder:l,onDownloadFolderChange:c,onCompletedFolderChange:u})},{id:`speed`,label:`Speed`,content:(0,b.jsx)(Il,{downloadBps:r.download_bps,uploadBps:r.upload_bps,peerLimit:r.peer_limit,concurrentInitLimit:r.concurrent_init_limit,onDownloadBpsChange:e=>i(t=>({...t,download_bps:e})),onUploadBpsChange:e=>i(t=>({...t,upload_bps:e})),onPeerLimitChange:e=>i(t=>({...t,peer_limit:e})),onConcurrentInitLimitChange:e=>i(t=>({...t,concurrent_init_limit:e}))})},{id:`connections`,label:`Connections`,content:(0,b.jsx)(Wl,{})},{id:`queue`,label:`Queue`,content:(0,b.jsx)(Ql,{maxActiveDownloads:r.max_active_downloads,maxActiveUploads:r.max_active_uploads,maxActiveTotal:r.max_active_total,onMaxActiveDownloadsChange:e=>i(t=>({...t,max_active_downloads:e})),onMaxActiveUploadsChange:e=>i(t=>({...t,max_active_uploads:e})),onMaxActiveTotalChange:e=>i(t=>({...t,max_active_total:e}))})},{id:`seeding`,label:`Seeding`,content:(0,b.jsx)(Zl,{})},{id:`dht`,label:`DHT`,content:(0,b.jsx)(ql,{})},{id:`security`,label:`Security`,content:(0,b.jsx)(Xl,{})},{id:`http-api`,label:`HTTP API`,content:(0,b.jsx)(Yl,{})},{id:`rss`,label:`RSS`,content:(0,b.jsx)($l,{rssHistoryLimit:a,onRssHistoryLimitChange:o})}],onSave:async()=>{m(!0),g(null);try{await Promise.all([y.setLimits(r),y.setFolders({download_folder:s,completed_folder:l||null})]),t()}catch(e){g({text:`Error saving settings`,details:e})}finally{m(!1)}},isSaving:p,error:h,showResetButton:!1})},iu=({title:e,version:t,onMultiFileSelect:n,onLogsClick:r,menuButtons:i})=>{let a=(0,_.useContext)(v),o=xc(),s=Z(e=>e.selectedTorrentIds),c=Z(e=>e.searchQuery),l=Z(e=>e.setSearchQuery),u=Z(e=>e.setSidebarOpen),d=Z(e=>e.currentPage),f=Z(e=>e.setCurrentPage),p=ua(e=>e.torrents),m=ua(e=>e.refreshTorrents),h=Ko(e=>e.setCloseableError),g=Wc(e=>e.status?.enabled??!1),y=Wc(e=>e.setStatus);(0,_.useEffect)(()=>{el.getStatus().then(y).catch(()=>y({enabled:!1}))},[]);let[x,S]=(0,_.useState)(!1),[C,w]=(0,_.useState)(!1),[T,E]=(0,_.useState)([]),[D,O]=(0,_.useState)(c),[ee,te]=(0,_.useState)(Tl.isDark()),[k,ne]=(0,_.useState)(!1),A=Jc(e=>e.state),j=Jc(e=>e.refreshToken),re=Jc(e=>e.clearTokens),M=async()=>{if(j)try{await $c.logout(j)}catch{}re()},N=(0,_.useCallback)((0,bi.default)(e=>l(e),150),[l]),P=e=>{let t=e.target.value;O(t),N(t)},ie=()=>{O(``),l(``)},F=()=>{Tl.toggle(),te(Tl.isDark())},I=s.size,L=I>0,R=e=>p?.find(t=>t.id===e),z=(0,_.useCallback)(()=>{E(Array.from(s).map(e=>({id:e,name:R(e)?.name??null}))),w(!0)},[s,p]);bs((0,_.useMemo)(()=>({onDelete:z}),[z]));let B=async(e,t,n)=>{S(!0);try{for(let r of s)if(R(r)?.stats?.state!==t)try{await e(r),m()}catch(e){h({text:`Error ${n} torrent id=${r}`,details:e})}}finally{S(!1)}},V=()=>B(e=>a.pause(e),Qi,`pausing`),H=()=>B(e=>a.start(e),$i,`starting`),ae=!i||i.length===0,U=d===`torrents`,oe=`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg transition-colors cursor-pointer whitespace-nowrap`,se=`${oe} bg-primary/12 text-primary`,ce=`${oe} text-secondary hover:text-text hover:bg-surface/50`,W=`p-1.5 text-secondary hover:text-text hover:bg-surface/50 rounded-lg cursor-pointer transition-colors inline-flex items-center justify-center`,le=`p-1.5 text-tertiary rounded-lg inline-flex items-center justify-center opacity-40 cursor-not-allowed`;return(0,b.jsxs)(`div`,{className:`bg-surface-raised drop-shadow-lg`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-1.5`,children:[!o&&(0,b.jsx)(`button`,{onClick:()=>{u(!0),f(`torrents`)},className:`p-1.5 text-secondary hover:text-primary cursor-pointer`,title:`Open sidebar`,children:(0,b.jsx)(Sl,{className:`w-5 h-5`})}),(0,b.jsx)(`div`,{className:`flex items-center mr-1`,title:e,children:(0,b.jsx)(Cl,{className:`w-6 h-6`,alt:e})}),o&&(0,b.jsx)(`div`,{className:`w-px h-5 bg-divider mx-1`}),o&&(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,b.jsxs)(`button`,{onClick:()=>f(`torrents`),className:d===`torrents`?se:ce,children:[(0,b.jsx)(Bi,{className:`w-3.5 h-3.5`}),`Torrents`]}),g&&(0,b.jsxs)(`button`,{onClick:()=>f(`indexarr`),className:d===`indexarr`?se:ce,children:[(0,b.jsx)(Ii,{className:`w-3.5 h-3.5`}),`Index`]}),(0,b.jsxs)(`button`,{onClick:()=>f(`rss`),className:d===`rss`?se:ce,children:[(0,b.jsx)(ji,{className:`w-3.5 h-3.5`}),`RSS`]})]}),(0,b.jsx)(`div`,{className:`flex-1`}),U&&(0,b.jsxs)(`div`,{className:`relative hidden lg:block`,children:[(0,b.jsx)(fi,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`input`,{type:`text`,"data-search-input":!0,value:D,onChange:P,placeholder:`Filter...`,className:`pl-8 pr-7 py-1.5 w-44 text-sm bg-surface/50 border border-divider rounded-lg focus:outline-none focus:border-primary placeholder:text-tertiary`}),D&&(0,b.jsx)(`button`,{onClick:ie,className:`absolute right-1.5 top-1/2 -translate-y-1/2 p-0.5 text-tertiary hover:text-secondary rounded cursor-pointer`,children:(0,b.jsx)(li,{className:`w-3.5 h-3.5`})})]}),U&&(0,b.jsx)(`div`,{className:`hidden lg:block w-px h-5 bg-divider mx-1`}),U&&(0,b.jsxs)(`div`,{className:`flex items-center gap-0.5 bg-surface/30 rounded-lg p-0.5`,children:[(0,b.jsx)(kl,{className:`grow-0 justify-center !px-2.5 !py-1 !text-sm !rounded-lg`}),(0,b.jsx)(Al,{className:`grow-0 justify-center !px-2.5 !py-1 !text-sm !rounded-lg`,onMultiFileSelect:n}),(0,b.jsx)(`div`,{className:`w-px h-5 bg-divider mx-0.5`}),(0,b.jsx)(`button`,{onClick:H,disabled:x||!L,className:x||!L?le:W,title:`Resume selected`,children:(0,b.jsx)(Po,{className:`w-3 h-3`})}),(0,b.jsx)(`button`,{onClick:V,disabled:x||!L,className:x||!L?le:W,title:`Pause selected`,children:(0,b.jsx)(Fo,{className:`w-3 h-3`})}),(0,b.jsx)(`button`,{onClick:z,disabled:x||!L,className:x||!L?`p-1.5 text-error rounded-lg inline-flex items-center justify-center opacity-40 cursor-not-allowed`:`p-1.5 text-error hover:text-error hover:bg-error/10 rounded-lg cursor-pointer transition-colors inline-flex items-center justify-center`,title:`Delete selected`,children:(0,b.jsx)(Oo,{className:`w-3 h-3`})}),L&&(0,b.jsx)(`span`,{className:`hidden lg:inline text-xs text-secondary ml-0.5 mr-1`,children:I})]}),(0,b.jsx)(`div`,{className:`hidden lg:block w-px h-5 bg-divider mx-1`}),i?.map((e,t)=>(0,b.jsx)(`span`,{children:e},t)),ae&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:()=>ne(!0),className:W,title:`Configure`,children:(0,b.jsx)(Ai,{className:`w-4 h-4`})}),(0,b.jsx)(ru,{isOpen:k,onClose:()=>ne(!1),version:t})]}),(0,b.jsx)(`button`,{onClick:r,className:W,title:`View logs`,children:(0,b.jsx)(Yi,{className:`w-4 h-4`})}),(0,b.jsx)(`button`,{onClick:F,className:W,title:`Toggle dark mode`,children:ee?(0,b.jsx)(Di,{className:`w-4 h-4`}):(0,b.jsx)(Fi,{className:`w-4 h-4`})}),A===`authenticated`&&(0,b.jsx)(`button`,{onClick:M,className:W,title:`Logout`,children:(0,b.jsx)(Ji,{className:`w-4 h-4`})})]}),(0,b.jsx)(To,{show:C,onHide:()=>w(!1),torrents:T})]})},au=()=>{let e=(0,_.useContext)(v),t=ua(e=>e.torrents),n=Z(e=>e.categoryFilter),r=Z(e=>e.setCategoryFilter),i=Z(e=>e.categories),a=Z(e=>e.setCategories),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(``),u=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=!1;return e.getCategories().then(e=>{t||a(e)}).catch(()=>{}),()=>{t=!0}},[e,a]),(0,_.useEffect)(()=>{o&&u.current&&u.current.focus()},[o]);let d=(0,_.useMemo)(()=>{let e={},n=0,r=0;if(t)for(let i of t)r++,i.category?e[i.category]=(e[i.category]||0)+1:n++;return{counts:e,uncategorized:n,total:r}},[t]),f=(0,_.useMemo)(()=>{let e=new Set;for(let t of Object.keys(i))e.add(t);for(let t of Object.keys(d.counts))e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[i,d.counts]),p=async()=>{let t=c.trim();if(!t){s(!1);return}try{await e.createCategory(t),a(await e.getCategories())}catch{}l(``),s(!1)},m=`bg-primary/10 text-primary font-medium`,h=`text-secondary hover:bg-surface-sunken hover:text-primary`,g=`w-3.5 h-3.5 shrink-0`;return(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`px-3 pt-3 pb-1 flex items-center justify-between`,children:[(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Categories`}),(0,b.jsx)(`button`,{onClick:()=>s(!0),className:`text-tertiary hover:text-primary cursor-pointer`,title:`New category`,children:(0,b.jsx)(Mi,{className:`w-4 h-4`})})]}),(0,b.jsxs)(`div`,{className:`px-1.5`,children:[o&&(0,b.jsx)(`div`,{className:`px-2.5 py-1`,children:(0,b.jsx)(`input`,{ref:u,type:`text`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&p(),e.key===`Escape`&&(l(``),s(!1))},onBlur:p,placeholder:`Category name...`,className:`w-full px-2 py-1 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary placeholder:text-tertiary`})}),(0,b.jsxs)(`button`,{onClick:()=>r(null),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===null?m:h}`,children:[(0,b.jsx)(Ti,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:`All`}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===null?`text-primary`:`text-tertiary`}`,children:d.total})]}),(0,b.jsxs)(`button`,{onClick:()=>r(``),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===``?m:h}`,children:[(0,b.jsx)(Ti,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:`Uncategorized`}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===``?`text-primary`:`text-tertiary`}`,children:d.uncategorized})]}),f.map(e=>(0,b.jsxs)(`button`,{onClick:()=>r(e),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${n===e?m:h}`,children:[(0,b.jsx)(Ei,{className:g}),(0,b.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${n===e?`text-primary`:`text-tertiary`}`,children:d.counts[e]??0})]},e))]})]})},ou=()=>{let e=ua(e=>e.torrents),t=Z(e=>e.trackerFilter),n=Z(e=>e.setTrackerFilter),r=(0,_.useMemo)(()=>{let t={},n=0,r=0;if(e)for(let i of e){r++;let e=hs(i);e.length===0&&n++;for(let n of e)t[n]=(t[n]||0)+1}return{counts:t,trackerless:n,total:r}},[e]),i=(0,_.useMemo)(()=>Object.keys(r.counts).sort((e,t)=>e.localeCompare(t)),[r.counts]),a=`w-3.5 h-3.5 shrink-0`,o=(e,r,i,a)=>(0,b.jsxs)(`button`,{onClick:()=>n(e),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${t===e?`bg-primary/10 text-primary font-medium`:`text-secondary hover:bg-surface-sunken hover:text-primary`}`,children:[a,(0,b.jsx)(`span`,{className:`flex-1 text-left truncate`,title:r,children:r}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${t===e?`text-primary`:`text-tertiary`}`,children:i})]},e??`__all__`);return i.length===0&&r.trackerless===0?null:(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`px-3 pt-3 pb-1`,children:(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Trackers`})}),(0,b.jsxs)(`div`,{className:`px-1.5 pb-2`,children:[o(null,`All`,r.total,(0,b.jsx)(Ki,{className:a})),r.trackerless>0&&o(``,`Trackerless`,r.trackerless,(0,b.jsx)(Ki,{className:a})),i.map(e=>o(e,e,r.counts[e],(0,b.jsx)(qi,{className:a})))]})]})},su=()=>{let e=ua(e=>e.torrents),t=Z(e=>e.statusFilter),n=Z(e=>e.setStatusFilter),r=Z(e=>e.setCurrentPage),i=Z(e=>e.sidebarCollapsed),a=Z(e=>e.toggleSidebar),o=e=>{n(e),r(`torrents`)},s=(0,_.useMemo)(()=>e?{all:e.length,downloading:e.filter(e=>e.stats?.state===`live`&&!e.stats?.finished).length,seeding:e.filter(e=>e.stats?.state===`live`&&e.stats?.finished).length,paused:e.filter(e=>e.stats?.state===`paused`).length,queued:e.filter(e=>e.stats?.queue_state===`Queued`).length,initializing:e.filter(e=>e.stats?.state===`initializing`).length,error:e.filter(e=>e.stats?.state===`error`).length}:{all:0,downloading:0,seeding:0,paused:0,queued:0,initializing:0,error:0},[e]),c=`w-3.5 h-3.5 shrink-0`,l=[{key:`all`,label:`All`,icon:(0,b.jsx)(Bi,{className:c}),count:s.all},{key:`downloading`,label:`Downloading`,icon:(0,b.jsx)(Lo,{className:c}),count:s.downloading},{key:`seeding`,label:`Seeding`,icon:(0,b.jsx)(Do,{className:c}),count:s.seeding},{key:`paused`,label:`Paused`,icon:(0,b.jsx)(Fo,{className:c}),count:s.paused},{key:`queued`,label:`Queued`,icon:(0,b.jsx)(ns,{className:c}),count:s.queued},{key:`error`,label:`Error`,icon:(0,b.jsx)(Io,{className:c}),count:s.error}],u=`bg-primary/10 text-primary font-medium`,d=`text-secondary hover:bg-surface-sunken hover:text-primary`;return i?(0,b.jsxs)(`div`,{className:`w-12 bg-surface border-r border-divider flex flex-col shrink-0`,children:[(0,b.jsx)(`div`,{className:`flex-1 pt-2`,children:l.map(e=>(0,b.jsx)(`button`,{onClick:()=>o(e.key),title:`${e.label} (${e.count})`,className:`w-full flex items-center justify-center py-2.5 cursor-pointer transition-colors ${t===e.key?u:d}`,children:e.icon},e.key))}),(0,b.jsx)(`button`,{onClick:a,className:`p-2 text-tertiary hover:text-secondary cursor-pointer border-t border-divider flex items-center justify-center`,title:`Expand sidebar`,children:(0,b.jsx)(Hi,{className:`w-3.5 h-3.5`})})]}):(0,b.jsxs)(`div`,{className:`w-48 bg-surface border-r border-divider flex flex-col shrink-0`,children:[(0,b.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,b.jsx)(`div`,{className:`px-3 pt-3 pb-1`,children:(0,b.jsx)(`h3`,{className:`text-xs font-semibold text-tertiary uppercase tracking-wider`,children:`Status`})}),(0,b.jsx)(`div`,{className:`px-1.5`,children:l.map(e=>(0,b.jsxs)(`button`,{onClick:()=>o(e.key),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded text-sm cursor-pointer transition-colors ${t===e.key?u:d}`,children:[e.icon,(0,b.jsx)(`span`,{className:`flex-1 text-left`,children:e.label}),(0,b.jsx)(`span`,{className:`text-xs tabular-nums ${t===e.key?`text-primary`:`text-tertiary`}`,children:e.count})]},e.key))}),(0,b.jsx)(au,{}),(0,b.jsx)(ou,{})]}),(0,b.jsxs)(`button`,{onClick:a,className:`p-2 text-tertiary hover:text-secondary cursor-pointer border-t border-divider flex items-center justify-center gap-1 text-xs`,title:`Collapse sidebar`,children:[(0,b.jsx)(Ui,{className:`w-3 h-3`}),(0,b.jsx)(`span`,{children:`Collapse`})]})]})},cu=()=>{let e=Ko(e=>e.alert),t=Ko(e=>e.removeAlert);return e?(0,b.jsxs)(So,{isOpen:!0,onClose:t,title:e.text,children:[(0,b.jsxs)(Co,{children:[e.details?.statusText&&(0,b.jsx)(`div`,{className:`pb-2 text-md`,children:e.details?.statusText}),(0,b.jsx)(`div`,{className:`whitespace-pre-wrap`,children:e.details?.text})]}),(0,b.jsx)(wo,{children:(0,b.jsx)(pa,{variant:`cancel`,onClick:t,children:`Close`})})]}):(0,b.jsx)(b.Fragment,{})},lu=({className:e})=>(0,b.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,className:e,children:(0,b.jsx)(`path`,{d:`M8.5 7.5C9.6 6.1 11.5 5 13.5 5c3.6 0 6.5 2.9 6.5 6.5 0 .5-.1 1-.2 1.5H21c.6 0 1 .4 1 1s-.4 1-1 1h-1.9c-.8 1.2-2 2.1-3.4 2.6l.6 1.2c.2.5 0 1.1-.5 1.3-.5.2-1.1 0-1.3-.5l-.7-1.4c-.1 0-.2 0-.3 0h-3l-.7 1.4c-.2.5-.8.7-1.3.5-.5-.2-.7-.8-.5-1.3l.5-1.1c-.9-.4-1.7-.9-2.3-1.6l-1.4.9c-.5.3-1.1.2-1.4-.3-.3-.5-.2-1.1.3-1.4l1.5-1c-.1-.4-.2-.9-.2-1.3H3c-.6 0-1-.4-1-1s.4-1 1-1h2.1c.2-.9.6-1.7 1.1-2.4l-.9-.9c-.4-.4-.4-1 0-1.4.4-.4 1-.4 1.4 0l.9.9c.3-.2.6-.4.9-.6zm5 .5c-2.5 0-4.5 2-4.5 4.5S11 17 13.5 17s4.5-2 4.5-4.5S16 8 13.5 8z`})}),uu=({children:e,title:t})=>(0,b.jsx)(`div`,{className:`flex items-center gap-1.5 px-2 py-1 whitespace-nowrap`,title:t,children:e}),du=()=>{let e=(0,_.useContext)(v),t=Ll(e=>e.stats),[n,r]=(0,_.useState)(!1),[i,a]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{let t=!1,n=()=>e.getAltSpeed().then(e=>{t||(r(!0),a(e.enabled))}).catch(()=>{t||r(!1)});n();let i=setInterval(n,1e4);return()=>{t=!0,clearInterval(i)}},[e]),(0,b.jsxs)(`div`,{className:`bg-surface-raised border-t border-divider text-sm text-secondary flex items-center flex-wrap gap-x-1 lg:gap-x-3 px-1`,children:[n&&(0,b.jsx)(`button`,{onClick:async()=>{let t=!i;a(t);try{await e.toggleAltSpeed(t)}catch{a(!t)}},className:`p-1 rounded cursor-pointer transition-colors ${i?`text-primary bg-primary/15`:`text-tertiary hover:text-secondary hover:bg-surface-sunken`}`,title:i?`Alternative speed limits are ON — click to disable`:`Alternative speed limits are OFF — click to enable`,children:(0,b.jsx)(lu,{className:`w-4 h-4`})}),(0,b.jsxs)(`div`,{className:`flex-1 flex items-center justify-evenly flex-wrap gap-x-1 lg:gap-x-5`,children:[(0,b.jsxs)(uu,{title:`Download speed (session total)`,children:[(0,b.jsx)(Uo,{className:`w-3 h-3 text-accent-download`}),(0,b.jsx)(`span`,{className:`text-accent-download font-medium tabular-nums`,children:t.download_speed.human_readable}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[`(`,Xo(t.counters.fetched_bytes),`)`]})]}),(0,b.jsxs)(uu,{title:`Upload speed (session total)`,children:[(0,b.jsx)(Vo,{className:`w-3 h-3 text-accent-upload`}),(0,b.jsx)(`span`,{className:`text-accent-upload font-medium tabular-nums`,children:t.upload_speed.human_readable}),(0,b.jsxs)(`span`,{className:`text-tertiary`,children:[`(`,Xo(t.counters.uploaded_bytes),`)`]})]}),(0,b.jsxs)(uu,{title:`Connected peers`,children:[(0,b.jsx)(Ni,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`span`,{className:`tabular-nums`,children:t.peers.live})]}),(0,b.jsxs)(uu,{title:`Session uptime`,children:[(0,b.jsx)(Vi,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`span`,{className:`tabular-nums`,children:Qo(t.uptime_seconds)})]}),(0,b.jsxs)(uu,{children:[(0,b.jsx)(ki,{className:`w-3.5 h-3.5 text-tertiary`}),(0,b.jsx)(`a`,{href:`/swagger/`,target:`_blank`,className:`text-primary hover:underline`,children:`API`})]})]})]})},fu=({files:e,onHide:t})=>{let n=(0,_.useContext)(v),r=ua(e=>e.refreshTorrents),i=Z(e=>e.categories),a=Z(e=>e.setCategories),[o,s]=(0,_.useState)(``),[c,l]=(0,_.useState)(``),[u,d]=(0,_.useState)(!0),[f,p]=(0,_.useState)(e.map(e=>({file:e,status:`pending`}))),[m,h]=(0,_.useState)(!1),[g,y]=(0,_.useState)(!1);(0,_.useEffect)(()=>{n.getCategories().then(e=>a(e)).catch(()=>{})},[n,a]);let x=Object.keys(i).sort((e,t)=>e.localeCompare(t)),S=async()=>{h(!0);let e=[...f];for(let t=0;t{switch(e){case`uploading`:return(0,b.jsx)(xi,{className:`w-4 h-4 inline-block`});case`success`:return(0,b.jsx)(Gi,{className:`text-green-500 inline-block`});case`error`:return(0,b.jsx)(Ci,{className:`text-red-500 inline-block`});default:return(0,b.jsx)(`span`,{className:`text-secondary`,children:`--`})}};return(0,b.jsxs)(So,{isOpen:!0,onClose:t,title:`Upload Multiple Torrents`,children:[(0,b.jsxs)(Co,{children:[(0,b.jsxs)(al,{children:[(0,b.jsx)(il,{label:`Output folder`,name:`multi_output_folder`,inputType:`text`,placeholder:`Server default`,value:o,onChange:e=>s(e.target.value)}),x.length>0&&(0,b.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,b.jsx)(`label`,{htmlFor:`multi_category`,className:`text-sm font-medium text-secondary`,children:`Category`}),(0,b.jsxs)(`select`,{id:`multi_category`,value:c,onChange:e=>l(e.target.value),className:`px-2 py-1.5 text-sm bg-surface border border-divider rounded focus:outline-none focus:border-primary`,children:[(0,b.jsx)(`option`,{value:``,children:`None`}),x.map(e=>(0,b.jsx)(`option`,{value:e,children:e},e))]})]}),(0,b.jsx)(ks,{label:`Start torrents after adding`,checked:u,onChange:()=>d(!u),name:`start_torrent`})]}),(0,b.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-divider rounded`,children:f.map((e,t)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-divider last:border-b-0`,children:[(0,b.jsx)(`span`,{className:`w-5 flex-shrink-0`,children:C(e.status)}),(0,b.jsx)(`span`,{className:`truncate min-w-0 flex-1`,children:e.file.name}),e.error&&(0,b.jsx)(`span`,{className:`text-red-500 text-xs truncate max-w-[200px]`,children:e.error})]},t))})]}),(0,b.jsxs)(wo,{children:[m&&(0,b.jsx)(xi,{}),(0,b.jsx)(pa,{onClick:t,variant:`cancel`,children:g?`Close`:`Cancel`}),!g&&(0,b.jsxs)(pa,{onClick:S,variant:`primary`,disabled:m,children:[`Upload All (`,f.length,`)`]})]})]})},pu=e=>{let[t,n]=(0,_.useState)(!1),r=Ko(e=>e.setOtherError),i=(0,_.useContext)(v),a=xc(),o=Z(e=>e.sidebarOpen),s=Z(e=>e.setSidebarOpen),c=Z(e=>e.currentPage),l=ua(e=>e.setTorrents),u=ua(e=>e.setTorrentsLoading),d=ua(e=>e.setRefreshTorrents),f=async()=>{u(!0);try{let e=await i.listTorrents({withStats:!0});return l(e.torrents),r(null),e.torrents.some(e=>e.stats?.state===`live`||e.stats?.state===`initializing`)?1e3:5e3}catch(e){return r({text:`Error refreshing torrents`,details:e}),console.error(e),5e3}finally{u(!1)}},p=Ll(e=>e.setStats);(0,_.useEffect)(()=>{d(f)},[]),(0,_.useEffect)(()=>Cs(async()=>f(),0),[]),(0,_.useEffect)(()=>Cs(async()=>i.stats().then(e=>(p(e),1e3),e=>(console.error(e),5e3)),0),[]);let[m,h]=(0,_.useState)(!1),g=(0,_.useRef)(0),[y,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(null),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null);(0,_.useEffect)(()=>{if(y?.type!==`single`)return;let e=y.file;T(!0),C(null),D(null);let t=!1,n=setTimeout(async()=>{try{let n=await i.uploadTorrent(e,{list_only:!0});t||C(n)}catch(e){t||D({text:`Error listing torrent files`,details:e})}finally{t||T(!1)}},0);return()=>{t=!0,clearTimeout(n)}},[y]);let O=()=>{x(null),C(null),D(null),T(!1)},ee=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current++,g.current===1&&h(!0)},[]),te=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current--,g.current===0&&h(!1)},[]),k=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),ne=(0,_.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),g.current=0,h(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.name.endsWith(`.torrent`));t.length!==0&&(t.length===1?x({type:`single`,file:t[0]}):x({type:`multi`,files:t}))},[]),A=(0,_.useCallback)(e=>{e.length===1?x({type:`single`,file:e[0]}):e.length>1&&x({type:`multi`,files:e})},[]);return(0,b.jsxs)(`div`,{className:`bg-surface h-dvh flex flex-col overflow-hidden`,children:[(0,b.jsx)(iu,{title:e.title,version:e.version,onMultiFileSelect:A,onLogsClick:()=>n(!0),menuButtons:e.menuButtons}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-row`,children:[a&&c===`torrents`&&(0,b.jsx)(su,{}),(0,b.jsxs)(`div`,{className:`flex-1 min-h-0 relative`,onDragEnter:ee,onDragLeave:te,onDragOver:k,onDrop:ne,children:[(0,b.jsx)(bl,{}),m&&(0,b.jsx)(`div`,{className:`absolute inset-0 z-50 flex items-center justify-center bg-surface/90`,children:(0,b.jsx)(`div`,{className:`border-2 border-dashed border-primary rounded-lg p-8 text-center`,children:(0,b.jsx)(`p`,{className:`text-lg font-semibold text-primary`,children:`Drop .torrent files here`})})})]})]}),!a&&o&&(0,b.jsxs)(`div`,{className:`fixed inset-0 z-40`,children:[(0,b.jsx)(`div`,{className:`absolute inset-0 bg-black/50`,onClick:()=>s(!1)}),(0,b.jsx)(`div`,{className:`absolute left-0 top-0 bottom-0 w-64 bg-surface shadow-xl`,children:(0,b.jsx)(su,{})})]}),(0,b.jsx)(du,{}),(0,b.jsx)(xl,{show:t,onClose:()=>n(!1)}),(0,b.jsx)(cu,{}),y?.type===`single`&&(0,b.jsx)(ol,{onHide:O,listTorrentResponse:S,listTorrentError:E,listTorrentLoading:w,data:y.file}),y?.type===`multi`&&(0,b.jsx)(fu,{files:y.files,onHide:()=>x(null)})]})},mu=`NebulaOS-26.07-desktop-x86_64.iso,CopperFinch-Linux-12.4-live-amd64.iso,Atlas.Public.Dataset.2026.07.parquet.zst,Moonbase.Manuals.Collection.v4.2.epub.zip,Open.Orchestra.Sessions.Vol.08.FLAC,Glass.River.2026.Short.Film.1080p.WEB.x264-DEMO,Cinder.Workstation-9.1-arm64.img.xz,Northstar.Game.Assets.CreativeCommons.v3.tar.zst,Pocket.Planetarium.Catalog.2026-07.sqlite.zst,Paper.Kites.Public.Domain.Collection.4K-DEMO,Field.Notes.Quarterly.Issue.42.pdf.zip,LighthouseOS-5.8-server-amd64.iso,Mosaic.Fonts.Open.Collection.2026.1.tar.gz,Signal.Garden.S01E04.1080p.WEB.x265-DEMO,Blue.Hour.Live.Session.2026.FLAC-DEMO,JuniperBSD-14.2-install-amd64.iso,Rookery.Container.Images.airgap-bundle-v7.tar,Cloud.Atlas.Weather.Archive.2026-06.nc.zst,Tiny.Museums.Photo.Archive.Vol.12.zip,Amber.Terminal-3.6.2-source-and-docs.tar.gz,Fable.Engine.Sample.Projects.v2.8.zip,Harbor.Light.2025.Open.Movie.2160p-DEMO,OrchardOS-rolling-2026.07-kde-x86_64.iso,Transit.Map.OpenData.Global.2026Q2.pbf,Night.Train.Radio.Archive.Episodes.101-125.opus,Stonecrop.Rescue.Environment.v5.1.iso,Wildflower.Macro.Photos.CC0.Collection.03.zip,CometDB-8.0.1-offline-documentation.tar.gz,Riverside.Ambience.24bit.96kHz.FLAC-DEMO,SundialOS-2.0-raspberrypi-arm64.img.xz,Workshop.CAD.Models.Open-Pack.2026-07.zip,Morning.Fog.2024.Short.Film.1080p-DEMO,Redwood.Security.Lab.v11.qcow2,Open.Cookbook.Archive.2026.07.epub,Aurora.Language.Corpus.v6.jsonl.zst,Telescope.Raw.Sample.Data.M31.2026.fits.tar`.split(`,`),hu=[`.iso`,`.img`,`.tar.gz`,`.zip`,`.qcow2`],gu=[`udp://tracker.demo-open.example:6969/announce`,`https://announce.publicbits.example:443/announce`,`udp://tr.linuxmirror.example:2710/announce`,`https://tracker.datasets.example/announce`,`udp://open.seedhub.example:6969/announce`];function _u(e){let t=yu(e*6659),n=1+Math.floor(t()*3),r=new Set;for(let e=0;e(e=e*1103515245+12345&2147483647,e/2147483647)}function bu(e){let t=yu(e*31337),n=``;for(let e=0;e<40;e++)n+=`0123456789abcdef`[Math.floor(t()*16)];return n}function xu(e){return mu[e%mu.length]}var Su=8;function Cu(e){if(e.1,attributes:{symlink:!1,hidden:!1,padding:!1,executable:!1}})}return a}function Ou(e,t,n){let r=yu(e*8737+Date.now()%1e4),i=n-t,a=Math.random()*50,o=Math.random()*10,s=a*1024*1024/8,c=s>0?i/s:null;return{snapshot:{have_bytes:t,downloaded_and_checked_bytes:t,downloaded_and_checked_pieces:Math.floor(t/n*1e3),fetched_bytes:t,uploaded_bytes:Math.floor(r()*t*.5),initially_needed_bytes:n,remaining_bytes:i,total_bytes:n,total_piece_download_ms:Math.floor(r()*1e5),peer_stats:{queued:Math.floor(r()*50),connecting:Math.floor(r()*10),live:Math.floor(r()*30)+1,seen:Math.floor(r()*200),dead:Math.floor(r()*100),not_needed:Math.floor(r()*20)}},average_piece_download_time:{secs:Math.floor(r()*2),nanos:Math.floor(r()*1e9)},download_speed:{mbps:a,human_readable:`${a.toFixed(1)} MB/s`},upload_speed:{mbps:o,human_readable:`${o.toFixed(1)} MB/s`},all_time_download_speed:{mbps:a*.8,human_readable:`${(a*.8).toFixed(1)} MB/s`},time_remaining:c===null?null:{human_readable:c<60?`${Math.floor(c)}s`:c<3600?`${Math.floor(c/60)}m`:`${Math.floor(c/3600)}h ${Math.floor(c%3600/60)}m`,duration:{secs:Math.floor(c)}}}}function ku(e){let t=ju.get(e)??Cu(e),n=wu(e),r=Eu(e,n,t),i=r>=n,a=yu(e*5501),o=Math.floor(a()*5)+1,s=Array(o).fill(0).map(()=>i?1:a()*(r/n));return{state:i&&t===`live`?`live`:t,error:t===`error`?`Connection timed out`:null,file_progress:s,progress_bytes:r,finished:i,total_bytes:n,live:t===`live`?Ou(e,r,n):null}}function Au(e,t){let n=wu(e),r=Math.ceil(n/(256*1024)),i={id:e,info_hash:bu(e),name:xu(e),output_folder:`/downloads/torrent_${e}`,total_pieces:r,added_on:vu(e),trackers:_u(e)},a=Vu.get(e);return a&&(i.category=a),t&&(i.stats=ku(e)),i}var ju=new Map,Mu=new Set,Nu={enabled:!1,config:{download_rate:2*1024*1024,upload_rate:512*1024},schedule:{enabled:!1,start_minutes:1320,end_minutes:360,days:127}},Pu=new Map,Fu=new Map;function Iu(e){let t=Pu.get(e);if(!t){let n=yu(e*9371),r=Math.floor(n()*15)+5;t=[];for(let e=0;e.3?`tcp`:`utp`,fetchedBytes:Math.floor(n()*1e7),uploadedBytes:Math.floor(n()*5e6),fetchRate:Math.floor(n()*2e6)+1e5,uploadRate:Math.floor(n()*5e5)+5e4});Pu.set(e,t),Fu.set(e,Date.now())}return t}function Lu(e){let t=Pu.get(e),n=Fu.get(e);if(!t||!n)return;let r=Date.now(),i=(r-n)/1e3;if(Fu.set(e,r),(ju.get(e)??Cu(e))===`live`)for(let e of t){let t=.5+Math.random(),n=.5+Math.random();e.fetchedBytes+=Math.floor(e.fetchRate*i*t),e.uploadedBytes+=Math.floor(e.uploadRate*i*n)}}var Ru=mu.length,zu=[`Linux ISOs`,`Software`,`Documents`,`Media`],Bu={"Linux ISOs":{name:`Linux ISOs`,save_path:`/downloads/linux`},Software:{name:`Software`,save_path:`/downloads/software`},Documents:{name:`Documents`,save_path:`/downloads/docs`},Media:{name:`Media`,save_path:`/downloads/media`}},Vu=new Map;for(let e=0;enew Date(Hu-e*36e5).toISOString(),Wu=[{name:`Open Media Weekly`,url:`https://feeds.example.invalid/open-media.xml`,poll_interval_secs:900,category:`Media`,enabled:!0,auto_download:!1},{name:`Demo Software Releases`,url:`https://feeds.example.invalid/software.xml`,poll_interval_secs:1800,category:`Software`,filter_regex:`(stable|release)`,enabled:!0,auto_download:!0},{name:`Public Data Dispatch`,url:`https://feeds.example.invalid/data.xml`,poll_interval_secs:3600,category:`Documents`,enabled:!0,auto_download:!1}],Gu=[[`rss-01`,`Open Media Weekly`,`Glass River (2026) — Open Short Film 1080p`,24e8,2,!0],[`rss-02`,`Demo Software Releases`,`Amber Terminal 3.6.2 stable source bundle`,184e6,5,!0],[`rss-03`,`Public Data Dispatch`,`Atlas public dataset — July 2026 snapshot`,87e8,9,!0],[`rss-04`,`Open Media Weekly`,`Blue Hour — live session in lossless audio`,11e8,15,!1],[`rss-05`,`Demo Software Releases`,`CometDB 8.0.1 offline documentation`,426e6,21,!0],[`rss-06`,`Open Media Weekly`,`Harbor Light (2025) — open movie 2160p`,68e8,28,!1],[`rss-07`,`Public Data Dispatch`,`Transit map OpenData — 2026 Q2 export`,43e8,37,!0],[`rss-08`,`Demo Software Releases`,`Fable Engine sample projects v2.8 release`,97e7,49,!1],[`rss-09`,`Open Media Weekly`,`Riverside Ambience — 24-bit field recording`,32e8,63,!0],[`rss-10`,`Public Data Dispatch`,`Pocket Planetarium catalog — July update`,74e7,76,!1]].map(([e,t,n,r,i,a])=>({id:e,feed_name:t,title:n,url:`magnet:?xt=urn:btih:${bu(Number(e.slice(-2)))}`,published_at:Uu(i),first_seen_at:Uu(i-.25),downloaded:a,downloaded_at:a?Uu(i-.5):null,category:Wu.find(e=>e.name===t)?.category,size_bytes:r})),Ku=[{id:`rule-1`,name:`Stable software`,feed_names:[`Demo Software Releases`],category:`Software`,priority:10,match_regex:`(?i)(stable|release)`,enabled:!0},{id:`rule-2`,name:`Open films`,feed_names:[`Open Media Weekly`],category:`Media`,priority:20,match_regex:`(?i)(open movie|short film)`,enabled:!0}],qu={getFeeds:async()=>[...Wu],addFeed:async e=>{Wu=[...Wu,e]},updateFeed:async(e,t)=>{Wu=Wu.map(n=>n.name===e?t:n)},deleteFeed:async e=>{Wu=Wu.filter(t=>t.name!==e)},getItems:async e=>Gu.filter(t=>!e||t.feed_name===e),downloadItem:async e=>{Gu=Gu.map(t=>t.id===e?{...t,downloaded:!0,downloaded_at:new Date().toISOString()}:t)},getRules:async()=>[...Ku],addRule:async e=>{Ku=[...Ku,{...e,id:`rule-${Ku.length+1}`}]},updateRule:async(e,t)=>{Ku=Ku.map(n=>n.id===e?{...t,id:e}:n)},deleteRule:async e=>{Ku=Ku.filter(t=>t.id!==e)},getSettings:async()=>({rss_history_limit:500})},Ju={getStreamLogsUrl:()=>null,listTorrents:async e=>{await new Promise(e=>setTimeout(e,50+Math.random()*100));let t=[];for(let n=0;n{if(await new Promise(e=>setTimeout(e,20+Math.random()*50)),Mu.has(e))throw{text:`Torrent not found`,status:404};let t=wu(e);return{name:xu(e),info_hash:bu(e),files:Du(e,t),total_pieces:Math.ceil(t/(256*1024)),output_folder:`/downloads/torrent_${e}`}},getTrackerStatus:async e=>{if(await new Promise(e=>setTimeout(e,20+Math.random()*40)),Mu.has(e))throw{text:`Torrent not found`,status:404};let t=ju.get(e)??Cu(e),n=_u(e),r=yu(e*8447);return{trackers:n.map((e,n)=>{let i=r()<.15;return t===`live`?i?{url:e,state:`error`,seeders:null,leechers:null,peers_returned:null,last_announce_unix:null,interval_secs:null,last_error:`tracker responded with 502 Bad Gateway`}:{url:e,state:`working`,seeders:Math.floor(r()*500)+5,leechers:Math.floor(r()*200),peers_returned:Math.floor(r()*50)+1,last_announce_unix:Math.floor(Date.now()/1e3)-Math.floor(r()*600)-n*30,interval_secs:1800,last_error:null}:{url:e,state:`not_contacted`,seeders:null,leechers:null,peers_returned:null,last_announce_unix:null,interval_secs:null,last_error:null}})}},getTorrentStats:async e=>{if(await new Promise(e=>setTimeout(e,10+Math.random()*30)),Mu.has(e))throw{text:`Torrent not found`,status:404};let t=ju.get(e),n=ku(e);return t&&(n.state=t,t!==`live`&&(n.live=null)),n},getPeerStats:async e=>{await new Promise(e=>setTimeout(e,20));let t=Iu(e);Lu(e);let n={},r=yu(e*4421);for(let e of t)n[`${e.ip}:${e.port}`]={counters:{incoming_connections:Math.floor(r()*10),fetched_bytes:e.fetchedBytes,uploaded_bytes:e.uploadedBytes,total_time_connecting_ms:Math.floor(r()*1e4)+1e3,connection_attempts:Math.floor(r()*3)+1,connections:1,errors:Math.floor(r()*2),fetched_chunks:Math.floor(e.fetchedBytes/16384),downloaded_and_checked_pieces:Math.floor(e.fetchedBytes/262144),total_piece_download_ms:Math.floor(r()*5e4)+5e3,times_stolen_from_me:0,times_i_stole:0},state:`live`,conn_kind:e.connKind};return{peers:n}},stats:async()=>{await new Promise(e=>setTimeout(e,30));let e=Math.random()*100,t=Math.random()*30;return{counters:{fetched_bytes:Math.floor(Math.random()*1e11),uploaded_bytes:Math.floor(Math.random()*5e10),blocked_incoming:Math.floor(Math.random()*100),blocked_outgoing:Math.floor(Math.random()*50)},peers:{queued:Math.floor(Math.random()*500),connecting:Math.floor(Math.random()*100),live:Math.floor(Math.random()*300)+50,seen:Math.floor(Math.random()*2e3),dead:Math.floor(Math.random()*500),not_needed:Math.floor(Math.random()*200)},connections:{tcp:{v4:{attempts:1e3,successes:800,errors:200},v6:{attempts:200,successes:150,errors:50}},utp:{v4:{attempts:500,successes:300,errors:200},v6:{attempts:100,successes:60,errors:40}},socks:{v4:{attempts:0,successes:0,errors:0},v6:{attempts:0,successes:0,errors:0}}},download_speed:{mbps:e,human_readable:`${e.toFixed(1)} MB/s`},upload_speed:{mbps:t,human_readable:`${t.toFixed(1)} MB/s`},uptime_seconds:Math.floor(Date.now()/1e3)%86400}},uploadTorrent:async()=>{throw{text:`Upload not supported in mock mode`,status:501}},updateOnlyFiles:async()=>{await new Promise(e=>setTimeout(e,100))},pause:async e=>{await new Promise(e=>setTimeout(e,50)),ju.set(e,`paused`)},start:async e=>{await new Promise(e=>setTimeout(e,50)),ju.set(e,`live`)},forget:async e=>{await new Promise(e=>setTimeout(e,50)),Mu.add(e)},delete:async e=>{await new Promise(e=>setTimeout(e,100)),Mu.add(e)},getVersion:async()=>`mock-1.0.0`,getTorrentStreamUrl:()=>null,getPlaylistUrl:()=>null,getTorrentHaves:async e=>{let t=wu(e),n=Math.ceil(t/(256*1024)),r=Math.ceil(n/8),i=new Uint8Array(r),a=yu(e*6173),o=Eu(e,t,Cu(e))/t;for(let e=0;e({upload_bps:null,download_bps:null}),setLimits:async()=>{await new Promise(e=>setTimeout(e,50))},getDhtStats:async()=>({id:`mock-dht-node-id-abc123def456`,outstanding_requests:5,seen_peers:1234,have_peers:567,inflight_peers:12}),setRustLog:async()=>{await new Promise(e=>setTimeout(e,100))},getMetadata:async()=>new TextEncoder().encode(`d8:announce35:udp://tracker.example.com:6969/announce13:announce-listll35:udp://tracker.example.com:6969/announceel38:https://tracker2.example.org:443/announceee4:infod6:lengthi1024ee8:url-list0:e`),getCategories:async()=>(await new Promise(e=>setTimeout(e,30)),{...Bu}),createCategory:async(e,t)=>{await new Promise(e=>setTimeout(e,50)),Bu[e]={name:e,save_path:t}},deleteCategory:async e=>{await new Promise(e=>setTimeout(e,50)),delete Bu[e];for(let[t,n]of Vu.entries())n===e&&Vu.delete(t)},setTorrentCategory:async(e,t)=>{await new Promise(e=>setTimeout(e,50)),t?Vu.set(e,t):Vu.delete(e)},getAltSpeed:async()=>({enabled:Nu.enabled,config:{...Nu.config},schedule:{...Nu.schedule}}),toggleAltSpeed:async e=>{await new Promise(e=>setTimeout(e,30)),Nu.enabled=e},setAltSpeedConfig:async e=>{Nu.config={...e}},getSpeedSchedule:async()=>({...Nu.schedule}),setSpeedSchedule:async e=>{Nu.schedule={...e}},getSeedLimits:async()=>({ratio_limit:null,time_limit_secs:null}),setSeedLimits:async e=>{},setTorrentSeedLimits:async(e,t)=>{},getTorrentLimits:async e=>({}),setTorrentLimits:async(e,t)=>{},setSequential:async(e,t)=>{},setSuperSeed:async(e,t)=>{},queueMoveTop:async e=>{},queueMoveBottom:async e=>{},queueMoveUp:async e=>{},queueMoveDown:async e=>{},getFolders:async()=>({download_folder:`/downloads`,completed_folder:null}),setFolders:async()=>{},browseDirectory:async e=>({current:e??`/`,parent:e&&e!==`/`?e.split(`/`).slice(0,-1).join(`/`)||`/`:null,entries:[{name:`downloads`,path:(e??`/`)+`/downloads`,is_dir:!0},{name:`completed`,path:(e??`/`)+`/completed`,is_dir:!0},{name:`media`,path:(e??`/`)+`/media`,is_dir:!0}]})};Object.assign(tl,qu),g.createRoot(document.getElementById(`app`)).render((0,b.jsx)(_.StrictMode,{children:(0,b.jsx)(()=>(0,b.jsx)(v.Provider,{value:Ju,children:(0,b.jsx)(pu,{title:`RustTorrent Demo`,version:`v0.1.0-beta.2`})}),{})})); \ No newline at end of file diff --git a/website/demo/index.html b/website/demo/index.html index e73e531..b65e00b 100644 --- a/website/demo/index.html +++ b/website/demo/index.html @@ -5,7 +5,7 @@ RustTorrent Live Demo - +