diff --git a/CHANGELOG.md b/CHANGELOG.md index 1810707..debbc51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,10 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions follo ## [0.16.0] - 2026-07-16 ### Changed -- Auth default is now **loopback-open** instead of reject-all. With no `PROXY_API_KEYS`, - no `PROXY_OPEN_RELAY`, no virtual keys and no OIDC, the proxy accepts unauthenticated - requests from localhost only; LAN/remote peers still get `401`. Decision uses the real - TCP peer (`ConnectInfo`), not the spoofable `X-Forwarded-For`. Set `PROXY_API_KEYS` when - running behind a reverse proxy. `GET /admin/api/status` now reports `auth_mode` - (`keys` / `open_relay` / `loopback_only`) and `proxy_key_count`. +- Auth default is **reject-all**. With no `PROXY_API_KEYS`, no `PROXY_OPEN_RELAY`, no + virtual keys, and no OIDC, every proxy request returns `401`, including from localhost. + Set `PROXY_API_KEYS` to allow authenticated access. `GET /admin/api/status` reports `auth_mode` + (`keys` / `open_relay` / `auth_required`) and `proxy_key_count`. - Proxy start-up now pre-checks the listen port and fails fast with a hint when it is already in use; the `wait_for_port` readiness timeout rose from 10s to 30s. diff --git a/CLAUDE.md b/CLAUDE.md index 719218f..16775de 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -104,7 +104,7 @@ Five-crate Cargo workspace: `providers` (metadata catalog), `client` (Anthropic - **CSRF tokens are one-time-use.** Fetch a fresh token from `GET /admin/csrf-token` before each admin POST/PUT/DELETE. The SPA does this automatically; scripts must too. - **Admin UI defaults on for bare invocation.** Running `anyllm-proxy` with **no args** starts proxy + admin UI and auto-opens the default browser to the admin page (the zero-arg desktop default). Passing `--webui`/`--admin` (or `WEBUI=1`/`ADMIN=1` env) forces it on alongside other args but does **not** open a browser. Passing any other arg (e.g. `--env-file`, `--redact-secrets`) keeps the proxy CLI-only. `DISABLE_ADMIN=1` force-disables it in all cases. Gate + zero-arg logic live in `main_helpers/bootstrap.rs` (`admin_enabled`/`admin_requested`/`is_default_launch`); browser open in `main_helpers/browser.rs`. - **Virtual key OnceLock in tests.** `set_virtual_keys` uses a global `OnceLock`. Integration tests in `crates/proxy/tests/virtual_keys.rs` use a shared `OnceLock` to avoid conflicts. -- **Auth defaults to loopback-open.** With no `PROXY_API_KEYS`, no `PROXY_OPEN_RELAY`, no virtual keys and no OIDC, requests from a loopback TCP peer are accepted; LAN/remote peers get 401. Gate: `no_auth_configured() && peer_is_loopback()` at the top of `validate_auth` (`server/middleware/auth.rs`), using `ConnectInfo` (the proxy is now served with `into_make_service_with_connect_info`), NOT `X-Forwarded-For`. `effective_auth_mode()` (`keys`/`open_relay`/`loopback_only`) is surfaced via `GET /admin/api/status` and the admin UI banner. +- **Auth defaults to reject-all.** Without `PROXY_API_KEYS`, `PROXY_OPEN_RELAY=true`, virtual keys, or OIDC, every request gets 401, including from localhost. `effective_auth_mode()` (`keys`/`open_relay`/`auth_required`) is surfaced via `GET /admin/api/status` and the admin UI banner. - **Admin rate limiter resets on restart.** 10 RPM per source IP, in-memory sliding window. `set_admin_rpm()` overrides for tests. - **Docker admin needs `ADMIN_BIND=0.0.0.0`.** Default binds to 127.0.0.1 which is unreachable from outside the container. - **PLAN.md references in source comments are stale.** Some files reference line ranges in a removed PLAN.md. diff --git a/crates/proxy/CLAUDE.md b/crates/proxy/CLAUDE.md index 0b45bb4..c177498 100644 --- a/crates/proxy/CLAUDE.md +++ b/crates/proxy/CLAUDE.md @@ -33,7 +33,7 @@ cargo test --test live_api -- --ignored --test-threads=1 # needs real key - **Admin UI defaults on for bare invocation.** Bare `anyllm-proxy` (no args) starts proxy + admin UI and auto-opens the browser (zero-arg default). `--webui`/`--admin` or `WEBUI=1`/`ADMIN=1` force it on with other args (no browser). Any other arg keeps it CLI-only. `DISABLE_ADMIN=1` force-disables. Single gate: `main_helpers::bootstrap::admin_enabled` (used by `main.rs` and `init_admin`); browser open only on `is_default_launch` via `main_helpers::browser::open`. - **Runtime smoke-test in isolation.** Use a fresh `ANYLLM_HOME=$(mktemp -d)` + non-default `LISTEN_PORT`/`ADMIN_PORT`: the real `~/.anyllm` DB's persisted admin config overrides can hang `--webui` *before* the servers bind (stalls right after "applied config overrides from database"), and port 3000 is often held by other dev servers (giving false `200`s from something that isn't the proxy). `--redact-secrets`/`REDACT_SECRETS` also adds multi-second startup — allow more time or omit for quick checks. - **`main_helpers` (bin-only) tests can't use `ENV_TEST_LOCK`.** It's `pub(crate)` in the lib crate, unreachable from the bin crate. For bin-only code that reads env, split the pure logic (e.g. `admin_requested(args)`) from the env read (`admin_enabled`) and unit-test the pure part with no env mutation, instead of trying to serialize on the lock. -- **Auth defaults to loopback-open.** No `PROXY_API_KEYS`, no `PROXY_OPEN_RELAY`, no virtual keys, no OIDC => loopback peers accepted, LAN/remote get 401. Gate is `no_auth_configured() && peer_is_loopback()` at the top of `validate_auth` (`middleware/auth.rs`); proxy is served with `into_make_service_with_connect_info` so `ConnectInfo` is present. `effective_auth_mode()` feeds `GET /admin/api/status` (`auth_mode`) and the admin UI banner. +- **Auth defaults to reject-all.** Without `PROXY_API_KEYS`, `PROXY_OPEN_RELAY=true`, virtual keys, or OIDC, every request gets 401, including from localhost. `effective_auth_mode()` feeds `GET /admin/api/status` (`auth_mode`) and the admin UI banner. - **CSRF tokens are one-time-use.** Fetch a fresh one from `GET /admin/csrf-token` before each admin POST/PUT/DELETE. Scripts must too. - **Live admin-endpoint smoke:** run with `ADMIN_TOKEN=<32+ chars> ... --webui` (admin on :3001). GET needs `Authorization: Bearer $ADMIN_TOKEN`. POST/PUT/DELETE ALSO need CSRF: `GET /admin/csrf-token` with a cookie jar (`curl -c jar`), then resend with `-b jar` + `X-CSRF-Token: ` (header must equal the cookie). Missing/mismatched CSRF returns 403 before your handler runs. - **`main_helpers` is bin-only** (declared in `main.rs`, NOT `lib.rs`). Library code (anything reached via `crate::` at runtime, e.g. `optimizer.rs`) cannot use `crate::main_helpers::bootstrap::*` — it won't compile. The data-dir/home helpers live in `crate::config::helpers::{resolve_data_dir, home_dir}`; use those from lib code. diff --git a/crates/proxy/admin-ui/dist/index.html b/crates/proxy/admin-ui/dist/index.html index df86df9..8ee8f2e 100644 --- a/crates/proxy/admin-ui/dist/index.html +++ b/crates/proxy/admin-ui/dist/index.html @@ -14,7 +14,7 @@ Error generating stack: `+e.message+` `+e.stack}}var De=Object.prototype.hasOwnProperty,Oe=t.unstable_scheduleCallback,ke=t.unstable_cancelCallback,Ae=t.unstable_shouldYield,je=t.unstable_requestPaint,Me=t.unstable_now,Ne=t.unstable_getCurrentPriorityLevel,Pe=t.unstable_ImmediatePriority,Fe=t.unstable_UserBlockingPriority,Ie=t.unstable_NormalPriority,Le=t.unstable_LowPriority,Re=t.unstable_IdlePriority,ze=t.log,Be=t.unstable_setDisableYieldValue,Ve=null,He=null;function Ue(e){if(typeof ze==`function`&&Be(e),He&&typeof He.setStrictMode==`function`)try{He.setStrictMode(Ve,e)}catch{}}var We=Math.clz32?Math.clz32:qe,Ge=Math.log,Ke=Math.LN2;function qe(e){return e>>>=0,e===0?32:31-(Ge(e)/Ke|0)|0}var Je=256,Ye=262144,Xe=4194304;function Ze(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 Qe(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=Ze(n))):i=Ze(o):i=Ze(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ze(n))):i=Ze(o)):i=Ze(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 $e(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function et(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 tt(){var e=Xe;return Xe<<=1,!(Xe&62914560)&&(Xe=4194304),e}function nt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function rt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function it(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),gn=!1;if(hn)try{var _n={};Object.defineProperty(_n,"passive",{get:function(){gn=!0}}),window.addEventListener(`test`,_n,_n),window.removeEventListener(`test`,_n,_n)}catch{gn=!1}var vn=null,yn=null,bn=null;function xn(){if(bn)return bn;var e,t=yn,n=t.length,r,i=`value`in vn?vn.value:vn.textContent,a=i.length;for(e=0;e=Xn),$n=` `,er=!1;function tr(e,t){switch(e){case`keyup`:return Jn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function nr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var rr=!1;function ir(e,t){switch(e){case`compositionend`:return nr(t);case`keypress`:return t.which===32?(er=!0,$n):null;case`textInput`:return e=t.data,e===$n&&er?null:e;default:return null}}function ar(e,t){if(rr)return e===`compositionend`||!Yn&&tr(e,t)?(e=xn(),bn=yn=vn=null,rr=!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=Dr(n)}}function kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ar(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ht(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=Ht(e.document)}return t}function jr(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 Mr=hn&&`documentMode`in document&&11>=document.documentMode,Nr=null,Pr=null,Fr=null,Ir=!1;function Lr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ir||Nr==null||Nr!==Ht(r)||(r=Nr,`selectionStart`in r&&jr(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}),Fr&&Er(Fr,r)||(Fr=r,r=Dd(Pr,`onSelect`),0>=o,i-=o,ki=1<<32-We(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),I&&ji(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),I&&ji(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 I&&ji(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)}),I&&ji(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&&Aa(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ia(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=gi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=hi(o.type,o.key,o.props,null,e.mode,c),Ia(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=yi(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Aa(o),b(e,r,o,c)}if(oe(o))return h(e,r,o,c);if(re(o)){if(l=re(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,Fa(o),c);if(o.$$typeof===C)return b(e,r,ia(e,o),c);La(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=_i(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Pa=0;var i=b(e,t,n,r);return R=null,i}catch(t){if(t===wa||t===Ea)throw t;var a=di(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var za=Ra(!0),Ba=Ra(!1),Va=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ua(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 Wa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ci(e),si(e,null,n),t}return ii(e,r,t,n),ci(e)}function Ka(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,ot(e,n)}}function qa(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 Ja=!1;function Ya(){if(Ja){var e=ha;if(e!==null)throw e}}function Xa(e,t,n,r){Ja=!1;var i=e.updateQueue;Va=!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?(J&f)===f:(r&f)===f){f!==0&&f===ma&&(Ja=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Va=!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),Kl|=o,e.lanes=o,e.memoizedState=d}}function Za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Qa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=k.T,s={};k.T=s,Is(e,!1,t,n);try{var c=i(),l=k.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fs(e,t,va(c,r),mu(e)):Fs(e,t,r,mu(e))}catch(n){Fs(e,t,{then:function(){},status:`rejected`,reason:n},mu())}finally{A.p=a,o!==null&&s.types!==null&&(o.types=s.types),k.T=o}}function Ts(){}function Es(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ds(e).queue;ws(e,a,t,se,n===null?Ts:function(){return Os(e),n(r)})}function Ds(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Os(e){var t=Ds(e);t.next===null&&(t=e.alternate.memoizedState),Fs(e,t.next.queue,{},mu())}function ks(){return L($f)}function As(){return Mo().memoizedState}function js(){return Mo().memoizedState}function Ms(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=mu();e=Wa(n);var r=Ga(t,e,n);r!==null&&(gu(r,t,n),Ka(r,t,n)),t={cache:ua()},e.payload=t;return}t=t.return}}function Ns(e,t,n){var r=mu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Rs(t,n):(n=ai(e,t,n,r),n!==null&&(gu(n,e,r),zs(n,t,r)))}function Ps(e,t,n){Fs(e,t,n,mu())}function Fs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Rs(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,Tr(s,o))return ii(e,t,i,0),K===null&&ri(),!1}catch{}if(n=ai(e,t,i,r),n!==null)return gu(n,e,r),zs(n,t,r),!0}return!1}function Is(e,t,n,r){if(r={lane:2,revertLane:fd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(t)throw Error(i(479))}else t=ai(e,n,r,2),t!==null&&gu(t,e,2)}function Ls(e){var t=e.alternate;return e===z||t!==null&&t===z}function Rs(e,t){_o=go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ot(e,n)}}var H={readContext:L,use:Fo,useCallback:So,useContext:So,useEffect:So,useImperativeHandle:So,useLayoutEffect:So,useInsertionEffect:So,useMemo:So,useReducer:So,useRef:So,useState:So,useDebugValue:So,useDeferredValue:So,useTransition:So,useSyncExternalStore:So,useId:So,useHostTransitionStatus:So,useFormState:So,useActionState:So,useOptimistic:So,useMemoCache:So,useCacheRefresh:So};H.useEffectEvent=So;var Bs={readContext:L,use:Fo,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:L,useEffect:ds,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ls(4194308,4,_s.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ls(4194308,4,e,t)},useInsertionEffect:function(e,t){ls(4,2,e,t)},useMemo:function(e,t){var n=jo();t=t===void 0?null:t;var r=e();if(vo){Ue(!0);try{e()}finally{Ue(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=jo();if(n!==void 0){var i=n(t);if(vo){Ue(!0);try{n(t)}finally{Ue(!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=Ns.bind(null,z,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ps.bind(null,z,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ys,useDeferredValue:function(e,t){return Ss(jo(),e,t)},useTransition:function(){var e=qo(!1);return e=ws.bind(null,z,e.queue,!0,!1),jo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=z,a=jo();if(I){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),K===null)throw Error(i(349));J&127||Ho(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,ds(Wo.bind(null,r,o,e),[e]),r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,o,n,t),null),n},useId:function(){var e=jo(),t=K.identifierPrefix;if(I){var n=Ai,r=ki;n=(r&~(1<<32-We(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=yo++,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[ft]=t,o[pt]=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(Fd(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&&Nc(t)}}return W(t),Pc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Nc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=me.current,Wi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ii,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ft]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Nd(e.nodeValue,n)),e||Vi(t,!0)}else e=Vd(e).createTextNode(r),e[ft]=t,t.stateNode=e}return W(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Wi(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[ft]=t}else Gi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),e=!1}else n=Ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(uo(t),t):(uo(t),null);if(t.flags&128)throw Error(i(558))}return W(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Wi(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[ft]=t}else Gi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;W(t),a=!1}else a=Ki(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(uo(t),t):(uo(t),null)}return uo(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),Ic(t,t.updateQueue),W(t),null);case 4:return _e(),e===null&&Cd(t.stateNode.containerInfo),W(t),null;case 10:return Qi(t.type),W(t),null;case 19:if(de(fo),r=t.memoizedState,r===null)return W(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Lc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=po(e),o!==null){for(t.flags|=128,Lc(r,!1),e=o.updateQueue,t.updateQueue=e,Ic(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)mi(n,e),n=n.sibling;return j(fo,fo.current&1|2),I&&ji(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Me()>nu&&(t.flags|=128,a=!0,Lc(r,!1),t.lanes=4194304)}else{if(!a)if(e=po(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ic(t,e),Lc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!I)return W(t),null}else 2*Me()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,a=!0,Lc(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?(W(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Me(),e.sibling=null,n=fo.current,j(fo,a?n&1|2:n&1),I&&ji(t,r.treeForkCount),e);case 22:case 23:return uo(t),ro(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(W(t),t.subtreeFlags&6&&(t.flags|=8192)):W(t),n=t.updateQueue,n!==null&&Ic(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&&de(ba),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Qi(la),W(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function zc(e,t){switch(Pi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Qi(la),_e(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ye(t),null;case 31:if(t.memoizedState!==null){if(uo(t),t.alternate===null)throw Error(i(340));Gi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(uo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Gi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(fo),null;case 4:return _e(),null;case 10:return Qi(t.type),null;case 22:case 23:return uo(t),ro(),e!==null&&de(ba),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Qi(la),null;case 25:return null;default:return null}}function Bc(e,t){switch(Pi(t),t.tag){case 3:Qi(la),_e();break;case 26:case 27:case 5:ye(t);break;case 4:_e();break;case 31:t.memoizedState!==null&&uo(t);break;case 13:uo(t);break;case 19:de(fo);break;case 10:Qi(t.type);break;case 22:case 23:uo(t),ro(),e!==null&&de(ba);break;case 24:Qi(la)}}function Vc(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){X(t,t.return,e)}}function Hc(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){X(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){X(t,t.return,e)}}function Uc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Qa(t,n)}catch(t){X(e,e.return,t)}}}function Wc(e,t,n){n.props=Ks(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){X(e,t,n)}}function Gc(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){X(e,t,n)}}function Kc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){X(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){X(e,t,n)}else n.current=null}function qc(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){X(e,e.return,t)}}function Jc(e,t,n){try{var r=e.stateNode;Id(r,e.type,n,t),r[pt]=t}catch(t){X(e,e.return,t)}}function Yc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Qd(e.type)||e.tag===4}function Xc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Yc(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&&Qd(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 Zc(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=on));else if(r!==4&&(r===27&&Qd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(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&&Qd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Fd(t,r,n),t[ft]=e,t[pt]=n}catch(t){X(e,e.return,t)}}var el=!1,tl=!1,nl=!1,rl=typeof WeakSet==`function`?WeakSet:Set,il=null;function al(e,t){if(e=e.containerInfo,zd=cp,e=Ar(e),jr(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=n||{start:0,end:0}}else n=null;for(Bd={focusedElem:e,selectionRange:n},cp=!1,il=t;il!==null;)if(t=il,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,il=e;else for(;il!==null;){switch(t=il,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`))),Fd(o,r,n),o[ft]=e,Tt(o),r=o;break a;case`link`:var s=Hf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Or(s,h),v=Or(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,k.T=null,n=uu,uu=null;var o=ou,s=cu;if(au=0,su=ou=null,cu=0,G&6)throw Error(i(331));var c=G;if(G|=4,Fl(o.current),Dl(o,o.current,s,n),G=c,ad(0,!1),He&&typeof He.onPostCommitFiberRoot==`function`)try{He.onPostCommitFiberRoot(Ve,o)}catch{}return!0}finally{A.p=a,k.T=r,Hu(e,t)}}function Gu(e,t,n){t=xi(n,t),t=Qs(e.stateNode,t,2),e=Ga(e,t,2),e!==null&&(rt(e,2),id(e))}function X(e,t,n){if(e.tag===3)Gu(e,e,n);else for(;t!==null;){if(t.tag===3){Gu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=xi(n,e),n=$s(2),r=Ga(t,n,2),r!==null&&(ec(n,r,t,e),rt(r,2),id(r));break}}t=t.return}}function Ku(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zl;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)||(Ul=!0,i.add(n),e=qu.bind(null,e,t,n),t.then(e,e))}function qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,K===e&&(J&n)===n&&(Gl===4||Gl===3&&(J&62914560)===J&&300>Me()-eu?!(G&2)&&Cu(e,0):Jl|=n,Xl===J&&(Xl=0)),id(e)}function Ju(e,t){t===0&&(t=tt()),e=oi(e,t),e!==null&&(rt(e,t),id(e))}function Yu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ju(e,n)}function Xu(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),Ju(e,n)}function Zu(e,t){return Oe(e,t)}var Qu=null,$u=null,ed=!1,td=!1,nd=!1,rd=0;function id(e){e!==$u&&e.next===null&&($u===null?Qu=$u=e:$u=$u.next=e),td=!0,ed||(ed=!0,dd())}function ad(e,t){if(!nd&&td){nd=!0;do for(var n=!1,r=Qu;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-We(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ud(r,a))}else a=J,a=Qe(r,r===K?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||$e(r,a)||(n=!0,ud(r,a));r=r.next}while(n);nd=!1}}function od(){sd()}function sd(){td=ed=!1;var e=0;rd!==0&&Kd()&&(e=rd);for(var t=Me(),n=null,r=Qu;r!==null;){var i=r.next,a=cd(r,t);a===0?(r.next=null,n===null?Qu=i:n.next=i,i===null&&($u=n)):(n=r,(e!==0||a&3)&&(td=!0)),r=i}au!==0&&au!==5||ad(e,!1),rd!==0&&(rd=0)}function cd(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&&Ld(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function Sf(e,t,n){var r=xf;if(r&&typeof t==`string`&&t){var i=Wt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),gf.has(i)||(gf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Fd(t,`link`,e),Tt(t),r.head.appendChild(t)))}}function Cf(e){vf.D(e),Sf(`dns-prefetch`,e,null)}function wf(e,t){vf.C(e,t),Sf(`preconnect`,e,t)}function Tf(e,t,n){vf.L(e,t,n);var r=xf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Wt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Wt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Wt(n.imageSizes)+`"]`)):i+=`[href="`+Wt(e)+`"]`;var a=i;switch(t){case`style`:a=jf(e);break;case`script`:a=Ff(e)}hf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),hf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Mf(a))||t===`script`&&r.querySelector(If(a))||(t=r.createElement(`link`),Fd(t,`link`,e),Tt(t),r.head.appendChild(t)))}}function Ef(e,t){vf.m(e,t);var n=xf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Wt(r)+`"][href="`+Wt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ff(e)}if(!hf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),hf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(If(a)))return}r=n.createElement(`link`),Fd(r,`link`,e),Tt(r),n.head.appendChild(r)}}}function Df(e,t,n){vf.S(e,t,n);var r=xf;if(r&&e){var i=wt(r).hoistableStyles,a=jf(e);t=t||`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Mf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=hf.get(a))&&zf(e,n);var c=o=r.createElement(`link`);Tt(c),Fd(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,Rf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Of(e,t){vf.X(e,t);var n=xf;if(n&&e){var r=wt(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=m({src:e,async:!0},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),Tt(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t){vf.M(e,t);var n=xf;if(n&&e){var r=wt(n).hoistableScripts,i=Ff(e),a=r.get(i);a||(a=n.querySelector(If(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=hf.get(i))&&Bf(e,t),a=n.createElement(`script`),Tt(a),Fd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Af(e,t,n,r){var a=(a=me.current)?_f(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=jf(n.href),n=wt(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=jf(n.href);var o=wt(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(Mf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),hf.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},hf.set(e,n),o||Pf(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=Ff(n),n=wt(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 jf(e){return`href="`+Wt(e)+`"`}function Mf(e){return`link[rel="stylesheet"][`+e+`]`}function Nf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Pf(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}),Fd(t,`link`,n),Tt(t),e.head.appendChild(t))}function Ff(e){return`[src="`+Wt(e)+`"]`}function If(e){return`script[async]`+e}function Lf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Wt(n.href)+`"]`);if(r)return t.instance=r,Tt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Tt(r),Fd(r,`style`,a),Rf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=jf(n.href);var o=e.querySelector(Mf(a));if(o)return t.state.loading|=4,t.instance=o,Tt(o),o;r=Nf(n),(a=hf.get(a))&&zf(r,a),o=(e.ownerDocument||e).createElement(`link`),Tt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Fd(o,`link`,r),t.state.loading|=4,Rf(o,n.precedence,e),t.instance=o;case`script`:return o=Ff(n.src),(a=e.querySelector(If(o)))?(t.instance=a,Tt(a),a):(r=n,(a=hf.get(o))&&(r=m({},n),Bf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Tt(a),Fd(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,Rf(r,n.precedence,e));return t.instance}function Rf(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 Wf(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 Gf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Kf(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=jf(r.href),a=t.querySelector(Mf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Yf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Tt(a);return}a=t.ownerDocument||t,r=Nf(r),(i=hf.get(i))&&zf(r,i),a=a.createElement(`link`),Tt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Fd(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=Yf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var qf=0;function Jf(e,t){return e.stylesheets&&e.count===0&&Zf(e,e.stylesheets),0qf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Yf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Zf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Xf=null;function Zf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Xf=new Map,t.forEach(Qf,e),Xf=null,Yf.call(e))}function Qf(e,t){if(!(t.state.loading&4)){var n=Xf.get(e);if(n)var r=n.get(null);else{n=new Map,Xf.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=g()})),v=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};function y(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}var b=o((()=>{}));function x(e,t,n){y(e,t),t.set(e,n)}var S=o((()=>{b()}));function C(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}var w=o((()=>{}));function T(e,t,n){return e.set(C(e,t),n),n}var E=o((()=>{w()}));function D(e,t){return e.get(C(e,t))}var O=o((()=>{w()}));S(),E(),O();var ee,te,ne,re=new(ee=new WeakMap,te=new WeakMap,ne=new WeakMap,class extends v{constructor(){super(),x(this,ee,void 0),x(this,te,void 0),x(this,ne,void 0),T(ne,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}})}onSubscribe(){D(te,this)||this.setEventListener(D(ne,this))}onUnsubscribe(){this.hasListeners()||(D(te,this)?.call(this),T(te,this,void 0))}setEventListener(e){T(ne,this,e),D(te,this)?.call(this),T(te,this,e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()}))}setFocused(e){D(ee,this)!==e&&(T(ee,this,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof D(ee,this)==`boolean`?D(ee,this):globalThis.document?.visibilityState!==`hidden`}});S(),O(),E();var ie,ae,oe={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},k=new(ie=new WeakMap,ae=new WeakMap,class{constructor(){x(this,ie,oe),x(this,ae,!1)}setTimeoutProvider(e){T(ie,this,e)}setTimeout(e,t){return D(ie,this).setTimeout(e,t)}clearTimeout(e){D(ie,this).clearTimeout(e)}setInterval(e,t){return D(ie,this).setInterval(e,t)}clearInterval(e){D(ie,this).clearInterval(e)}});function A(e){setTimeout(e,0)}var se=typeof window>`u`||`Deno`in globalThis;function ce(){}function le(e,t){return typeof e==`function`?e(t):e}function ue(e){return typeof e==`number`&&e>=0&&e!==1/0}function de(e,t){return Math.max(e+(t||0)-Date.now(),0)}function j(e,t){return typeof e==`function`?e(t):e}function fe(e,t){return typeof e==`function`?e(t):e}function pe(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==he(o,t.options))return!1}else if(!_e(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function me(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ge(t.options.mutationKey)!==ge(a))return!1}else if(!_e(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function he(e,t){return(t?.queryKeyHashFn||ge)(e)}function ge(e){return JSON.stringify(e,(e,t)=>Se(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function _e(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>_e(e[n],t[n])):!1}var ve=Object.prototype.hasOwnProperty;function ye(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=xe(e)&&xe(t);if(!r&&!(Se(e)&&Se(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l{k.setTimeout(t,e)})}function Te(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:ye(e,t)}function Ee(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function De(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Oe=Symbol();function ke(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Oe?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ae(e,t){return typeof e==`function`?e(...t):!!e}function je(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var Me=(()=>{let e=()=>se;return{isServer(){return e()},setIsServer(t){e=t}}})();function Ne(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var Pe=A;function Fe(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Pe,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Ie=Fe();S(),E(),O();var Le,Re,ze,Be=new(Le=new WeakMap,Re=new WeakMap,ze=new WeakMap,class extends v{constructor(){super(),x(this,Le,!0),x(this,Re,void 0),x(this,ze,void 0),T(ze,this,e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}})}onSubscribe(){D(Re,this)||this.setEventListener(D(ze,this))}onUnsubscribe(){this.hasListeners()||(D(Re,this)?.call(this),T(Re,this,void 0))}setEventListener(e){T(ze,this,e),D(Re,this)?.call(this),T(Re,this,e(this.setOnline.bind(this)))}setOnline(e){D(Le,this)!==e&&(T(Le,this,e),this.listeners.forEach(t=>{t(e)}))}isOnline(){return D(Le,this)}});function Ve(e){return Math.min(1e3*2**e,3e4)}function He(e){return(e??`online`)===`online`?Be.isOnline():!0}var Ue=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function We(e){let t=!1,n=0,r,i=Ne(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new Ue(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>re.isFocused()&&(e.networkMode===`always`||Be.isOnline())&&e.canRun(),u=()=>He(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(Me.isServer()?0:3),o=e.retryDelay??Ve,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&nl()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}S(),E(),O();var Ge,Ke=(Ge=new WeakMap,class{constructor(){x(this,Ge,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ue(this.gcTime)&&T(Ge,this,k.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Me.isServer()?1/0:300*1e3))}clearGcTimeout(){D(Ge,this)&&(k.clearTimeout(D(Ge,this)),T(Ge,this,void 0))}});function qe(e,t){y(e,t),t.add(e)}var Je=o((()=>{b()}));Je(),S(),E(),O(),w();var Ye,Xe,Ze,Qe,$e,et,tt,nt,rt=(Ye=new WeakMap,Xe=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,$e=new WeakMap,et=new WeakMap,tt=new WeakMap,nt=new WeakSet,class extends Ke{constructor(e){super(),qe(this,nt),x(this,Ye,void 0),x(this,Xe,void 0),x(this,Ze,void 0),x(this,Qe,void 0),x(this,$e,void 0),x(this,et,void 0),x(this,tt,void 0),T(tt,this,!1),T(et,this,e.defaultOptions),this.setOptions(e.options),this.observers=[],T(Qe,this,e.client),T(Ze,this,D(Qe,this).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,T(Ye,this,ct(this.options)),this.state=e.state??D(Ye,this),this.scheduleGc()}get meta(){return this.options.meta}get promise(){return D($e,this)?.promise}setOptions(e){if(this.options={...D(et,this),...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=ct(this.options);e.data!==void 0&&(this.setState(st(e.data,e.dataUpdatedAt)),T(Ye,this,e))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&D(Ze,this).remove(this)}setData(e,t){let n=Te(this.state.data,e,this.options);return C(nt,this,at).call(this,{data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){C(nt,this,at).call(this,{type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=D($e,this)?.promise;return D($e,this)?.cancel(e),t?t.then(ce).catch(ce):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return D(Ye,this)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>fe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oe||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>j(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!de(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),D($e,this)?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),D($e,this)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),D(Ze,this).notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(D($e,this)&&(D(tt,this)||C(nt,this,it).call(this)?D($e,this).cancel({revert:!0}):D($e,this).cancelRetry()),this.scheduleGc()),D(Ze,this).notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||C(nt,this,at).call(this,{type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&D($e,this)?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(D($e,this))return D($e,this).continueRetry(),D($e,this).promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(T(tt,this,!0),n.signal)})},i=()=>{let e=ke(this.options,t),n=(()=>{let e={client:D(Qe,this),queryKey:this.queryKey,meta:this.meta};return r(e),e})();return T(tt,this,!1),this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:D(Qe,this),state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),T(Xe,this,this.state),(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&C(nt,this,at).call(this,{type:`fetch`,meta:a.fetchOptions?.meta}),T($e,this,We({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ue&&e.revert&&this.setState({...D(Xe,this),fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{C(nt,this,at).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{C(nt,this,at).call(this,{type:`pause`})},onContinue:()=>{C(nt,this,at).call(this,{type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0}));try{let e=await D($e,this).start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),D(Ze,this).config.onSuccess?.(e,this),D(Ze,this).config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ue){if(e.silent)return D($e,this).promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw C(nt,this,at).call(this,{type:`error`,error:e}),D(Ze,this).config.onError?.(e,this),D(Ze,this).config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}});function it(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}function at(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...ot(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...st(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return T(Xe,this,e.manual?n:void 0),n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),Ie.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),D(Ze,this).notify({query:this,type:`updated`,action:e})})}function ot(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:He(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function st(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function ct(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}Je(),S(),E(),O(),w();var lt,M,ut,dt,ft,pt,mt,ht,gt,_t,vt,yt,bt,xt,St,Ct,wt=(lt=new WeakMap,M=new WeakMap,ut=new WeakMap,dt=new WeakMap,ft=new WeakMap,pt=new WeakMap,mt=new WeakMap,ht=new WeakMap,gt=new WeakMap,_t=new WeakMap,vt=new WeakMap,yt=new WeakMap,bt=new WeakMap,xt=new WeakMap,St=new WeakMap,Ct=new WeakSet,class extends v{constructor(e,t){super(),qe(this,Ct),x(this,lt,void 0),x(this,M,void 0),x(this,ut,void 0),x(this,dt,void 0),x(this,ft,void 0),x(this,pt,void 0),x(this,mt,void 0),x(this,ht,void 0),x(this,gt,void 0),x(this,_t,void 0),x(this,vt,void 0),x(this,yt,void 0),x(this,bt,void 0),x(this,xt,void 0),x(this,St,new Set),this.options=t,T(lt,this,e),T(ht,this,null),T(mt,this,Ne()),this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(D(M,this).addObserver(this),Ft(D(M,this),this.options)?C(Ct,this,Tt).call(this):this.updateResult(),C(Ct,this,kt).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return It(D(M,this),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return It(D(M,this),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,C(Ct,this,At).call(this),C(Ct,this,jt).call(this),D(M,this).removeObserver(this)}setOptions(e){let t=this.options,n=D(M,this);if(this.options=D(lt,this).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof fe(this.options.enabled,D(M,this))!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);C(Ct,this,Mt).call(this),D(M,this).setOptions(this.options),t._defaulted&&!be(this.options,t)&&D(lt,this).getQueryCache().notify({type:`observerOptionsUpdated`,query:D(M,this),observer:this});let r=this.hasListeners();r&&Lt(D(M,this),n,this.options,t)&&C(Ct,this,Tt).call(this),this.updateResult(),r&&(D(M,this)!==n||fe(this.options.enabled,D(M,this))!==fe(t.enabled,D(M,this))||j(this.options.staleTime,D(M,this))!==j(t.staleTime,D(M,this)))&&C(Ct,this,Et).call(this);let i=C(Ct,this,Dt).call(this);r&&(D(M,this)!==n||fe(this.options.enabled,D(M,this))!==fe(t.enabled,D(M,this))||i!==D(xt,this))&&C(Ct,this,Ot).call(this,i)}getOptimisticResult(e){let t=D(lt,this).getQueryCache().build(D(lt,this),e),n=this.createResult(t,e);return zt(this,n)&&(T(dt,this,n),T(pt,this,this.options),T(ft,this,D(M,this).state)),n}getCurrentResult(){return D(dt,this)}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&D(mt,this).status===`pending`&&D(mt,this).reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){D(St,this).add(e)}getCurrentQuery(){return D(M,this)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=D(lt,this).defaultQueryOptions(e),n=D(lt,this).getQueryCache().build(D(lt,this),t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return C(Ct,this,Tt).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),D(dt,this)))}createResult(e,t){let n=D(M,this),r=this.options,i=D(dt,this),a=D(ft,this),o=D(pt,this),s=e===n?D(ut,this):e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Ft(e,t),o=i&&Lt(e,n,t,r);(a||o)&&(l={...l,...ot(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(D(vt,this)?.state.data,D(vt,this)):t.placeholderData,e!==void 0&&(m=`success`,d=Te(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===D(gt,this))d=D(_t,this);else try{T(gt,this,t.select),d=t.select(d),d=Te(i?.data,d,t),T(_t,this,d),T(ht,this,null)}catch(e){T(ht,this,e)}D(ht,this)&&(f=D(ht,this),d=D(_t,this),p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Rt(e,t),refetch:this.refetch,promise:D(mt,this),isEnabled:fe(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(T(mt,this,x.promise=Ne()))},o=D(mt,this);switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=D(dt,this),t=this.createResult(D(M,this),this.options);T(ft,this,D(M,this).state),T(pt,this,this.options),D(ft,this).data!==void 0&&T(vt,this,D(M,this)),!be(t,e)&&(T(dt,this,t),C(Ct,this,Nt).call(this,{listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!D(St,this).size)return!0;let r=new Set(n??D(St,this));return this.options.throwOnError&&r.add(`error`),Object.keys(D(dt,this)).some(t=>{let n=t;return D(dt,this)[n]!==e[n]&&r.has(n)})})()}))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&C(Ct,this,kt).call(this)}});function Tt(e){C(Ct,this,Mt).call(this);let t=D(M,this).fetch(this.options,e);return e?.throwOnError||(t=t.catch(ce)),t}function Et(){C(Ct,this,At).call(this);let e=j(this.options.staleTime,D(M,this));if(Me.isServer()||D(dt,this).isStale||!ue(e))return;let t=de(D(dt,this).dataUpdatedAt,e)+1;T(yt,this,k.setTimeout(()=>{D(dt,this).isStale||this.updateResult()},t))}function Dt(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(D(M,this)):this.options.refetchInterval)??!1}function Ot(e){C(Ct,this,jt).call(this),T(xt,this,e),!(Me.isServer()||fe(this.options.enabled,D(M,this))===!1||!ue(D(xt,this))||D(xt,this)===0)&&T(bt,this,k.setInterval(()=>{(this.options.refetchIntervalInBackground||re.isFocused())&&C(Ct,this,Tt).call(this)},D(xt,this)))}function kt(){C(Ct,this,Et).call(this),C(Ct,this,Ot).call(this,C(Ct,this,Dt).call(this))}function At(){D(yt,this)&&(k.clearTimeout(D(yt,this)),T(yt,this,void 0))}function jt(){D(bt,this)&&(k.clearInterval(D(bt,this)),T(bt,this,void 0))}function Mt(){let e=D(lt,this).getQueryCache().build(D(lt,this),this.options);if(e===D(M,this))return;let t=D(M,this);T(M,this,e),T(ut,this,e.state),this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}function Nt(e){Ie.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(D(dt,this))}),D(lt,this).getQueryCache().notify({query:D(M,this),type:`observerResultsUpdated`})})}function Pt(e,t){return fe(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Ft(e,t){return Pt(e,t)||e.state.data!==void 0&&It(e,t,t.refetchOnMount)}function It(e,t,n){if(fe(t.enabled,e)!==!1&&j(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Rt(e,t)}return!1}function Lt(e,t,n,r){return(e!==t||fe(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Rt(e,n)}function Rt(e,t){return fe(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function zt(e,t){return!be(e.getCurrentResult(),t)}function Bt(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{je(e,()=>t.signal,()=>n=!0)},u=ke(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?De:Ee;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ht:Vt,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Vt(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(ct.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Vt(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ht(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}Je(),S(),E(),O(),w();var Ut,Wt,Gt,Kt,qt,Jt=(Ut=new WeakMap,Wt=new WeakMap,Gt=new WeakMap,Kt=new WeakMap,qt=new WeakSet,class extends Ke{constructor(e){super(),qe(this,qt),x(this,Ut,void 0),x(this,Wt,void 0),x(this,Gt,void 0),x(this,Kt,void 0),T(Ut,this,e.client),this.mutationId=e.mutationId,T(Gt,this,e.mutationCache),T(Wt,this,[]),this.state=e.state||Xt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){D(Wt,this).includes(e)||(D(Wt,this).push(e),this.clearGcTimeout(),D(Gt,this).notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){T(Wt,this,D(Wt,this).filter(t=>t!==e)),this.scheduleGc(),D(Gt,this).notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){D(Wt,this).length||(this.state.status===`pending`?this.scheduleGc():D(Gt,this).remove(this))}continue(){return D(Kt,this)?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{C(qt,this,Yt).call(this,{type:`continue`})},n={client:D(Ut,this),meta:this.options.meta,mutationKey:this.options.mutationKey};T(Kt,this,We({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{C(qt,this,Yt).call(this,{type:`failed`,failureCount:e,error:t})},onPause:()=>{C(qt,this,Yt).call(this,{type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>D(Gt,this).canRun(this)}));let r=this.state.status===`pending`,i=!D(Kt,this).canStart();try{if(r)t();else{C(qt,this,Yt).call(this,{type:`pending`,variables:e,isPaused:i}),D(Gt,this).config.onMutate&&await D(Gt,this).config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&C(qt,this,Yt).call(this,{type:`pending`,context:t,variables:e,isPaused:i})}let a=await D(Kt,this).start();return await D(Gt,this).config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await D(Gt,this).config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),C(qt,this,Yt).call(this,{type:`success`,data:a}),a}catch(t){try{await D(Gt,this).config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await D(Gt,this).config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw C(qt,this,Yt).call(this,{type:`error`,error:t}),t}finally{D(Gt,this).runNext(this)}}});function Yt(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Ie.batch(()=>{D(Wt,this).forEach(t=>{t.onMutationUpdate(e)}),D(Gt,this).notify({mutation:this,type:`updated`,action:e})})}function Xt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}S(),E(),O();var Zt,Qt,$t,en=(Zt=new WeakMap,Qt=new WeakMap,$t=new WeakMap,class extends v{constructor(e={}){super(),x(this,Zt,void 0),x(this,Qt,void 0),x(this,$t,void 0),this.config=e,T(Zt,this,new Set),T(Qt,this,new Map),T($t,this,0)}build(e,t,n){var r;let i=new Jt({client:e,mutationCache:this,mutationId:T($t,this,(r=D($t,this),++r)),options:e.defaultMutationOptions(t),state:n});return this.add(i),i}add(e){D(Zt,this).add(e);let t=tn(e);if(typeof t==`string`){let n=D(Qt,this).get(t);n?n.push(e):D(Qt,this).set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(D(Zt,this).delete(e)){let t=tn(e);if(typeof t==`string`){let n=D(Qt,this).get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&D(Qt,this).delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=tn(e);if(typeof t==`string`){let n=D(Qt,this).get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=tn(e);return typeof t==`string`?(D(Qt,this).get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Ie.batch(()=>{D(Zt,this).forEach(e=>{this.notify({type:`removed`,mutation:e})}),D(Zt,this).clear(),D(Qt,this).clear()})}getAll(){return Array.from(D(Zt,this))}find(e){let t={exact:!0,...e};return this.getAll().find(e=>me(t,e))}findAll(e={}){return this.getAll().filter(t=>me(e,t))}notify(e){Ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Ie.batch(()=>Promise.all(e.map(e=>e.continue().catch(ce))))}});function tn(e){return e.options.scope?.id}Je(),S(),E(),w(),O();var nn,rn,an,on,sn,cn=(nn=new WeakMap,rn=new WeakMap,an=new WeakMap,on=new WeakMap,sn=new WeakSet,class extends v{constructor(e,t){super(),qe(this,sn),x(this,nn,void 0),x(this,rn,void 0),x(this,an,void 0),x(this,on,void 0),T(nn,this,e),this.setOptions(t),this.bindMethods(),C(sn,this,ln).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=D(nn,this).defaultMutationOptions(e),be(this.options,t)||D(nn,this).getMutationCache().notify({type:`observerOptionsUpdated`,mutation:D(an,this),observer:this}),t?.mutationKey&&this.options.mutationKey&&ge(t.mutationKey)!==ge(this.options.mutationKey)?this.reset():D(an,this)?.state.status===`pending`&&D(an,this).setOptions(this.options)}onUnsubscribe(){this.hasListeners()||D(an,this)?.removeObserver(this)}onMutationUpdate(e){C(sn,this,ln).call(this),C(sn,this,un).call(this,e)}getCurrentResult(){return D(rn,this)}reset(){D(an,this)?.removeObserver(this),T(an,this,void 0),C(sn,this,ln).call(this),C(sn,this,un).call(this)}mutate(e,t){return T(on,this,t),D(an,this)?.removeObserver(this),T(an,this,D(nn,this).getMutationCache().build(D(nn,this),this.options)),D(an,this).addObserver(this),D(an,this).execute(e)}});function ln(){let e=D(an,this)?.state??Xt();T(rn,this,{...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset})}function un(e){Ie.batch(()=>{if(D(on,this)&&this.hasListeners()){let t=D(rn,this).variables,n=D(rn,this).context,r={client:D(nn,this),meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{D(on,this).onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{D(on,this).onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{D(on,this).onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{D(on,this).onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(D(rn,this))})})}S(),E(),O();var dn,fn=(dn=new WeakMap,class extends v{constructor(e={}){super(),x(this,dn,void 0),this.config=e,T(dn,this,new Map)}build(e,t,n){let r=t.queryKey,i=t.queryHash??he(r,t),a=this.get(i);return a||(a=new rt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){D(dn,this).has(e.queryHash)||(D(dn,this).set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=D(dn,this).get(e.queryHash);t&&(e.destroy(),t===e&&D(dn,this).delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Ie.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return D(dn,this).get(e)}getAll(){return[...D(dn,this).values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>pe(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>pe(e,t)):t}notify(e){Ie.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Ie.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Ie.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}});S(),E(),O();var pn,mn,hn,gn,_n,vn,yn,bn,xn=(pn=new WeakMap,mn=new WeakMap,hn=new WeakMap,gn=new WeakMap,_n=new WeakMap,vn=new WeakMap,yn=new WeakMap,bn=new WeakMap,class{constructor(e={}){x(this,pn,void 0),x(this,mn,void 0),x(this,hn,void 0),x(this,gn,void 0),x(this,_n,void 0),x(this,vn,void 0),x(this,yn,void 0),x(this,bn,void 0),T(pn,this,e.queryCache||new fn),T(mn,this,e.mutationCache||new en),T(hn,this,e.defaultOptions||{}),T(gn,this,new Map),T(_n,this,new Map),T(vn,this,0)}mount(){var e;T(vn,this,(e=D(vn,this),e++,e)),D(vn,this)===1&&(T(yn,this,re.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(pn,this).onFocus())})),T(bn,this,Be.subscribe(async e=>{e&&(await this.resumePausedMutations(),D(pn,this).onOnline())})))}unmount(){var e;T(vn,this,(e=D(vn,this),e--,e)),D(vn,this)===0&&(D(yn,this)?.call(this),T(yn,this,void 0),D(bn,this)?.call(this),T(bn,this,void 0))}isFetching(e){return D(pn,this).findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return D(mn,this).findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return D(pn,this).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=D(pn,this).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(j(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return D(pn,this).findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=D(pn,this).get(r.queryHash)?.state.data,a=le(t,i);if(a!==void 0)return D(pn,this).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Ie.batch(()=>D(pn,this).findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return D(pn,this).get(t.queryHash)?.state}removeQueries(e){let t=D(pn,this);Ie.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=D(pn,this);return Ie.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Ie.batch(()=>D(pn,this).findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(ce).catch(ce)}invalidateQueries(e,t={}){return Ie.batch(()=>(D(pn,this).findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ie.batch(()=>D(pn,this).findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(ce)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(ce)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=D(pn,this).build(this,t);return n.isStaleByTime(j(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(ce).catch(ce)}fetchInfiniteQuery(e){return e.behavior=Bt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(ce).catch(ce)}ensureInfiniteQueryData(e){return e.behavior=Bt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Be.isOnline()?D(mn,this).resumePausedMutations():Promise.resolve()}getQueryCache(){return D(pn,this)}getMutationCache(){return D(mn,this)}getDefaultOptions(){return D(hn,this)}setDefaultOptions(e){T(hn,this,e)}setQueryDefaults(e,t){D(gn,this).set(ge(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...D(gn,this).values()],n={};return t.forEach(t=>{_e(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){D(_n,this).set(ge(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...D(_n,this).values()],n={};return t.forEach(t=>{_e(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...D(hn,this).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=he(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Oe&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...D(hn,this).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){D(pn,this).clear(),D(mn,this).clear()}}),Sn=s((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})),Cn=s(((e,t)=>{t.exports=Sn()})),N=l(d(),1),P=Cn(),wn=N.createContext(void 0),F=e=>{let t=N.useContext(wn);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Tn=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(wn.Provider,{value:e,children:t})),En=N.createContext(!1),Dn=()=>N.useContext(En);En.Provider;function On(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var kn=N.createContext(On()),An=()=>N.useContext(kn),jn=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Ae(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Mn=e=>{N.useEffect(()=>{e.clearReset()},[e])},Nn=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Ae(n,[e.error,r])),Pn=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Fn=(e,t)=>e.isLoading&&e.isFetching&&!t,In=(e,t)=>e?.suspense&&t.isPending,Ln=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function Rn(e,t,n){let r=Dn(),i=An(),a=F(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,Pn(o),jn(o,i,s),Mn(i);let c=!a.getQueryCache().get(o.queryHash),[l]=N.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(e=>{let t=d?l.subscribe(Ie.batchCalls(e)):ce;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),N.useEffect(()=>{l.setOptions(o)},[o,l]),In(o,u))throw Ln(o,l,i);if(Nn({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!Me.isServer()&&Fn(u,r)&&(c?Ln(o,l,i):s?.promise)?.catch(ce).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function zn(e,t){return Rn(e,wt,t)}function Bn(e,t){let n=F(t),[r]=N.useState(()=>new cn(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(Ie.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(ce)},[r]);if(i.error&&Ae(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var Vn=l(h()),Hn=_();function Un(){return Un=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function er(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=Wn.Pop,c=null,l=u();l??(l=0,o.replaceState(Un({},o.state,{idx:l}),``));function u(){return(o.state||{idx:null}).idx}function d(){s=Wn.Pop;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=Wn.Push;let r=Zn(h.location,e,t);n&&n(r,e),l=u()+1;let d=Xn(r,l),f=h.createHref(r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=Wn.Replace;let r=Zn(h.location,e,t);n&&n(r,e),l=u();let i=Xn(r,l),d=h.createHref(r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){let t=i.location.origin===`null`?i.location.href:i.location.origin,n=typeof e==`string`?e:Qn(e);return n=n.replace(/ $/,`%20`),qn(t,`No window.location.(origin|href) available to create URL for href: `+n),new URL(n,t)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(Gn,d),c=e,()=>{i.removeEventListener(Gn,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}var tr;(function(e){e.data=`data`,e.deferred=`deferred`,e.redirect=`redirect`,e.error=`error`})(tr||(tr={}));function nr(e,t,n){return n===void 0&&(n=`/`),rr(e,t,n,!1)}function rr(e,t,n,r){let i=br((typeof t==`string`?$n(t):t).pathname||`/`,n);if(i==null)return null;let a=ir(e);or(a);let o=null,s=yr(i);for(let e=0;o==null&&e{let o={relativePath:a===void 0?e.path||``:a,caseSensitive:e.caseSensitive===!0,childrenIndex:i,route:e};o.relativePath.startsWith(`/`)&&(qn(o.relativePath.startsWith(r),`Absolute route path "`+o.relativePath+`" nested under path `+(`"`+r+`" is not valid. An absolute child route path `)+`must start with the combined path of all its parent routes.`),o.relativePath=o.relativePath.slice(r.length));let s=Ar([r,o.relativePath]),c=n.concat(o);e.children&&e.children.length>0&&(qn(e.index!==!0,`Index routes must not have child routes. Please remove `+(`all child routes from route path "`+s+`".`)),ir(e.children,t,c,s)),!(e.path==null&&!e.index)&&t.push({path:s,score:mr(s,e.index),routesMeta:c})};return e.forEach((e,t)=>{var n;if(e.path===``||!((n=e.path)!=null&&n.includes(`?`)))i(e,t);else for(let n of ar(e.path))i(e,t,n)}),t}function ar(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ar(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function or(e){e.sort((e,t)=>e.score===t.score?hr(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var sr=/^:[\w-]+$/,cr=3,lr=2,ur=1,dr=10,fr=-2,pr=e=>e===`*`;function mr(e,t){let n=e.split(`/`),r=n.length;return n.some(pr)&&(r+=fr),t&&(r+=lr),n.filter(e=>!pr(e)).reduce((e,t)=>e+(sr.test(t)?cr:t===``?ur:dr),r)}function hr(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function gr(e,t,n){n===void 0&&(n=!1);let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e{let{paramName:r,isOptional:i}=t;if(r===`*`){let e=s[n]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let c=s[n];return i&&!c?e[r]=void 0:e[r]=(c||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function vr(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Jn(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "`+e+`" will be treated as if it were `+(`"`+e.replace(/\*$/,`/*`)+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+(`please change the route path to "`+e.replace(/\*$/,`/*`)+`".`));let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n)=>(r.push({paramName:t,isOptional:n!=null}),n?`/?([^\\/]+)?`:`/([^\\/]+)`));return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function yr(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Jn(!1,`The URL path "`+e+`" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent `+(`encoding (`+t+`).`)),e}}function br(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}var xr=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Sr=e=>xr.test(e);function Cr(e,t){t===void 0&&(t=`/`);let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?$n(e):e,a;if(n)if(Sr(n))a=n;else{if(n.includes(`//`)){let e=n;n=kr(n),Jn(!1,`Pathnames cannot have embedded double slashes - normalizing `+(e+` -> `+n))}a=n.startsWith(`/`)?wr(n.substring(1),`/`):wr(n,t)}else a=t;return{pathname:a,search:Mr(r),hash:Nr(i)}}function wr(e,t){let n=t.replace(/\/+$/,``).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Tr(e,t,n,r){return`Cannot include a '`+e+`' character in a manually specified `+("`to."+t+"` field ["+JSON.stringify(r)+`]. Please separate it out to the `)+("`to."+n+"` field. Alternatively you may provide the full path as ")+`a string in and the router will parse it for you.`}function Er(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Dr(e,t){let n=Er(e);return t?n.map((e,t)=>t===n.length-1?e.pathname:e.pathnameBase):n.map(e=>e.pathnameBase)}function Or(e,t,n,r){r===void 0&&(r=!1);let i;typeof e==`string`?i=$n(e):(i=Un({},e),qn(!i.pathname||!i.pathname.includes(`?`),Tr(`?`,`pathname`,`search`,i)),qn(!i.pathname||!i.pathname.includes(`#`),Tr(`#`,`pathname`,`hash`,i)),qn(!i.search||!i.search.includes(`#`),Tr(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Cr(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var kr=e=>e.replace(/\/\/+/g,`/`),Ar=e=>kr(e.join(`/`)),jr=e=>e.replace(/\/+$/,``).replace(/^\/*/,`/`),Mr=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,Nr=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e;function Pr(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}var Fr=[`post`,`put`,`patch`,`delete`];new Set(Fr);var Ir=[`get`,...Fr];new Set(Ir);function Lr(){return Lr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{s.current=!0}),N.useCallback(function(n,i){if(i===void 0&&(i={}),!s.current)return;if(typeof n==`number`){r.go(n);return}let c=Or(n,JSON.parse(o),a,i.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Ar([t,c.pathname])),(i.replace?r.replace:r.push)(c,i.state,i)},[t,r,o,a,e])}function Xr(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=N.useContext(Br),{matches:i}=N.useContext(Hr),{pathname:a}=Kr(),o=JSON.stringify(Dr(i,r.v7_relativeSplatPath));return N.useMemo(()=>Or(e,JSON.parse(o),a,n===`path`),[e,o,a,n])}function Zr(e,t){return Qr(e,t)}function Qr(e,t,n,r){!Gr()&&qn(!1);let{navigator:i}=N.useContext(Br),{matches:a}=N.useContext(Hr),o=a[a.length-1],s=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:`/`;o&&o.route;let l=Kr(),u;if(t){let e=typeof t==`string`?$n(t):t;!(c===`/`||e.pathname?.startsWith(c))&&qn(!1),u=e}else u=l;let d=u.pathname||`/`,f=d;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);f=`/`+d.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let p=nr(e,{pathname:f}),m=ri(p&&p.map(e=>Object.assign({},e,{params:Object.assign({},s,e.params),pathname:Ar([c,i.encodeLocation?i.encodeLocation(e.pathname).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:Ar([c,i.encodeLocation?i.encodeLocation(e.pathnameBase).pathname:e.pathnameBase])})),a,n,r);return t&&m?N.createElement(Vr.Provider,{value:{location:Lr({pathname:`/`,search:``,hash:``,state:null,key:`default`},u),navigationType:Wn.Pop}},m):m}function $r(){let e=ui(),t=Pr(e)?e.status+` `+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null;return N.createElement(N.Fragment,null,N.createElement(`h2`,null,`Unexpected Application Error!`),N.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?N.createElement(`pre`,{style:{padding:`0.5rem`,backgroundColor:`rgba(200,200,200, 0.5)`}},n):null,null)}var ei=N.createElement($r,null),ti=class extends N.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){console.error(`React Router caught the following error during render`,e,t)}render(){return this.state.error===void 0?this.props.children:N.createElement(Hr.Provider,{value:this.props.routeContext},N.createElement(Ur.Provider,{value:this.state.error,children:this.props.component}))}};function ni(e){let{routeContext:t,match:n,children:r}=e,i=N.useContext(Rr);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),N.createElement(Hr.Provider,{value:t},r)}function ri(e,t,n,r){if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=n?.errors;if(o!=null){let e=a.findIndex(e=>e.route.id&&o?.[e.route.id]!==void 0);!(e>=0)&&qn(!1),a=a.slice(0,Math.min(a.length,e+1))}let s=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let e=0;e=0?a.slice(0,c+1):[a[0]];break}}}return a.reduceRight((e,r,i)=>{let l,u=!1,d=null,f=null;n&&(l=o&&r.route.id?o[r.route.id]:void 0,d=r.route.errorElement||ei,s&&(c<0&&i===0?(pi(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),u=!0,f=null):c===i&&(u=!0,f=r.route.hydrateFallbackElement||null)));let p=t.concat(a.slice(0,i+1)),m=()=>{let t;return t=l?d:u?f:r.route.Component?N.createElement(r.route.Component,null):r.route.element?r.route.element:e,N.createElement(ni,{match:r,routeContext:{outlet:e,matches:p,isDataRoute:n!=null},children:t})};return n&&(r.route.ErrorBoundary||r.route.errorElement||i===0)?N.createElement(ti,{location:n.location,revalidation:n.revalidation,component:d,error:l,children:m(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):m()},null)}var ii=function(e){return e.UseBlocker=`useBlocker`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e}(ii||{}),ai=function(e){return e.UseBlocker=`useBlocker`,e.UseLoaderData=`useLoaderData`,e.UseActionData=`useActionData`,e.UseRouteError=`useRouteError`,e.UseNavigation=`useNavigation`,e.UseRouteLoaderData=`useRouteLoaderData`,e.UseMatches=`useMatches`,e.UseRevalidator=`useRevalidator`,e.UseNavigateStable=`useNavigate`,e.UseRouteId=`useRouteId`,e}(ai||{});function oi(e){let t=N.useContext(Rr);return!t&&qn(!1),t}function si(e){let t=N.useContext(zr);return!t&&qn(!1),t}function ci(e){let t=N.useContext(Hr);return!t&&qn(!1),t}function li(e){let t=ci(e),n=t.matches[t.matches.length-1];return!n.route.id&&qn(!1),n.route.id}function ui(){let e=N.useContext(Ur),t=si(ai.UseRouteError),n=li(ai.UseRouteError);return e===void 0?t.errors?.[n]:e}function di(){let{router:e}=oi(ii.UseNavigateStable),t=li(ai.UseNavigateStable),n=N.useRef(!1);return qr(()=>{n.current=!0}),N.useCallback(function(r,i){i===void 0&&(i={}),n.current&&(typeof r==`number`?e.navigate(r):e.navigate(r,Lr({fromRouteId:t},i)))},[e,t])}var fi={};function pi(e,t,n){!t&&!fi[e]&&(fi[e]=!0)}var mi=(e,t,n)=>(``+t+("You can use the `"+e+"` future flag to opt-in early. ")+(`For more information, see `+n+`.`),void 0);function hi(e,t){e?.v7_startTransition===void 0&&mi(`v7_startTransition`,"React Router will begin wrapping state updates in `React.startTransition` in v7",`https://reactrouter.com/v6/upgrading/future#v7_starttransition`),e?.v7_relativeSplatPath===void 0&&(!t||t.v7_relativeSplatPath===void 0)&&mi(`v7_relativeSplatPath`,`Relative route resolution within Splat routes is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_relativesplatpath`),t&&(t.v7_fetcherPersist===void 0&&mi(`v7_fetcherPersist`,`The persistence behavior of fetchers is changing in v7`,`https://reactrouter.com/v6/upgrading/future#v7_fetcherpersist`),t.v7_normalizeFormMethod===void 0&&mi(`v7_normalizeFormMethod`,"Casing of `formMethod` fields is being normalized to uppercase in v7",`https://reactrouter.com/v6/upgrading/future#v7_normalizeformmethod`),t.v7_partialHydration===void 0&&mi(`v7_partialHydration`,"`RouterProvider` hydration behavior is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_partialhydration`),t.v7_skipActionErrorRevalidation===void 0&&mi(`v7_skipActionErrorRevalidation`,"The revalidation behavior after 4xx/5xx `action` responses is changing in v7",`https://reactrouter.com/v6/upgrading/future#v7_skipactionerrorrevalidation`))}function gi(e){let{to:t,replace:n,state:r,relative:i}=e;!Gr()&&qn(!1);let{future:a,static:o}=N.useContext(Br),{matches:s}=N.useContext(Hr),{pathname:c}=Kr(),l=Jr(),u=Or(t,Dr(s,a.v7_relativeSplatPath),c,i===`path`),d=JSON.stringify(u);return N.useEffect(()=>l(JSON.parse(d),{replace:n,state:r,relative:i}),[l,d,i,n,r]),null}function _i(e){qn(!1)}function vi(e){let{basename:t=`/`,children:n=null,location:r,navigationType:i=Wn.Pop,navigator:a,static:o=!1,future:s}=e;Gr()&&qn(!1);let c=t.replace(/^\/*/,`/`),l=N.useMemo(()=>({basename:c,navigator:a,static:o,future:Lr({v7_relativeSplatPath:!1},s)}),[c,s,a,o]);typeof r==`string`&&(r=$n(r));let{pathname:u=`/`,search:d=``,hash:f=``,state:p=null,key:m=`default`}=r,h=N.useMemo(()=>{let e=br(u,c);return e==null?null:{location:{pathname:e,search:d,hash:f,state:p,key:m},navigationType:i}},[c,u,d,f,p,m,i]);return h==null?null:N.createElement(Br.Provider,{value:l},N.createElement(Vr.Provider,{children:n,value:h}))}function yi(e){let{children:t,location:n}=e;return Zr(xi(t),n)}var bi=function(e){return e[e.pending=0]=`pending`,e[e.success=1]=`success`,e[e.error=2]=`error`,e}(bi||{});new Promise(()=>{}),N.Component;function xi(e,t){t===void 0&&(t=[]);let n=[];return N.Children.forEach(e,(e,r)=>{if(!N.isValidElement(e))return;let i=[...t,r];if(e.type===N.Fragment){n.push.apply(n,xi(e.props.children,i));return}e.type!==_i&&qn(!1),!(!e.props.index||!e.props.children)&&qn(!1);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,loader:e.props.loader,action:e.props.action,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=xi(e.props.children,i)),n.push(a)}),n}function Si(){return Si=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Di(e,t){let n=Ei(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var Oi=[`onClick`,`relative`,`reloadDocument`,`replace`,`state`,`target`,`to`,`preventScrollReset`,`viewTransition`],ki=[`aria-current`,`caseSensitive`,`className`,`end`,`style`,`to`,`viewTransition`,`children`],Ai=`6`;try{window.__reactRouterVersion=Ai}catch{}var ji=N.createContext({isTransitioning:!1}),Mi=N.startTransition;function Ni(e){let{basename:t,children:n,future:r,window:i}=e,a=N.useRef();a.current??(a.current=Kn({window:i,v5Compat:!0}));let o=a.current,[s,c]=N.useState({action:o.action,location:o.location}),{v7_startTransition:l}=r||{},u=N.useCallback(e=>{l&&Mi?Mi(()=>c(e)):c(e)},[c,l]);return N.useLayoutEffect(()=>o.listen(u),[o,u]),N.useEffect(()=>hi(r),[r]),N.createElement(vi,{basename:t,children:n,location:s.location,navigationType:s.action,navigator:o,future:r})}var Pi=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,Fi=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ii=N.forwardRef(function(e,t){let{onClick:n,relative:r,reloadDocument:i,replace:a,state:o,target:s,to:c,preventScrollReset:l,viewTransition:u}=e,d=Ci(e,Oi),{basename:f}=N.useContext(Br),p,m=!1;if(typeof c==`string`&&Fi.test(c)&&(p=c,Pi))try{let e=new URL(window.location.href),t=c.startsWith(`//`)?new URL(e.protocol+c):new URL(c),n=br(t.pathname,f);t.origin===e.origin&&n!=null?c=n+t.search+t.hash:m=!0}catch{}let h=Wr(c,{relative:r}),g=Bi(c,{replace:a,state:o,target:s,preventScrollReset:l,relative:r,viewTransition:u});function _(e){n&&n(e),e.defaultPrevented||g(e)}return N.createElement(`a`,Si({},d,{href:p||h,onClick:m||i?n:_,ref:t,target:s}))}),Li=N.forwardRef(function(e,t){let{"aria-current":n=`page`,caseSensitive:r=!1,className:i=``,end:a=!1,style:o,to:s,viewTransition:c,children:l}=e,u=Ci(e,ki),d=Xr(s,{relative:u.relative}),f=Kr(),p=N.useContext(zr),{navigator:m,basename:h}=N.useContext(Br),g=p!=null&&Hi(d)&&c===!0,_=m.encodeLocation?m.encodeLocation(d).pathname:d.pathname,v=f.pathname,y=p&&p.navigation&&p.navigation.location?p.navigation.location.pathname:null;r||(v=v.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&h&&(y=br(y,h)||y);let b=_!==`/`&&_.endsWith(`/`)?_.length-1:_.length,x=v===_||!a&&v.startsWith(_)&&v.charAt(b)===`/`,S=y!=null&&(y===_||!a&&y.startsWith(_)&&y.charAt(_.length)===`/`),C={isActive:x,isPending:S,isTransitioning:g},w=x?n:void 0,T;T=typeof i==`function`?i(C):[i,x?`active`:null,S?`pending`:null,g?`transitioning`:null].filter(Boolean).join(` `);let E=typeof o==`function`?o(C):o;return N.createElement(Ii,Si({},u,{"aria-current":w,className:T,ref:t,style:E,to:s,viewTransition:c}),typeof l==`function`?l(C):l)}),I;(function(e){e.UseScrollRestoration=`useScrollRestoration`,e.UseSubmit=`useSubmit`,e.UseSubmitFetcher=`useSubmitFetcher`,e.UseFetcher=`useFetcher`,e.useViewTransitionState=`useViewTransitionState`})(I||(I={}));var Ri;(function(e){e.UseFetcher=`useFetcher`,e.UseFetchers=`useFetchers`,e.UseScrollRestoration=`useScrollRestoration`})(Ri||(Ri={}));function zi(e){let t=N.useContext(Rr);return!t&&qn(!1),t}function Bi(e,t){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:s}=t===void 0?{}:t,c=Jr(),l=Kr(),u=Xr(e,{relative:o});return N.useCallback(t=>{Ti(t,n)&&(t.preventDefault(),c(e,{replace:r===void 0?Qn(l)===Qn(u):r,state:i,preventScrollReset:a,relative:o,viewTransition:s}))},[l,c,u,r,i,n,e,a,o,s])}function Vi(e){let t=N.useRef(Ei(e)),n=N.useRef(!1),r=Kr(),i=N.useMemo(()=>Di(r.search,n.current?null:t.current),[r.search]),a=Jr();return[i,N.useCallback((e,t)=>{let r=Ei(typeof e==`function`?e(i):e);n.current=!0,a(`?`+r,t)},[a,i])]}function Hi(e,t){t===void 0&&(t={});let n=N.useContext(ji);n??qn(!1);let{basename:r}=zi(I.useViewTransitionState),i=Xr(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=br(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=br(n.nextLocation.pathname,r)||n.nextLocation.pathname;return _r(i.pathname,o)!=null||_r(i.pathname,a)!=null}var Ui=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},Wi=(e=>e?Ui(e):Ui),Gi=e=>e;function Ki(e,t=Gi){let n=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(n),n}var qi=e=>{let t=Wi(e),n=e=>Ki(t,e);return Object.assign(n,t),n},Ji=(e=>e?qi(e):qi),Yi=`anyllm_admin_token`;function Xi(){try{let e=new URLSearchParams(window.location.search),t=e.get(`token`);if(!t)return null;e.delete(`token`);let n=e.toString(),r=window.location.pathname+(n?`?${n}`:``)+window.location.hash;return window.history.replaceState(null,``,r),t}catch{return null}}function Zi(){let e=Xi();if(e)return Qi(e),e;try{return window.sessionStorage.getItem(Yi)}catch{return null}}function Qi(e){try{window.sessionStorage.setItem(Yi,e)}catch{}}function $i(){try{window.sessionStorage.removeItem(Yi)}catch{}}var ea=Ji(e=>({token:Zi(),login(t){Qi(t),e({token:t})},logout(){$i(),e({token:null})}})),ta=Ji(e=>({status:`disconnected`,lastEvent:null,setStatus:t=>e({status:t}),pushEvent:t=>e({lastEvent:t})})),na=3e4,ra=1e3,L=null,ia=null,aa=0,oa=!1;function sa(){oa=!1,!(L&&(L.readyState===WebSocket.OPEN||L.readyState===WebSocket.CONNECTING))&&la()}function ca(){oa=!0,ia&&clearTimeout(ia),L?.close(),L=null,ta.getState().setStatus(`disconnected`)}function la(){if(oa)return;let e=ea.getState().token;if(!e)return;ta.getState().setStatus(`connecting`);let t=location.protocol===`https:`?`wss:`:`ws:`;L=new WebSocket(`${t}//${location.host}/admin/ws`),L.onopen=()=>{L.send(JSON.stringify({token:e}))},L.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}if(typeof t==`object`&&t&&`status`in t&&t.status===`authenticated`){aa=0,ta.getState().setStatus(`connected`);return}typeof t==`object`&&t&&`type`in t&&ta.getState().pushEvent(t)},L.onclose=()=>{if(oa)return;ta.getState().setStatus(`disconnected`);let e=Math.min(ra*2**aa,na);aa++,ia=setTimeout(la,e)},L.onerror=()=>{L?.close()}}var ua=5,da=4e3,fa=1,pa=Ji(e=>({toasts:[],push({variant:t,message:n,ttlMs:r}){let i=fa++,a=r===void 0?t===`error`?null:da:r;return e(e=>{let r=[...e.toasts,{id:i,variant:t,message:n,ttlMs:a}];return{toasts:r.length>ua?r.slice(-5):r}}),i},dismiss(t){e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))},clear(){e({toasts:[]})}}));function ma(e){return pa.getState().push(e)}function ha(){let e=Promise.resolve();return function(t){let n=e.then(t,t);return e=n.catch(()=>void 0),n}}var ga=ha();async function _a(e,t){let n=await e(`/admin/csrf-token`,{headers:{Authorization:`Bearer ${t()}`}});if(!n.ok)throw Error(`Failed to fetch CSRF token`);let r=await n.json();if(typeof r.csrf_token!=`string`)throw Error(`Failed to fetch CSRF token`);return r.csrf_token}function va(e,t,n){return{Authorization:`Bearer ${t}`,"X-CSRF-Token":e,...n?{"Content-Type":n}:{}}}function ya(e){return e.status===204||e.headers.get(`content-length`)===`0`}async function ba(e,t,n,r,i){let a=async a=>i.fetchImpl(t,{method:e,headers:va(a,i.getToken(),r),body:n}),o=await _a(i.fetchImpl,i.getToken),s=await a(o);if(s.status===403&&(o=await _a(i.fetchImpl,i.getToken),s=await a(o)),await i.handleAuthAndErrors(s),!ya(s))return s.json()}function xa(e){"@babel/helpers - typeof";return xa=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xa(e)}var Sa=o((()=>{}));function Ca(e,t){if(xa(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(xa(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var wa=o((()=>{Sa()}));function Ta(e){var t=Ca(e,`string`);return xa(t)==`symbol`?t:t+``}var Ea=o((()=>{Sa(),wa()}));function Da(e,t,n){return(t=Ta(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}o((()=>{Ea()}))();function Oa(){return ea.getState().token??``}var ka=class extends Error{constructor(e){super(`Rate limited. Retry in ${e}s.`),Da(this,`retryAfterSeconds`,void 0),this.name=`RateLimitError`,this.retryAfterSeconds=e}};function Aa(e){let t=e.headers.get(`retry-after`);if(!t)return 1;let n=Number(t);if(Number.isFinite(n)&&n>0)return Math.ceil(n);let r=Date.parse(t);return Number.isNaN(r)?1:Math.max(1,Math.ceil((r-Date.now())/1e3))}async function ja(e){if(e.status===401)throw ea.getState().logout(),Error(`Unauthorized`);if(e.status===429){let t=Aa(e);throw ma({variant:`warn`,message:`Admin API rate-limited. Retry in ${t}s.`,ttlMs:t*1e3}),new ka(t)}if(!e.ok){let t=await e.text().catch(()=>e.statusText);throw Error(t||`HTTP ${e.status}`)}}async function Ma(e,t){let n=await fetch(e,{...t,headers:{Authorization:`Bearer ${Oa()}`,...t?.headers??{}}});return await ja(n),n.json()}async function Na(e,t,n,r){return ga(()=>ba(e,t,n,r,{fetchImpl:(e,t)=>fetch(e,t),getToken:Oa,handleAuthAndErrors:ja}))}function R(e,t,n){return Na(e,t,n===void 0?void 0:JSON.stringify(n),n===void 0?void 0:`application/json`)}function Pa(e,t){return Na(`POST`,e,t)}function Fa(e=!0){return zn({queryKey:[`status`],queryFn:()=>Ma(`/admin/api/status`),enabled:e,refetchInterval:1e4})}function Ia(){return zn({queryKey:[`metrics`],queryFn:()=>Ma(`/admin/api/metrics`),refetchInterval:5e3,staleTime:0})}function La(e,t){return zn({queryKey:[`observability`,e,t],queryFn:()=>Ma(`/admin/api/observability/overview?window=${e}&backend=${encodeURIComponent(t)}`),refetchInterval:3e4,staleTime:0})}function Ra(e){let t=new URLSearchParams;return t.set(`limit`,String(e.page_size)),t.set(`offset`,String((e.page-1)*e.page_size)),e.backend&&t.set(`backend`,e.backend),e.status&&t.set(`status`,e.status),e.since&&t.set(`since`,e.since),e.until&&t.set(`until`,e.until),e.model&&t.set(`model`,e.model),zn({queryKey:[`requests`,e],queryFn:()=>Ma(`/admin/api/requests?${t}`),staleTime:1/0})}function za(){return zn({queryKey:[`keys`],queryFn:()=>Ma(`/admin/api/keys`).then(e=>e.keys),staleTime:1/0})}function Ba(){let e=F();return Bn({mutationFn:e=>R(`POST`,`/admin/api/keys`,e),onSuccess:()=>{e.invalidateQueries({queryKey:[`keys`]})}})}function Va(){let e=F();return Bn({mutationFn:({id:e,body:t})=>R(`PUT`,`/admin/api/keys/${e}`,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`keys`]})}})}function Ha(){let e=F();return Bn({mutationFn:e=>R(`DELETE`,`/admin/api/keys/${e}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`keys`]})}})}function Ua(){return zn({queryKey:[`backends`],queryFn:()=>Ma(`/admin/api/backends`).then(e=>e.backends),staleTime:1/0})}function Wa(){return zn({queryKey:[`config`],queryFn:()=>Promise.all([Ma(`/admin/api/config`),Ma(`/admin/api/config/overrides`)]).then(([e,t])=>({...e,entries:t.overrides??[],env:{}})),staleTime:1/0})}function Ga(){let e=F();return Bn({mutationFn:e=>R(`PUT`,`/admin/api/config`,e),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]}),ma({variant:`success`,message:`Setting saved — applied live, no restart needed`})}})}function Ka(){let e=F();return Bn({mutationFn:e=>R(`DELETE`,`/admin/api/config/overrides/${encodeURIComponent(e)}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`config`]})}})}function qa(){return zn({queryKey:[`optimizer-model`],queryFn:()=>Ma(`/admin/api/optimizer/model`),refetchInterval:e=>e.state.data?.downloading?2e3:!1})}function Ja(){let e=F();return Bn({mutationFn:()=>R(`POST`,`/admin/api/optimizer/model`),onSuccess:()=>{e.invalidateQueries({queryKey:[`optimizer-model`]}),ma({variant:`success`,message:`Model download started`})}})}function Ya(){return zn({queryKey:[`env`],queryFn:()=>Ma(`/admin/api/env`),staleTime:1/0})}function Xa(){return zn({queryKey:[`models`],queryFn:()=>Ma(`/admin/api/models`),staleTime:1/0})}function Za(){let e=F();return Bn({mutationFn:e=>R(`POST`,`/admin/api/models`,e),onSuccess:()=>{e.invalidateQueries({queryKey:[`models`]})}})}function Qa(){let e=F();return Bn({mutationFn:e=>R(`DELETE`,`/admin/api/models/${encodeURIComponent(e)}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`models`]})}})}function $a(){return Bn({mutationFn:e=>R(`POST`,`/admin/api/models/discover`,e)})}function eo(e){return zn({queryKey:[`audit`,e],queryFn:()=>Ma(`/admin/api/audit?limit=${e.page_size}&offset=${(e.page-1)*e.page_size}`),staleTime:1/0})}function to(e){return zn({queryKey:[`traffic`,e],queryFn:()=>Ma(`/admin/api/traffic?window=${e}`),refetchInterval:3e4,staleTime:0})}function no(){return zn({queryKey:[`uptime`],queryFn:()=>Ma(`/admin/api/uptime`),refetchInterval:3e4,staleTime:0})}function ro(){return Bn({mutationFn:e=>{let t=new FormData;return t.append(`file`,e),Pa(`/admin/api/env/import`,t)}})}function io(){return zn({queryKey:[`catalog-providers`],queryFn:()=>Ma(`/admin/api/catalog/providers`).then(e=>e.providers),staleTime:1/0})}function ao(e){return zn({queryKey:[`catalog-provider-models`,e],queryFn:()=>Ma(`/admin/api/catalog/providers/${encodeURIComponent(e)}/models`),enabled:!!e,staleTime:3e4})}function oo(){return zn({queryKey:[`favorites`],queryFn:()=>Ma(`/admin/api/favorites`).then(e=>e.favorites),staleTime:1/0})}function so(){let e=F();return Bn({mutationFn:({providerId:e,on:t})=>t?R(`POST`,`/admin/api/favorites`,{provider_id:e}):R(`DELETE`,`/admin/api/favorites/${encodeURIComponent(e)}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`favorites`]})}})}function co(){return zn({queryKey:[`managed-backends`],queryFn:()=>Ma(`/admin/api/backends/managed`),staleTime:1/0})}function lo(){let e=F();return Bn({mutationFn:e=>R(`POST`,`/admin/api/backends/managed`,e),onSuccess:()=>{e.invalidateQueries({queryKey:[`managed-backends`]}),e.invalidateQueries({queryKey:[`status`]})}})}function uo(){let e=F();return Bn({mutationFn:({name:e,data:t})=>R(`PUT`,`/admin/api/backends/managed/${e}`,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`managed-backends`]})}})}function fo(){let e=F();return Bn({mutationFn:e=>R(`DELETE`,`/admin/api/backends/managed/${e}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`managed-backends`]}),e.invalidateQueries({queryKey:[`status`]})}})}function po(){return zn({queryKey:[`routes`],queryFn:()=>Ma(`/admin/api/routes`),staleTime:1/0})}function mo(){let e=F();return Bn({mutationFn:e=>R(`POST`,`/admin/api/routes`,e),onSuccess:()=>{e.invalidateQueries({queryKey:[`routes`]})}})}function z(){let e=F();return Bn({mutationFn:({id:e,data:t})=>R(`PUT`,`/admin/api/routes/${e}`,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`routes`]})}})}function B(){let e=F();return Bn({mutationFn:e=>R(`DELETE`,`/admin/api/routes/${e}`),onSuccess:()=>{e.invalidateQueries({queryKey:[`routes`]})}})}function ho(e){return zn({queryKey:[`route-providers`,e],queryFn:()=>Ma(`/admin/api/routes/${e}/providers`),enabled:!!e,staleTime:1/0})}function go(){let e=F();return Bn({mutationFn:({routeId:e,data:t})=>R(`POST`,`/admin/api/routes/${e}/providers`,t),onSuccess:(t,{routeId:n})=>{e.invalidateQueries({queryKey:[`route-providers`,n]}),e.invalidateQueries({queryKey:[`routes`]})}})}function _o(){let e=F();return Bn({mutationFn:({routeId:e,providerId:t,data:n})=>R(`PUT`,`/admin/api/routes/${e}/providers/${t}`,n),onSuccess:(t,{routeId:n})=>{e.invalidateQueries({queryKey:[`route-providers`,n]})}})}function vo(){let e=F();return Bn({mutationFn:({routeId:e,providerId:t})=>R(`DELETE`,`/admin/api/routes/${e}/providers/${t}`),onSuccess:(t,{routeId:n})=>{e.invalidateQueries({queryKey:[`route-providers`,n]}),e.invalidateQueries({queryKey:[`routes`]})}})}function yo(){let e=F();return Bn({mutationFn:({routeId:e,data:t})=>R(`PUT`,`/admin/api/routes/${e}/providers/reorder`,t),onSuccess:(t,{routeId:n})=>{e.invalidateQueries({queryKey:[`route-providers`,n]}),e.invalidateQueries({queryKey:[`routes`]})}})}async function bo(){let e=ea.getState().token??``,t=await fetch(`/admin/api/env/export`,{headers:{Authorization:`Bearer ${e}`}});if(!t.ok)throw Error(`Export failed: HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`.anyllm.env`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function V(...e){let t=[],n=e=>{e&&(typeof e==`string`||typeof e==`number`?t.push(String(e)):Array.isArray(e)&&e.forEach(n))};return e.forEach(n),t.join(` `)}var xo=(0,N.forwardRef)(({glyph:e=`✦`,solid:t,static:n,className:r,...i},a)=>(0,P.jsx)(`span`,{ref:a,"aria-hidden":`true`,className:V(`pui-sparkle`,!n&&`pui-sparkle--blink`,t&&`pui-sparkle--solid`,r),...i,children:e}));xo.displayName=`Sparkle`;var So=(0,N.forwardRef)(({as:e,static:t,className:n,children:r,...i},a)=>(0,P.jsx)(e??`span`,{ref:a,className:V(`pui-gradient-text`,!t&&`pui-gradient-text--animate`,n),...i,children:r}));So.displayName=`GradientText`;var Co=(0,N.forwardRef)(({color:e,static:t,className:n,style:r,...i},a)=>(0,P.jsx)(`span`,{ref:a,"aria-hidden":`true`,className:V(`pui-dot`,!t&&`pui-dot--pulse`,n),style:e?{...r,background:e,color:e}:r,...i}));Co.displayName=`StatusDot`;var wo=new Set([`flash1`,`flash2`,`flash3`,`glow1`,`glow2`,`glow3`]),To=(0,N.forwardRef)(({text:e,animation:t=`wave`,color:n=`glow1`,className:r,style:i,...a},o)=>{let s=wo.has(n),c=s?`pui-quest--${n}`:void 0,l=s?void 0:{color:n};if(t===`wave`){let t=[...e];return(0,P.jsx)(`span`,{ref:o,className:V(`pui-quest`,`pui-quest--wave`,c,r),style:{...l,...i},...a,children:t.map((e,t)=>(0,P.jsx)(`span`,{className:`pui-quest__char`,style:{animationDelay:`${-(t+1)*50}ms`},children:e===` `?`\xA0`:e},t))})}let u=t===`scroll`?`pui-quest__scroll`:`pui-quest__slide`;return(0,P.jsx)(`span`,{ref:o,className:V(`pui-quest`,`pui-quest--${t}`,c,r),style:{...l,...i},...a,children:(0,P.jsx)(`span`,{className:u,children:e})})});To.displayName=`QuestText`;function Eo({variant:e=`glow`,size:t=`md`,sparkle:n,loading:r,block:i,as:a,className:o,children:s,disabled:c,...l},u){let d=a??`button`;return(0,P.jsxs)(d,{ref:u,className:V(`pui-btn`,`pui-btn--${e}`,t!==`md`&&`pui-btn--${t}`,i&&`pui-btn--block`,o),disabled:d===`button`?c||r:void 0,"aria-busy":r||void 0,...l,children:[r?(0,P.jsx)(`span`,{className:`pui-btn__spinner`,"aria-hidden":!0}):null,(0,P.jsx)(`span`,{children:s}),n?(0,P.jsx)(xo,{}):null]})}var Do=(0,N.forwardRef)(Eo),Oo=(0,N.forwardRef)(({hideSparkle:e,trailing:t,className:n,children:r,...i},a)=>(0,P.jsxs)(`div`,{ref:a,className:V(`pui-sticky-banner`,n),...i,children:[!e&&(0,P.jsx)(xo,{}),(0,P.jsx)(`span`,{children:r}),t]}));Oo.displayName=`StickyBanner`;var ko=(0,N.forwardRef)(({icon:e,statusColor:t,className:n,children:r,...i},a)=>(0,P.jsxs)(`span`,{ref:a,className:V(`pui-eyebrow`,n),...i,children:[e===!1?null:e??(0,P.jsx)(Co,{color:t}),(0,P.jsx)(`span`,{children:r})]}));ko.displayName=`EyebrowPill`;function Ao({words:e,typeMs:t=70,deleteMs:n=32,holdMs:r=1500,loop:i=!0,onWordReached:a}){let[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(0),[u,d]=(0,N.useState)(!1),[f,p]=(0,N.useState)(!1),m=(0,N.useRef)({word:o,index:c,isDeleting:u});return m.current={word:o,index:c,isDeleting:u},(0,N.useEffect)(()=>{let o=null,c=!1;if(!e.length)return;let u=()=>{if(c)return;let{word:f,index:h,isDeleting:g}=m.current,_=e[h],v=g?_.slice(0,f.length-1):_.slice(0,f.length+1);if(s(v),!g&&v===_){if(a?.(_,h),!i&&h===e.length-1){p(!0);return}o=setTimeout(()=>{c||(d(!0),o=setTimeout(u,n))},r);return}g&&v===``&&(d(!1),l(t=>(t+1)%e.length)),o=setTimeout(u,g?n:t)};return o=setTimeout(u,t),()=>{c=!0,o&&clearTimeout(o)}},[]),{word:o,index:c,isDeleting:u,isComplete:f}}var jo=(0,N.forwardRef)(({words:e,typeMs:t,deleteMs:n,holdMs:r,loop:i,onWordReached:a,hideCursor:o,cursor:s,renderWord:c,className:l,...u},d)=>{let{word:f,index:p}=Ao({words:e,typeMs:t,deleteMs:n,holdMs:r,loop:i,onWordReached:a});return(0,P.jsxs)(`span`,{ref:d,className:V(`pui-rotator`,l),...u,children:[c?c(f,p):f,!o&&(0,P.jsx)(`span`,{"aria-hidden":`true`,className:V(`pui-rotator__cursor`,s===void 0&&`pui-rotator__cursor--block`,`pui-rotator__cursor--blink`),children:s})]})});jo.displayName=`Rotator`;var Mo=(0,N.forwardRef)(({words:e,intervalMs:t=2200,transitionMs:n=500,direction:r=`up`,gradient:i,className:a,style:o,...s},c)=>{let[l,u]=(0,N.useState)(0);(0,N.useEffect)(()=>{if(!e.length)return;let n=setInterval(()=>u(t=>(t+1)%e.length),t);return()=>clearInterval(n)},[t,e.length]);let d={...o,"--pui-roll-ms":`${n}ms`},f=(l-1+e.length)%e.length;return(0,P.jsxs)(`span`,{ref:c,className:V(`pui-roll`,r===`down`&&`pui-roll--down`,i&&`pui-roll--gradient`,a),style:d,...s,children:[(0,P.jsx)(`span`,{className:`pui-roll__sizer`,"aria-hidden":`true`,children:e[l]}),e.map((e,t)=>(0,P.jsx)(`span`,{className:V(`pui-roll__word`,t===l&&`pui-roll__word--active`,t===f&&l!==f&&`pui-roll__word--past`),"aria-hidden":t===l?void 0:`true`,children:e},t))]})});Mo.displayName=`WordRoll`;var No=(0,N.forwardRef)(({placeholder:e=`Describe what you want to build…`,defaultValue:t,value:n,onChange:r,onSubmit:i,leading:a,ctaLabel:o=`Generate`,hideCta:s,className:c,...l},u)=>{let d=n!==void 0,[f,p]=(0,N.useState)(t??``),m=d?n:f;return(0,P.jsxs)(`form`,{ref:u,className:V(`pui-prompt`,c),onSubmit:e=>{e.preventDefault(),i?.(m)},...l,children:[a===!1?null:(0,P.jsx)(`span`,{className:`pui-prompt__icon`,children:a??(0,P.jsx)(xo,{})}),(0,P.jsx)(`input`,{className:`pui-prompt__input`,type:`text`,placeholder:e,value:m,onChange:e=>{let t=e.target.value;d||p(t),r?.(t)},autoComplete:`off`}),!s&&(0,P.jsx)(Do,{type:`submit`,variant:`glow`,sparkle:!0,children:o})]})});No.displayName=`PromptHero`;var Po=[`GPT-5 Turbo Vision`,`Claude Opus 4.7`,`Gemini 3 Pro`],Fo=(0,N.forwardRef)(({value:e,defaultValue:t=``,onChange:n,onSubmit:r,placeholder:i=`Build me a…`,rows:a=3,models:o=Po,model:s,defaultModel:c,onModelChange:l,onAddContext:u,onVoice:d,hideAddContext:f,hideModel:p,hideVoice:m,hideSend:h,submitOnCmdEnter:g=!0,toolbarExtras:_,className:v,...y},b)=>{let x=e!==void 0,[S,C]=(0,N.useState)(t),w=x?e:S,T=s!==void 0,[E,D]=(0,N.useState)(c??o[0]??``),O=T?s:E,[ee,te]=(0,N.useState)(!1),ne=(0,N.useRef)(null);(0,N.useEffect)(()=>{if(!ee)return;let e=e=>{var t;(t=ne.current)!=null&&t.contains(e.target)||te(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[ee]);let re=e=>{x||C(e),n?.(e)},ie=e=>{T||D(e),l?.(e),te(!1)},ae=e=>{e?.preventDefault(),r?.(w,{model:O})},oe=e=>{g&&e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),ae())};return(0,P.jsxs)(`form`,{ref:b,className:V(`pui-promptbox`,v),onSubmit:ae,...y,children:[(0,P.jsx)(`textarea`,{className:`pui-promptbox__textarea`,value:w,onChange:e=>re(e.target.value),onKeyDown:oe,placeholder:i,rows:a}),(0,P.jsxs)(`div`,{className:`pui-promptbox__toolbar`,children:[!f&&(0,P.jsx)(`button`,{type:`button`,className:`pui-promptbox__iconbtn`,onClick:u,title:`Add context`,"aria-label":`Add context`,children:(0,P.jsx)(Io,{})}),!p&&o.length>0&&(0,P.jsxs)(`div`,{className:`pui-promptbox__model-wrap`,ref:ne,children:[(0,P.jsxs)(`button`,{type:`button`,className:`pui-promptbox__model`,onClick:()=>te(e=>!e),"aria-expanded":ee,"aria-haspopup":`menu`,children:[(0,P.jsx)(`span`,{children:O}),(0,P.jsx)(Lo,{})]}),ee&&(0,P.jsx)(`div`,{className:`pui-promptbox__menu`,role:`menu`,children:o.map(e=>(0,P.jsxs)(`button`,{type:`button`,className:V(`pui-promptbox__menu-item`,e===O&&`pui-promptbox__menu-item--active`),onClick:()=>ie(e),role:`menuitemradio`,"aria-checked":e===O,children:[(0,P.jsx)(`span`,{children:e}),e===O&&(0,P.jsx)(Bo,{})]},e))})]}),(0,P.jsx)(`div`,{className:`pui-promptbox__spacer`}),_,!m&&(0,P.jsx)(`button`,{type:`button`,className:`pui-promptbox__iconbtn`,onClick:d,title:`Voice mode`,"aria-label":`Voice mode`,children:(0,P.jsx)(Ro,{})}),!h&&(0,P.jsx)(`button`,{type:`submit`,className:`pui-promptbox__iconbtn pui-promptbox__send`,title:`Send`,"aria-label":`Send`,children:(0,P.jsx)(zo,{})})]})]})});Fo.displayName=`Prompt`;function Io(){return(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,P.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}function Lo(){return(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`10`,height:`10`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,P.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}function Ro(){return(0,P.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`rect`,{x:`9`,y:`2`,width:`6`,height:`12`,rx:`3`}),(0,P.jsx)(`path`,{d:`M19 10a7 7 0 0 1-14 0`}),(0,P.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`22`})]})}function zo(){return(0,P.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,P.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]})}function Bo(){return(0,P.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,P.jsx)(`polyline`,{points:`20 6 9 17 4 12`})})}var Vo=` .\`'",:;Il!i><~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$`,Ho=[`#a78bfa`,`#ec4899`,`#67e8f9`,`#fbbf24`];function Uo(e,t,n={}){let{cols:r,rows:i,fontSize:a=11,fontFamily:o=`JetBrains Mono, ui-monospace, monospace`,charRamp:s=Vo,colorful:c=!1,palette:l,baseOpacity:u=1,reactive:d=!0,rippleStrength:f=1.4,rippleRadius:p=6,spotlightOpacity:m,spotlightRadius:h=8,frameMs:g=50}=n,_=(0,N.useMemo)(()=>l??(c?Ho:null),[l,c]);(0,N.useEffect)(()=>{let n=e.current,c=t.current;if(!n||!c)return;let l=n.getContext(`2d`);if(!l)return;let v=0,y=0,b=0,x=0,S=0,C=0,w=new Float32Array,T=1,E={x:-9999,y:-9999},D=()=>{w=new Float32Array(b*x);for(let e=0;e{let e=c.getBoundingClientRect();e.width===0||e.height===0||(T=Math.min(window.devicePixelRatio||1,2),n.width=Math.max(1,Math.floor(e.width*T)),n.height=Math.max(1,Math.floor(e.height*T)),l.setTransform(T,0,0,T,0,0),l.font=`${a}px ${o}`,l.textBaseline=`top`,S=l.measureText(`M`).width||a*.6,C=a*1.15,b=r??Math.max(1,Math.floor(e.width/S)),x=i??Math.max(1,Math.floor(e.height/C)),r!==void 0&&(S=e.width/b),i!==void 0&&(C=e.height/x),D())},ee=e=>{if(e-y=r.left-24&&E.x<=r.right+24&&E.y>=r.top-24&&E.y<=r.bottom+24;l.clearRect(0,0,r.width,r.height);let c=s.length-1,T=typeof m==`number`&&m!==u,D=h*h*2;for(let e=0;e1&&(te=1)}if(te<=.01)continue;let ne=`#c8c8d4`;if(_&&_.length){let r=(n*.1+e*.07+t*.12)%_.length;ne=_[Math.floor(Math.abs(r))%_.length]}l.globalAlpha=te,l.fillStyle=ne,l.fillText(ee,n*S,e*C)}l.globalAlpha=1,v=requestAnimationFrame(ee)},te=e=>{E.x=e.clientX,E.y=e.clientY},ne=new ResizeObserver(O);return ne.observe(c),O(),d&&window.addEventListener(`mousemove`,te,{passive:!0}),v=requestAnimationFrame(ee),()=>{cancelAnimationFrame(v),ne.disconnect(),d&&window.removeEventListener(`mousemove`,te)}},[e,t,r,i,a,o,s,_,u,d,f,p,m,h,g])}var Wo=(0,N.forwardRef)(({variant:e=`panel`,cols:t,rows:n,fontSize:r,fontFamily:i,charRamp:a,colorful:o,palette:s,baseOpacity:c,reactive:l,rippleStrength:u,rippleRadius:d,spotlightOpacity:f,spotlightRadius:p,frameMs:m,className:h,...g},_)=>{let v=(0,N.useRef)(null),y=(0,N.useRef)(null);return Uo(y,v,{cols:t,rows:n,fontSize:r,fontFamily:i,charRamp:a,colorful:o,palette:s,baseOpacity:c,reactive:l,rippleStrength:u,rippleRadius:d,spotlightOpacity:f,spotlightRadius:p,frameMs:m}),(0,P.jsx)(`div`,{ref:e=>{v.current=e,typeof _==`function`?_(e):_&&(_.current=e)},className:V(`pui-ascii`,e===`panel`&&`pui-ascii--panel`,h),"aria-hidden":`true`,...g,children:(0,P.jsx)(`canvas`,{ref:y})})});Wo.displayName=`AsciiHero`;var Go=`circle(0px at -9999px -9999px)`,Ko=(0,N.forwardRef)(({text_default:e,text_reveal:t,pattern:n=`0 1 0 1 `,pattern_size_default:r=14,pattern_size_reveal:i=22,scopeSize:a=320,fontSize:o,fontFamily:s,className:c,style:l,...u},d)=>{let f=(0,N.useRef)(null),p=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=f.current,t=p.current;if(!e||!t)return;let n=a/2,r=0,i=0,o=0,s=!1,c=()=>{if(r=0,!s)return;s=!1;let e=`circle(${n}px at ${i}px ${o}px)`;t.style.clipPath=e,t.style.webkitClipPath=e},l=t=>{let n=e.getBoundingClientRect();i=t.clientX-n.left,o=t.clientY-n.top,s=!0,r||(r=requestAnimationFrame(c))},u=()=>{r&&(cancelAnimationFrame(r),r=0,s=!1),t.style.clipPath=Go,t.style.webkitClipPath=Go};return e.addEventListener(`pointermove`,l),e.addEventListener(`pointerleave`,u),e.addEventListener(`pointercancel`,u),()=>{e.removeEventListener(`pointermove`,l),e.removeEventListener(`pointerleave`,u),e.removeEventListener(`pointercancel`,u),r&&cancelAnimationFrame(r)}},[a]);let m=e=>{f.current=e,typeof d==`function`?d(e):d&&(d.current=e)},h=(0,N.useMemo)(()=>n.repeat(40),[n]),g=(0,N.useMemo)(()=>Array.from({length:40},(e,t)=>t),[]),_=e=>(0,P.jsx)(`div`,{className:`pui-goldeneye__pattern`,style:{fontSize:`${e}px`},children:g.map(e=>(0,P.jsx)(`div`,{className:`pui-goldeneye__pattern-row`,children:h},e))}),v={...s?{"--pui-goldeneye-font":s}:{},...o==null?{}:{"--pui-goldeneye-headline-size":typeof o==`number`?`${o}px`:o}};return(0,P.jsxs)(`div`,{ref:m,className:V(`pui-goldeneye`,c),style:{...v,...l},...u,children:[(0,P.jsxs)(`div`,{className:`pui-goldeneye__base`,children:[_(r),(0,P.jsx)(`div`,{className:`pui-goldeneye__headline`,children:e})]}),(0,P.jsxs)(`div`,{ref:p,className:`pui-goldeneye__scope`,"aria-hidden":`true`,style:{clipPath:Go,WebkitClipPath:Go},children:[_(i),(0,P.jsx)(`div`,{className:`pui-goldeneye__headline`,children:t})]})]})});Ko.displayName=`Goldeneye`;var qo=[{color:`rgba(124,58,237,0.45)`,x:20,y:30,size:60},{color:`rgba(236,72,153,0.35)`,x:80,y:25,size:50},{color:`rgba(6,182,212,0.30)`,x:50,y:80,size:50}],Jo=(0,N.forwardRef)(({blobs:e=qo,blur:t=50,static:n,animated:r,repulsion:i=.18,className:a,style:o,...s},c)=>{let l=(0,N.useRef)([]);(0,N.useEffect)(()=>{if(!r)return;let t=e.map(e=>({x:e.x,y:e.y,homeX:e.x,homeY:e.y,size:e.size??50,vx:(Math.random()-.5)*.06,vy:(Math.random()-.5)*.06})),n=0,a=()=>{for(let e=0;e.001){let e=(l-c)/l*i;n.vx+=o/c*e,n.vy+=s/c*e}}n.vx+=(Math.random()-.5)*.012,n.vy+=(Math.random()-.5)*.012,n.x+=n.vx,n.y+=n.vy,n.x<-10&&(n.x=-10,n.vx=Math.abs(n.vx)*.6),n.x>110&&(n.x=110,n.vx=-Math.abs(n.vx)*.6),n.y<-10&&(n.y=-10,n.vy=Math.abs(n.vy)*.6),n.y>110&&(n.y=110,n.vy=-Math.abs(n.vy)*.6);let r=l.current[e];r&&(r.style.left=`${n.x}%`,r.style.top=`${n.y}%`)}n=requestAnimationFrame(a)};return n=requestAnimationFrame(a),()=>cancelAnimationFrame(n)},[r,e,i]);let u={...o,filter:`blur(${t}px) saturate(140%)`};return(0,P.jsx)(`div`,{ref:c,"aria-hidden":`true`,className:V(`pui-aurora`,!n&&!r&&`pui-aurora--drift`,a),style:u,...s,children:e.map((e,t)=>{let n=e.size??50;return(0,P.jsx)(`div`,{ref:e=>{l.current[t]=e},className:`pui-aurora__blob`,style:{position:`absolute`,left:`${e.x}%`,top:`${e.y}%`,width:`${n}%`,height:`${n}%`,background:`radial-gradient(circle at center, ${e.color} 0%, transparent 70%)`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,borderRadius:`50%`}},t)})})});Jo.displayName=`Aurora`;var Yo=(0,N.forwardRef)(({density:e=70,speed:t=.4,linkDistance:n=140,colors:r=[`#a78bfa`,`#f0abfc`,`#67e8f9`],linkColor:i=`#7c3aed`,hoverDistance:a=200,hoverGravity:o=.005,hoverBrighten:s=.8,baseOpacity:c=.45,overscan:l=80,className:u,...d},f)=>{let p=(0,N.useRef)(null),m=(0,N.useRef)(null);return(0,N.useEffect)(()=>{let u=p.current,d=m.current,f=d.getContext(`2d`);if(!f)return;let h=0,g=0,_=1,v={x:-9999,y:-9999},y=0,b=[],x=()=>{let n=-l,i=h+l,a=-l,o=g+l;b=Array.from({length:e},()=>({x:n+Math.random()*(i-n),y:a+Math.random()*(o-a),vx:(Math.random()-.5)*t*2,vy:(Math.random()-.5)*t*2,r:1+Math.random()*1.6,color:r[Math.floor(Math.random()*r.length)]}))},S=()=>{let e=u.getBoundingClientRect();_=Math.min(window.devicePixelRatio||1,2),h=e.width,g=e.height,d.width=h*_,d.height=g*_,d.style.width=`${h}px`,d.style.height=`${g}px`,f.setTransform(_,0,0,_,0,0),x()},C=()=>{f.clearRect(0,0,h,g);let e=-l,t=h+l,r=-l,u=g+l,d=v.x>-9e3;for(let n of b)if(n.x+=n.vx,n.y+=n.vy,(n.xt)&&(n.vx*=-1),(n.yu)&&(n.vy*=-1),a>0&&o>0&&d){let e=v.x-n.x,t=v.y-n.y,r=Math.hypot(e,t);if(r{if(!d||a<=0||s<=0)return 0;let n=Math.hypot(v.x-e,v.y-t);return n>=a?0:(1-n/a)*s};f.lineWidth=1;for(let e=0;e{let t=u.getBoundingClientRect();v.x=e.clientX-t.left,v.y=e.clientY-t.top},T=()=>{v.x=-9999,v.y=-9999},E=new ResizeObserver(S);return E.observe(u),S(),u.addEventListener(`mousemove`,w),u.addEventListener(`mouseleave`,T),y=requestAnimationFrame(C),()=>{cancelAnimationFrame(y),E.disconnect(),u.removeEventListener(`mousemove`,w),u.removeEventListener(`mouseleave`,T)}},[e,t,n,a,o,s,c,l,r,i]),(0,P.jsx)(`div`,{ref:e=>{p.current=e,typeof f==`function`?f(e):f&&(f.current=e)},"aria-hidden":`true`,className:V(`pui-node-graph`,u),...d,children:(0,P.jsx)(`canvas`,{ref:m})})});Yo.displayName=`NodeGraphBackground`;function Xo(e,t){if(e.startsWith(`#`)){let n,r,i;return e.length===4?(n=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16),i=parseInt(e[3]+e[3],16)):(n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16)),`rgba(${n},${r},${i},${t})`}return e}var Zo=(0,N.forwardRef)(({count:e=18,glyphs:t=[`✦`,`✧`,`✶`,`✺`,`✹`,`·`],durationS:n=[8,18],sizeRange:r=[8,20],className:i,...a},o)=>{let s=(0,N.useMemo)(()=>Array.from({length:e},()=>({glyph:t[Math.floor(Math.random()*t.length)],left:Math.random()*100,duration:n[0]+Math.random()*(n[1]-n[0]),delay:Math.random()*n[1],size:r[0]+Math.random()*(r[1]-r[0]),opacity:.4+Math.random()*.5})),[e,t,n,r]);return(0,P.jsx)(`div`,{ref:o,"aria-hidden":`true`,className:V(`pui-sparkle-field`,i),...a,children:s.map((e,t)=>(0,P.jsx)(`span`,{className:`pui-sparkle-field__item`,style:{left:`${e.left}%`,fontSize:`${e.size}px`,"--pui-sparkle-peak":e.opacity.toFixed(2),animationDuration:`${e.duration}s`,animationDelay:`${e.delay}s`},children:e.glyph},t))})});Zo.displayName=`FloatingSparkles`;var Qo=(0,N.forwardRef)(({breathing:e,glowOnHover:t=!0,className:n,children:r,...i},a)=>(0,P.jsx)(`article`,{ref:a,className:V(`pui-glass-card`,e&&`pui-glass-card--breathing`,t&&`pui-glass-card--glow-hover`,n),...i,children:r}));Qo.displayName=`GlassCard`;var $o=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`div`,{ref:n,className:V(`pui-glass-card__icon`,e),...t}));$o.displayName=`GlassCard.Icon`;var es=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`h3`,{ref:n,className:V(`pui-glass-card__title`,e),...t}));es.displayName=`GlassCard.Title`;var ts=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`p`,{ref:n,className:V(`pui-glass-card__body`,e),...t}));ts.displayName=`GlassCard.Body`;var ns=(0,N.forwardRef)(({className:e,children:t,...n},r)=>(0,P.jsxs)(`a`,{ref:r,className:V(`pui-glass-card__link`,e),...n,children:[(0,P.jsx)(`span`,{children:t}),(0,P.jsx)(`span`,{className:`pui-arrow`,children:`→`})]}));ns.displayName=`GlassCard.Link`;var rs=Object.assign(Qo,{Icon:$o,Title:es,Body:ts,Link:ns}),is=(0,N.forwardRef)(({filename:e,tokens:t,loop:n=!0,charMs:r=[14,42],thinkingLabel:i=`AI is writing…`,className:a,children:o,...s},c)=>(0,P.jsx)(`div`,{ref:c,"data-theme":`dark`,className:V(`pui-ide`,a),...s,children:o??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(as,{filename:e,thinking:i}),(0,P.jsx)(os,{tokens:t??[],loop:n,charMs:r})]})}));is.displayName=`MockIDE`;var as=(0,N.forwardRef)(({filename:e,thinking:t,className:n,children:r,...i},a)=>(0,P.jsxs)(`div`,{ref:a,className:V(`pui-ide__chrome`,n),...i,children:[(0,P.jsx)(`span`,{className:`pui-ide__dot pui-ide__dot--red`}),(0,P.jsx)(`span`,{className:`pui-ide__dot pui-ide__dot--yellow`}),(0,P.jsx)(`span`,{className:`pui-ide__dot pui-ide__dot--green`}),e&&(0,P.jsx)(`span`,{className:`pui-ide__tab`,children:e}),r,t!==!1&&(0,P.jsxs)(`span`,{className:`pui-ide__thinking`,children:[(0,P.jsx)(`span`,{className:`pui-spinner`}),(0,P.jsx)(`span`,{children:t})]})]}));as.displayName=`MockIDE.Chrome`;var os=(0,N.forwardRef)(({tokens:e,loop:t=!0,charMs:n=[14,42],className:r,...i},a)=>{let o=(0,N.useRef)(null),s=a??o,[c,l]=(0,N.useState)(0);return(0,N.useEffect)(()=>{let r=s.current;if(!r||!e.length)return;let i=!1,a=null,o=0,c=0,u=``,d=e=>e.replace(/&/g,`&`).replace(//g,`>`),f=()=>{if(i)return;if(o>=e.length){t&&(a=setTimeout(()=>{o=0,c=0,r.innerHTML=u,l(e=>e+1),f()},3e3));return}let s=e[o];if(c+=1,c>s.c.length){o+=1,c=0,f();return}let p=``;for(let t=0;t${d(n.c)}`:d(n.c)}let m=s.c.slice(0,c);p+=s.cls?`${d(m)}`:d(m),p+=u,r.innerHTML=p;let[h,g]=n,_=h+Math.random()*(g-h)+(m.endsWith(` -`)?120:0);a=setTimeout(f,_)};return r.innerHTML=u,f(),()=>{i=!0,a&&clearTimeout(a)}},[e,t,n,s,c]),(0,P.jsx)(`pre`,{ref:s,className:V(`pui-ide__body`,r),...i})});os.displayName=`MockIDE.Body`,Object.assign(is,{Chrome:as,Body:os});var ss=(0,N.forwardRef)(({role:e,agent:t,thinking:n,icon:r,className:i,children:a,...o},s)=>(0,P.jsxs)(`div`,{ref:s,className:V(`pui-bubble`,e===`user`?`pui-bubble--user`:`pui-bubble--ai`,i),...o,children:[e===`ai`&&(t||n!==!1||r!==!1)&&(0,P.jsxs)(`div`,{className:`pui-bubble__meta`,children:[r===!1?null:r??(0,P.jsx)(xo,{}),t&&(0,P.jsx)(`span`,{children:t}),n!==!1&&(0,P.jsxs)(`span`,{className:`pui-bubble__thinking-pill`,children:[(0,P.jsx)(`span`,{className:`pui-spinner pui-spinner--sm`}),(0,P.jsx)(`span`,{children:n??`thinking…`})]})]}),(0,P.jsx)(`div`,{className:`pui-bubble__stream`,children:a})]}));ss.displayName=`ChatBubble`;var cs=e=>e.split(/(\s+)/);function ls({text:e,speedMs:t=[18,80],tokenize:n=cs,loop:r=!1,loopDelayMs:i=6e3,onComplete:a}){let[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(!1),u=(0,N.useRef)(a);return u.current=a,(0,N.useEffect)(()=>{let a=!1,o=null,c=n(e),d=()=>Array.isArray(t)?t[0]+Math.random()*(t[1]-t[0]):t,f=()=>{let e=0,t=``,n=()=>{var p;if(!a){if(e>=c.length){l(!0),(p=u.current)==null||p.call(u),r&&(o=setTimeout(()=>{a||(l(!1),s(``),f())},i));return}t+=c[e],e+=1,s(t),o=setTimeout(n,d())}};n()};return f(),()=>{a=!0,o&&clearTimeout(o)}},[]),{output:o,isStreaming:!c,isComplete:c}}var us=(0,N.forwardRef)(({text:e,speedMs:t,tokenize:n,loop:r,loopDelayMs:i,onComplete:a,hideCaret:o,className:s,...c},l)=>{let{output:u,isStreaming:d}=ls({text:e,speedMs:t,tokenize:n,loop:r,loopDelayMs:i,onComplete:a});return(0,P.jsxs)(`span`,{ref:l,className:V(s),...c,children:[u,!o&&d&&(0,P.jsx)(`span`,{className:`pui-bubble__stream-caret`})]})});us.displayName=`TokenStream`;var ds=[`·`,`✢`,`✳`,`✶`,`✻`,`✽`],fs=`Accomplishing.Actioning.Actualizing.Architecting.Baking.Beaming.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Bunning.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Dilly-dallying.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Gesticulating.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Mustering.Musing.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzle-dazzling.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Sautéing.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Sock-hopping.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Topsy-turvying.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`);function ps(e){return e[Math.floor(Math.random()*e.length)]}var ms=(0,N.forwardRef)(({verbs:e=fs,glyphs:t=ds,glyphInterval:n=250,verbInterval:r,ellipsis:i=`…`,info:a,glyphColor:o,className:s,...c},l)=>{let[u,d]=(0,N.useState)(0),[f,p]=(0,N.useState)(()=>e.length?ps(e):``);(0,N.useEffect)(()=>{if(!t.length)return;let e=setInterval(()=>{d(e=>(e+1)%t.length)},n);return()=>clearInterval(e)},[n,t.length]),(0,N.useEffect)(()=>{if(r==null||!e.length)return;let t=setInterval(()=>{p(ps(e))},r);return()=>clearInterval(t)},[e,r]);let m=f;return(0,P.jsxs)(`span`,{ref:l,className:V(`pui-wibble`,s),...c,children:[(0,P.jsx)(`span`,{className:`pui-wibble__glyph`,"aria-hidden":`true`,style:o?{color:o}:void 0,children:t[u]??``}),(0,P.jsxs)(`span`,{className:`pui-wibble__verb`,children:[m,i]}),a!=null&&a!==!1&&(0,P.jsxs)(`span`,{className:`pui-wibble__info`,children:[`(`,a,`)`]})]})});ms.displayName=`WibblingSpinner`;var hs=(0,N.forwardRef)(({label:e=`Ask AI`,open:t,defaultOpen:n,onOpenChange:r,popover:i,className:a,onClick:o,...s},c)=>{let l=t!==void 0,[u,d]=(0,N.useState)(n??!1),f=l?!!t:u,p=()=>{let e=!f;l||d(e),r?.(e)},m=()=>{l||d(!1),r?.(!1)};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{ref:c,className:V(`pui-fab`,a),onClick:e=>{o?.(e),p()},"aria-expanded":f,...s,children:[(0,P.jsx)(xo,{}),(0,P.jsx)(`span`,{children:e})]}),f&&(0,P.jsx)(`div`,{role:`dialog`,className:`pui-fab-popover`,children:(0,P.jsx)(gs.Provider,{value:m,children:i})})]})});hs.displayName=`ChatFAB`;var gs=(0,N.createContext)(()=>{}),_s=(0,N.forwardRef)(({onClose:e,className:t,children:n,...r},i)=>{let a=(0,N.useContext)(gs);return(0,P.jsxs)(`div`,{ref:i,className:V(`pui-fab-popover__header`,t),...r,children:[(0,P.jsx)(xo,{}),(0,P.jsx)(`span`,{children:n}),(0,P.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`pui-fab-popover__close`,onClick:e??a,children:`×`})]})});_s.displayName=`ChatFAB.Header`;var vs=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`div`,{ref:n,className:V(`pui-fab-popover__body`,e),...t}));vs.displayName=`ChatFAB.Body`,Object.assign(hs,{Header:_s,Body:vs});var ys=(0,N.forwardRef)(({logos:e,speed:t=40,gap:n=56,fade:r=!0,pauseOnHover:i,className:a,style:o,...s},c)=>{let l={...o??{},"--pui-marquee-speed":`${t}s`,"--pui-marquee-gap":`${n}px`},u=(e,t)=>e.kind===`img`?(0,P.jsx)(`span`,{className:`pui-marquee__item`,children:(0,P.jsx)(`img`,{src:e.src,alt:e.alt??``})},`a${t}`):(0,P.jsx)(`span`,{className:`pui-marquee__item`,children:e.node},e.key??`b${t}`);return(0,P.jsx)(`div`,{ref:c,className:V(`pui-marquee`,r&&`pui-marquee--fade`,i&&`pui-marquee--paused-on-hover`,a),style:l,"aria-label":`Trusted by`,...s,children:(0,P.jsxs)(`div`,{className:`pui-marquee__track`,children:[e.map(u),e.map((t,n)=>u(t,n+e.length))]})})});ys.displayName=`LogoMarquee`;var bs=(0,N.forwardRef)(({heading:e,logos:t,className:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-logo-row`,n),...r,children:[e&&(0,P.jsx)(`p`,{className:`pui-logo-row__heading`,children:e}),(0,P.jsx)(`div`,{className:`pui-logo-row__items`,children:t.map((e,t)=>e.kind===`img`?(0,P.jsx)(`img`,{src:e.src,alt:e.alt??``},t):(0,P.jsx)(`span`,{className:`pui-logo-row__text`,children:e.node},e.key??t))})]}));bs.displayName=`LogoRow`;var xs=(0,N.forwardRef)(({rows:e,intensity:t=240,startDirection:n=`left`,gap:r=12,fade:i=!0,gradient:a=!1,static:o,className:s,style:c,...l},u)=>{let d=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=d.current;if(!e||o||window.matchMedia?.call(window,`(prefers-reduced-motion: reduce)`).matches)return;let n=0,r=()=>{n=0;let r=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,a=(i-r.top)/(i+r.height),o=(Math.min(1,Math.max(0,a))-.5)*t;e.style.setProperty(`--pui-slip`,`${o}px`)},i=()=>{n||(n=requestAnimationFrame(r))};return r(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i,{passive:!0}),()=>{n&&cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[t,o]);let f=e=>{d.current=e,typeof u==`function`?u(e):u&&(u.current=e)},p=n===`left`?-1:1,m={...c??{},"--pui-slip-gap":`${r}px`};return(0,P.jsx)(`div`,{ref:f,className:V(`pui-slippy`,i&&`pui-slippy--fade`,s),style:m,"aria-label":`Featured terms`,...l,children:e.map((e,t)=>(0,P.jsx)(`div`,{className:`pui-slippy__row`,style:{"--pui-slip-dir":t%2==0?p:-p},children:e.map((e,n)=>{let r=typeof e==`string`?{label:e}:e;return(0,P.jsx)(`span`,{className:V(`pui-slippy__word`,(a||typeof e==`object`&&e.gradient)&&`pui-slippy__word--gradient`),children:r.label},typeof e==`object`&&e.key||`${t}-${n}`)})},t))})});xs.displayName=`SlippyWords`;function Ss({target:e,durationMs:t=1800,from:n=0,ease:r=e=>1-(1-e)**3}){let[i,a]=(0,N.useState)(n);return(0,N.useEffect)(()=>{let i=0,o=performance.now(),s=c=>{let l=Math.min(1,(c-o)/t);a(Math.floor(n+(e-n)*r(l))),l<1&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>cancelAnimationFrame(i)},[]),i}var Cs=(0,N.forwardRef)(({target:e,durationMs:t,from:n,ease:r,format:i=e=>e.toLocaleString(),className:a,...o},s)=>{let c=Ss({target:e,durationMs:t,from:n,ease:r});return(0,P.jsx)(`span`,{ref:s,className:V(`pui-stat`,a),...o,children:i(c)})});Cs.displayName=`StatCounter`;var ws=(0,N.forwardRef)(({icon:e,iconNode:t,title:n,subtitle:r,className:i,...a},o)=>(0,P.jsxs)(`a`,{ref:o,className:V(`pui-community`,i),...a,children:[t??(e&&(0,P.jsx)(`img`,{className:`pui-community__icon`,src:e,alt:``})),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`pui-community__top`,children:n}),(0,P.jsx)(`div`,{className:`pui-community__bottom`,children:r})]})]}));ws.displayName=`CommunityBadge`;var Ts=(0,N.forwardRef)(({featured:e,className:t,...n},r)=>(0,P.jsx)(`article`,{ref:r,className:V(`pui-price`,e&&`pui-price--featured`,t),...n}));Ts.displayName=`PricingCard`;var Es=(0,N.forwardRef)(({hideSparkle:e,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-price__flag`,t),...r,children:[!e&&(0,P.jsx)(xo,{solid:!0}),(0,P.jsx)(`span`,{children:n})]}));Es.displayName=`PricingCard.Flag`;var Ds=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`div`,{ref:n,className:V(`pui-price__tier`,e),...t}));Ds.displayName=`PricingCard.Tier`;var Os=(0,N.forwardRef)(({unit:e,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-price__amount`,t),...r,children:[n,e&&(0,P.jsx)(`span`,{className:`pui-price__amount-unit`,children:e})]}));Os.displayName=`PricingCard.Amount`;var ks=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`p`,{ref:n,className:V(`pui-price__blurb`,e),...t}));ks.displayName=`PricingCard.Blurb`;var As=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`ul`,{ref:n,className:V(`pui-price__features`,e),...t}));As.displayName=`PricingCard.Features`;var js=(0,N.forwardRef)(({className:e,children:t,...n},r)=>(0,P.jsx)(`a`,{ref:r,className:V(`pui-btn pui-btn--glow pui-btn--block`,e),...n,children:(0,P.jsx)(`span`,{children:t})}));js.displayName=`PricingCard.CTA`,Object.assign(Ts,{Flag:Es,Tier:Ds,Amount:Os,Blurb:ks,Features:As,CTA:js});var Ms=(0,N.forwardRef)(({before:e,after:t,brand:n,beforeLabel:r=`Before`,afterLabel:i=`After`,className:a,children:o,...s},c)=>(0,P.jsx)(`div`,{ref:c,className:V(`pui-ba`,a),...s,children:o??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Ns,{label:r,children:(0,P.jsx)(`ul`,{children:(e??[]).map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})}),(0,P.jsx)(Fs,{brand:n}),(0,P.jsx)(Ps,{label:i,children:(0,P.jsx)(`ul`,{children:(t??[]).map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})})]})}));Ms.displayName=`BeforeAfter`;var Ns=(0,N.forwardRef)(({label:e=`Before`,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-ba__panel pui-ba__panel--before`,t),...r,children:[(0,P.jsx)(`div`,{className:`pui-ba__tag`,children:e}),n]}));Ns.displayName=`BeforeAfter.Before`;var Ps=(0,N.forwardRef)(({label:e=`After`,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-ba__panel pui-ba__panel--after`,t),...r,children:[(0,P.jsx)(`div`,{className:`pui-ba__tag`,children:e}),n]}));Ps.displayName=`BeforeAfter.After`;var Fs=(0,N.forwardRef)(({brand:e,className:t,...n},r)=>(0,P.jsxs)(`div`,{ref:r,className:V(`pui-ba__arrow`,t),...n,children:[(0,P.jsx)(xo,{}),e?(0,P.jsxs)(`span`,{children:[`with `,e]}):(0,P.jsx)(`span`,{children:`after`}),(0,P.jsx)(`span`,{children:`→`})]}));Fs.displayName=`BeforeAfter.Arrow`,Object.assign(Ms,{Before:Ns,After:Ps,Arrow:Fs});var Is=(0,N.forwardRef)(({placeholder:e=`you@startup.ai`,defaultValue:t=``,ctaLabel:n=`Notify me`,leading:r,footnote:i,onSubmit:a,className:o,...s},c)=>{let[l,u]=(0,N.useState)(t);return(0,P.jsxs)(`div`,{className:V(`pui-waitlist-wrap`,o),children:[(0,P.jsxs)(`form`,{ref:c,className:`pui-waitlist`,onSubmit:e=>{e.preventDefault(),a?.(l)},...s,children:[r===!1?null:(0,P.jsx)(`span`,{className:`pui-waitlist__icon`,"aria-hidden":`true`,children:r??(0,P.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,width:`18`,height:`18`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),(0,P.jsx)(`path`,{d:`M3 7l9 6 9-6`})]})}),(0,P.jsx)(`input`,{className:`pui-waitlist__input`,type:`email`,placeholder:e,value:l,onChange:e=>u(e.target.value)}),(0,P.jsx)(Do,{type:`submit`,variant:`solid`,children:n})]}),i&&(0,P.jsx)(`div`,{className:`pui-waitlist__footnote`,children:i})]})});Is.displayName=`WaitlistForm`;function Ls({open:e,defaultOpen:t=!1,onOpenChange:n,timer:r=0,title:i,children:a,closeLabel:o=`Maybe later`,closeOnEscape:s=!1,closeOnBackdrop:c=!1,container:l,className:u}){let d=e!==void 0,[f,p]=(0,N.useState)(t),m=d?e:f,h=e=>{d||p(e),n?.(e)};if((0,N.useEffect)(()=>{if(r<=0||m)return;let e=setTimeout(()=>h(!0),r);return()=>clearTimeout(e)},[]),(0,N.useEffect)(()=>{if(!m||!s)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),h(!1))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m,s]),(0,N.useEffect)(()=>{if(!m)return;let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||[`[`,`]`,`j`,`k`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[m]),(0,N.useEffect)(()=>{if(!m)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[m]),!m)return null;let g=l??(typeof document<`u`?document.body:null);return g?(0,Vn.createPortal)((0,P.jsxs)(`div`,{className:`pui-popover-overlay`,role:`dialog`,"aria-modal":`true`,children:[(0,P.jsx)(`div`,{className:`pui-popover-backdrop`,"aria-hidden":`true`,onClick:c?()=>h(!1):void 0}),(0,P.jsxs)(`div`,{className:V(`pui-popover`,u),children:[i&&(0,P.jsx)(`div`,{className:`pui-popover__title`,children:i}),(0,P.jsx)(`div`,{className:`pui-popover__body`,children:a}),o!==!1&&(0,P.jsx)(`button`,{type:`button`,className:`pui-popover__dismiss`,onClick:()=>h(!1),children:o})]})]}),g):null}Ls.displayName=`Popover`;var Rs={primary:`wave`,secondary:`ghost`,danger:`ghost`,icon:`ghost`},zs={sm:`sm`,md:`md`};function H({tone:e=`secondary`,size:t=`md`,loading:n=!1,block:r=!1,className:i,children:a,disabled:o,...s}){return(0,P.jsx)(Do,{variant:Rs[e],size:zs[t],loading:n,block:r,className:[`admin-button`,`admin-button-${e}`,i].filter(Boolean).join(` `),disabled:o||n,...s,children:a})}var Bs={ok:`var(--ok)`,warn:`var(--warn)`,err:`var(--err)`,dim:`var(--text-3)`};function Vs({status:e,pulse:t}){return(0,P.jsx)(Co,{color:Bs[e],static:!t,className:`admin-status-dot`})}function U({children:e,className:t,breathing:n=!1,glowOnHover:r=!1,...i}){return(0,P.jsx)(rs,{breathing:n,glowOnHover:r,className:[`admin-surface`,t].filter(Boolean).join(` `),...i,children:e})}function Hs({label:e=`Loading`,info:t,className:n}){return(0,P.jsx)(ms,{verbs:[e],glyphs:[`.`,`o`,`O`,`o`],glyphInterval:220,ellipsis:`...`,info:t,glyphColor:`var(--accent)`,className:[`admin-loading`,n].filter(Boolean).join(` `)})}function Us({value:e,precision:t=0,durationMs:n=450,className:r,format:i}){let a=10**t,o=Math.round(e*a),s=(0,N.useRef)(o),c=s.current;return(0,N.useEffect)(()=>{s.current=o},[o]),(0,P.jsx)(Cs,{target:o,from:c,durationMs:n,className:r,format:e=>{let t=e/a;return i?i(t):t.toLocaleString()}},o)}function Ws(){let e=ea(e=>e.login),[t,n]=(0,N.useState)(``),[r,i]=(0,N.useState)(!1);async function a(t){t.preventDefault();let r=t.currentTarget.elements.namedItem(`token`).value.trim();if(r){i(!0),n(``);try{if(!(await fetch(`/admin/api/metrics`,{headers:{Authorization:`Bearer ${r}`}})).ok)throw Error(`Invalid token`);e(r)}catch{n(`Invalid token`)}finally{i(!1)}}}return(0,P.jsxs)(`div`,{className:`login-overlay`,children:[(0,P.jsx)(Yo,{density:24,speed:.16,linkDistance:110,hoverDistance:120,hoverGravity:.002,baseOpacity:.18,colors:[`#e8a030`,`#4caf6e`,`#5aa9e6`],linkColor:`#e8a030`,className:`login-node-bg`}),(0,P.jsxs)(U,{className:`login-card`,glowOnHover:!0,breathing:!0,children:[(0,P.jsxs)(`div`,{className:`login-title`,children:[(0,P.jsx)(`span`,{className:`prompt`,children:`>\xA0`}),`proxy admin`]}),(0,P.jsxs)(`form`,{onSubmit:a,children:[(0,P.jsx)(`input`,{type:`password`,name:`token`,placeholder:`Admin token`,autoComplete:`current-password`,autoFocus:!0}),(0,P.jsx)(H,{type:`submit`,tone:`primary`,loading:r,block:!0,children:`Sign in`})]}),(0,P.jsx)(`div`,{className:`login-error`,children:t})]})]})}var Gs={stroke:`currentColor`,fill:`none`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`},Ks={"/dashboard":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),"/requests":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,P.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,P.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`6`,r:`1`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`12`,r:`1`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`18`,r:`1`})]}),"/traffic":(0,P.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:(0,P.jsx)(`polyline`,{points:`3 12 7 12 10 5 14 19 17 12 21 12`})}),"/providers":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,P.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,P.jsx)(`line`,{x1:`7`,y1:`7.5`,x2:`7`,y2:`7.5`}),(0,P.jsx)(`line`,{x1:`7`,y1:`16.5`,x2:`7`,y2:`16.5`})]}),"/routing":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`18`,cy:`12`,r:`2.5`}),(0,P.jsx)(`path`,{d:`M8.5 6H14a2 2 0 0 1 2 2v1.5M8.5 18H14a2 2 0 0 0 2-2v-1.5`})]}),"/routes":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`5`,cy:`19`,r:`2`}),(0,P.jsx)(`circle`,{cx:`19`,cy:`5`,r:`2`}),(0,P.jsx)(`path`,{d:`M5 17V9a4 4 0 0 1 4-4h6`}),(0,P.jsx)(`polyline`,{points:`13 3 16 5 13 7`})]}),"/models":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`path`,{d:`M12 2 21 7v10l-9 5-9-5V7z`}),(0,P.jsx)(`path`,{d:`M3.5 7.5 12 12l8.5-4.5M12 12v9.5`})]}),"/backends":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,P.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,P.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),"/keys":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`}),(0,P.jsx)(`path`,{d:`M11 11l8 8M16 16l2-2M19 19l2-2`})]}),"/audit":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`path`,{d:`M12 3l7 3v5c0 4.4-3 7.6-7 9-4-1.4-7-4.6-7-9V6z`}),(0,P.jsx)(`polyline`,{points:`9 12 11 14 15 10`})]}),"/settings":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,P.jsx)(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2`})]}),"/uptime":(0,P.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:(0,P.jsx)(`path`,{d:`M3 12h4l2-6 4 12 2-6h6`})})},qs=[{label:`Overview`,items:[{to:`/dashboard`,label:`Dashboard`},{to:`/requests`,label:`Request Log`},{to:`/traffic`,label:`Traffic`}]},{label:`Configure`,items:[{to:`/providers`,label:`Providers`},{to:`/routing`,label:`Routing`},{to:`/models`,label:`Models`},{to:`/backends`,label:`Backends`}]},{label:`Access`,items:[{to:`/keys`,label:`API Keys`},{to:`/audit`,label:`Audit Log`}]},{label:`System`,items:[{to:`/settings`,label:`Settings`},{to:`/uptime`,label:`Uptime`}]}];function Js(){let e=ea(e=>e.logout),t=ta(e=>e.status);return(0,P.jsxs)(`aside`,{className:`sidebar`,children:[(0,P.jsxs)(`div`,{className:`sidebar-brand`,children:[(0,P.jsxs)(`div`,{className:`sidebar-brand-row`,children:[(0,P.jsx)(`span`,{className:`sidebar-brand-dot`}),`anyllm`]}),(0,P.jsx)(`span`,{className:`sidebar-brand-sub`,children:`Proxy Console`})]}),(0,P.jsx)(`nav`,{className:`sidebar-scroll`,children:qs.map(e=>(0,P.jsxs)(`div`,{className:`sidebar-group`,children:[(0,P.jsx)(`div`,{className:`sidebar-group-label`,children:e.label}),e.items.map(e=>(0,P.jsxs)(Li,{to:e.to,className:({isActive:e})=>`sidebar-item${e?` active`:``}`,children:[(0,P.jsx)(`span`,{className:`nav-ico`,children:Ks[e.to]}),(0,P.jsx)(`span`,{children:e.label})]},e.to))]},e.label))}),(0,P.jsx)(`div`,{className:`sidebar-footer`,children:(0,P.jsxs)(`div`,{className:`sidebar-footer-row`,children:[(0,P.jsx)(`span`,{className:`ws-status ${t===`connected`?`connected`:`disconnected`}`,children:t===`connected`?`Live`:`Offline`}),(0,P.jsx)(H,{size:`sm`,onClick:e,children:`Sign out`})]})})]})}function Ys(){let e=pa(e=>e.toasts);return e.length===0?null:(0,P.jsx)(`div`,{className:`toast-stack`,role:`region`,"aria-label":`Notifications`,children:e.map(e=>(0,P.jsx)(Xs,{toast:e},e.id))})}function Xs({toast:e}){let t=pa(e=>e.dismiss);return(0,N.useEffect)(()=>{if(e.ttlMs==null)return;let n=window.setTimeout(()=>t(e.id),e.ttlMs);return()=>window.clearTimeout(n)},[e.id,e.ttlMs,t]),(0,P.jsxs)(`div`,{className:`toast toast-${e.variant}`,role:`status`,children:[(0,P.jsx)(`div`,{className:`toast-message`,children:e.message}),(0,P.jsx)(`button`,{type:`button`,className:`toast-close`,"aria-label":`Dismiss`,onClick:()=>t(e.id),children:`×`})]})}var Zs=e=>({padding:`10px 16px`,border:`1px solid var(--border)`,borderLeft:`3px solid ${e}`,borderRadius:`var(--r)`,fontSize:13,marginBottom:12});function Qs(){let{data:e}=Fa(!0),t=[];return e?.auth_mode===`open_relay`?t.push((0,P.jsxs)(`div`,{style:Zs(`var(--err)`),children:[(0,P.jsx)(`strong`,{children:`No API key set.`}),` The proxy accepts any request on all interfaces (`,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_OPEN_RELAY`}),`). Anyone who can reach this port can spend your provider tokens. Set`,` `,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_API_KEYS`}),` to require a key.`]},`auth`)):e?.auth_mode===`loopback_only`&&t.push((0,P.jsxs)(`div`,{style:Zs(`var(--warn)`),children:[(0,P.jsx)(`strong`,{children:`No API key set.`}),` The proxy is open on localhost only; LAN/remote requests are rejected. Set`,` `,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_API_KEYS`}),` to require a key for remote access.`]},`auth`)),t.length===0?null:(0,P.jsx)(`div`,{children:t})}function $s({req:e}){return(0,P.jsxs)(`div`,{className:`feed-detail`,children:[(0,P.jsx)(`span`,{className:`label`,children:`Request ID`}),(0,P.jsx)(`span`,{className:`val`,children:e.request_id}),(0,P.jsx)(`span`,{className:`label`,children:`Backend`}),(0,P.jsx)(`span`,{className:`val`,children:e.backend}),(0,P.jsx)(`span`,{className:`label`,children:`Model (req)`}),(0,P.jsx)(`span`,{className:`val`,children:e.model_requested??`—`}),(0,P.jsx)(`span`,{className:`label`,children:`Model (mapped)`}),(0,P.jsx)(`span`,{className:`val`,children:e.model_mapped??`—`}),(0,P.jsx)(`span`,{className:`label`,children:`Latency`}),(0,P.jsxs)(`span`,{className:`val`,children:[e.latency_ms,` ms`]}),(0,P.jsx)(`span`,{className:`label`,children:`Tokens in/out`}),(0,P.jsxs)(`span`,{className:`val`,children:[e.input_tokens??`—`,` / `,e.output_tokens??`—`]}),(0,P.jsx)(`span`,{className:`label`,children:`Cost`}),(0,P.jsx)(`span`,{className:`val`,children:e.cost_usd==null?`—`:`$${e.cost_usd.toFixed(6)}`}),e.error_message&&(0,P.jsx)(`div`,{className:`error-msg`,children:e.error_message})]})}function ec(e){return e<300?`status-2xx`:e<500?`status-4xx`:`status-5xx`}function tc({req:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`feed-row`,onClick:()=>n(e=>!e),children:[(0,P.jsx)(`span`,{className:`mono dim`,children:e.timestamp.slice(11,19)}),(0,P.jsx)(`span`,{className:`mono ${ec(e.status_code)}`,children:e.status_code}),(0,P.jsxs)(`span`,{className:`mono`,children:[e.latency_ms,`ms`]}),(0,P.jsxs)(`span`,{className:`mono`,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.model_requested??e.backend,e.is_streaming&&(0,P.jsx)(`span`,{className:`streaming-badge`,children:`stream`})]}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.input_tokens??`—`}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.output_tokens??`—`}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.cost_usd==null?`—`:`$${e.cost_usd.toFixed(5)}`})]}),t&&(0,P.jsx)($s,{req:e})]})}var nc=200;function rc({initial:e}){let[t,n]=(0,N.useState)(e??[]),[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(r);a.current=r;let o=ta(e=>e.lastEvent);return(0,N.useEffect)(()=>{!o||o.type!==`request_completed`||a.current||n(e=>[o.data,...e].slice(0,nc))},[o]),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`section-header`,children:[(0,P.jsx)(`span`,{className:`section-label`,children:`Live Feed`}),(0,P.jsx)(H,{size:`sm`,tone:r?`primary`:`secondary`,onClick:()=>i(e=>!e),children:r?`Resume`:`Pause`})]}),(0,P.jsxs)(`div`,{className:`feed`,children:[(0,P.jsxs)(`div`,{className:`feed-header`,children:[(0,P.jsx)(`span`,{children:`Time`}),(0,P.jsx)(`span`,{children:`Status`}),(0,P.jsx)(`span`,{children:`Latency`}),(0,P.jsx)(`span`,{children:`Model`}),(0,P.jsx)(`span`,{children:`In`}),(0,P.jsx)(`span`,{children:`Out`}),(0,P.jsx)(`span`,{children:`Cost`})]}),t.length===0?(0,P.jsx)(`div`,{className:`empty`,children:`Waiting for requests…`}):t.map(e=>(0,P.jsx)(tc,{req:e},e.request_id))]})]})}function ic({text:e}){return(0,P.jsx)(`span`,{className:`info-tip`,title:e,"aria-label":e,role:`img`,children:`?`})}var ac=120;function oc({data:e,color:t=`var(--accent)`,height:n=30,fillOpacity:r=.1}){let i=n;if(!e||e.length<2)return(0,P.jsx)(`svg`,{viewBox:`0 0 ${ac} ${i}`,preserveAspectRatio:`none`,style:{width:`100%`,height:i,display:`block`}});let a=Math.max(...e),o=Math.min(...e),s=a-o||1,c=t=>t/(e.length-1)*ac,l=e=>i-(e-o)/s*(i-4)-2,u=e.map((e,t)=>`${c(t).toFixed(1)},${l(e).toFixed(1)}`).join(` `),d=`0,${i} ${u} ${ac},${i}`;return(0,P.jsxs)(`svg`,{viewBox:`0 0 ${ac} ${i}`,preserveAspectRatio:`none`,style:{width:`100%`,height:i,display:`block`},children:[(0,P.jsx)(`polyline`,{points:d,fill:t,fillOpacity:r,stroke:`none`}),(0,P.jsx)(`polyline`,{points:u,fill:`none`,stroke:t,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})]})}function sc(e,t,n=24){let r=(0,N.useRef)({}),[,i]=(0,N.useState)(0);return(0,N.useEffect)(()=>{if(!e)return;let a=t(e);for(let e of Object.keys(a)){let t=r.current[e]??[];r.current[e]=[...t,a[e]].slice(-n)}i(e=>e+1)},[e]),r.current}function cc(e){if(!e||e.length<2)return null;let t=e[0],n=e[e.length-1];return t===0?null:(n-t)/Math.abs(t)*100}function lc({series:e,gridColor:t=`var(--border-sub)`,height:n=130}){let r=n,i={top:8,right:8,bottom:0,left:0},a=600-i.left-i.right,o=r-i.top-i.bottom,s=e.flatMap(e=>e.data),c=Math.max(...s,1),l=Math.max(...e.map(e=>e.data.length),2);function u(e){return i.left+e/(l-1)*a}function d(e){return i.top+o-e/c*o}let f=Array.from({length:4},(e,t)=>i.top+t/3*o);return(0,P.jsxs)(`svg`,{className:`chart-svg`,viewBox:`0 0 600 ${r}`,preserveAspectRatio:`none`,style:{height:n},children:[f.map((e,n)=>(0,P.jsx)(`line`,{className:`chart-grid-line`,x1:i.left,y1:e,x2:600-i.right,y2:e,stroke:t},n)),e.map((e,t)=>{if(e.data.length<2)return null;let n=e.data.map((e,t)=>`${u(t)},${d(e)}`).join(` `);return(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`polygon`,{className:`chart-area`,points:[`${u(0)},${i.top+o}`,...e.data.map((e,t)=>`${u(t)},${d(e)}`),`${u(e.data.length-1)},${i.top+o}`].join(` `),fill:e.color}),(0,P.jsx)(`polyline`,{className:`chart-line${e.secondary?` secondary`:``}`,points:n,stroke:e.color})]},t)})]})}function uc({loading:e,error:t,empty:n,message:r}){return e?(0,P.jsx)(`div`,{className:`empty`,children:(0,P.jsx)(Hs,{})}):t?(0,P.jsx)(`div`,{className:`empty error`,children:t}):n?(0,P.jsx)(`div`,{className:`empty`,children:r??`No data`}):null}function dc(){let[e,t]=(0,N.useState)(6),[n,r]=(0,N.useState)(``),{data:i}=Ua(),{data:a,isLoading:o,error:s}=La(e,n),c=a?[{label:`Requests`,color:`#e8a030`,data:a.series.map(e=>e.requests)},{label:`Errors`,color:`#e05252`,data:a.series.map(e=>e.errors),secondary:!0}]:[],l=a?[{label:`Input`,color:`#4caf6e`,data:a.series.map(e=>e.input_tokens)},{label:`Output`,color:`#6eb5c0`,data:a.series.map(e=>e.output_tokens),secondary:!0}]:[],u=a?[{label:`Cost`,color:`#c87dd4`,data:a.series.map(e=>e.cost_usd)}]:[];return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`operator-controls`,children:[(0,P.jsx)(`span`,{className:`section-label`,style:{marginBottom:0},children:`Operator View`}),(0,P.jsxs)(`div`,{className:`form-row`,style:{flexWrap:`wrap`,gap:6,marginTop:0},children:[(0,P.jsxs)(`select`,{value:e,onChange:e=>t(Number(e.target.value)),children:[(0,P.jsx)(`option`,{value:1,children:`Last 1 hour`}),(0,P.jsx)(`option`,{value:6,children:`Last 6 hours`}),(0,P.jsx)(`option`,{value:24,children:`Last 24 hours`})]}),(0,P.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`All backends`}),i?.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]})]}),a&&(0,P.jsxs)(`div`,{className:`stats-row`,children:[(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Input Tokens`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_input_tokens})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Output Tokens`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_output_tokens})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[`Window Failures`,(0,P.jsx)(ic,{text:`Failed (error) requests within the selected time window and backend filter.`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_errors})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[`Window Cost`,(0,P.jsx)(ic,{text:`Estimated USD spend within the selected time window and backend filter, from model pricing.`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_cost_usd,precision:2,format:e=>`$${e.toFixed(2)}`})})]})]}),(0,P.jsx)(uc,{loading:o,error:s?.message}),a&&(0,P.jsxs)(`div`,{className:`operator-grid`,children:[(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Request Volume`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`Rolling request count and errors`})]}),(0,P.jsx)(`div`,{className:`chart-value`,children:a.total_requests})]}),(0,P.jsx)(lc,{series:c})]}),(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Tokens`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`Input and output usage`})]}),(0,P.jsx)(`div`,{className:`chart-value`,children:(a.total_input_tokens+a.total_output_tokens).toLocaleString()})]}),(0,P.jsx)(lc,{series:l})]}),(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Estimated Cost`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`USD by minute bucket`})]}),(0,P.jsxs)(`div`,{className:`chart-value`,children:[`$`,a.total_cost_usd.toFixed(4)]})]}),(0,P.jsx)(lc,{series:u})]})]})]})}function fc({series:e,goodWhenUp:t}){let n=cc(e);if(n===null||Math.abs(n)<.05)return(0,P.jsx)(`span`,{className:`stat-delta`,style:{color:`var(--text-3)`},children:`—`});let r=n>0;return(0,P.jsxs)(`span`,{className:`stat-delta`,style:{color:r===t?`var(--ok)`:`var(--err)`},children:[r?`▲`:`▼`,` `,Math.abs(n).toFixed(1),`%`]})}function pc(){let{data:e}=Ia(),t=sc(e,e=>({rpm:e.requests_per_minute,err:e.error_rate*100,p50:e.p50_latency_ms??0,p95:e.p95_latency_ms??0}),24);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`stats-row`,children:[(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Requests/min`}),(0,P.jsx)(fc,{series:t.rpm,goodWhenUp:!0})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.requests_per_minute,precision:1,format:e=>e.toFixed(1)}):`—`}),(0,P.jsx)(oc,{data:t.rpm??[],color:`var(--accent)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Error Rate`}),(0,P.jsx)(fc,{series:t.err,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.error_rate*100,precision:1,format:e=>`${e.toFixed(1)}%`}):`—`}),(0,P.jsx)(oc,{data:t.err??[],color:`var(--err)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsxs)(`span`,{children:[`P50 Latency`,(0,P.jsx)(ic,{text:`Median response latency — half of requests were faster than this.`})]}),(0,P.jsx)(fc,{series:t.p50,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.p50_latency_ms??0,format:e=>`${Math.round(e)}ms`}):`—`}),(0,P.jsx)(oc,{data:t.p50??[],color:`var(--ok)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsxs)(`span`,{children:[`P95 Latency`,(0,P.jsx)(ic,{text:`95th-percentile latency — 95% of requests were faster than this. Captures tail slowness.`})]}),(0,P.jsx)(fc,{series:t.p95,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.p95_latency_ms??0,format:e=>`${Math.round(e)}ms`}):`—`}),(0,P.jsx)(oc,{data:t.p95??[],color:`var(--accent-2)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Total Requests`}),(0,P.jsx)(`span`,{className:`stat-delta`,style:{color:`var(--text-3)`},children:`24h`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.total_requests??0})})]})]}),(0,P.jsxs)(`div`,{className:`stats-row`,style:{marginBottom:16},children:[(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Streams Started`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.streams_started??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Completed`}),(0,P.jsx)(`div`,{className:`stat-value ok`,children:(0,P.jsx)(Us,{value:e?.streams_completed??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Failed`}),(0,P.jsx)(`div`,{className:`stat-value`,style:{color:`var(--err)`},children:(0,P.jsx)(Us,{value:e?.streams_failed??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Client Disconnects`}),(0,P.jsx)(`div`,{className:`stat-value`,style:{color:`var(--warn)`},children:(0,P.jsx)(Us,{value:e?.streams_client_disconnected??0})})]})]}),(e?.pxpipe_compressed_total??0)>0&&(0,P.jsxs)(`div`,{className:`stats-row`,style:{marginBottom:16},children:[(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Image-Compressed Requests`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_compressed_total??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Images Emitted`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_images_total??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Chars Imaged`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_imaged_chars_total??0})})]})]}),(0,P.jsx)(dc,{}),(0,P.jsx)(`div`,{style:{marginTop:16},children:(0,P.jsx)(rc,{})})]})}function mc({page:e,hasMore:t,onPrev:n,onNext:r}){return(0,P.jsxs)(`div`,{className:`pagination`,children:[(0,P.jsx)(H,{size:`sm`,onClick:n,disabled:e<=1,children:`Prev`}),(0,P.jsxs)(`span`,{children:[`Page `,e]}),(0,P.jsx)(H,{size:`sm`,onClick:r,disabled:!t,children:`Next`})]})}function hc({query:e,children:t,empty:n,loading:r,errorTitle:i=`Failed to load`,skeletonRows:a=3}){return e.isLoading&&e.data===void 0?(0,P.jsx)(P.Fragment,{children:r??(0,P.jsx)(gc,{count:a})}):e.isError?(0,P.jsxs)(`div`,{className:`async-error`,role:`alert`,children:[(0,P.jsx)(`div`,{className:`async-error-title`,children:i}),(0,P.jsx)(`div`,{className:`async-error-message`,children:e.error instanceof Error?e.error.message:String(e.error)}),(0,P.jsx)(H,{type:`button`,onClick:()=>{e.refetch()},disabled:e.isFetching,loading:e.isFetching,children:`Retry`})]}):e.data===void 0?null:n&&n.when(e.data)?(0,P.jsx)(P.Fragment,{children:n.render()}):(0,P.jsx)(P.Fragment,{children:t(e.data)})}function gc({count:e}){return(0,P.jsx)(`div`,{className:`skeleton-stack`,"aria-hidden":`true`,children:Array.from({length:e},(e,t)=>(0,P.jsx)(`div`,{className:`skeleton skeleton-row`},t))})}function _c(){let[e,t]=Vi(),n=Math.max(1,Number(e.get(`page`)??`1`)||1),r=e.get(`backend`)??``,i=e.get(`status`)??``;function a(n,r,i){let a=new URLSearchParams(e);r?a.set(n,r):a.delete(n),i?.resetPage&&a.delete(`page`),t(a,{replace:!0})}function o(r){let i=new URLSearchParams(e),a=r(n);a<=1?i.delete(`page`):i.set(`page`,String(a)),t(i,{replace:!0})}let s=Ra({page:n,page_size:50,backend:r,status:i}),{data:c}=Ua();return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`section-header`,children:[(0,P.jsx)(`span`,{className:`section-label`,children:`Request Log`}),(0,P.jsxs)(`div`,{className:`form-row`,style:{marginTop:0},children:[(0,P.jsxs)(`select`,{name:`requestlog-backend`,value:r,onChange:e=>a(`backend`,e.target.value,{resetPage:!0}),children:[(0,P.jsx)(`option`,{value:``,children:`All backends`}),c?.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,P.jsxs)(`select`,{name:`requestlog-status`,value:i,onChange:e=>a(`status`,e.target.value,{resetPage:!0}),children:[(0,P.jsx)(`option`,{value:``,children:`All status`}),(0,P.jsx)(`option`,{value:`ok`,children:`2xx`}),(0,P.jsx)(`option`,{value:`error`,children:`4xx/5xx`})]})]})]}),(0,P.jsx)(hc,{query:s,errorTitle:`Failed to load request log`,empty:{when:e=>e.requests.length===0&&n===1,render:()=>(0,P.jsxs)(`div`,{className:`empty-cta`,children:[(0,P.jsx)(`div`,{className:`empty-cta-title`,children:`No requests logged`}),(0,P.jsx)(`div`,{className:`empty-cta-body`,children:`Send a request through the proxy and it will appear here. Only proxied traffic is logged; admin API calls are in the Audit tab.`})]})},children:e=>(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`feed`,children:[(0,P.jsxs)(`div`,{className:`feed-header`,children:[(0,P.jsx)(`span`,{children:`Time`}),(0,P.jsx)(`span`,{children:`Status`}),(0,P.jsx)(`span`,{children:`Latency`}),(0,P.jsx)(`span`,{children:`Model`}),(0,P.jsx)(`span`,{children:`In`}),(0,P.jsx)(`span`,{children:`Out`}),(0,P.jsx)(`span`,{children:`Cost`})]}),e.requests.map(e=>(0,P.jsx)(tc,{req:e},e.request_id))]}),(0,P.jsx)(mc,{page:n,hasMore:e.has_more,onPrev:()=>o(e=>Math.max(1,e-1)),onNext:()=>o(e=>e+1)})]})})]})}function vc({configured:e}){return e?null:(0,P.jsxs)(`div`,{style:{marginBottom:20,padding:`12px 16px`,border:`1px solid var(--border)`,borderLeft:`3px solid var(--warn)`,borderRadius:`var(--r)`,fontSize:13},children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:8},children:`No backend configured — nothing to forward requests to.`}),(0,P.jsxs)(`div`,{style:{marginBottom:10},children:[`Add a backend on the `,(0,P.jsx)(`span`,{className:`mono`,children:`Backends`}),` tab, or configure one via env. The proxy needs a backend endpoint (where to forward) and a listen port (where to accept). LISTEN_PORT defaults to 3000. Create a `,(0,P.jsx)(`span`,{className:`mono`,children:`.anyllm.env`}),` and import it below, or pass it at startup: `,(0,P.jsx)(`span`,{className:`mono`,children:`anyllm-proxy --webui --env-file .anyllm.env`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:4,fontSize:12},children:`OpenAI`}),(0,P.jsx)(`pre`,{style:{margin:0,padding:`6px 10px`,background:`var(--surface-2)`,borderRadius:`var(--r)`,fontSize:11,overflowX:`auto`},children:`OPENAI_API_KEY=sk-... +`)?120:0);a=setTimeout(f,_)};return r.innerHTML=u,f(),()=>{i=!0,a&&clearTimeout(a)}},[e,t,n,s,c]),(0,P.jsx)(`pre`,{ref:s,className:V(`pui-ide__body`,r),...i})});os.displayName=`MockIDE.Body`,Object.assign(is,{Chrome:as,Body:os});var ss=(0,N.forwardRef)(({role:e,agent:t,thinking:n,icon:r,className:i,children:a,...o},s)=>(0,P.jsxs)(`div`,{ref:s,className:V(`pui-bubble`,e===`user`?`pui-bubble--user`:`pui-bubble--ai`,i),...o,children:[e===`ai`&&(t||n!==!1||r!==!1)&&(0,P.jsxs)(`div`,{className:`pui-bubble__meta`,children:[r===!1?null:r??(0,P.jsx)(xo,{}),t&&(0,P.jsx)(`span`,{children:t}),n!==!1&&(0,P.jsxs)(`span`,{className:`pui-bubble__thinking-pill`,children:[(0,P.jsx)(`span`,{className:`pui-spinner pui-spinner--sm`}),(0,P.jsx)(`span`,{children:n??`thinking…`})]})]}),(0,P.jsx)(`div`,{className:`pui-bubble__stream`,children:a})]}));ss.displayName=`ChatBubble`;var cs=e=>e.split(/(\s+)/);function ls({text:e,speedMs:t=[18,80],tokenize:n=cs,loop:r=!1,loopDelayMs:i=6e3,onComplete:a}){let[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(!1),u=(0,N.useRef)(a);return u.current=a,(0,N.useEffect)(()=>{let a=!1,o=null,c=n(e),d=()=>Array.isArray(t)?t[0]+Math.random()*(t[1]-t[0]):t,f=()=>{let e=0,t=``,n=()=>{var p;if(!a){if(e>=c.length){l(!0),(p=u.current)==null||p.call(u),r&&(o=setTimeout(()=>{a||(l(!1),s(``),f())},i));return}t+=c[e],e+=1,s(t),o=setTimeout(n,d())}};n()};return f(),()=>{a=!0,o&&clearTimeout(o)}},[]),{output:o,isStreaming:!c,isComplete:c}}var us=(0,N.forwardRef)(({text:e,speedMs:t,tokenize:n,loop:r,loopDelayMs:i,onComplete:a,hideCaret:o,className:s,...c},l)=>{let{output:u,isStreaming:d}=ls({text:e,speedMs:t,tokenize:n,loop:r,loopDelayMs:i,onComplete:a});return(0,P.jsxs)(`span`,{ref:l,className:V(s),...c,children:[u,!o&&d&&(0,P.jsx)(`span`,{className:`pui-bubble__stream-caret`})]})});us.displayName=`TokenStream`;var ds=[`·`,`✢`,`✳`,`✶`,`✻`,`✽`],fs=`Accomplishing.Actioning.Actualizing.Architecting.Baking.Beaming.Befuddling.Billowing.Blanching.Bloviating.Boogieing.Boondoggling.Booping.Bootstrapping.Brewing.Bunning.Burrowing.Calculating.Canoodling.Caramelizing.Cascading.Catapulting.Cerebrating.Channeling.Channelling.Choreographing.Churning.Clauding.Coalescing.Cogitating.Combobulating.Composing.Computing.Concocting.Considering.Contemplating.Cooking.Crafting.Creating.Crunching.Crystallizing.Cultivating.Deciphering.Deliberating.Determining.Dilly-dallying.Discombobulating.Doing.Doodling.Drizzling.Ebbing.Effecting.Elucidating.Embellishing.Enchanting.Envisioning.Evaporating.Fermenting.Fiddle-faddling.Finagling.Flambéing.Flibbertigibbeting.Flowing.Flummoxing.Fluttering.Forging.Forming.Frolicking.Frosting.Gallivanting.Galloping.Garnishing.Generating.Gesticulating.Germinating.Gitifying.Grooving.Gusting.Harmonizing.Hashing.Hatching.Herding.Honking.Hullaballooing.Hyperspacing.Ideating.Imagining.Improvising.Incubating.Inferring.Infusing.Ionizing.Jitterbugging.Julienning.Kneading.Leavening.Levitating.Lollygagging.Manifesting.Marinating.Meandering.Metamorphosing.Misting.Moonwalking.Moseying.Mulling.Mustering.Musing.Nebulizing.Nesting.Newspapering.Noodling.Nucleating.Orbiting.Orchestrating.Osmosing.Perambulating.Percolating.Perusing.Philosophising.Photosynthesizing.Pollinating.Pondering.Pontificating.Pouncing.Precipitating.Prestidigitating.Processing.Proofing.Propagating.Puttering.Puzzling.Quantumizing.Razzle-dazzling.Razzmatazzing.Recombobulating.Reticulating.Roosting.Ruminating.Sautéing.Scampering.Schlepping.Scurrying.Seasoning.Shenaniganing.Shimmying.Simmering.Skedaddling.Sketching.Slithering.Smooshing.Sock-hopping.Spelunking.Spinning.Sprouting.Stewing.Sublimating.Swirling.Swooping.Symbioting.Synthesizing.Tempering.Thinking.Thundering.Tinkering.Tomfoolering.Topsy-turvying.Transfiguring.Transmuting.Twisting.Undulating.Unfurling.Unravelling.Vibing.Waddling.Wandering.Warping.Whatchamacalliting.Whirlpooling.Whirring.Whisking.Wibbling.Working.Wrangling.Zesting.Zigzagging`.split(`.`);function ps(e){return e[Math.floor(Math.random()*e.length)]}var ms=(0,N.forwardRef)(({verbs:e=fs,glyphs:t=ds,glyphInterval:n=250,verbInterval:r,ellipsis:i=`…`,info:a,glyphColor:o,className:s,...c},l)=>{let[u,d]=(0,N.useState)(0),[f,p]=(0,N.useState)(()=>e.length?ps(e):``);(0,N.useEffect)(()=>{if(!t.length)return;let e=setInterval(()=>{d(e=>(e+1)%t.length)},n);return()=>clearInterval(e)},[n,t.length]),(0,N.useEffect)(()=>{if(r==null||!e.length)return;let t=setInterval(()=>{p(ps(e))},r);return()=>clearInterval(t)},[e,r]);let m=f;return(0,P.jsxs)(`span`,{ref:l,className:V(`pui-wibble`,s),...c,children:[(0,P.jsx)(`span`,{className:`pui-wibble__glyph`,"aria-hidden":`true`,style:o?{color:o}:void 0,children:t[u]??``}),(0,P.jsxs)(`span`,{className:`pui-wibble__verb`,children:[m,i]}),a!=null&&a!==!1&&(0,P.jsxs)(`span`,{className:`pui-wibble__info`,children:[`(`,a,`)`]})]})});ms.displayName=`WibblingSpinner`;var hs=(0,N.forwardRef)(({label:e=`Ask AI`,open:t,defaultOpen:n,onOpenChange:r,popover:i,className:a,onClick:o,...s},c)=>{let l=t!==void 0,[u,d]=(0,N.useState)(n??!1),f=l?!!t:u,p=()=>{let e=!f;l||d(e),r?.(e)},m=()=>{l||d(!1),r?.(!1)};return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`button`,{ref:c,className:V(`pui-fab`,a),onClick:e=>{o?.(e),p()},"aria-expanded":f,...s,children:[(0,P.jsx)(xo,{}),(0,P.jsx)(`span`,{children:e})]}),f&&(0,P.jsx)(`div`,{role:`dialog`,className:`pui-fab-popover`,children:(0,P.jsx)(gs.Provider,{value:m,children:i})})]})});hs.displayName=`ChatFAB`;var gs=(0,N.createContext)(()=>{}),_s=(0,N.forwardRef)(({onClose:e,className:t,children:n,...r},i)=>{let a=(0,N.useContext)(gs);return(0,P.jsxs)(`div`,{ref:i,className:V(`pui-fab-popover__header`,t),...r,children:[(0,P.jsx)(xo,{}),(0,P.jsx)(`span`,{children:n}),(0,P.jsx)(`button`,{type:`button`,"aria-label":`Close`,className:`pui-fab-popover__close`,onClick:e??a,children:`×`})]})});_s.displayName=`ChatFAB.Header`;var vs=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`div`,{ref:n,className:V(`pui-fab-popover__body`,e),...t}));vs.displayName=`ChatFAB.Body`,Object.assign(hs,{Header:_s,Body:vs});var ys=(0,N.forwardRef)(({logos:e,speed:t=40,gap:n=56,fade:r=!0,pauseOnHover:i,className:a,style:o,...s},c)=>{let l={...o??{},"--pui-marquee-speed":`${t}s`,"--pui-marquee-gap":`${n}px`},u=(e,t)=>e.kind===`img`?(0,P.jsx)(`span`,{className:`pui-marquee__item`,children:(0,P.jsx)(`img`,{src:e.src,alt:e.alt??``})},`a${t}`):(0,P.jsx)(`span`,{className:`pui-marquee__item`,children:e.node},e.key??`b${t}`);return(0,P.jsx)(`div`,{ref:c,className:V(`pui-marquee`,r&&`pui-marquee--fade`,i&&`pui-marquee--paused-on-hover`,a),style:l,"aria-label":`Trusted by`,...s,children:(0,P.jsxs)(`div`,{className:`pui-marquee__track`,children:[e.map(u),e.map((t,n)=>u(t,n+e.length))]})})});ys.displayName=`LogoMarquee`;var bs=(0,N.forwardRef)(({heading:e,logos:t,className:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-logo-row`,n),...r,children:[e&&(0,P.jsx)(`p`,{className:`pui-logo-row__heading`,children:e}),(0,P.jsx)(`div`,{className:`pui-logo-row__items`,children:t.map((e,t)=>e.kind===`img`?(0,P.jsx)(`img`,{src:e.src,alt:e.alt??``},t):(0,P.jsx)(`span`,{className:`pui-logo-row__text`,children:e.node},e.key??t))})]}));bs.displayName=`LogoRow`;var xs=(0,N.forwardRef)(({rows:e,intensity:t=240,startDirection:n=`left`,gap:r=12,fade:i=!0,gradient:a=!1,static:o,className:s,style:c,...l},u)=>{let d=(0,N.useRef)(null);(0,N.useEffect)(()=>{let e=d.current;if(!e||o||window.matchMedia?.call(window,`(prefers-reduced-motion: reduce)`).matches)return;let n=0,r=()=>{n=0;let r=e.getBoundingClientRect(),i=window.innerHeight||document.documentElement.clientHeight,a=(i-r.top)/(i+r.height),o=(Math.min(1,Math.max(0,a))-.5)*t;e.style.setProperty(`--pui-slip`,`${o}px`)},i=()=>{n||(n=requestAnimationFrame(r))};return r(),window.addEventListener(`scroll`,i,{passive:!0}),window.addEventListener(`resize`,i,{passive:!0}),()=>{n&&cancelAnimationFrame(n),window.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i)}},[t,o]);let f=e=>{d.current=e,typeof u==`function`?u(e):u&&(u.current=e)},p=n===`left`?-1:1,m={...c??{},"--pui-slip-gap":`${r}px`};return(0,P.jsx)(`div`,{ref:f,className:V(`pui-slippy`,i&&`pui-slippy--fade`,s),style:m,"aria-label":`Featured terms`,...l,children:e.map((e,t)=>(0,P.jsx)(`div`,{className:`pui-slippy__row`,style:{"--pui-slip-dir":t%2==0?p:-p},children:e.map((e,n)=>{let r=typeof e==`string`?{label:e}:e;return(0,P.jsx)(`span`,{className:V(`pui-slippy__word`,(a||typeof e==`object`&&e.gradient)&&`pui-slippy__word--gradient`),children:r.label},typeof e==`object`&&e.key||`${t}-${n}`)})},t))})});xs.displayName=`SlippyWords`;function Ss({target:e,durationMs:t=1800,from:n=0,ease:r=e=>1-(1-e)**3}){let[i,a]=(0,N.useState)(n);return(0,N.useEffect)(()=>{let i=0,o=performance.now(),s=c=>{let l=Math.min(1,(c-o)/t);a(Math.floor(n+(e-n)*r(l))),l<1&&(i=requestAnimationFrame(s))};return i=requestAnimationFrame(s),()=>cancelAnimationFrame(i)},[]),i}var Cs=(0,N.forwardRef)(({target:e,durationMs:t,from:n,ease:r,format:i=e=>e.toLocaleString(),className:a,...o},s)=>{let c=Ss({target:e,durationMs:t,from:n,ease:r});return(0,P.jsx)(`span`,{ref:s,className:V(`pui-stat`,a),...o,children:i(c)})});Cs.displayName=`StatCounter`;var ws=(0,N.forwardRef)(({icon:e,iconNode:t,title:n,subtitle:r,className:i,...a},o)=>(0,P.jsxs)(`a`,{ref:o,className:V(`pui-community`,i),...a,children:[t??(e&&(0,P.jsx)(`img`,{className:`pui-community__icon`,src:e,alt:``})),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`pui-community__top`,children:n}),(0,P.jsx)(`div`,{className:`pui-community__bottom`,children:r})]})]}));ws.displayName=`CommunityBadge`;var Ts=(0,N.forwardRef)(({featured:e,className:t,...n},r)=>(0,P.jsx)(`article`,{ref:r,className:V(`pui-price`,e&&`pui-price--featured`,t),...n}));Ts.displayName=`PricingCard`;var Es=(0,N.forwardRef)(({hideSparkle:e,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-price__flag`,t),...r,children:[!e&&(0,P.jsx)(xo,{solid:!0}),(0,P.jsx)(`span`,{children:n})]}));Es.displayName=`PricingCard.Flag`;var Ds=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`div`,{ref:n,className:V(`pui-price__tier`,e),...t}));Ds.displayName=`PricingCard.Tier`;var Os=(0,N.forwardRef)(({unit:e,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-price__amount`,t),...r,children:[n,e&&(0,P.jsx)(`span`,{className:`pui-price__amount-unit`,children:e})]}));Os.displayName=`PricingCard.Amount`;var ks=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`p`,{ref:n,className:V(`pui-price__blurb`,e),...t}));ks.displayName=`PricingCard.Blurb`;var As=(0,N.forwardRef)(({className:e,...t},n)=>(0,P.jsx)(`ul`,{ref:n,className:V(`pui-price__features`,e),...t}));As.displayName=`PricingCard.Features`;var js=(0,N.forwardRef)(({className:e,children:t,...n},r)=>(0,P.jsx)(`a`,{ref:r,className:V(`pui-btn pui-btn--glow pui-btn--block`,e),...n,children:(0,P.jsx)(`span`,{children:t})}));js.displayName=`PricingCard.CTA`,Object.assign(Ts,{Flag:Es,Tier:Ds,Amount:Os,Blurb:ks,Features:As,CTA:js});var Ms=(0,N.forwardRef)(({before:e,after:t,brand:n,beforeLabel:r=`Before`,afterLabel:i=`After`,className:a,children:o,...s},c)=>(0,P.jsx)(`div`,{ref:c,className:V(`pui-ba`,a),...s,children:o??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(Ns,{label:r,children:(0,P.jsx)(`ul`,{children:(e??[]).map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})}),(0,P.jsx)(Fs,{brand:n}),(0,P.jsx)(Ps,{label:i,children:(0,P.jsx)(`ul`,{children:(t??[]).map((e,t)=>(0,P.jsx)(`li`,{children:e},t))})})]})}));Ms.displayName=`BeforeAfter`;var Ns=(0,N.forwardRef)(({label:e=`Before`,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-ba__panel pui-ba__panel--before`,t),...r,children:[(0,P.jsx)(`div`,{className:`pui-ba__tag`,children:e}),n]}));Ns.displayName=`BeforeAfter.Before`;var Ps=(0,N.forwardRef)(({label:e=`After`,className:t,children:n,...r},i)=>(0,P.jsxs)(`div`,{ref:i,className:V(`pui-ba__panel pui-ba__panel--after`,t),...r,children:[(0,P.jsx)(`div`,{className:`pui-ba__tag`,children:e}),n]}));Ps.displayName=`BeforeAfter.After`;var Fs=(0,N.forwardRef)(({brand:e,className:t,...n},r)=>(0,P.jsxs)(`div`,{ref:r,className:V(`pui-ba__arrow`,t),...n,children:[(0,P.jsx)(xo,{}),e?(0,P.jsxs)(`span`,{children:[`with `,e]}):(0,P.jsx)(`span`,{children:`after`}),(0,P.jsx)(`span`,{children:`→`})]}));Fs.displayName=`BeforeAfter.Arrow`,Object.assign(Ms,{Before:Ns,After:Ps,Arrow:Fs});var Is=(0,N.forwardRef)(({placeholder:e=`you@startup.ai`,defaultValue:t=``,ctaLabel:n=`Notify me`,leading:r,footnote:i,onSubmit:a,className:o,...s},c)=>{let[l,u]=(0,N.useState)(t);return(0,P.jsxs)(`div`,{className:V(`pui-waitlist-wrap`,o),children:[(0,P.jsxs)(`form`,{ref:c,className:`pui-waitlist`,onSubmit:e=>{e.preventDefault(),a?.(l)},...s,children:[r===!1?null:(0,P.jsx)(`span`,{className:`pui-waitlist__icon`,"aria-hidden":`true`,children:r??(0,P.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,width:`18`,height:`18`,children:[(0,P.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),(0,P.jsx)(`path`,{d:`M3 7l9 6 9-6`})]})}),(0,P.jsx)(`input`,{className:`pui-waitlist__input`,type:`email`,placeholder:e,value:l,onChange:e=>u(e.target.value)}),(0,P.jsx)(Do,{type:`submit`,variant:`solid`,children:n})]}),i&&(0,P.jsx)(`div`,{className:`pui-waitlist__footnote`,children:i})]})});Is.displayName=`WaitlistForm`;function Ls({open:e,defaultOpen:t=!1,onOpenChange:n,timer:r=0,title:i,children:a,closeLabel:o=`Maybe later`,closeOnEscape:s=!1,closeOnBackdrop:c=!1,container:l,className:u}){let d=e!==void 0,[f,p]=(0,N.useState)(t),m=d?e:f,h=e=>{d||p(e),n?.(e)};if((0,N.useEffect)(()=>{if(r<=0||m)return;let e=setTimeout(()=>h(!0),r);return()=>clearTimeout(e)},[]),(0,N.useEffect)(()=>{if(!m||!s)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),h(!1))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[m,s]),(0,N.useEffect)(()=>{if(!m)return;let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||[`[`,`]`,`j`,`k`,`ArrowLeft`,`ArrowRight`].includes(e.key)&&e.stopPropagation()};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[m]),(0,N.useEffect)(()=>{if(!m)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[m]),!m)return null;let g=l??(typeof document<`u`?document.body:null);return g?(0,Vn.createPortal)((0,P.jsxs)(`div`,{className:`pui-popover-overlay`,role:`dialog`,"aria-modal":`true`,children:[(0,P.jsx)(`div`,{className:`pui-popover-backdrop`,"aria-hidden":`true`,onClick:c?()=>h(!1):void 0}),(0,P.jsxs)(`div`,{className:V(`pui-popover`,u),children:[i&&(0,P.jsx)(`div`,{className:`pui-popover__title`,children:i}),(0,P.jsx)(`div`,{className:`pui-popover__body`,children:a}),o!==!1&&(0,P.jsx)(`button`,{type:`button`,className:`pui-popover__dismiss`,onClick:()=>h(!1),children:o})]})]}),g):null}Ls.displayName=`Popover`;var Rs={primary:`wave`,secondary:`ghost`,danger:`ghost`,icon:`ghost`},zs={sm:`sm`,md:`md`};function H({tone:e=`secondary`,size:t=`md`,loading:n=!1,block:r=!1,className:i,children:a,disabled:o,...s}){return(0,P.jsx)(Do,{variant:Rs[e],size:zs[t],loading:n,block:r,className:[`admin-button`,`admin-button-${e}`,i].filter(Boolean).join(` `),disabled:o||n,...s,children:a})}var Bs={ok:`var(--ok)`,warn:`var(--warn)`,err:`var(--err)`,dim:`var(--text-3)`};function Vs({status:e,pulse:t}){return(0,P.jsx)(Co,{color:Bs[e],static:!t,className:`admin-status-dot`})}function U({children:e,className:t,breathing:n=!1,glowOnHover:r=!1,...i}){return(0,P.jsx)(rs,{breathing:n,glowOnHover:r,className:[`admin-surface`,t].filter(Boolean).join(` `),...i,children:e})}function Hs({label:e=`Loading`,info:t,className:n}){return(0,P.jsx)(ms,{verbs:[e],glyphs:[`.`,`o`,`O`,`o`],glyphInterval:220,ellipsis:`...`,info:t,glyphColor:`var(--accent)`,className:[`admin-loading`,n].filter(Boolean).join(` `)})}function Us({value:e,precision:t=0,durationMs:n=450,className:r,format:i}){let a=10**t,o=Math.round(e*a),s=(0,N.useRef)(o),c=s.current;return(0,N.useEffect)(()=>{s.current=o},[o]),(0,P.jsx)(Cs,{target:o,from:c,durationMs:n,className:r,format:e=>{let t=e/a;return i?i(t):t.toLocaleString()}},o)}function Ws(){let e=ea(e=>e.login),[t,n]=(0,N.useState)(``),[r,i]=(0,N.useState)(!1);async function a(t){t.preventDefault();let r=t.currentTarget.elements.namedItem(`token`).value.trim();if(r){i(!0),n(``);try{if(!(await fetch(`/admin/api/metrics`,{headers:{Authorization:`Bearer ${r}`}})).ok)throw Error(`Invalid token`);e(r)}catch{n(`Invalid token`)}finally{i(!1)}}}return(0,P.jsxs)(`div`,{className:`login-overlay`,children:[(0,P.jsx)(Yo,{density:24,speed:.16,linkDistance:110,hoverDistance:120,hoverGravity:.002,baseOpacity:.18,colors:[`#e8a030`,`#4caf6e`,`#5aa9e6`],linkColor:`#e8a030`,className:`login-node-bg`}),(0,P.jsxs)(U,{className:`login-card`,glowOnHover:!0,breathing:!0,children:[(0,P.jsxs)(`div`,{className:`login-title`,children:[(0,P.jsx)(`span`,{className:`prompt`,children:`>\xA0`}),`proxy admin`]}),(0,P.jsxs)(`form`,{onSubmit:a,children:[(0,P.jsx)(`input`,{type:`password`,name:`token`,placeholder:`Admin token`,autoComplete:`current-password`,autoFocus:!0}),(0,P.jsx)(H,{type:`submit`,tone:`primary`,loading:r,block:!0,children:`Sign in`})]}),(0,P.jsx)(`div`,{className:`login-error`,children:t})]})]})}var Gs={stroke:`currentColor`,fill:`none`,strokeWidth:1.7,strokeLinecap:`round`,strokeLinejoin:`round`},Ks={"/dashboard":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1.5`}),(0,P.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1.5`})]}),"/requests":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`line`,{x1:`8`,y1:`6`,x2:`21`,y2:`6`}),(0,P.jsx)(`line`,{x1:`8`,y1:`12`,x2:`21`,y2:`12`}),(0,P.jsx)(`line`,{x1:`8`,y1:`18`,x2:`21`,y2:`18`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`6`,r:`1`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`12`,r:`1`}),(0,P.jsx)(`circle`,{cx:`3.5`,cy:`18`,r:`1`})]}),"/traffic":(0,P.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:(0,P.jsx)(`polyline`,{points:`3 12 7 12 10 5 14 19 17 12 21 12`})}),"/providers":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`7`,rx:`2`}),(0,P.jsx)(`rect`,{x:`3`,y:`13`,width:`18`,height:`7`,rx:`2`}),(0,P.jsx)(`line`,{x1:`7`,y1:`7.5`,x2:`7`,y2:`7.5`}),(0,P.jsx)(`line`,{x1:`7`,y1:`16.5`,x2:`7`,y2:`16.5`})]}),"/routing":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.5`}),(0,P.jsx)(`circle`,{cx:`18`,cy:`12`,r:`2.5`}),(0,P.jsx)(`path`,{d:`M8.5 6H14a2 2 0 0 1 2 2v1.5M8.5 18H14a2 2 0 0 0 2-2v-1.5`})]}),"/routes":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`5`,cy:`19`,r:`2`}),(0,P.jsx)(`circle`,{cx:`19`,cy:`5`,r:`2`}),(0,P.jsx)(`path`,{d:`M5 17V9a4 4 0 0 1 4-4h6`}),(0,P.jsx)(`polyline`,{points:`13 3 16 5 13 7`})]}),"/models":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`path`,{d:`M12 2 21 7v10l-9 5-9-5V7z`}),(0,P.jsx)(`path`,{d:`M3.5 7.5 12 12l8.5-4.5M12 12v9.5`})]}),"/backends":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,P.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,P.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]}),"/keys":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`}),(0,P.jsx)(`path`,{d:`M11 11l8 8M16 16l2-2M19 19l2-2`})]}),"/audit":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`path`,{d:`M12 3l7 3v5c0 4.4-3 7.6-7 9-4-1.4-7-4.6-7-9V6z`}),(0,P.jsx)(`polyline`,{points:`9 12 11 14 15 10`})]}),"/settings":(0,P.jsxs)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:[(0,P.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,P.jsx)(`path`,{d:`M12 2v3M12 19v3M2 12h3M19 12h3M5 5l2 2M17 17l2 2M19 5l-2 2M7 17l-2 2`})]}),"/uptime":(0,P.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,...Gs,children:(0,P.jsx)(`path`,{d:`M3 12h4l2-6 4 12 2-6h6`})})},qs=[{label:`Overview`,items:[{to:`/dashboard`,label:`Dashboard`},{to:`/requests`,label:`Request Log`},{to:`/traffic`,label:`Traffic`}]},{label:`Configure`,items:[{to:`/providers`,label:`Providers`},{to:`/routing`,label:`Routing`},{to:`/models`,label:`Models`},{to:`/backends`,label:`Backends`}]},{label:`Access`,items:[{to:`/keys`,label:`API Keys`},{to:`/audit`,label:`Audit Log`}]},{label:`System`,items:[{to:`/settings`,label:`Settings`},{to:`/uptime`,label:`Uptime`}]}];function Js(){let e=ea(e=>e.logout),t=ta(e=>e.status);return(0,P.jsxs)(`aside`,{className:`sidebar`,children:[(0,P.jsxs)(`div`,{className:`sidebar-brand`,children:[(0,P.jsxs)(`div`,{className:`sidebar-brand-row`,children:[(0,P.jsx)(`span`,{className:`sidebar-brand-dot`}),`anyllm`]}),(0,P.jsx)(`span`,{className:`sidebar-brand-sub`,children:`Proxy Console`})]}),(0,P.jsx)(`nav`,{className:`sidebar-scroll`,children:qs.map(e=>(0,P.jsxs)(`div`,{className:`sidebar-group`,children:[(0,P.jsx)(`div`,{className:`sidebar-group-label`,children:e.label}),e.items.map(e=>(0,P.jsxs)(Li,{to:e.to,className:({isActive:e})=>`sidebar-item${e?` active`:``}`,children:[(0,P.jsx)(`span`,{className:`nav-ico`,children:Ks[e.to]}),(0,P.jsx)(`span`,{children:e.label})]},e.to))]},e.label))}),(0,P.jsx)(`div`,{className:`sidebar-footer`,children:(0,P.jsxs)(`div`,{className:`sidebar-footer-row`,children:[(0,P.jsx)(`span`,{className:`ws-status ${t===`connected`?`connected`:`disconnected`}`,children:t===`connected`?`Live`:`Offline`}),(0,P.jsx)(H,{size:`sm`,onClick:e,children:`Sign out`})]})})]})}function Ys(){let e=pa(e=>e.toasts);return e.length===0?null:(0,P.jsx)(`div`,{className:`toast-stack`,role:`region`,"aria-label":`Notifications`,children:e.map(e=>(0,P.jsx)(Xs,{toast:e},e.id))})}function Xs({toast:e}){let t=pa(e=>e.dismiss);return(0,N.useEffect)(()=>{if(e.ttlMs==null)return;let n=window.setTimeout(()=>t(e.id),e.ttlMs);return()=>window.clearTimeout(n)},[e.id,e.ttlMs,t]),(0,P.jsxs)(`div`,{className:`toast toast-${e.variant}`,role:`status`,children:[(0,P.jsx)(`div`,{className:`toast-message`,children:e.message}),(0,P.jsx)(`button`,{type:`button`,className:`toast-close`,"aria-label":`Dismiss`,onClick:()=>t(e.id),children:`×`})]})}var Zs=e=>({padding:`10px 16px`,border:`1px solid var(--border)`,borderLeft:`3px solid ${e}`,borderRadius:`var(--r)`,fontSize:13,marginBottom:12});function Qs(){let{data:e}=Fa(!0),t=[];return e?.auth_mode===`open_relay`?t.push((0,P.jsxs)(`div`,{style:Zs(`var(--err)`),children:[(0,P.jsx)(`strong`,{children:`No API key set.`}),` The proxy accepts any request on all interfaces (`,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_OPEN_RELAY`}),`). Anyone who can reach this port can spend your provider tokens. Set`,` `,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_API_KEYS`}),` to require a key.`]},`auth`)):e?.auth_mode===`auth_required`&&t.push((0,P.jsxs)(`div`,{style:Zs(`var(--warn)`),children:[(0,P.jsx)(`strong`,{children:`No API key set.`}),` The proxy rejects all requests. Set`,` `,(0,P.jsx)(`span`,{className:`mono`,children:`PROXY_API_KEYS`}),` to allow authenticated access.`]},`auth`)),t.length===0?null:(0,P.jsx)(`div`,{children:t})}function $s({req:e}){return(0,P.jsxs)(`div`,{className:`feed-detail`,children:[(0,P.jsx)(`span`,{className:`label`,children:`Request ID`}),(0,P.jsx)(`span`,{className:`val`,children:e.request_id}),(0,P.jsx)(`span`,{className:`label`,children:`Backend`}),(0,P.jsx)(`span`,{className:`val`,children:e.backend}),(0,P.jsx)(`span`,{className:`label`,children:`Model (req)`}),(0,P.jsx)(`span`,{className:`val`,children:e.model_requested??`—`}),(0,P.jsx)(`span`,{className:`label`,children:`Model (mapped)`}),(0,P.jsx)(`span`,{className:`val`,children:e.model_mapped??`—`}),(0,P.jsx)(`span`,{className:`label`,children:`Latency`}),(0,P.jsxs)(`span`,{className:`val`,children:[e.latency_ms,` ms`]}),(0,P.jsx)(`span`,{className:`label`,children:`Tokens in/out`}),(0,P.jsxs)(`span`,{className:`val`,children:[e.input_tokens??`—`,` / `,e.output_tokens??`—`]}),(0,P.jsx)(`span`,{className:`label`,children:`Cost`}),(0,P.jsx)(`span`,{className:`val`,children:e.cost_usd==null?`—`:`$${e.cost_usd.toFixed(6)}`}),e.error_message&&(0,P.jsx)(`div`,{className:`error-msg`,children:e.error_message})]})}function ec(e){return e<300?`status-2xx`:e<500?`status-4xx`:`status-5xx`}function tc({req:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`feed-row`,onClick:()=>n(e=>!e),children:[(0,P.jsx)(`span`,{className:`mono dim`,children:e.timestamp.slice(11,19)}),(0,P.jsx)(`span`,{className:`mono ${ec(e.status_code)}`,children:e.status_code}),(0,P.jsxs)(`span`,{className:`mono`,children:[e.latency_ms,`ms`]}),(0,P.jsxs)(`span`,{className:`mono`,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:[e.model_requested??e.backend,e.is_streaming&&(0,P.jsx)(`span`,{className:`streaming-badge`,children:`stream`})]}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.input_tokens??`—`}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.output_tokens??`—`}),(0,P.jsx)(`span`,{className:`mono dim`,children:e.cost_usd==null?`—`:`$${e.cost_usd.toFixed(5)}`})]}),t&&(0,P.jsx)($s,{req:e})]})}var nc=200;function rc({initial:e}){let[t,n]=(0,N.useState)(e??[]),[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(r);a.current=r;let o=ta(e=>e.lastEvent);return(0,N.useEffect)(()=>{!o||o.type!==`request_completed`||a.current||n(e=>[o.data,...e].slice(0,nc))},[o]),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`section-header`,children:[(0,P.jsx)(`span`,{className:`section-label`,children:`Live Feed`}),(0,P.jsx)(H,{size:`sm`,tone:r?`primary`:`secondary`,onClick:()=>i(e=>!e),children:r?`Resume`:`Pause`})]}),(0,P.jsxs)(`div`,{className:`feed`,children:[(0,P.jsxs)(`div`,{className:`feed-header`,children:[(0,P.jsx)(`span`,{children:`Time`}),(0,P.jsx)(`span`,{children:`Status`}),(0,P.jsx)(`span`,{children:`Latency`}),(0,P.jsx)(`span`,{children:`Model`}),(0,P.jsx)(`span`,{children:`In`}),(0,P.jsx)(`span`,{children:`Out`}),(0,P.jsx)(`span`,{children:`Cost`})]}),t.length===0?(0,P.jsx)(`div`,{className:`empty`,children:`Waiting for requests…`}):t.map(e=>(0,P.jsx)(tc,{req:e},e.request_id))]})]})}function ic({text:e}){return(0,P.jsx)(`span`,{className:`info-tip`,title:e,"aria-label":e,role:`img`,children:`?`})}var ac=120;function oc({data:e,color:t=`var(--accent)`,height:n=30,fillOpacity:r=.1}){let i=n;if(!e||e.length<2)return(0,P.jsx)(`svg`,{viewBox:`0 0 ${ac} ${i}`,preserveAspectRatio:`none`,style:{width:`100%`,height:i,display:`block`}});let a=Math.max(...e),o=Math.min(...e),s=a-o||1,c=t=>t/(e.length-1)*ac,l=e=>i-(e-o)/s*(i-4)-2,u=e.map((e,t)=>`${c(t).toFixed(1)},${l(e).toFixed(1)}`).join(` `),d=`0,${i} ${u} ${ac},${i}`;return(0,P.jsxs)(`svg`,{viewBox:`0 0 ${ac} ${i}`,preserveAspectRatio:`none`,style:{width:`100%`,height:i,display:`block`},children:[(0,P.jsx)(`polyline`,{points:d,fill:t,fillOpacity:r,stroke:`none`}),(0,P.jsx)(`polyline`,{points:u,fill:`none`,stroke:t,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,vectorEffect:`non-scaling-stroke`})]})}function sc(e,t,n=24){let r=(0,N.useRef)({}),[,i]=(0,N.useState)(0);return(0,N.useEffect)(()=>{if(!e)return;let a=t(e);for(let e of Object.keys(a)){let t=r.current[e]??[];r.current[e]=[...t,a[e]].slice(-n)}i(e=>e+1)},[e]),r.current}function cc(e){if(!e||e.length<2)return null;let t=e[0],n=e[e.length-1];return t===0?null:(n-t)/Math.abs(t)*100}function lc({series:e,gridColor:t=`var(--border-sub)`,height:n=130}){let r=n,i={top:8,right:8,bottom:0,left:0},a=600-i.left-i.right,o=r-i.top-i.bottom,s=e.flatMap(e=>e.data),c=Math.max(...s,1),l=Math.max(...e.map(e=>e.data.length),2);function u(e){return i.left+e/(l-1)*a}function d(e){return i.top+o-e/c*o}let f=Array.from({length:4},(e,t)=>i.top+t/3*o);return(0,P.jsxs)(`svg`,{className:`chart-svg`,viewBox:`0 0 600 ${r}`,preserveAspectRatio:`none`,style:{height:n},children:[f.map((e,n)=>(0,P.jsx)(`line`,{className:`chart-grid-line`,x1:i.left,y1:e,x2:600-i.right,y2:e,stroke:t},n)),e.map((e,t)=>{if(e.data.length<2)return null;let n=e.data.map((e,t)=>`${u(t)},${d(e)}`).join(` `);return(0,P.jsxs)(`g`,{children:[(0,P.jsx)(`polygon`,{className:`chart-area`,points:[`${u(0)},${i.top+o}`,...e.data.map((e,t)=>`${u(t)},${d(e)}`),`${u(e.data.length-1)},${i.top+o}`].join(` `),fill:e.color}),(0,P.jsx)(`polyline`,{className:`chart-line${e.secondary?` secondary`:``}`,points:n,stroke:e.color})]},t)})]})}function uc({loading:e,error:t,empty:n,message:r}){return e?(0,P.jsx)(`div`,{className:`empty`,children:(0,P.jsx)(Hs,{})}):t?(0,P.jsx)(`div`,{className:`empty error`,children:t}):n?(0,P.jsx)(`div`,{className:`empty`,children:r??`No data`}):null}function dc(){let[e,t]=(0,N.useState)(6),[n,r]=(0,N.useState)(``),{data:i}=Ua(),{data:a,isLoading:o,error:s}=La(e,n),c=a?[{label:`Requests`,color:`#e8a030`,data:a.series.map(e=>e.requests)},{label:`Errors`,color:`#e05252`,data:a.series.map(e=>e.errors),secondary:!0}]:[],l=a?[{label:`Input`,color:`#4caf6e`,data:a.series.map(e=>e.input_tokens)},{label:`Output`,color:`#6eb5c0`,data:a.series.map(e=>e.output_tokens),secondary:!0}]:[],u=a?[{label:`Cost`,color:`#c87dd4`,data:a.series.map(e=>e.cost_usd)}]:[];return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`operator-controls`,children:[(0,P.jsx)(`span`,{className:`section-label`,style:{marginBottom:0},children:`Operator View`}),(0,P.jsxs)(`div`,{className:`form-row`,style:{flexWrap:`wrap`,gap:6,marginTop:0},children:[(0,P.jsxs)(`select`,{value:e,onChange:e=>t(Number(e.target.value)),children:[(0,P.jsx)(`option`,{value:1,children:`Last 1 hour`}),(0,P.jsx)(`option`,{value:6,children:`Last 6 hours`}),(0,P.jsx)(`option`,{value:24,children:`Last 24 hours`})]}),(0,P.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value),children:[(0,P.jsx)(`option`,{value:``,children:`All backends`}),i?.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]})]}),a&&(0,P.jsxs)(`div`,{className:`stats-row`,children:[(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Input Tokens`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_input_tokens})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Output Tokens`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_output_tokens})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[`Window Failures`,(0,P.jsx)(ic,{text:`Failed (error) requests within the selected time window and backend filter.`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_errors})})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[`Window Cost`,(0,P.jsx)(ic,{text:`Estimated USD spend within the selected time window and backend filter, from model pricing.`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:a.total_cost_usd,precision:2,format:e=>`$${e.toFixed(2)}`})})]})]}),(0,P.jsx)(uc,{loading:o,error:s?.message}),a&&(0,P.jsxs)(`div`,{className:`operator-grid`,children:[(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Request Volume`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`Rolling request count and errors`})]}),(0,P.jsx)(`div`,{className:`chart-value`,children:a.total_requests})]}),(0,P.jsx)(lc,{series:c})]}),(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Tokens`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`Input and output usage`})]}),(0,P.jsx)(`div`,{className:`chart-value`,children:(a.total_input_tokens+a.total_output_tokens).toLocaleString()})]}),(0,P.jsx)(lc,{series:l})]}),(0,P.jsxs)(U,{className:`chart-card`,children:[(0,P.jsxs)(`div`,{className:`chart-header`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`chart-title`,children:`Estimated Cost`}),(0,P.jsx)(`div`,{className:`chart-subtitle`,children:`USD by minute bucket`})]}),(0,P.jsxs)(`div`,{className:`chart-value`,children:[`$`,a.total_cost_usd.toFixed(4)]})]}),(0,P.jsx)(lc,{series:u})]})]})]})}function fc({series:e,goodWhenUp:t}){let n=cc(e);if(n===null||Math.abs(n)<.05)return(0,P.jsx)(`span`,{className:`stat-delta`,style:{color:`var(--text-3)`},children:`—`});let r=n>0;return(0,P.jsxs)(`span`,{className:`stat-delta`,style:{color:r===t?`var(--ok)`:`var(--err)`},children:[r?`▲`:`▼`,` `,Math.abs(n).toFixed(1),`%`]})}function pc(){let{data:e}=Ia(),t=sc(e,e=>({rpm:e.requests_per_minute,err:e.error_rate*100,p50:e.p50_latency_ms??0,p95:e.p95_latency_ms??0}),24);return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`stats-row`,children:[(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Requests/min`}),(0,P.jsx)(fc,{series:t.rpm,goodWhenUp:!0})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.requests_per_minute,precision:1,format:e=>e.toFixed(1)}):`—`}),(0,P.jsx)(oc,{data:t.rpm??[],color:`var(--accent)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Error Rate`}),(0,P.jsx)(fc,{series:t.err,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.error_rate*100,precision:1,format:e=>`${e.toFixed(1)}%`}):`—`}),(0,P.jsx)(oc,{data:t.err??[],color:`var(--err)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsxs)(`span`,{children:[`P50 Latency`,(0,P.jsx)(ic,{text:`Median response latency — half of requests were faster than this.`})]}),(0,P.jsx)(fc,{series:t.p50,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.p50_latency_ms??0,format:e=>`${Math.round(e)}ms`}):`—`}),(0,P.jsx)(oc,{data:t.p50??[],color:`var(--ok)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsxs)(`span`,{children:[`P95 Latency`,(0,P.jsx)(ic,{text:`95th-percentile latency — 95% of requests were faster than this. Captures tail slowness.`})]}),(0,P.jsx)(fc,{series:t.p95,goodWhenUp:!1})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:e?(0,P.jsx)(Us,{value:e.p95_latency_ms??0,format:e=>`${Math.round(e)}ms`}):`—`}),(0,P.jsx)(oc,{data:t.p95??[],color:`var(--accent-2)`})]}),(0,P.jsxs)(U,{className:`stat`,children:[(0,P.jsxs)(`div`,{className:`stat-label`,children:[(0,P.jsx)(`span`,{children:`Total Requests`}),(0,P.jsx)(`span`,{className:`stat-delta`,style:{color:`var(--text-3)`},children:`24h`})]}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.total_requests??0})})]})]}),(0,P.jsxs)(`div`,{className:`stats-row`,style:{marginBottom:16},children:[(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Streams Started`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.streams_started??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Completed`}),(0,P.jsx)(`div`,{className:`stat-value ok`,children:(0,P.jsx)(Us,{value:e?.streams_completed??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Failed`}),(0,P.jsx)(`div`,{className:`stat-value`,style:{color:`var(--err)`},children:(0,P.jsx)(Us,{value:e?.streams_failed??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Client Disconnects`}),(0,P.jsx)(`div`,{className:`stat-value`,style:{color:`var(--warn)`},children:(0,P.jsx)(Us,{value:e?.streams_client_disconnected??0})})]})]}),(e?.pxpipe_compressed_total??0)>0&&(0,P.jsxs)(`div`,{className:`stats-row`,style:{marginBottom:16},children:[(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Image-Compressed Requests`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_compressed_total??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Images Emitted`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_images_total??0})})]}),(0,P.jsxs)(U,{className:`stat stat-compact`,children:[(0,P.jsx)(`div`,{className:`stat-label`,children:`Chars Imaged`}),(0,P.jsx)(`div`,{className:`stat-value`,children:(0,P.jsx)(Us,{value:e?.pxpipe_imaged_chars_total??0})})]})]}),(0,P.jsx)(dc,{}),(0,P.jsx)(`div`,{style:{marginTop:16},children:(0,P.jsx)(rc,{})})]})}function mc({page:e,hasMore:t,onPrev:n,onNext:r}){return(0,P.jsxs)(`div`,{className:`pagination`,children:[(0,P.jsx)(H,{size:`sm`,onClick:n,disabled:e<=1,children:`Prev`}),(0,P.jsxs)(`span`,{children:[`Page `,e]}),(0,P.jsx)(H,{size:`sm`,onClick:r,disabled:!t,children:`Next`})]})}function hc({query:e,children:t,empty:n,loading:r,errorTitle:i=`Failed to load`,skeletonRows:a=3}){return e.isLoading&&e.data===void 0?(0,P.jsx)(P.Fragment,{children:r??(0,P.jsx)(gc,{count:a})}):e.isError?(0,P.jsxs)(`div`,{className:`async-error`,role:`alert`,children:[(0,P.jsx)(`div`,{className:`async-error-title`,children:i}),(0,P.jsx)(`div`,{className:`async-error-message`,children:e.error instanceof Error?e.error.message:String(e.error)}),(0,P.jsx)(H,{type:`button`,onClick:()=>{e.refetch()},disabled:e.isFetching,loading:e.isFetching,children:`Retry`})]}):e.data===void 0?null:n&&n.when(e.data)?(0,P.jsx)(P.Fragment,{children:n.render()}):(0,P.jsx)(P.Fragment,{children:t(e.data)})}function gc({count:e}){return(0,P.jsx)(`div`,{className:`skeleton-stack`,"aria-hidden":`true`,children:Array.from({length:e},(e,t)=>(0,P.jsx)(`div`,{className:`skeleton skeleton-row`},t))})}function _c(){let[e,t]=Vi(),n=Math.max(1,Number(e.get(`page`)??`1`)||1),r=e.get(`backend`)??``,i=e.get(`status`)??``;function a(n,r,i){let a=new URLSearchParams(e);r?a.set(n,r):a.delete(n),i?.resetPage&&a.delete(`page`),t(a,{replace:!0})}function o(r){let i=new URLSearchParams(e),a=r(n);a<=1?i.delete(`page`):i.set(`page`,String(a)),t(i,{replace:!0})}let s=Ra({page:n,page_size:50,backend:r,status:i}),{data:c}=Ua();return(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`section-header`,children:[(0,P.jsx)(`span`,{className:`section-label`,children:`Request Log`}),(0,P.jsxs)(`div`,{className:`form-row`,style:{marginTop:0},children:[(0,P.jsxs)(`select`,{name:`requestlog-backend`,value:r,onChange:e=>a(`backend`,e.target.value,{resetPage:!0}),children:[(0,P.jsx)(`option`,{value:``,children:`All backends`}),c?.map(e=>(0,P.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,P.jsxs)(`select`,{name:`requestlog-status`,value:i,onChange:e=>a(`status`,e.target.value,{resetPage:!0}),children:[(0,P.jsx)(`option`,{value:``,children:`All status`}),(0,P.jsx)(`option`,{value:`ok`,children:`2xx`}),(0,P.jsx)(`option`,{value:`error`,children:`4xx/5xx`})]})]})]}),(0,P.jsx)(hc,{query:s,errorTitle:`Failed to load request log`,empty:{when:e=>e.requests.length===0&&n===1,render:()=>(0,P.jsxs)(`div`,{className:`empty-cta`,children:[(0,P.jsx)(`div`,{className:`empty-cta-title`,children:`No requests logged`}),(0,P.jsx)(`div`,{className:`empty-cta-body`,children:`Send a request through the proxy and it will appear here. Only proxied traffic is logged; admin API calls are in the Audit tab.`})]})},children:e=>(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`feed`,children:[(0,P.jsxs)(`div`,{className:`feed-header`,children:[(0,P.jsx)(`span`,{children:`Time`}),(0,P.jsx)(`span`,{children:`Status`}),(0,P.jsx)(`span`,{children:`Latency`}),(0,P.jsx)(`span`,{children:`Model`}),(0,P.jsx)(`span`,{children:`In`}),(0,P.jsx)(`span`,{children:`Out`}),(0,P.jsx)(`span`,{children:`Cost`})]}),e.requests.map(e=>(0,P.jsx)(tc,{req:e},e.request_id))]}),(0,P.jsx)(mc,{page:n,hasMore:e.has_more,onPrev:()=>o(e=>Math.max(1,e-1)),onNext:()=>o(e=>e+1)})]})})]})}function vc({configured:e}){return e?null:(0,P.jsxs)(`div`,{style:{marginBottom:20,padding:`12px 16px`,border:`1px solid var(--border)`,borderLeft:`3px solid var(--warn)`,borderRadius:`var(--r)`,fontSize:13},children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:8},children:`No backend configured — nothing to forward requests to.`}),(0,P.jsxs)(`div`,{style:{marginBottom:10},children:[`Add a backend on the `,(0,P.jsx)(`span`,{className:`mono`,children:`Backends`}),` tab, or configure one via env. The proxy needs a backend endpoint (where to forward) and a listen port (where to accept). LISTEN_PORT defaults to 3000. Create a `,(0,P.jsx)(`span`,{className:`mono`,children:`.anyllm.env`}),` and import it below, or pass it at startup: `,(0,P.jsx)(`span`,{className:`mono`,children:`anyllm-proxy --webui --env-file .anyllm.env`})]}),(0,P.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`1fr 1fr 1fr`,gap:10},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:4,fontSize:12},children:`OpenAI`}),(0,P.jsx)(`pre`,{style:{margin:0,padding:`6px 10px`,background:`var(--surface-2)`,borderRadius:`var(--r)`,fontSize:11,overflowX:`auto`},children:`OPENAI_API_KEY=sk-... PROXY_API_KEYS=my-key`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:4,fontSize:12},children:`Ollama / local LLM`}),(0,P.jsx)(`pre`,{style:{margin:0,padding:`6px 10px`,background:`var(--surface-2)`,borderRadius:`var(--r)`,fontSize:11,overflowX:`auto`},children:`OPENAI_BASE_URL=http://localhost:11434/v1 PROXY_OPEN_RELAY=true`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{style:{fontWeight:600,marginBottom:4,fontSize:12},children:`OpenRouter / custom`}),(0,P.jsx)(`pre`,{style:{margin:0,padding:`6px 10px`,background:`var(--surface-2)`,borderRadius:`var(--r)`,fontSize:11,overflowX:`auto`},children:`OPENAI_BASE_URL=https://openrouter.ai/api/v1 OPENAI_API_KEY=sk-or-... diff --git a/crates/proxy/admin-ui/src/api/types/proxy.ts b/crates/proxy/admin-ui/src/api/types/proxy.ts index f62af67..be6f739 100644 --- a/crates/proxy/admin-ui/src/api/types/proxy.ts +++ b/crates/proxy/admin-ui/src/api/types/proxy.ts @@ -8,10 +8,10 @@ export interface ProxyStatus { proxy_running: boolean /** * Effective proxy auth posture. "keys": a key is required. "open_relay": any - * key accepted on all interfaces. "loopback_only": no auth, localhost open and - * LAN rejected (the default). Drives the top-of-app warning banner. + * key accepted on all interfaces. "auth_required": no authentication source is + * configured, so all requests are rejected. Drives the top-of-app warning banner. */ - auth_mode: 'keys' | 'open_relay' | 'loopback_only' + auth_mode: 'keys' | 'open_relay' | 'auth_required' /** Number of distinct static PROXY_API_KEYS entries. */ proxy_key_count: number } diff --git a/crates/proxy/admin-ui/src/components/shared/AppBanner.tsx b/crates/proxy/admin-ui/src/components/shared/AppBanner.tsx index f23e0b2..57cf017 100644 --- a/crates/proxy/admin-ui/src/components/shared/AppBanner.tsx +++ b/crates/proxy/admin-ui/src/components/shared/AppBanner.tsx @@ -14,7 +14,7 @@ const box = (accent: string): CSSProperties => ({ /** * Site-wide warning banners rendered above every tab. Reflects live state * (cleared automatically when fixed): proxy auth is open (open_relay) or unset - * (loopback_only). useStatus is React Query-cached, so no extra fetch. + * (auth_required). useStatus is React Query-cached, so no extra fetch. * * Deliberately does NOT warn on an empty Models tab: that lists only * model-router deployments (virtual model aliases), which are optional. A @@ -35,13 +35,11 @@ export default function AppBanner() { PROXY_API_KEYS to require a key. , ) - } else if (status?.auth_mode === 'loopback_only') { + } else if (status?.auth_mode === 'auth_required') { banners.push(
- No API key set. The proxy is open on localhost only; - LAN/remote requests are rejected. Set{' '} - PROXY_API_KEYS to require a key for remote - access. + No API key set. The proxy rejects all requests. Set{' '} + PROXY_API_KEYS to allow authenticated access.
, ) } diff --git a/crates/proxy/src/admin/routes/status.rs b/crates/proxy/src/admin/routes/status.rs index 54df794..4c9eede 100644 --- a/crates/proxy/src/admin/routes/status.rs +++ b/crates/proxy/src/admin/routes/status.rs @@ -11,8 +11,8 @@ pub struct ProxyStatus { /// Whether the proxy's own port accepts a TCP connection right now. pub proxy_running: bool, /// Effective proxy auth posture: `"keys"` (enforced), `"open_relay"` (any - /// key accepted on all interfaces), or `"loopback_only"` (no auth; localhost - /// open, LAN rejected, the default). Drives the admin UI warning banner. + /// key accepted on all interfaces), or `"auth_required"` (no authentication + /// source configured; all requests rejected). Drives the admin UI warning banner. pub auth_mode: crate::server::middleware::EffectiveAuthMode, /// Number of distinct static `PROXY_API_KEYS` entries (deduplicated). pub proxy_key_count: usize, diff --git a/crates/proxy/src/main_helpers/async_main/mod.rs b/crates/proxy/src/main_helpers/async_main/mod.rs index 2fd09d0..e859249 100644 --- a/crates/proxy/src/main_helpers/async_main/mod.rs +++ b/crates/proxy/src/main_helpers/async_main/mod.rs @@ -336,8 +336,7 @@ pub async fn async_main(args: Vec, data_dir: PathBuf) { let (shutdown_tx, mut shutdown_rx1) = tokio::sync::watch::channel(false); let proxy_handle = tokio::spawn(async move { - // connect-info supplies the TCP peer SocketAddr to request extensions; - // auth's loopback-open default and the IP allowlist read it. + // ConnectInfo supplies the TCP peer SocketAddr for the IP allowlist. axum::serve( proxy_listener, app.into_make_service_with_connect_info::(), diff --git a/crates/proxy/src/server/middleware/auth.rs b/crates/proxy/src/server/middleware/auth.rs index c899c6a..1884c81 100644 --- a/crates/proxy/src/server/middleware/auth.rs +++ b/crates/proxy/src/server/middleware/auth.rs @@ -74,7 +74,7 @@ pub struct VirtualKeyContext { pub(crate) period_reset: Option, } -/// Which of `validate_auth`'s four success paths authenticated this request. +/// Which of `validate_auth`'s success paths authenticated this request. /// Inserted into request extensions at every success branch so a handler can /// tell what kind of credential got it in -- used by `ANTHROPIC_FORWARD_CLIENT_AUTH` /// to decide whether it's safe to forward that same credential upstream as the @@ -93,10 +93,6 @@ pub enum ClientAuthPath { VirtualKey, /// `PROXY_OPEN_RELAY=true`: any non-empty credential accepted. OpenRelay, - /// Loopback-open default: no proxy auth configured at all, request came - /// from a loopback peer. Not a real credential, so never forwarded upstream - /// (`client_auth_forwardable` returns false for it). - LoopbackOpen, } /// Controls which authentication paths are active. @@ -155,7 +151,7 @@ static ALLOWED_KEY_HASHES: LazyLock> = LazyLock::new(|| { .map(|s| s.trim().to_string()) .filter(|s| !s.is_empty()) .collect(); - // Posture logging (open-relay warn / loopback-open warn) is emitted once at + // Posture logging is emitted once at // startup by `log_effective_auth_posture`, AFTER virtual keys and OIDC are // registered, so it reflects the true posture instead of the partial // static-key/open-relay state visible at this LazyLock's init time. @@ -202,10 +198,7 @@ fn has_virtual_keys() -> bool { VIRTUAL_KEYS.get().map(|m| !m.is_empty()).unwrap_or(false) } -/// Whether the proxy has NO auth configured at all: no static keys, no open -/// relay, no virtual keys, no OIDC. In this state the proxy falls back to the -/// loopback-open default (see [`validate_auth`]): localhost is accepted without -/// a credential, LAN/remote peers are still rejected with 401. +/// Whether the proxy has no usable authentication source configured. fn no_auth_configured() -> bool { ALLOWED_KEY_HASHES.is_empty() && !*OPEN_RELAY @@ -225,21 +218,21 @@ pub enum EffectiveAuthMode { OpenRelay, /// At least one static key, virtual key, or OIDC configured (auth enforced). Keys, - /// Nothing configured: localhost open, LAN rejected (the default). - LoopbackOnly, + /// Nothing configured: every request is rejected. + AuthRequired, } /// The effective auth posture for this process: /// - [`EffectiveAuthMode::OpenRelay`] when `PROXY_OPEN_RELAY=true` (any non-empty /// key accepted on all interfaces). -/// - [`EffectiveAuthMode::LoopbackOnly`] when nothing is configured (localhost -/// open, LAN rejected, the default). +/// - [`EffectiveAuthMode::AuthRequired`] when nothing is configured (all +/// requests are rejected, the default). /// - [`EffectiveAuthMode::Keys`] otherwise (auth enforced). pub fn effective_auth_mode() -> EffectiveAuthMode { if open_relay_active() { EffectiveAuthMode::OpenRelay } else if no_auth_configured() { - EffectiveAuthMode::LoopbackOnly + EffectiveAuthMode::AuthRequired } else { EffectiveAuthMode::Keys } @@ -249,18 +242,18 @@ pub fn effective_auth_mode() -> EffectiveAuthMode { /// from `async_main` after virtual keys and OIDC are registered, so the message /// is accurate even for an OIDC-only or virtual-key-only deployment (unlike the /// old boot-time warn, which fired from the static-key `LazyLock` before those -/// sources existed and could mislabel such setups as "loopback-only"). +/// sources existed and could mislabel such setups as unconfigured). pub fn log_effective_auth_posture() { match effective_auth_mode() { EffectiveAuthMode::OpenRelay => tracing::warn!( "PROXY_OPEN_RELAY=true: proxy accepts ANY non-empty key on all \ interfaces. Set PROXY_API_KEYS to restrict access." ), - EffectiveAuthMode::LoopbackOnly => tracing::warn!( + EffectiveAuthMode::AuthRequired => tracing::warn!( "No PROXY_API_KEYS, virtual keys, OIDC, or PROXY_OPEN_RELAY set: \ - accepting unauthenticated requests from localhost only; LAN/remote \ - peers get 401. Set PROXY_API_KEYS to require a key, or \ - PROXY_OPEN_RELAY=true to accept any key on all interfaces." + rejecting all proxy requests. Set PROXY_API_KEYS to allow \ + authenticated access, or PROXY_OPEN_RELAY=true to accept any key \ + on all interfaces." ), EffectiveAuthMode::Keys => { tracing::info!("proxy auth enforced via keys / virtual keys / OIDC") @@ -268,35 +261,6 @@ pub fn log_effective_auth_posture() { } } -/// Whether the request's TCP peer is a loopback address. Reads `ConnectInfo` -/// (the real connection peer), NOT `X-Forwarded-For`, which is client-spoofable. -/// Fails closed: if `ConnectInfo` is absent (proxy not served with connect -/// info), returns false so the loopback-open default never accidentally opens. -fn peer_is_loopback(request: &Request) -> bool { - request - .extensions() - .get::>() - .map(|ci| is_loopback_ip(ci.0.ip())) - .unwrap_or(false) -} - -/// Loopback test that also accepts IPv4-mapped IPv6 (`::ffff:127.0.0.1`): -/// dual-stack listeners present IPv4 loopback peers as mapped v6, which std's -/// `Ipv6Addr::is_loopback()` (only `::1`) would wrongly classify as remote and -/// reject with 401. Never widens the surface beyond a genuine loopback peer. -fn is_loopback_ip(ip: std::net::IpAddr) -> bool { - match ip { - std::net::IpAddr::V4(v4) => v4.is_loopback(), - std::net::IpAddr::V6(v6) => { - v6.is_loopback() - || v6 - .to_ipv4_mapped() - .map(|v4| v4.is_loopback()) - .unwrap_or(false) - } - } -} - /// True when forwarding the client's own credential upstream /// (`ANTHROPIC_FORWARD_CLIENT_AUTH`) could let different callers each /// redirect the real Anthropic credential: 2+ distinct static keys with no @@ -310,7 +274,8 @@ pub fn forward_client_auth_misconfigured(key_count: usize, open_relay: bool) -> /// Validate that the request carries a valid API key. /// If `PROXY_API_KEYS` is set, the caller's key must be in the allowlist. -/// Otherwise, any non-empty key is accepted (backward-compatible open mode). +/// `PROXY_OPEN_RELAY=true` explicitly accepts any non-empty key; otherwise, +/// requests are rejected when no authentication source is configured. /// /// Anthropic: pub async fn validate_auth( @@ -318,20 +283,6 @@ pub async fn validate_auth( mut request: Request, next: Next, ) -> Result { - // Loopback-open default: when NO proxy auth is configured (no static keys, - // no open relay, no virtual keys, no OIDC), accept requests whose TCP peer - // is loopback so `localhost` works out of the box. LAN/remote peers fall - // through to the checks below and get 401. Runs before credential parsing so - // a header-less localhost call succeeds. - // ponytail: trusts the TCP peer. Behind a reverse proxy on localhost every - // request looks loopback -> effectively open; set PROXY_API_KEYS then. - if no_auth_configured() && peer_is_loopback(&request) { - request - .extensions_mut() - .insert(ClientAuthPath::LoopbackOpen); - return Ok(next.run(request).await); - } - // Accept x-api-key (Anthropic), x-goog-api-key (Gemini CLI), or Authorization: Bearer. let api_key = headers .get("x-api-key") @@ -597,12 +548,11 @@ pub async fn validate_auth( return Ok(next.run(request).await); } - // No match found: reject. `no_auth_configured()` here means the peer is - // non-loopback (loopback short-circuits at the top), so explain the - // localhost-only default rather than a generic "not configured". + // No match found: reject. When no auth source is configured, fail closed + // rather than exposing a browser-reachable local proxy. let message = if no_auth_configured() { - "This proxy accepts unauthenticated requests from localhost only. \ - Set PROXY_API_KEYS to allow authenticated remote access." + "Authentication is not configured. Set PROXY_API_KEYS to allow \ + authenticated access." } else { "Invalid API key." }; diff --git a/crates/proxy/src/server/middleware/auth/tests.rs b/crates/proxy/src/server/middleware/auth/tests.rs index efb20d3..6ad9f34 100644 --- a/crates/proxy/src/server/middleware/auth/tests.rs +++ b/crates/proxy/src/server/middleware/auth/tests.rs @@ -71,30 +71,3 @@ fn forward_client_auth_allows_exactly_one_key() { fn forward_client_auth_allows_zero_keys() { assert!(!forward_client_auth_misconfigured(0, false)); } - -#[test] -fn peer_is_loopback_reads_connect_info() { - use axum::extract::ConnectInfo; - use std::net::SocketAddr; - - let loopback = |addr: &str| { - let mut req = axum::http::Request::new(axum::body::Body::empty()); - req.extensions_mut() - .insert(ConnectInfo(addr.parse::().unwrap())); - peer_is_loopback(&req) - }; - assert!(loopback("127.0.0.1:5000")); - assert!(loopback("[::1]:5000")); - // IPv4-mapped IPv6: dual-stack listeners present IPv4 loopback peers as - // `::ffff:127.0.0.1`, which std `Ipv6Addr::is_loopback()` (only `::1`) - // would reject. Must still count as loopback. - assert!(loopback("[::ffff:127.0.0.1]:5000")); - // ... but a mapped non-loopback IPv4 must not. - assert!(!loopback("[::ffff:192.168.1.5]:5000")); - assert!(!loopback("192.168.1.5:5000")); - assert!(!loopback("10.0.0.3:5000")); - - // No ConnectInfo present -> fail closed (never auto-open). - let bare = axum::http::Request::new(axum::body::Body::empty()); - assert!(!peer_is_loopback(&bare)); -} diff --git a/crates/proxy/src/server/passthrough/auth.rs b/crates/proxy/src/server/passthrough/auth.rs index 6d0e2ec..9fb4063 100644 --- a/crates/proxy/src/server/passthrough/auth.rs +++ b/crates/proxy/src/server/passthrough/auth.rs @@ -161,9 +161,6 @@ mod tests { assert!(client_auth_forwardable(Some(ClientAuthPath::OpenRelay))); assert!(!client_auth_forwardable(Some(ClientAuthPath::VirtualKey))); assert!(!client_auth_forwardable(Some(ClientAuthPath::OidcJwt))); - // Loopback-open is not a real credential, so it must never be forwarded - // upstream (locks the security-relevant default against future regressions). - assert!(!client_auth_forwardable(Some(ClientAuthPath::LoopbackOpen))); assert!(!client_auth_forwardable(None)); } diff --git a/docs/ENDPOINTS.md b/docs/ENDPOINTS.md index c2e1658..8b6bf7b 100644 --- a/docs/ENDPOINTS.md +++ b/docs/ENDPOINTS.md @@ -55,11 +55,11 @@ Every proxy API endpoint except `/health` requires authentication. Unauthenticated requests return `401 Unauthorized` with an Anthropic-shaped error body. -### Loopback-open default +### Authentication default -When **no** proxy auth is configured (no `PROXY_API_KEYS`, no `PROXY_OPEN_RELAY=true`, no virtual keys, no OIDC), the proxy accepts unauthenticated requests **from loopback (localhost) peers only**; LAN/remote peers still get `401`. This makes local dev work out of the box while keeping the port closed to the network. The decision uses the real TCP peer address (`ConnectInfo`), not the client-spoofable `X-Forwarded-For`. +When **no** proxy auth is configured (no `PROXY_API_KEYS`, no `PROXY_OPEN_RELAY=true`, no virtual keys, no OIDC), the proxy rejects every request with `401`, including requests from localhost. Set `PROXY_API_KEYS` to allow authenticated access, or set `PROXY_OPEN_RELAY=true` only for explicitly open local development. -Caveat: behind a reverse proxy running on localhost, every request appears to come from loopback, so the proxy is effectively open. Set `PROXY_API_KEYS` in that topology. The effective posture is reported as `auth_mode` (`keys` / `open_relay` / `loopback_only`) by `GET /admin/api/status` and surfaced as a warning banner in the admin UI. +The effective posture is reported as `auth_mode` (`keys` / `open_relay` / `auth_required`) by `GET /admin/api/status` and surfaced as a warning banner in the admin UI. ### IP allowlist