omnigateway 0.10.3 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +19 -2
  2. package/bin/omni.js +621 -333
  3. package/gateway.js +715 -395
  4. package/package.json +2 -2
  5. package/public/assets/{Chip-BeKVtewW.js → Chip-BBNaA-sL.js} +1 -1
  6. package/public/assets/{CopyValue-NTHhiCuT.js → CopyValue-DQMqneTT.js} +1 -1
  7. package/public/assets/{Lamp-C2Q3t5Mn.js → Lamp-CosPf-gw.js} +7 -7
  8. package/public/assets/Rack-BGrdPQRN.js +476 -0
  9. package/public/assets/RequestTable-B5pOnwDe.js +11 -0
  10. package/public/assets/SummaryDeck-DAvCcP_N.js +15 -0
  11. package/public/assets/{Toggle-DwKz1aVq.js → Toggle-ZS3zIMNF.js} +1 -1
  12. package/public/assets/{TokenBreakdown-DM-1HvOr.js → TokenBreakdown-VV2U0Fgv.js} +1 -1
  13. package/public/assets/{WindowChart-BsonO5Py.js → WindowChart-eqPzFE06.js} +2 -2
  14. package/public/assets/_app.accounts-wJdiS7Ue.js +59 -0
  15. package/public/assets/{_app.console-BQJMLRv4.js → _app.console-DPuEIJl7.js} +2 -2
  16. package/public/assets/{_app.database-BIiajZm6.js → _app.database-BWxxqrNy.js} +4 -4
  17. package/public/assets/_app.index-C_jGPDHc.js +67 -0
  18. package/public/assets/_app.keys-vLOZaX9s.js +92 -0
  19. package/public/assets/{_app.logs-AyVq3lLb.js → _app.logs-4fRTXz5H.js} +3 -3
  20. package/public/assets/{_app.models-CwlkGPrx.js → _app.models-BFWk7FBf.js} +4 -4
  21. package/public/assets/{_app.plugins._pluginId-BhvEnawY.js → _app.plugins._pluginId-B2R5TEp9.js} +1 -1
  22. package/public/assets/_app.settings-BKUhzFsw.js +88 -0
  23. package/public/assets/_app.usage-Dme4K70C.js +76 -0
  24. package/public/assets/{chevron-right-S84SGCvk.js → chevron-right-CL2vJUko.js} +1 -1
  25. package/public/assets/client-DIfYMjPd.js +39 -0
  26. package/public/assets/index-teScS3wF.js +13 -0
  27. package/public/assets/{login-CitmheGz.js → login-CCLJgPoH.js} +2 -2
  28. package/public/assets/plus-C3pkG04C.js +1 -0
  29. package/public/assets/{preload-helper-BC9bKUg1.js → preload-helper-Dv9CFok1.js} +1 -1
  30. package/public/assets/{shared-C47BfV_u.js → shared-5YRtk6PC.js} +12 -12
  31. package/public/assets/{trash-2-DmtElUHr.js → trash-2-CLOg_lJ7.js} +1 -1
  32. package/public/index.html +4 -4
  33. package/public/assets/Rack-sUGRoZUx.js +0 -476
  34. package/public/assets/RequestTable-C2RLARWy.js +0 -11
  35. package/public/assets/SummaryDeck-BHXcb_Ji.js +0 -15
  36. package/public/assets/_app.accounts-DUYxItf0.js +0 -59
  37. package/public/assets/_app.index-DagK0Pqp.js +0 -62
  38. package/public/assets/_app.keys-DLAG_bmt.js +0 -82
  39. package/public/assets/_app.settings-BKA-1YLs.js +0 -88
  40. package/public/assets/_app.usage-C7JEWKZM.js +0 -76
  41. package/public/assets/client-DCvpw0LS.js +0 -39
  42. package/public/assets/index-pZbadEun.js +0 -13
  43. package/public/assets/plus-E7qLz9CF.js +0 -1
@@ -1,4 +1,4 @@
1
- import{wt as e}from"./Lamp-C2Q3t5Mn.js";import{t}from"./preload-helper-BC9bKUg1.js";import{C as n,a as r,c as i,d as a,f as o,i as s,l as c,r as l,t as u}from"./Panel-BlNr9j6-.js";import{t as d}from"./Rack-sUGRoZUx.js";import{t as f}from"./index-pZbadEun.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let t=w.get(e);if(t!==void 0)return t;let n={get:(t,n)=>c(C(e,t),n),post:(t,n)=>a(C(e,t),n),put:(t,n)=>o(C(e,t),n),del:t=>i(C(e,t))};return w.set(e,n),n}var E=h(e=>t(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
1
+ import{Dt as e}from"./Lamp-CosPf-gw.js";import{t}from"./preload-helper-Dv9CFok1.js";import{C as n,a as r,c as i,d as a,f as o,i as s,l as c,r as l,t as u}from"./Panel-BlNr9j6-.js";import{t as d}from"./Rack-BGrdPQRN.js";import{t as f}from"./index-teScS3wF.js";import{Component as p,Suspense as m,createContext as h,lazy as g,useContext as _,useMemo as v}from"react";import{Fragment as y,jsx as b,jsxs as x}from"react/jsx-runtime";import S from"styled-components";import{pluginApiPath as C}from"@omnigateway/dashboard-sdk";var w=new Map;function T(e){let t=w.get(e);if(t!==void 0)return t;let n={get:(t,n)=>c(C(e,t),n),post:(t,n)=>a(C(e,t),n),put:(t,n)=>o(C(e,t),n),del:t=>i(C(e,t))};return w.set(e,n),n}var E=h(e=>t(()=>import(e),[]));E.Provider;function D(){return _(E)}function O(e,t){let n=e?.default;if(n==null)throw Error(`plugin ${t} has no default export from definePluginUI`);if(typeof n.mount!=`function`)throw Error(`plugin ${t} exported a default without a mount function`);return n}function k(e,t,n){return g(async()=>{let r=O(await n(t),e);return{default:()=>r.mount({pluginId:e,api:T(e)})}})}var A=S.p`
2
2
  font-size: 13px;
3
3
  color: ${({theme:e})=>e.color.down};
4
4
  `,j=S.p`
@@ -0,0 +1,88 @@
1
+ import{Bt as e,Gt as t,It as n,Tt as r,Vt as i,X as a,Y as o,q as s}from"./Lamp-CosPf-gw.js";import{C as c,D as l,S as u,_ as d,a as f,b as p,g as m,h,i as g,o as _,t as v,v as y}from"./Panel-BlNr9j6-.js";import{t as b}from"./Rack-BGrdPQRN.js";import{t as x}from"./Toggle-ZS3zIMNF.js";import{i as S,n as C,t as w}from"./Field-DcNu4yw-.js";import{t as T}from"./Meter-stpt3vQu.js";import{n as E}from"./reasons-Du1OBWAM.js";import{useEffect as ee,useId as D,useState as O}from"react";import{Fragment as te,jsx as k,jsxs as A}from"react/jsx-runtime";import j from"styled-components";var M=j.p`
2
+ font-size: 12px;
3
+ color: ${({theme:e})=>e.color.inkDim};
4
+ max-width: 62ch;
5
+ `,N=j.p`
6
+ font-size: 12px;
7
+ color: ${({theme:e})=>e.color.down};
8
+ `,P=j.p`
9
+ font-size: 12px;
10
+ color: ${({theme:e})=>e.color.ok};
11
+ `,F=j(c)`
12
+ max-width: 320px;
13
+ `,I=j(d)`
14
+ color: ${({theme:e})=>e.color.inkDim};
15
+ `;function L(){let e=a(),[t,n]=O(``),[r,i]=O(``),[o,s]=O(``),[u,d]=O(null);return A(c,{$gap:2,children:[k(I,{children:`Admin password`}),k(M,{children:`Changing this signs every session out, including this one.`}),A(F,{$gap:2,children:[k(w,{label:`Current password`,children:e=>k(C,{...e,type:`password`,autoComplete:`current-password`,value:t,onChange:e=>n(e.target.value)})}),k(w,{label:`New password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>i(e.target.value)})}),k(w,{label:`Repeat new password`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:o,onChange:e=>s(e.target.value)})}),k(p,{$gap:2,children:k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(r.length<12){d(`A password must be at least 12 characters.`);return}if(r!==o){d(`The two new passwords do not match.`);return}d(null),e.mutate({current:t,password:r},{onSuccess:()=>E(`password-changed`),onError:e=>d(_(e))})},disabled:e.isPending||t.length===0||r.length===0,children:`Change password`})})]}),u===null?null:k(N,{role:`alert`,children:u})]})}function R(){let n=t(),r=e(),[i,a]=O(``),[o,s]=O(null),[u,d]=O(null),f=n.data?.viewerConfigured===!0;return A(c,{$gap:2,children:[k(I,{children:`Read-only password`}),A(M,{children:[`Opens a read-only console: every screen, without mutations, snapshot downloads, or request bodies.`,` `,n.isPending?`Checking whether one is set…`:f?`One is set. A new one replaces it; withdrawing ends read-only sessions at once.`:`None is set, so nobody can sign in read-only. There is no default password.`]}),A(F,{$gap:2,children:[k(w,{label:f?`Replace read-only password`:`Set read-only password`,hint:`At least 12 characters.`,children:e=>k(C,{...e,type:`password`,autoComplete:`new-password`,value:i,onChange:e=>a(e.target.value)})}),A(p,{$gap:2,children:[k(l,{type:`button`,$variant:`primary`,onClick:()=>{if(i.length<12){s(`A password must be at least 12 characters.`);return}s(null),r.mutate(i,{onSuccess:()=>{a(``),d(f?`Read-only password replaced.`:`Read-only access granted.`)},onError:e=>s(_(e))})},disabled:r.isPending||i.length===0,children:f?`Replace`:`Set`}),f?k(l,{type:`button`,$variant:`danger`,onClick:()=>{s(null),r.mutate(null,{onSuccess:()=>d(`Read-only access withdrawn.`),onError:e=>s(_(e))})},disabled:r.isPending,children:`Withdraw access`}):null]})]}),o===null?null:k(N,{role:`alert`,children:o}),u===null||o!==null?null:k(P,{role:`status`,children:u})]})}function ne(){return k(v,{legend:`Access`,children:A(c,{$gap:3,children:[k(L,{}),k(h,{}),k(R,{})]})})}var z=[{id:`claude`,label:`Claude Code`,where:`settings.json under ~/.claude`},{id:`opencode`,label:`opencode`,where:`opencode.json in your project`}],re=j(y)`
16
+ display: block;
17
+ white-space: pre;
18
+ overflow-x: auto;
19
+ padding: 0.75rem;
20
+ background: ${({theme:e})=>e.color.panelSunk};
21
+ border: 1px solid ${({theme:e})=>e.color.rule};
22
+ border-radius: 4px;
23
+ font-size: 0.8125rem;
24
+ line-height: 1.5;
25
+ `,ie=j.div`
26
+ color: ${({theme:e})=>e.color.inkDim};
27
+ font-size: 0.8125rem;
28
+ margin-bottom: 0.25rem;
29
+ `,B=j.p`
30
+ color: ${({theme:e})=>e.color.inkDim};
31
+ font-size: 0.8125rem;
32
+ margin: 0;
33
+ `,ae=j.div`
34
+ display: grid;
35
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
36
+ gap: ${({theme:e})=>e.space(2)};
37
+ `,oe=[{key:`defaultModel`,label:`Default model`,required:!0},{key:`fableModel`,label:`Fable model`,required:!1},{key:`opusModel`,label:`Opus model`,required:!1},{key:`sonnetModel`,label:`Sonnet model`,required:!1},{key:`haikuModel`,label:`Haiku model`,required:!1}];function V(){let[e,t]=O(`claude`),[n,i]=O(()=>({claude:{},opencode:{}})),a=r(),o=n[e],u=typeof o.defaultModel==`string`&&o.defaultModel!==``?o:void 0,d=s(e,u),m=z.find(t=>t.id===e);return k(v,{legend:`Agent setup`,children:A(c,{children:[k(p,{children:z.map(n=>k(l,{type:`button`,$variant:n.id===e?`primary`:`ghost`,onClick:()=>t(n.id),children:n.label},n.id))}),A(B,{children:[m?.where,`. The key is a placeholder — paste your own over it. Or run`,` `,A(y,{children:[`omni setup `,e]}),` to write these files directly.`]}),(a.data?.length??0)>0?k(ae,{children:oe.map(t=>k(w,{label:t.label,children:n=>A(S,{...n,value:o[t.key]??``,onChange:n=>i(r=>({...r,[e]:{...r[e],[t.key]:n.target.value||void 0}})),children:[k(`option`,{value:``,children:t.required?`Choose a pool`:`Not mapped`}),a.data?.map(e=>k(`option`,{value:e.id,children:e.id},e.id))]})},t.key))}):null,a.isLoading?k(f,{rows:2}):d.isError?k(g,{error:d.error,onRetry:()=>void d.refetch()}):d.isLoading?k(f,{rows:4}):(a.data?.length??0)===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):u===void 0?A(B,{children:[`Choose a default model to generate `,m?.label,` settings.`]}):d.data===void 0||d.data.length===0?k(B,{children:`No virtual models configured yet, so there is nothing to point a client at.`}):d.data.map(e=>A(`div`,{children:[k(ie,{children:e.path}),k(re,{as:`pre`,children:e.contents.trimEnd()})]},e.path)),d.isError?k(B,{children:_(d.error)}):null]})})}var H={off:`Off`,lite:`Lite — names the lazier option`,full:`Full — the ladder enforced`,ultra:`Ultra — challenges the requirement`},U=[{id:`tier`,label:`Tier`,blurb:`Prefers a lower tier.`},{id:`health`,label:`Health`,blurb:`Penalises recent failures and an open breaker.`},{id:`quota`,label:`Quota`,blurb:`Prefers accounts ahead of their window's burn rate.`},{id:`cost`,label:`Cost`,blurb:`Prefers the cheaper candidate.`},{id:`latency`,label:`Latency`,blurb:`Prefers the faster observed first token.`},{id:`load`,label:`Load`,blurb:`Prefers accounts with fewer requests in flight.`}],W=[{id:`maxAttempts`,label:`Attempts per request`,hint:`Candidates dispatch may try. 1 disables failover.`,unit:`attempts`,step:1,min:1},{id:`requestDeadlineMs`,label:`Request deadline`,hint:`Across all attempts. 0 disables only OmniGateway's deadline.`,unit:`ms`,step:1e3,min:0},{id:`breakerThreshold`,label:`Breaker threshold`,hint:`Consecutive failures before an account and model leaves rotation.`,unit:`failures`,step:1,min:1},{id:`breakerCooldownMs`,label:`Breaker cooldown`,hint:`Wait before a tripped account is probed. Doubles per extra failure.`,unit:`ms`,step:1e3,min:1},{id:`logRetentionDays`,label:`Log retention`,hint:`How long request rows are kept before pruning.`,unit:`days`,step:1,min:1},{id:`quotaPollIntervalMs`,label:`Quota poll interval`,hint:`How often a provider is asked for remaining quota. 0 disables. Needs a restart.`,unit:`ms`,step:6e4,min:0}],G=j.div`
38
+ display: grid;
39
+ grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
40
+ gap: ${({theme:e})=>e.space(3)};
41
+ `,K=j(c)`
42
+ gap: 6px;
43
+ `,q=j.p`
44
+ font-size: 11px;
45
+ color: ${({theme:e})=>e.color.inkDim};
46
+ `,J=j.div`
47
+ display: grid;
48
+ grid-template-columns: 1fr;
49
+ gap: ${({theme:e})=>e.space(2)};
50
+ align-items: start;
51
+ `,Y=j.div`
52
+ display: grid;
53
+ grid-template-columns: auto 1fr;
54
+ column-gap: ${({theme:e})=>e.space(2)};
55
+ row-gap: 4px;
56
+ align-items: center;
57
+ padding: ${({theme:e})=>e.space(2)};
58
+ background: ${({theme:e})=>e.color.panelSunk};
59
+ border: 1px solid ${({theme:e})=>e.color.rule};
60
+ border-radius: 3px;
61
+ `,X=j(q)`
62
+ grid-column: 2;
63
+ `,Z=j.label`
64
+ font-size: 12px;
65
+ font-weight: 600;
66
+ color: ${({theme:e})=>e.color.ink};
67
+ cursor: pointer;
68
+ `,se=j(Y)`
69
+ grid-template-columns: 1fr;
70
+
71
+ ${X} {
72
+ grid-column: 1;
73
+ }
74
+ `;function ce({label:e,children:t,blurb:n}){let r=D();return A(se,{children:[k(Z,{htmlFor:r,children:e}),t({id:r}),k(X,{children:n})]})}function Q({label:e,checked:t,disabled:n,onCheckedChange:r,children:i}){let a=D();return A(Y,{children:[k(x,{id:a,checked:t,onCheckedChange:r,label:e,...n===void 0?{}:{disabled:n}}),k(Z,{htmlFor:a,children:e}),k(X,{children:i})]})}var le=j.p`
75
+ font-size: 12px;
76
+ color: ${({theme:e})=>e.color.down};
77
+ `,$=j.p`
78
+ font-size: 12px;
79
+ color: ${({theme:e})=>e.color.ok};
80
+ `,ue=j.p`
81
+ font-size: 12px;
82
+ color: ${({theme:e})=>e.color.warn};
83
+ max-width: 72ch;
84
+
85
+ code {
86
+ font-family: ${({theme:e})=>e.font.mono};
87
+ }
88
+ `;function de(e){let t={};for(let n of U)t[`w.${n.id}`]=String(e.weights[n.id]);for(let n of W)t[n.id]=String(e[n.id]);return t.rtkEnabled=String(e.rtkEnabled),t.autoCacheEnabled=String(e.autoCacheEnabled),t.ponytailMode=e.ponytailMode,t.bodyLoggingEnabled=String(e.bodyLoggingEnabled),t.bodyLoggingCaptureStreamChunks=String(e.bodyLoggingCaptureStreamChunks),t}function fe(e){let t={};for(let n of U){let r=(e[`w.${n.id}`]??``).trim(),i=Number(r);if(r.length===0||!Number.isFinite(i))return{ok:!1,problem:`${n.label} must be a number.`};t[n.id]=i}let n={};for(let t of W){let r=(e[t.id]??``).trim(),i=Number(r);if(r.length===0||!Number.isInteger(i)||i<t.min)return{ok:!1,problem:`${t.label} must be a whole number of ${t.min} or more.`};n[t.id]=i}return n.maxAttempts>10?{ok:!1,problem:`Attempts per request cannot exceed 10.`}:{ok:!0,settings:{weights:t,...n,rtkEnabled:e.rtkEnabled===`true`,autoCacheEnabled:e.autoCacheEnabled===`true`,ponytailMode:e.ponytailMode!==void 0&&Object.hasOwn(H,e.ponytailMode)?e.ponytailMode:`off`,bodyLoggingEnabled:e.bodyLoggingEnabled===`true`,bodyLoggingCaptureStreamChunks:e.bodyLoggingCaptureStreamChunks===`true`}}}function pe(){let e=i(),t=o(),r=n(),[a,s]=O({}),[h,x]=O(null),[E,D]=O(!1);ee(()=>{e.data!==void 0&&s(de(e.data))},[e.data]);let j=Math.max(1e-4,...U.map(e=>Math.abs(Number(a[`w.${e.id}`])||0)));return A(te,{children:[k(b,{legend:`Settings`,title:`Routing and retention`,summary:`Applied to every request the gateway routes. Changes take effect on the next request; nothing restarts.`,actions:k(l,{type:`button`,$variant:`primary`,disabled:r.isPending||e.isLoading,onClick:()=>{D(!1);let e=fe(a);if(!e.ok){x(e.problem);return}x(null),r.mutate(e.settings,{onSuccess:()=>D(!0),onError:e=>x(_(e))})},children:r.isPending?`Saving…`:`Save changes`})}),e.isError?k(v,{legend:`Settings`,children:k(g,{error:e.error,onRetry:()=>void e.refetch()})}):e.isLoading?k(v,{legend:`Settings`,children:k(f,{rows:6})}):A(c,{$gap:4,children:[k(v,{legend:`Scoring weights`,meta:`relative to each other`,footer:A(p,{children:[k(d,{children:`Score is the sum of each term times its weight, then multiplied by the account and target weights.`}),k(u,{})]}),children:k(G,{children:U.map(e=>{let t=Number(a[`w.${e.id}`])||0;return A(K,{children:[k(w,{label:e.label,children:t=>k(C,{...t,type:`number`,step:.5,value:a[`w.${e.id}`]??``,onChange:t=>s({...a,[`w.${e.id}`]:t.target.value})})}),k(T,{fraction:Math.abs(t)/j,height:4,tone:`var(--accent)`,label:`${e.label} weight ${t}`}),k(q,{children:e.blurb})]},e.id)})})}),k(v,{legend:`Limits`,children:k(G,{children:W.map(e=>k(K,{children:k(w,{label:e.label,hint:e.hint,children:t=>A(p,{$gap:2,children:[k(C,{...t,type:`number`,min:e.min,step:e.step,value:a[e.id]??``,onChange:t=>s({...a,[e.id]:t.target.value})}),k(d,{children:e.unit})]})})},e.id))})}),A(m,{$min:`380px`,$stretch:!0,children:[k(v,{legend:`Request handling`,meta:`applied before dispatch`,children:A(J,{children:[k(Q,{label:`Enable RTK compression`,checked:a.rtkEnabled===`true`,onCheckedChange:e=>s({...a,rtkEnabled:String(e)}),children:`Compresses recognized historical tool results. Confirmed non-shell tools are excluded; unknown-origin results may be compressed only when a detector recognizes shell output. Lossy.`}),k(Q,{label:`Add a cache breakpoint when a client sends none`,checked:a.autoCacheEnabled===`true`,onCheckedChange:e=>s({...a,autoCacheEnabled:String(e)}),children:`Marks the end of the system prompt on Anthropic requests carrying no breakpoint of their own. Requests that mark one are untouched.`}),k(ce,{label:`Lazy senior dev mode`,blurb:`Appends the ponytail ruleset, about 1,240 tokens, to every system prompt. A request already carrying it is left alone.`,children:e=>k(S,{...e,value:a.ponytailMode??`off`,onChange:e=>s({...a,ponytailMode:e.target.value}),children:Object.entries(H).map(([e,t])=>k(`option`,{value:e,children:t},e))})})]})}),k(v,{legend:`Request and response bodies`,meta:t.data===!0?`permitted by the environment`:`not permitted`,children:A(c,{$gap:2,children:[t.data===!0?null:A(ue,{children:[`This gateway started without `,k(`code`,{children:`OMNI_BODY_LOGGING_ALLOWED`}),`, so nothing below can record anything. Set it in the installation's `,k(`code`,{children:`.env`}),` and restart first.`]}),A(J,{children:[k(Q,{label:`Capture request and response bodies`,checked:a.bodyLoggingEnabled===`true`,disabled:t.data!==!0,onCheckedChange:e=>s({...a,bodyLoggingEnabled:String(e)}),children:`Stores what each client sent and each provider returned, encrypted beside the database. Tokens and keys are masked; headers are never captured. Expires on the log retention window above.`}),k(Q,{label:`Also keep raw stream frames`,checked:a.bodyLoggingCaptureStreamChunks===`true`,disabled:t.data!==!0||a.bodyLoggingEnabled!==`true`,onCheckedChange:e=>s({...a,bodyLoggingCaptureStreamChunks:String(e)}),children:`Also keeps the raw SSE frames of each attempt. The most expensive thing capture stores.`})]})]})})]}),h===null?null:k(le,{role:`alert`,children:h}),E&&h===null?k($,{role:`status`,children:`Settings saved.`}):null,A(m,{$min:`380px`,$stretch:!0,children:[k(V,{}),k(ne,{})]}),k(v,{legend:`Known limits`,children:A(c,{$gap:2,children:[A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`rate limits`}),k(q,{children:`Counted per gateway process and reset when it restarts. Not shared across instances.`})]}),A(p,{$gap:2,$align:`start`,children:[k(y,{$dim:!0,children:`logs`}),k(q,{children:`Request rows record routing and token counts only. Prompts and responses only when body capture is on, to a separate encrypted store. Credentials to neither.`})]})]})})]})]})}var me=pe;export{me as component};
@@ -0,0 +1,76 @@
1
+ import{$ as e,A as t,At as n,B as r,C as i,Ct as a,D as o,Dt as s,E as c,Et as l,F as u,G as d,H as f,I as p,J as m,K as h,L as g,M as _,Mt as v,N as y,O as b,Ot as x,P as S,Q as C,R as w,S as T,St as E,T as D,Tt as O,U as k,V as ee,W as A,X as te,Y as ne,Z as re,_ as ie,_t as ae,a as j,at as oe,b as M,bt as N,c as se,ct as ce,d as P,dt as le,et as ue,f as de,ft as fe,g as pe,gt as me,h as he,ht as ge,i as _e,it as ve,j as ye,jt as be,k as xe,kt as Se,l as Ce,lt as we,m as Te,mt as Ee,n as De,nt as Oe,o as ke,ot as Ae,p as je,pt as Me,q as Ne,r as Pe,rt as Fe,s as F,st as Ie,t as Le,tt as Re,u as ze,ut as Be,v as Ve,vt as He,w as Ue,wt as We,x as I,xt as Ge,y as Ke,yt as qe,z as Je}from"./shared-5YRtk6PC.js";import{F as Ye,L,Ot as Xe,P as Ze,Tt as Qe,U as $e,bt as et,ft as tt,j as R,mt as nt,qt as z}from"./Lamp-CosPf-gw.js";import{C as B,_ as rt,b as V,g as it,t as at,v as H,w as ot,x as st}from"./Panel-BlNr9j6-.js";import{_ as ct,f as lt,m as ut,t as dt}from"./Rack-BGrdPQRN.js";import{i as ft,n as U,r as W,t as pt}from"./Table-CVDZ69Zx.js";import{i as G,n as mt,r as ht,t as gt}from"./SummaryDeck-DAvCcP_N.js";import*as K from"react";import{PureComponent as _t,forwardRef as vt,useMemo as q,useRef as yt,useState as bt}from"react";import{jsx as J,jsxs as Y}from"react/jsx-runtime";import X from"styled-components";function xt(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function St(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var Ct=(e,t,n)=>C(e,`xAxis`,xt(e,t),n),wt=(e,t,n)=>ue(e,`xAxis`,xt(e,t),n),Tt=(e,t,n)=>C(e,`yAxis`,St(e,t),n),Et=(e,t,n)=>ue(e,`yAxis`,St(e,t),n),Dt=N([ce,Ct,Tt,wt,Et],(e,t,n,r,i)=>He(e,`xAxis`)?Me(t,r,!1):Me(n,i,!1)),Ot=N([Re,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),kt=e=>{var t=ce(e);return He(t,`xAxis`)?`yAxis`:`xAxis`},At=(e,t)=>kt(e)===`yAxis`?St(e,t):xt(e,t),jt=(t,n,r)=>e(t,kt(t),At(t,n),r),Mt=N([Ot,jt],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=Oe(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),Nt=N([Ot,jt],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(O)}}),Pt=N([ce,Ct,Tt,wt,Et,Mt,oe,Dt,Ot,ve,Nt],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return pn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),Ft=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],It=[`id`,`baseLine`];function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(null,arguments)}function Rt(e,t){if(e==null)return{};var n,r,i=zt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Bt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.x,o=r[r.length-1]?.x;if(!qe(a)||!qe(o))return null;var c=t*Math.abs(a-o),l=Math.max(...r.map(e=>e.y||0));return s(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(e=>e.y||0),l)),s(l)?K.createElement(`rect`,{x:a<o?a:a-c,y:0,width:c,height:Math.floor(l+(i?parseInt(`${i}`,10):1))}):null}function Vt(e){var t=e.alpha,n=e.baseLine,r=e.points,i=e.strokeWidth,a=r[0]?.y,o=r[r.length-1]?.y;if(!qe(a)||!qe(o))return null;var c=t*Math.abs(a-o),l=Math.max(...r.map(e=>e.x||0));return s(n)?l=Math.max(n,l):n&&Array.isArray(n)&&n.length&&(l=Math.max(...n.map(e=>e.x||0),l)),s(l)?K.createElement(`rect`,{x:0,y:a<o?a:a-c,width:l+(i?parseInt(`${i}`,10):1),height:Math.floor(c)}):null}function Ht(e){var t=e.alpha,n=e.layout,r=e.points,i=e.baseLine,a=e.strokeWidth;return n===`vertical`?K.createElement(Vt,{alpha:t,points:r,baseLine:i,strokeWidth:a}):K.createElement(Bt,{alpha:t,points:r,baseLine:i,strokeWidth:a})}function Ut(e){var t=e.animationElapsedTime,n=t===void 0?1:t,r=e.isAnimating,i=r!==void 0&&r,a=e.isEntrance,o=a!==void 0&&a,s=e.layout,c=e.isRange,l=e.stroke,u=e.connectNulls,d=Rt(e,Ft),f=s===`vertical`?`vertical`:`horizontal`,m=u??!1,h=p(),g=d.id,_=d.baseLine,v=Rt(d,It),y=be(v),b=K.createElement(Ae,Lt({},d,{id:g,baseLine:_,connectNulls:m,stroke:`none`,className:`recharts-area-area`,layout:f})),x=l!==`none`&&K.createElement(Ae,Lt({},y,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:m,fill:`none`,stroke:l,points:d.points})),S=l!==`none`&&c&&Array.isArray(_)&&K.createElement(Ae,Lt({},y,{className:`recharts-area-curve`,layout:f,type:d.type,connectNulls:m,fill:`none`,stroke:l,points:_}));return o&&(i||n<1)?K.createElement(Se,null,K.createElement(`defs`,null,K.createElement(`clipPath`,{id:h},K.createElement(Ht,{alpha:n,points:d.points??[],baseLine:_,layout:f,strokeWidth:d.strokeWidth}))),K.createElement(Se,{clipPath:`url(#${h})`},b,x,S)):K.createElement(K.Fragment,null,b,x,S)}var Wt=[`id`],Gt=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function Kt(){return Kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Kt.apply(null,arguments)}function qt(e,t){if(e==null)return{};var n,r,i=Jt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Jt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Yt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Yt(Object(n),!0).forEach(function(t){Xt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xt(e,t,n){return(t=Zt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zt(e){var t=Qt(e,`string`);return typeof t==`symbol`?t:t+``}function Qt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var $t={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationMatchBy:ee,animationInterpolateFn:(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[Z(Z({},e.next),{},{x:a(e.prev.x,e.next.x,t),y:a(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:Ut,xAxisId:0,yAxisId:0,zIndex:Fe.area};function en(e,t){return e&&e!==`none`?e:t}var tn=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:en(r,i),value:me(n,t),payload:e}]},nn=K.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:x,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:me(o,t),hide:s,type:u,color:en(r,a),unit:c,formatter:l,graphicalItemId:d}};return K.createElement(k,{tooltipEntrySettings:f})});function rn(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=be(r);return K.createElement(y,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function an(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return K.createElement(h,{value:t?r:void 0},n)}function on(e){var t=e.points,r=e.baseLine,i=e.needClip,a=e.clipPathId,o=e.props,s=e.animationElapsedTime,c=e.isAnimating,l=e.isEntrance,u=o.layout,d=o.type,f=o.stroke,p=o.connectNulls,m=o.isRange,h=o.shape,g=o.id,_=qt(o,Wt),v=Z(Z({},n(_)),{},{id:g,points:t,connectNulls:p,type:d,baseLine:r,layout:u,stroke:f,isRange:m,animationElapsedTime:s,isAnimating:c,isEntrance:l});return K.createElement(K.Fragment,null,t?.length>1&&K.createElement(Se,{clipPath:i?`url(#clipPath-${a})`:void 0},K.createElement(A,{option:h,DefaultShape:$t.shape,shapeProps:v})),K.createElement(rn,{points:t,props:_,clipPathId:a}))}function sn(e,t,n){if(s(e)){var r=s(t)?t:void 0;return a(r,e,n)}if(l(e)||We(e)){var i=s(t)?t:void 0;return a(i,0,n)}return e}function cn(e){var t=e.needClip,n=e.clipPathId,i=e.props,a=e.previousPointsRef,o=e.previousBaselineRef,s=i.points,c=i.baseLine,l=i.isAnimationActive,u=i.animationBegin,d=i.animationDuration,f=i.animationEasing,p=i.animationMatchBy,m=i.animationInterpolateFn,h=q(()=>({points:s,baseLine:c}),[s,c]),_=Je(h,o),v=we(),y=w(i.onAnimationStart,i.onAnimationEnd),b=y.isAnimating,x=y.handleAnimationStart,S=y.handleAnimationEnd,C=_.startValue;if(v==null)return null;var T=Array.isArray(c)&&Array.isArray(C)?r(C,c,p):Array.isArray(c)?r(null,c,p):null;return K.createElement(g,{animationInput:h,animationIdPrefix:`recharts-area-`,items:s,previousItemsRef:a,isAnimationActive:l,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:x,onAnimationEnd:S,animationInterpolateFn:m,animationMatchBy:p,layout:v},(e,r,a)=>{var o=r===1?c:Array.isArray(c)?m(T,r,v):a?c:sn(c,C,r);return _.syncStepValue(o,r),K.createElement(an,{showLabels:!b,points:s},i.children,K.createElement(on,{points:e,baseLine:o,needClip:t,clipPathId:n,props:i,animationElapsedTime:r,isAnimating:b||r<1,isEntrance:a}),K.createElement(Ne,{label:i.label}))})}function ln(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=yt(null),a=yt();return K.createElement(cn,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var un=class extends _t{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,s=e.left,c=e.needClip,l=e.xAxisId,u=e.yAxisId,f=e.width,p=e.height,m=e.id,h=e.baseLine,g=e.zIndex;if(t)return null;var _=v(`recharts-area`,i),y=m,x=o(n),S=x.r,C=x.strokeWidth,w=d(n),T=S*2+C,E=c?`url(#clipPath-${w?``:`dots-`}${y})`:void 0;return K.createElement(te,{zIndex:g},K.createElement(Se,{className:_},c&&K.createElement(`defs`,null,K.createElement(b,{clipPathId:y,xAxisId:l,yAxisId:u}),!w&&K.createElement(`clipPath`,{id:`clipPath-dots-${y}`},K.createElement(`rect`,{x:s-T/2,y:a-T/2,width:f+T,height:p+T}))),K.createElement(ln,{needClip:c,clipPathId:y,props:this.props})),K.createElement(ye,{points:r,mainColor:en(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}),this.props.isRange&&Array.isArray(h)&&K.createElement(ye,{points:h,mainColor:en(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:E}))}};function dn(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=qt(e,Gt),g=Be(),v=re(),y=xe(p,m).needClip,b=fe(),x=Ge(t=>Pt(t,e.id,b))??{},S=x.points,C=x.isRange,w=x.baseLine,T=_();if(g!==`horizontal`&&g!==`vertical`||T==null||v!==`AreaChart`&&v!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:K.createElement(un,Kt({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:y,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var fn=(e,t,n,r,i)=>{var a=n??t;if(s(a))return a;var o=e===`horizontal`?i:r,c=o.scale.domain();if(o.type===`number`){var l=Math.max(c[0],c[1]),u=Math.min(c[0],c[1]);return a===`dataMin`?u:a===`dataMax`||l<0?l:Math.max(Math.min(c[0],c[1]),0)}return a===`dataMin`?c[0]:a===`dataMax`?c[1]:c[0]};function pn(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=fn(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=ae(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=ae(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>ae(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:Ee({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:Ee({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function mn(e){var t=E(e,$t),n=fe();return K.createElement(u,{id:t.id,type:`area`},e=>K.createElement(K.Fragment,null,K.createElement(f,{legendPayload:tn(t)}),K.createElement(nn,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),K.createElement(S,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:ge(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),K.createElement(dn,Kt({},t,{id:e}))))}var hn=K.memo(mn,Ie);hn.displayName=`Area`;var gn=[`axis`],_n=vt((e,t)=>K.createElement(i,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:gn,tooltipPayloadSearcher:ne,categoricalChartProps:e,ref:t})),vn=[`axis`],yn=vt((e,t)=>K.createElement(i,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:vn,tooltipPayloadSearcher:ne,categoricalChartProps:e,ref:t})),bn=53,Q=9,$=2,xn=X.div`
2
+ display: flex;
3
+ gap: ${$}px;
4
+ `,Sn=X.div`
5
+ display: grid;
6
+ grid-template-rows: repeat(7, ${Q}px);
7
+ gap: ${$}px;
8
+ padding-top: ${11}px;
9
+ font-size: 9px;
10
+ color: ${({theme:e})=>e.color.inkFaint};
11
+ `,Cn=X.div`
12
+ line-height: ${Q}px;
13
+ padding-right: 2px;
14
+ text-align: right;
15
+ `,wn=X.div`
16
+ display: grid;
17
+ grid-template-columns: repeat(${bn}, ${Q}px);
18
+ gap: ${$}px;
19
+ height: ${Q}px;
20
+ font-size: 9px;
21
+ color: ${({theme:e})=>e.color.inkFaint};
22
+ `,Tn=X.div`
23
+ white-space: nowrap;
24
+ line-height: ${Q}px;
25
+ `,En=X.div`
26
+ display: grid;
27
+ grid-template-columns: repeat(${bn}, ${Q}px);
28
+ gap: ${$}px;
29
+ `,Dn=X.div`
30
+ display: grid;
31
+ grid-template-rows: repeat(7, ${Q}px);
32
+ gap: ${$}px;
33
+ `,On=X.div`
34
+ width: ${Q}px;
35
+ height: ${Q}px;
36
+ border-radius: 2px;
37
+ background: ${({$level:e})=>e===0?`var(--panel-sunk)`:`color-mix(in oklch, var(--accent) ${[0,24,46,70,100][e]??100}%, var(--panel-sunk))`};
38
+ border: 1px solid var(--rule);
39
+ visibility: ${({$future:e})=>e?`hidden`:`visible`};
40
+
41
+ &:hover,
42
+ &:focus-visible {
43
+ outline: 1px solid var(--ink-dim);
44
+ outline-offset: 1px;
45
+ }
46
+ `,kn=X(V)`
47
+ gap: ${$}px;
48
+ `,An=X(H)`
49
+ color: ${({theme:e})=>e.color.inkDim};
50
+ font-size: 11px;
51
+ `;function jn(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(t.length*e))]??0;return[n(.25),n(.5),n(.75)]}function Mn(e,[t,n,r]){return e<=0?0:e<=t?1:e<=n?2:e<=r?3:4}function Nn({days:e,now:t,dayOffsetMinutes:n=null}){let[r,i]=bt(`tokens`),[a,o]=bt(null),s=pe(r),c=q(()=>{let r=new Map;for(let t of e){let e=Number(t.key);Number.isFinite(e)&&r.set(Ke(e,n),{requests:t.requests,errors:t.errors,costUsd:t.costUsd,inputTokens:t.inputTokens,outputTokens:t.outputTokens,cacheReadTokens:t.cacheReadTokens,cacheWriteTokens:t.cacheWriteTokens,rtkSavedTokens:t.rtkSavedTokens,rtkAppliedRequests:t.rtkAppliedRequests,durationMsSum:t.durationMsSum})}let i=Ke(t,n),a=se(i,6-Te(i,n)-370,n);return Array.from({length:bn},()=>Array.from({length:7},()=>{let e=a;return a=se(a,1,n),{at:e,totals:r.get(e)??F,future:e>i}}))},[e,t,n]),l=c.flat(),u=jn(l.map(e=>s.of({key:``,...e.totals}))),d=l.reduce((e,t)=>Ce(e,P(t.totals)),F),f=l.reduce((e,t)=>e+ +(t.totals.requests>0),0),p=(e,t)=>`${e}: ${R(t.requests)} requests, ${R(ze(t))} tokens, ${L(t.costUsd)}`;return J(at,{legend:`Activity`,meta:a===null?`${R(f)} active days`:void 0,actions:J(mt,{children:Pe.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:e.label},e.id))}),children:Y(B,{$gap:2,children:[J(st,{children:J(B,{$gap:1,style:{width:611},children:Y(xn,{children:[J(Sn,{"aria-hidden":`true`,children:[``,`Mon`,``,`Wed`,``,`Fri`,``].map((e,t)=>J(Cn,{children:e},t))}),Y(B,{$gap:1,children:[J(wn,{"aria-hidden":`true`,children:c.map((e,t)=>{let n=e[0],r=c[t-1]?.[0],i=n!==void 0&&(r===void 0||new Date(r.at).getMonth()!==new Date(n.at).getMonth());return J(Tn,{children:i&&n!==void 0?new Date(n.at).toLocaleDateString(`en-GB`,{month:`short`}):``},n?.at??t)})}),J(En,{role:`grid`,"aria-label":`${s.label} per day over the last year`,children:c.map(e=>J(Dn,{role:`row`,children:e.map(e=>J(On,{role:`gridcell`,tabIndex:-1,"aria-label":p(je(e.at),e.totals),title:p(je(e.at),e.totals),$future:e.future,$level:e.future?0:Mn(s.of({key:``,...e.totals}),u),onMouseEnter:()=>o(e),onMouseLeave:()=>o(null)},e.at))},e[0]?.at))})]})]})})}),Y(V,{$justify:`space-between`,$wrap:!0,children:[J(An,{children:a===null?p(`Last 12 months`,d):p(je(a.at),a.totals)}),Y(V,{$gap:1,children:[J(rt,{children:`Less`}),J(kn,{"aria-hidden":`true`,children:[0,1,2,3,4].map(e=>J(On,{$level:e,$future:!1},e))}),J(rt,{children:`More`})]})]})]})})}function Pn({buckets:e,by:t,since:n,until:r,metric:i,names:a,dayOffsetMinutes:o}){let s=I(n,r,t,o),c=new Map,l=new Map;for(let n of e){let e=n.split??`unknown`;c.set(e,Ce(c.get(e)??F,n));let r=l.get(e)??new Map,a=he(n.key,t);r.set(a,(r.get(a)??0)+i.of(n)),l.set(e,r)}let u=[...c.entries()].sort((e,t)=>i.of(P(t[1]))-i.of(P(e[1])));return J(st,{children:Y(pt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Key`}),J(W,{children:`Trend`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Failed`}),J(W,{$align:`right`,children:`Tokens`}),J(W,{$align:`right`,children:`Mean`}),J(W,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:u.map(([e,t])=>{let n=l.get(e)??new Map,r=e===`unknown`?`Unattributed`:a.get(e)??e;return Y(ft,{children:[J(U,{children:J(ot,{style:{display:`block`,maxWidth:`28ch`},children:r})}),J(U,{style:{width:120},children:J(lt,{values:s.map(e=>n.get(e)??0),height:20,label:`${r}: ${i.format(i.of(P(t)))} over the window`})}),J(U,{$align:`right`,$mono:!0,children:R(t.requests)}),J(U,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:Ye(t.requests===0?0:t.errors/t.requests,0)}),J(U,{$align:`right`,$mono:!0,children:R(ze(t))}),J(U,{$align:`right`,$mono:!0,children:Ze(t.requests===0?null:t.durationMsSum/t.requests)}),J(U,{$align:`right`,$mono:!0,children:L(t.costUsd)})]},e)})})]})})}var Fn=6,In=`__other__`,Ln=`unknown`;function Rn(e,t,n){let r=n.get(t);return r===void 0?e.find(e=>e.models.some(e=>e.id===t))?.id??null:r}function zn(e,t){return e===null?`var(--ink-faint)`:`color-mix(in oklch, ${ut(e)} ${Math.max(30,100-t*22)}%, var(--panel))`}function Bn({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a,metric:o,providers:s}){let c=Xe().data??[],l=[...de(e,o).entries()],u=l.slice(0,Fn),d=l.slice(Fn),f=[...new Set(u.map(([e])=>Rn(c,e,s)))].filter(e=>e!==null&&$e(c,e)===void 0).sort(),p=[];for(let e of[...c.map(e=>e.id),...f,null])u.filter(([t])=>Rn(c,t,s)===e).forEach(([t,n],r)=>{p.push({name:t,label:t===Ln?`Unresolved`:t,color:zn(e,r),totals:n})});d.length>0&&p.push({name:In,label:`${d.length} more`,color:`var(--ink-faint)`,totals:d.reduce((e,[,t])=>Ce(e,P(t)),F)});let h=new Set(u.map(([e])=>e)),g=new Map;for(let t of e){let e=t.split??Ln,r=`${he(t.key,n)} ${h.has(e)?e:In}`;g.set(r,(g.get(r)??0)+o.of(t))}let _=I(r,i,n,a).map(e=>{let t={at:e};for(let n of p)t[n.name]=g.get(`${e} ${n.name}`)??0;return t}),v=new Map(p.map(e=>[e.name,e.label]));return Y(B,{$gap:2,children:[J(Le,{$height:220,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:_,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tickFormatter:e=>o.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>{if(e!==!0||t===void 0||t.length===0)return null;let i=t.filter(e=>Number(e.value??0)>0);return Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),i.length===0?J(`div`,{children:`No ${o.label.toLowerCase()}`}):i.map(e=>Y(`div`,{children:[v.get(String(e.dataKey))??String(e.dataKey),` `,o.format(Number(e.value??0))]},String(e.dataKey)))]})}}),p.map(e=>J(hn,{type:`monotone`,dataKey:e.name,stackId:`models`,stroke:e.color,strokeWidth:2,fill:e.color,fillOpacity:.22,isAnimationActive:!1},e.name))]})})}),J(De,{children:p.map(e=>Y(`span`,{children:[J(j,{$color:e.color}),` `,J(ot,{title:`${e.label}: ${o.format(o.of(P(e.totals)))} ${o.label.toLowerCase()}`,style:{display:`inline-block`,maxWidth:`24ch`,verticalAlign:`bottom`},children:e.label})]},e.name))})]})}var Vn=`unknown`;function Hn(e,t){return $e(e,t)===void 0?`var(--ink-faint)`:ut(t)}function Un(e,t){return t===Vn?`Unresolved`:$e(e,t)?.label??t}function Wn({buckets:e,by:n,since:r,until:i,metric:a,dayOffsetMinutes:o}){let s=Xe().data??[],c=de(e,a),l=[...c.keys()].filter(e=>e!==Vn&&$e(s,e)===void 0).sort(),u=[...s.map(e=>e.id),...l,Vn].map(e=>({name:e,totals:c.get(e)})).filter(e=>e.totals!==void 0),d=u.map(e=>e.name),f=I(r,i,n,o),p=Ve(e,f,n,a),h=[...c.values()].reduce((e,t)=>e+t.requests,0);return Y(B,{$gap:3,children:[J(Le,{$height:200,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:p,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tickFormatter:e=>a.format(e),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:48}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>e!==!0||t===void 0||t.length===0?null:Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),t.map(e=>Y(`div`,{children:[Un(s,String(e.dataKey)),` `,a.format(Number(e.value??0))]},String(e.dataKey)))]})}),d.map(e=>J(hn,{type:`monotone`,dataKey:e,stackId:`providers`,stroke:Hn(s,e),strokeWidth:2,fill:Hn(s,e),fillOpacity:.22,isAnimationActive:!1},e))]})})}),J(De,{children:d.map(e=>Y(`span`,{children:[J(j,{$color:Hn(s,e)}),` `,Un(s,e)]},e))}),Y(pt,{children:[J(`thead`,{children:Y(`tr`,{children:[J(W,{children:`Provider`}),J(W,{$align:`right`,children:`Share`}),J(W,{$align:`right`,children:`Requests`}),J(W,{$align:`right`,children:`Failed`}),J(W,{$align:`right`,children:`Tokens`}),J(W,{$align:`right`,children:`Cost`})]})}),J(`tbody`,{children:u.map(({name:e,totals:t})=>Y(ft,{children:[Y(U,{children:[J(j,{$color:Hn(s,e)}),` `,Un(s,e)]}),J(U,{$align:`right`,$mono:!0,children:Ye(h===0?0:t.requests/h,0)}),J(U,{$align:`right`,$mono:!0,children:R(t.requests)}),J(U,{$align:`right`,$mono:!0,style:t.errors>0?{color:`var(--down)`}:void 0,children:R(t.errors)}),J(U,{$align:`right`,$mono:!0,children:R(ze(t))}),J(U,{$align:`right`,$mono:!0,children:L(t.costUsd)})]},e))})]})]})}var Gn=X.li`
52
+ display: grid;
53
+ grid-template-columns: minmax(0, 20ch) 1fr auto;
54
+ align-items: center;
55
+ gap: ${({theme:e})=>e.space(2)};
56
+ `,Kn=X.ol`
57
+ display: flex;
58
+ flex-direction: column;
59
+ gap: ${({theme:e})=>e.space(2)};
60
+ `,qn=X.div`
61
+ height: 8px;
62
+ border-radius: 2px;
63
+ background: ${({theme:e})=>e.color.panelSunk};
64
+ border: 1px solid ${({theme:e})=>e.color.rule};
65
+ overflow: hidden;
66
+ `,Jn=X.div`
67
+ width: ${({$share:e})=>`${Math.max(1.5,e*100)}%`};
68
+ height: 100%;
69
+ border-radius: 0 2px 2px 0;
70
+ background: ${({theme:e,$fault:t})=>t?e.color.down:e.color.accent};
71
+ opacity: 0.85;
72
+ `,Yn=X(ot)`
73
+ display: block;
74
+ font-family: ${({theme:e})=>e.font.mono};
75
+ font-size: 12px;
76
+ `,Xn=12;function Zn({buckets:e,metric:t,names:n,unknownLabel:r}){let i=new Map;for(let t of e)i.set(t.key,Ce(i.get(t.key)??F,t));let a=e=>e===`unknown`?r??`Unattributed`:n?.get(e)??e,o=[...i.entries()].map(([e,n])=>({name:a(e),entry:n,value:t.of(P(n))})).sort((e,t)=>t.value-e.value),s=o.slice(0,Xn),c=o.slice(Xn),l=s[0]?.value??0;return Y(B,{$gap:3,children:[J(Kn,{children:s.map(({name:e,entry:n,value:r})=>Y(Gn,{children:[J(Yn,{title:e,children:e}),J(qn,{children:J(Jn,{$share:l===0?0:r/l,$fault:n.requests>0&&n.errors===n.requests})}),Y(V,{$gap:2,children:[J(H,{$size:`12px`,children:t.format(r)}),J(H,{$size:`11px`,$dim:!0,children:L(n.costUsd)})]})]},e))}),c.length===0?null:J(H,{$size:`11px`,$dim:!0,children:`+ ${c.length} more, ${R(c.reduce((e,t)=>e+t.entry.requests,0))} requests`})]})}var Qn=[{id:`inputTokens`,label:`Uncached input`,opacity:.95},{id:`outputTokens`,label:`Output`,opacity:.7},{id:`cacheReadTokens`,label:`Cache read`,opacity:.45},{id:`cacheWriteTokens`,label:`Cache write`,opacity:.22}];function $n({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a}){let o=new Map;for(let t of e)o.set(he(t.key,n),t);let s=I(r,i,n,a).map(e=>{let t=o.get(e);return{at:e,inputTokens:t?.inputTokens??0,outputTokens:t?.outputTokens??0,cacheReadTokens:t?.cacheReadTokens??0,cacheWriteTokens:t?.cacheWriteTokens??0}}),c=Qn.map(e=>({...e,value:s.reduce((t,n)=>t+n[e.id],0)})),l=c.reduce((e,t)=>e+t.value,0);return Y(B,{$gap:3,children:[J(Le,{$height:200,children:J(le,{width:`100%`,height:`100%`,children:Y(_n,{data:s,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`at`,tickFormatter:e=>M(e,n),tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:44,tickFormatter:e=>R(e)}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t,label:r})=>e!==!0||t===void 0||t.length===0?null:Y(ke,{children:[J(`div`,{children:M(Number(r),n)}),Qn.map(e=>Y(`div`,{children:[e.label,` `,R(Number(t.find(t=>t.dataKey===e.id)?.value??0))]},e.id))]})}),Qn.map(e=>J(hn,{type:`monotone`,dataKey:e.id,stackId:`tokens`,stroke:`var(--accent)`,strokeOpacity:e.opacity,strokeWidth:1.5,fill:`var(--accent)`,fillOpacity:e.opacity*.5,isAnimationActive:!1},e.id))]})})}),J(De,{children:c.map(e=>Y(V,{$gap:1,children:[J(j,{$color:`var(--accent)`,style:{opacity:e.opacity}}),J(`span`,{children:e.label}),J(H,{$size:`11px`,children:R(e.value)}),J(H,{$size:`11px`,$dim:!0,children:Ye(l===0?0:e.value/l,0)})]},e.id))})]})}function er({buckets:e,by:n,since:r,until:i,dayOffsetMinutes:a}){let o=new Map;for(let t of e)o.set(he(t.key,n),t);let s=I(r,i,n,a).map(e=>{let t=o.get(e);return{at:e,label:M(e,n),requests:t?.requests??0,errors:t?.errors??0,costUsd:t?.costUsd??0,tokens:t===void 0?0:ze(t)}});return Y(B,{$gap:2,children:[J(Le,{$height:220,children:J(le,{width:`100%`,height:`100%`,children:Y(yn,{data:s,margin:{top:4,right:4,bottom:4,left:4},children:[J(t,{stroke:`var(--rule)`,vertical:!1}),J(D,{dataKey:`label`,tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,interval:`preserveStartEnd`,minTickGap:28}),J(Ue,{tick:{fill:`var(--ink-faint)`,fontSize:10},stroke:`var(--rule-strong)`,width:40}),J(m,{cursor:{stroke:`var(--rule-strong)`},content:({active:e,payload:t})=>{if(e!==!0||t===void 0||t.length===0)return null;let n=t[0]?.payload;return n===void 0?null:Y(ke,{children:[J(`div`,{children:n.label}),Y(`div`,{children:[R(n.requests),` requests`]}),Y(`div`,{children:[R(n.errors),` failed`]}),Y(`div`,{children:[R(n.tokens),` tokens`]}),J(`div`,{children:L(n.costUsd)})]})}}),J(hn,{type:`monotone`,dataKey:`requests`,stroke:`none`,fill:`var(--accent)`,fillOpacity:.12,isAnimationActive:!1}),J(c,{type:`monotone`,dataKey:`requests`,stroke:`var(--accent)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1}),J(c,{type:`monotone`,dataKey:`errors`,stroke:`var(--down)`,strokeWidth:2,dot:!1,activeDot:{r:4,stroke:`var(--panel)`,strokeWidth:2},isAnimationActive:!1})]})})}),Y(De,{children:[Y(`span`,{children:[J(j,{$color:`var(--accent)`}),` Requests`]}),Y(`span`,{children:[J(j,{$color:`var(--down)`}),` Failed`]})]})]})}var tr=864e5,nr=[{id:`requestedModel`,label:`As requested`,column:`Virtual model`},{id:`model`,label:`As served`,column:`Upstream model`}];function rr(){let{cadence:e}=ct(),[t,n]=bt(`24h`),[r,i]=bt(`tokens`),[a,o]=bt(`model`),s=ie(t),c=pe(r),l=nt().data??null,u=q(()=>s.grain===`daily`?Ke(Date.now()-s.ms,l):Math.floor((Date.now()-s.ms)/6e4)*6e4,[s,l]),d=q(()=>u+s.ms,[u,s]),f=q(()=>Ke(Date.now()-371*tr,l),[l]),p={since:u,grain:s.grain},m=z({...p,groupBy:s.by},e(6e4,`res:usage`)),h=z({...p,groupBy:s.by,splitBy:`provider`},e(6e4,`res:usage`)),g=z({...p,groupBy:s.by,splitBy:`model`},e(6e4,`res:usage`)),_=z({...p,groupBy:s.by,splitBy:`apiKey`},e(6e4,`res:usage`)),v=z({...p,groupBy:a},e(6e4,`res:usage`)),y=z({...p,groupBy:`credential`},e(6e4,`res:usage`)),b=z({since:f,grain:`daily`,groupBy:`day`},e(3e5,`res:usage`)),x=et(),S=tt(),C=Qe(),w=q(()=>{let e=new Map;for(let t of C.data??[])for(let n of t.targets)e.set(n.model,n.provider);return e},[C.data]),E=q(()=>{let e=new Map;for(let t of x.data??[])e.set(t.id,t.label);return e},[x.data]),D=q(()=>{let e=new Map;for(let t of S.data??[])e.set(t.id,t.label);return e},[S.data]),O=m.data??[],k=T(O),ee=ze(k),A={legend:`Nothing recorded`,message:`No requests landed in this window. Widen the range, or send traffic through the gateway.`};return Y(B,{$gap:4,children:[J(dt,{legend:`Usage`,title:`Requests, tokens, and spend`,summary:m.isLoading?`Reading usage…`:`${R(k.requests)} requests and ${L(k.costUsd)} over the last ${s.label}.`,actions:J(mt,{children:_e.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===t,"aria-pressed":e.id===t,onClick:()=>n(e.id),children:e.id},e.id))})}),J(gt,{buckets:O,since:u,until:d,by:s.by,rangeLabel:s.label,dayOffsetMinutes:l}),J(G,{legend:`Traffic`,meta:s.by===`hour`?`By hour`:`By day`,query:m,isEmpty:O.length===0,empty:A,children:J(er,{buckets:O,by:s.by,since:u,until:d,dayOffsetMinutes:l})}),J(mt,{children:Pe.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===r,"aria-pressed":e.id===r,onClick:()=>i(e.id),children:`Rank by ${e.label.toLowerCase()}`},e.id))}),J(G,{legend:`Traffic by upstream model`,meta:`${c.label}, ${s.by===`hour`?`by hour`:`by day`}`,query:g,isEmpty:(g.data??[]).length===0,empty:A,children:J(Bn,{buckets:g.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c,providers:w})}),Y(it,{$min:`480px`,$gap:4,children:[Y(B,{$gap:4,children:[J(G,{legend:`Providers`,meta:c.label,query:h,isEmpty:(h.data??[]).length===0,empty:A,children:J(Wn,{buckets:h.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c})}),J(Nn,{days:b.data??[],now:Date.now(),dayOffsetMinutes:l})]}),Y(B,{$gap:4,children:[J(G,{legend:`Token mix`,meta:R(ee),query:m,isEmpty:O.length===0,empty:A,children:J($n,{buckets:O,by:s.by,since:u,until:d,dayOffsetMinutes:l})}),J(G,{legend:`Models`,meta:nr.find(e=>e.id===a)?.column,query:v,isEmpty:(v.data??[]).length===0,empty:A,actions:J(mt,{children:nr.map(e=>J(ht,{type:`button`,$size:`sm`,$on:e.id===a,"aria-pressed":e.id===a,onClick:()=>o(e.id),children:e.label},e.id))}),children:J(Zn,{buckets:v.data??[],metric:c})}),J(G,{legend:`Accounts`,meta:c.label,query:y,isEmpty:(y.data??[]).length===0,empty:A,children:J(Zn,{buckets:y.data??[],metric:c,names:D,unknownLabel:`No account`})})]})]}),J(G,{legend:`API keys`,meta:c.label,query:_,isEmpty:(_.data??[]).length===0,empty:A,children:J(Pn,{buckets:_.data??[],by:s.by,since:u,until:d,dayOffsetMinutes:l,metric:c,names:E})})]})}var ir=rr;export{ir as component};
@@ -1 +1 @@
1
- import{b as e}from"./Rack-sUGRoZUx.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t as n,n as t};
1
+ import{b as e}from"./Rack-BGrdPQRN.js";var t=e(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),n=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t as n,n as t};
@@ -0,0 +1,39 @@
1
+ import{_ as e,i as t,y as n}from"./shared-5YRtk6PC.js";import{$ as r,F as i,I as ee,L as a,Q as te,V as ne,et as re,g as o,it as s,j as c,l as ie,nt as ae,r as l,rt as oe,tt as se,u as ce}from"./Lamp-CosPf-gw.js";import{C as u,D as le,O as d,_ as f,a as ue,b as p,i as de,t as fe,v as m,x as h,y as g}from"./Panel-BlNr9j6-.js";import{_ as pe,d as _,i as me,t as he}from"./Rack-BGrdPQRN.js";import{n as v,t as y}from"./chevron-right-CL2vJUko.js";import{i as b,r as x}from"./index-teScS3wF.js";import{i as S,n as ge}from"./Field-DcNu4yw-.js";import{t as C}from"./Meter-stpt3vQu.js";import{i as w,n as T,r as E,t as D}from"./Table-CVDZ69Zx.js";import{n as _e,r as O}from"./WindowChart-eqPzFE06.js";import{i as ve,n as ye,r as be,t as xe}from"./RequestTable-B5pOnwDe.js";import{i as k,n as A,r as Se,t as Ce}from"./SummaryDeck-DAvCcP_N.js";import{Fragment as we,useMemo as j,useState as M}from"react";import{jsx as N,jsxs as P}from"react/jsx-runtime";import F from"styled-components";var I=F.div`
2
+ display: grid;
3
+ grid-template-areas:
4
+ "chassis"
5
+ "main";
6
+ grid-template-columns: minmax(0, 1fr);
7
+ grid-template-rows: auto minmax(0, 1fr);
8
+ height: 100vh;
9
+ min-height: 0;
10
+ overflow: hidden;
11
+ `,L=F.main`
12
+ grid-area: main;
13
+ padding: ${({theme:e})=>e.space(4)};
14
+ display: flex;
15
+ flex-direction: column;
16
+ gap: ${({theme:e})=>e.space(4)};
17
+ min-width: 0;
18
+ min-height: 0;
19
+ overflow-y: auto;
20
+
21
+ @media (max-width: 720px) {
22
+ padding: ${({theme:e})=>e.space(3)};
23
+ }
24
+ `;function R({children:e}){let{cadence:t}=pe(),n=r(),i=re(200,t(1e4,`res:logs`));return P(I,{"data-testid":`client-shell`,children:[N(_,{logs:i.data??[],logsFailed:i.isError,signOut:{pending:n.isPending,run:()=>{n.mutate(void 0,{onSuccess:()=>window.location.assign(`/login`)})}}}),N(L,{children:e})]})}var z=[20,50,100,250],B={"1m":`per minute`,"5h":`per 5 hours`,"1w":`per week`};function Te({reading:e}){let t=e.window===null?`concurrent requests`:`${e.dimension} ${B[e.window]??e.window}`,n=e.dimension===`spend`?a:c,r=e.used===null?null:e.limit===0?1:e.used/e.limit;return P(w,{children:[N(T,{children:t}),N(T,{$align:`right`,$mono:!0,children:e.used===null?N(g,{children:`unknown`}):n(e.used)}),N(T,{$align:`right`,$mono:!0,children:n(e.limit)}),N(T,{children:r===null?null:N(C,{fraction:r,label:`${t}, ${Math.round(Math.min(1,r)*100)}% used`})})]})}function V(e){return{observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio}}function H(e){return{stale:e.stale,rolledOver:e.rolledOver,estimateStale:e.stale||e.rolledOver,survives:e.survives,exhaustsAt:e.exhaustsAt}}var U=F.div`
25
+ display: flex;
26
+ flex-direction: column;
27
+ gap: 4px;
28
+ `,Ee=F.div`
29
+ display: grid;
30
+ /* Bar, figure, legend — the accounts page's own three columns, so the two
31
+ screens read the same way and the legends stay aligned down the stack. */
32
+ grid-template-columns: 96px 34px 1fr;
33
+ align-items: center;
34
+ min-width: 208px;
35
+ gap: 6px;
36
+ `,W=F(m)`
37
+ font-size: 11px;
38
+ text-align: right;
39
+ `;function De({windows:e,open:t,onToggle:n}){let r=e[0],a=e.filter(e=>e.usedRatio!==null);return P(w,{children:[N(T,{children:r.label}),N(T,{children:a.length===0?N(g,{children:`unknown`}):N(U,{children:a.map(e=>P(Ee,{children:[N(C,{fraction:e.usedRatio,label:`${e.label} ${e.windowType} window, ${Math.round(e.usedRatio*100)}% used`}),N(W,{children:i(e.usedRatio,0)}),N(f,{children:o(e,H(e),Date.now(),ee)})]},e.windowType))})}),N(T,{$align:`right`,children:N(d,{type:`button`,$variant:`ghost`,$size:`sm`,"aria-expanded":t,"aria-label":`${t?`Hide`:`Show`} quota history for ${r.label}`,title:`${t?`Hide`:`Show`} quota history for ${r.label}`,onClick:n,children:N(t?v:y,{})})})]})}function G(){let{cadence:r,live:ee}=pe(),[o,d]=M(`24h`),[_,v]=M(`all`),[y,b]=M(``),[x,C]=M(z[0]),[F,I]=M(null),[L,R]=M(null),B=e(o),H=te().data??null,U=j(()=>B.grain===`daily`?n(Date.now()-B.ms,H):Math.floor((Date.now()-B.ms)/6e4)*6e4,[B,H]),Ee=j(()=>U+B.ms,[U,B]),W=oe(),G={since:U,grain:B.grain},K=s({...G,groupBy:B.by},r(6e4,`res:usage`)),q=s({...G,groupBy:`model`},r(6e4,`res:usage`)),J=re(x,r(ne,`res:logs`)),Y=se(6e4),X=Y.data??[],Oe=j(()=>{let e=new Map;for(let t of X){let n=e.get(t.provider)??new Map,r=n.get(t.credentialId);r===void 0?n.set(t.credentialId,[t]):r.push(t),e.set(t.provider,n)}return[...e.entries()].map(([e,t])=>[e,[...t.entries()].map(([e,t])=>({credentialId:e,windows:[...t].sort((e,t)=>l[e.windowType]-l[t.windowType])}))])},[X]),Z=X.map(e=>O(V(e))).filter(e=>e!==null),ke=Z.length===0?0:Math.floor(Math.min(...Z)/6e4)*6e4,Ae=ae({since:ke},L!==null&&Z.length>0),je=(J.data??[]).some(ce),Me=ve(ee&&je),Q=be(J.data??[],_,y),Ne=(J.data??[]).filter(ie).length,$=K.data??[],Pe=$.reduce((e,t)=>e+t.requests,0),Fe=$.reduce((e,t)=>e+t.costUsd,0);return P(u,{$gap:4,children:[N(he,{legend:`Client`,title:`Your usage`,summary:K.isLoading?`Reading your usage…`:`${c(Pe)} requests and ${a(Fe)} over the last ${B.label}.`,actions:N(A,{children:t.map(e=>N(Se,{type:`button`,$size:`sm`,$on:e.id===o,"aria-pressed":e.id===o,onClick:()=>d(e.id),children:e.id},e.id))})}),N(fe,{legend:`Your key`,meta:W.data===void 0?void 0:P(m,{$dim:!0,children:[W.data.prefix,`…`]}),children:W.isPending?N(ue,{rows:2}):W.isError?N(de,{legend:`Could not read your key`,error:W.error}):P(u,{$gap:2,children:[P(p,{$gap:2,$wrap:!0,children:[N(f,{children:W.data.label}),W.data.bodyLoggingOptOut?N(g,{children:`Request bodies are never stored for this key.`}):null]}),W.data.modelAllowlist===null?N(g,{children:`Every model this gateway serves.`}):W.data.modelAllowlist.length===0?N(g,{children:`No models. This key cannot serve a request.`}):N(p,{$gap:1,$wrap:!0,children:W.data.modelAllowlist.map(e=>N(m,{children:e},e))})]})}),N(Ce,{buckets:$,since:U,until:Ee,by:B.by,rangeLabel:B.label,dayOffsetMinutes:H}),N(k,{legend:`By model`,meta:B.label,query:{isLoading:q.isLoading,isError:q.isError,error:q.error,refetch:()=>void q.refetch()},failure:`Could not read usage`,empty:{legend:`No traffic`,message:`Nothing served in this window.`},isEmpty:(q.data??[]).length===0,children:N(h,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Model`}),N(E,{$align:`right`,children:`Requests`}),N(E,{$align:`right`,children:`Tokens`}),N(E,{$align:`right`,children:`Spend`})]})}),N(`tbody`,{children:(q.data??[]).map(e=>P(w,{children:[N(T,{$mono:!0,children:e.key}),N(T,{$align:`right`,$mono:!0,children:c(e.requests)}),N(T,{$align:`right`,$mono:!0,children:c(e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheWriteTokens)}),N(T,{$align:`right`,$mono:!0,children:a(e.costUsd)})]},e.key))})]})})}),N(k,{legend:`Your limits`,query:{isLoading:W.isLoading,isError:W.isError,error:W.error,refetch:()=>void W.refetch()},failure:`Could not read your limits`,empty:W.data?.limits===null?{legend:`Limits unreadable`,message:`This key's limits could not be read. Requests are refused until an operator repairs it.`}:{legend:`No limits`,message:`This key is not rate limited.`},isEmpty:W.data?.limits===null||(W.data?.limitUsage.length??0)===0,footer:N(g,{children:`Counted from completed requests, so a burst in flight right now may not be included yet.`}),children:N(h,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Limit`}),N(E,{$align:`right`,children:`Used`}),N(E,{$align:`right`,children:`Ceiling`}),N(E,{$width:`30%`,children:`Consumption`})]})}),N(`tbody`,{children:(W.data?.limitUsage??[]).map(e=>N(Te,{reading:e},`${e.dimension}:${e.window??`gauge`}`))})]})})}),N(k,{legend:`Provider headroom`,query:{isLoading:Y.isLoading,isError:Y.isError,error:Y.error,refetch:()=>void Y.refetch()},failure:`Could not read provider headroom`,empty:{legend:`No data`,message:`No provider has reported a usage window.`},isEmpty:X.length===0,footer:N(g,{children:`What each account serving this gateway has left. A request is served by whichever account of a provider can take it.`}),children:N(u,{$gap:4,children:Oe.map(([e,t])=>P(u,{$gap:1,children:[N(f,{children:e}),N(h,{children:P(D,{children:[N(`thead`,{children:P(`tr`,{children:[N(E,{children:`Account`}),N(E,{$width:`60%`,children:`Quota`}),N(E,{})]})}),N(`tbody`,{children:t.map(({credentialId:e,windows:t})=>P(we,{children:[N(De,{windows:t,open:L===e,onToggle:()=>R(L===e?null:e)}),L===e?N(w,{children:N(T,{colSpan:3,children:N(u,{$gap:4,children:t.map(e=>{let t=V(e),n=O(t),r=(Ae.data?.samples??[]).filter(t=>t.credentialId===e.credentialId&&t.windowType===e.windowType&&t.observedAt>=(n??0));return N(_e,{live:t,samples:r.map(e=>({observedAt:e.observedAt,windowType:e.windowType,windowMs:e.windowMs,resetsAt:e.resetsAt,usedRatio:e.usedRatio})),since:n,now:Date.now(),truncated:Ae.data?.truncated===!0&&n!==null&&r.length>0&&(r[0]?.observedAt??0)>n,ratePerHourRatio:e.ratePerHourRatio,exhaustsAt:e.exhaustsAt,survives:e.survives,stale:e.stale,rolledOver:e.rolledOver,spent:e.usedRatio===null?`no ceiling reported`:`${i(e.usedRatio,0)} used`,rateText:e.ratePerHourRatio===null?`unknown`:`${i(e.ratePerHourRatio,1)}/h`},e.windowType)})})})}):null]},e))})]})})]},e))})}),N(k,{legend:`Recent requests`,meta:`${Q.length} shown`,actions:P(A,{children:[N(ge,{value:y,placeholder:`Filter by model or error`,"aria-label":`Filter requests`,style:{width:200},onChange:e=>b(e.target.value)}),P(S,{value:_,"aria-label":`Show which requests`,style:{width:`auto`},onChange:e=>v(e.target.value),children:[N(`option`,{value:`all`,children:`All requests`}),N(`option`,{value:`failed`,children:`Failed only`})]}),N(S,{value:x,"aria-label":`How many requests to fetch`,style:{width:`auto`},onChange:e=>C(Number(e.target.value)),children:z.map(e=>P(`option`,{value:e,children:[`last `,e]},e))})]}),query:{isLoading:J.isLoading,isError:J.isError,error:J.error,refetch:()=>void J.refetch()},failure:`Could not read your requests`,empty:{legend:`No requests`,message:(J.data??[]).length===0?`Nothing served through this key yet.`:`No request in this window matches the filter. Clear it to see everything.`},isEmpty:Q.length===0,footer:P(g,{children:[c(Ne),` of the last `,c((J.data??[]).length),` failed.`]}),children:N(h,{children:N(ye,{rows:Q,now:Me,onOpen:I})})}),N(me,{open:F!==null,onOpenChange:e=>{e||I(null)},title:`Request detail`,width:`640px`,footer:N(le,{type:`button`,onClick:()=>I(null),children:`Close`}),children:F===null?null:N(xe,{log:F})})]})}var K=()=>N(x,{children:N(b,{children:N(R,{children:N(G,{})})})});export{K as component};
@@ -0,0 +1,13 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/_app-CWXzHdhc.js","assets/Panel-BlNr9j6-.js","assets/client-DIfYMjPd.js","assets/shared-5YRtk6PC.js","assets/Lamp-CosPf-gw.js","assets/Rack-BGrdPQRN.js","assets/chevron-right-CL2vJUko.js","assets/Field-DcNu4yw-.js","assets/Meter-stpt3vQu.js","assets/Table-CVDZ69Zx.js","assets/WindowChart-eqPzFE06.js","assets/RequestTable-B5pOnwDe.js","assets/TokenBreakdown-VV2U0Fgv.js","assets/Chip-BBNaA-sL.js","assets/SummaryDeck-DAvCcP_N.js","assets/Readout-D8Ofl3Gz.js","assets/login-CCLJgPoH.js","assets/reasons-Du1OBWAM.js","assets/_app.index-C_jGPDHc.js","assets/_app.accounts-wJdiS7Ue.js","assets/CopyValue-DQMqneTT.js","assets/plus-C3pkG04C.js","assets/trash-2-CLOg_lJ7.js","assets/Toggle-ZS3zIMNF.js","assets/_app.console-DPuEIJl7.js","assets/_app.database-BWxxqrNy.js","assets/_app.keys-vLOZaX9s.js","assets/_app.logs-4fRTXz5H.js","assets/_app.models-BFWk7FBf.js","assets/_app.settings-BKUhzFsw.js","assets/_app.usage-Dme4K70C.js","assets/_app.plugins._pluginId-B2R5TEp9.js","assets/preload-helper-Dv9CFok1.js"])))=>i.map(i=>d[i]);
2
+ import{$t as e,En as t,G as n,H as r,On as i,Ot as a,Sn as o,Tn as s,Zt as c,_n as l,bn as u,cn as d,dn as f,en as p,fn as m,gn as h,hn as g,in as _,ln as v,nn as y,on as b,pn as x,rn as S,sn as C,tn as w,un as T,vn as E,wn as D,xn as ee,yn as te}from"./Lamp-CosPf-gw.js";import{a as ne,c as re,i as ie,n as O,o as ae,r as k,s as oe,t as A}from"./preload-helper-Dv9CFok1.js";import{A as se,C as ce,D as le,_ as ue,a as de,k as j,l as fe,s as pe,t as me}from"./Panel-BlNr9j6-.js";import{g as he,h as ge,n as _e,p as ve}from"./Rack-BGrdPQRN.js";import{MutationCache as ye,QueryCache as be,QueryClient as xe,QueryClientProvider as Se,useQueryClient as Ce}from"@tanstack/react-query";import*as M from"react";import{StrictMode as we,createContext as Te,use as Ee,useEffect as N,useRef as De,useState as Oe,useSyncExternalStore as ke}from"react";import{Fragment as Ae,jsx as P,jsxs as F}from"react/jsx-runtime";import{createRoot as je}from"react-dom/client";import Me from"styled-components";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();function I(e){return e?.isNotFound===!0}function Ne(){try{return sessionStorage}catch{return}}var Pe=`tsr-scroll-restoration-v1_3`,Fe=Ne();function Ie(){try{return JSON.parse(Fe?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function Le(){try{Fe?.setItem(Pe,JSON.stringify(L))}catch{}}var L=Ie(),Re=`data-scroll-restoration-id`,ze=e=>e.state.__TSR_key||e.href;function Be(e){let t=e.getAttribute(Re);if(t)return`[${Re}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var Ve=!1,He=`window`;function Ue(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function We(e){let t=new Set;for(let n of e){if(n===He)continue;let e=Ue(n);e&&t.add(e)}return t}function Ge(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||ze,a=new Set,o=e=>{let t=L[e]||={};for(let e of a)e===document?t[He]={scrollX,scrollY}:e.isConnected&&(t[Be(e)]={scrollX:e.scrollLeft,scrollY:e.scrollTop})};n&&!r.restoration&&(r.restoration=!0,Ve=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,e=>{Ve||a.add(e.target)},!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&o(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{o(i(e.stores.resolvedLocation.get()??e.stores.location.get())),Le()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c=r.hash,l;if(a.clear(),r.next=!0,r.hash=!1,typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let u=i(t.toLocation),d=t.fromLocation&&i(t.fromLocation);if(r.restoring&&d&&d!==u){let e=L[d];if(e){let t=L[u];for(let n in e){if(n===He){if(s)continue}else{let e=Ue(n);if(!e||s&&o&&(l??=We(o),l.has(e)))continue}t||=L[u]={},t[n]??=e[n]}}}Ve=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){!e&&o&&(l??=We(o));let t=e&&i&&c,s=r.restoring?L[u]:void 0;if(s)for(let e in s){let{scrollX:r,scrollY:i}=s[e];if(e===He){if(t)continue;scrollTo({top:i,left:r,behavior:n}),a=!0}else{let t=Ue(e);t&&(t.scrollLeft=r,t.scrollTop=i,l?.delete(t))}}if(!e){let e={top:0,left:0,behavior:n};if(a||scrollTo(e),l)for(let t of l)t.scrollTo(e)}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{Ve=!1}}))}function Ke(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function qe(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function Je(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=qe(r):Array.isArray(t)?t.push(qe(r)):n[e]=[t,qe(r)]}return n}var Ye=/^(?:\s|["[{\d-]|fa|nu|tr)/,Xe=Qe(JSON.parse),Ze=$e(JSON.stringify,JSON.parse);function Qe(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=Je(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function $e(e,t){let n=t===JSON.parse;function r(r){if(r&&typeof r==`object`)try{return e(r)}catch{}else if(t&&typeof r==`string`){if(n&&!Ye.test(r))return r;try{return t(r),e(r)}catch{}}return r}return e=>{let t=Ke(e,r);return t?`?${t}`:``}}function et(e){return{input:({url:t})=>{for(let n of e)t=nt(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=rt(e[n],t);return t}}}function tt(e){let t=_(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=y([`/`,t,e.pathname]),e)}}function nt(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function rt(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function it(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i}=t,a=new Map,o=n(`idle`),s=n(e),c=n(void 0),l=n([]),u=r(()=>l.get().map(e=>a.get(e).get())),d=r(()=>({status:o.get(),isLoading:o.get()===`pending`,matches:u.get(),location:s.get(),resolvedLocation:c.get()}));function f(e){let t=a.get(e);return t||(t=n(void 0),a.set(e,t)),t}let p={status:o,location:s,resolvedLocation:c,ids:l,matches:u,byRoute:a,__store:d,getMatchStore:f,setMatches:m};function m(e){let t=l.get(),n=e.map(e=>e.routeId);i(()=>{h(t,n)||l.set(n);for(let e of t)n.includes(e)||a.get(e).set(()=>void 0);for(let t of e){let e=f(t.routeId);e.get()!==t&&e.set(t)}})}return p}var R=`__TSR_index`,at=`popstate`,ot=`beforeunload`;function st(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=dt(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[R];i=ct(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[R];i=ct(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[R]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function ct(e,t){t||={};let n=ft();return{...t,key:n,__TSR_key:n,[R]:e}}function lt(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>dt(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=ft();t.history.replaceState({[R]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_=()=>{g&&(S._ignoreSubscribers=!0,(g[2]?t.history.pushState:t.history.replaceState)(g[1],``,g[0]),S._ignoreSubscribers=!1,g=void 0,u=void 0)},v=(e,t,n)=>{let r=s(t),i=!!g;i||(u=l),l=dt(t,n),g=[r,n,g?.[2]||e],i||queueMicrotask(()=>_())},y=e=>{l=c(),S.notify({type:e})},b=async()=>{if(f){f=!1;return}let e=c(),n=e.state[R]-l.state[R],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),S.notify(u);return}}}l=c(),S.notify(u)},x=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},S=st({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>v(!0,e,t),replaceState:(e,t)=>v(!1,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:_,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(ot,x,{capture:!0}),t.removeEventListener(at,b)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(ot,x,{capture:!0}),t.addEventListener(at,b),t.history.pushState=function(...e){let r=n.apply(t.history,e);return S._ignoreSubscribers||y(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return S._ignoreSubscribers||y(`REPLACE`),n},S}function ut(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function dt(e,t){let n=ut(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=ft();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[R]:0,key:a,__TSR_key:a}}}function ft(){return(Math.random()+1).toString(36).substring(7)}function pt(e){return e.options.loader||e.options.beforeLoad||e.lazyFn||e.options.component?.preload||e.options.pendingComponent?.preload}function mt(e,t){return{fromLocation:t,toLocation:e,pathChanged:t?.pathname!==e.pathname,hrefChanged:t?.href!==e.href,hashChanged:t?.hash!==e.hash}}function ht({key:e,__TSR_key:t,__TSR_index:n,__hashScrollIntoViewOptions:r,...i}){return i}function gt(e,t,n,r){for(let i of t){if(r&&e._tx!==r)return;n.some(e=>e.routeId===i.routeId)||e.routesById[i.routeId].options.onLeave?.(i)}for(let i of n){if(r&&e._tx!==r)return;e.routesById[i.routeId].options[t.some(e=>e.routeId===i.routeId)?`onStay`:`onEnter`]?.(i)}}var _t=class{constructor(e,n){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.subscribers=new Set,this._cache=new Map,this._committed=[],this.routeBranchCache=new WeakMap,this.lightweightCache=new WeakMap,this.startTransition=async e=>(e(),!1),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??!1??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=p(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.history=this.options.history?this.options.history:lt()),this.origin=this.options.origin,this.origin||=window?.origin&&window.origin!==`null`?window.origin:`http://localhost`,this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=x(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=it(this.latestLocation,e),Ge(this)}let a=this.options.basepath??`/`,o=this.options.rewrite;if(r||n!==a||i!==o){this.basepath=a;let e=[],t=_(a);t&&t!==`/`&&e.push(tt({basepath:a})),o&&e.push(o),this.rewrite=e.length===0?void 0:e.length===1?e[0]:et(e),this.history&&this.updateLatestLocation(),this.stores&&this.stores.location.set(this.latestLocation)}},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=m(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&f(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{for(let t of this.subscribers)if(t.eventType===e.type)try{t.fn(e)}catch(e){console.error(e)}},this.parseLocation=(e,n)=>{let r=({pathname:e,search:r,hash:i,href:a,state:o})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let a=this.options.parseSearch(r),c=this.options.stringifySearch(a);return{href:e+c+i,publicHref:e+c+i,pathname:l(e).path,external:!1,searchStr:c,search:s(n?.search,a),hash:l(i.slice(1)).path,state:t(n?.state,o)}}let c=new URL(a,this.origin),u=nt(this.rewrite,c),d=this.options.parseSearch(u.search),f=this.options.stringifySearch(d);return u.search=f,{href:u.href.replace(u.origin,``),publicHref:a,pathname:l(u.pathname).path,external:!!this.rewrite&&u.origin!==this.origin,searchStr:f,search:s(n?.search,d),hash:l(u.hash.slice(1)).path,state:t(n?.state,o)}},i=r(e),{__tempLocation:a,__tempKey:o}=i.state;if(a&&(!o||o===this.tempLocationKey)){let e=r(a);return e.state.key=i.state.key,e.state.__TSR_key=i.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:i}}return i},this.resolvePathWithBase=(e,t)=>S({base:e,to:t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>{let t=Object.create(null),n=v(b(e),this.processedTree,!0);return n&&Object.assign(t,n.rawParams),[n?.branch||[this.routesById.__root__],t,n?.route]},this.buildLocation=e=>{let n=(n={})=>{if(n.href){let e=dt(n.href,{});n={...n,to:nt(this.rewrite,new URL(e.pathname,this.origin)).pathname,search:this.options.parseSearch(e.search),hash:e.hash.slice(1)}}let r=n._fromLocation||this._pendingLocation||this.latestLocation,i=this.matchRoutesLightweight(r);n.from;let a=n.unsafeRelative===`path`?r.pathname:n.from??i[1],o=i[2],c=i[3],d=this.resolvePathWithBase(a,n.to?`${n.to}`:`.`),f=Ct(n.params,c),p=this.routesByPath[b(d)],m;if(p)m=this.getRouteBranch(p);else if(d.includes(`$`))m=[];else{let[e,t,n]=this.getMatchedRoutes(d);m=e,this.options.notFoundRoute&&(!n||n.path!==`/`&&t[`**`])&&(m=[...m,this.options.notFoundRoute])}if(m.length&&ee(f))for(let e of m){let t=e.options.params?.stringify??e.options.stringifyParams;if(t){f===c&&(f=Object.assign(Object.create(null),f));try{Object.assign(f,t(f))}catch{}}}let h=e.leaveParams?d:l(w({path:d,params:f,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,g=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};m.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,bt(t.options.validateSearch,{...e,...g}))}catch{}}),g=e}g=xt(g,n,m,e._includeValidateSearch),g=s(o,g);let _=this.options.stringifySearch(g),v=n.hash===!0?r.hash:n.hash?u(n.hash,r.hash):void 0,y=v?`#${v}`:``,x=n.state===!0?r.state:n.state?u(n.state,r.state):{};n.state&&(x=t(r.state,x));let S=`${h}${_}${y}`,C,T,E=!1;if(this.rewrite){let e=new URL(S,this.origin),t=rt(this.rewrite,e);C=e.href.replace(e.origin,``),t.origin===this.origin?T=t.pathname+t.search+t.hash:(T=t.href,E=!0)}else C=te(S),T=C;return{publicHref:T,href:C,pathname:h,search:g,searchStr:_,state:x,hash:v??``,external:E,unmaskOnReload:n.unmaskOnReload}},r=n(e);if(e.mask)r.maskedLocation=n({from:e.from,...e.mask});else if(this.options.routeMasks){let t=d(r.pathname,this.processedTree);if(t){let i=Object.assign(Object.create(null),t.rawParams),{from:a,params:o,...s}=t.route,c=Ct(o,i);r.maskedLocation=n({from:e.from,...s,params:c})}}return r},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=b(this.latestLocation.href)===b(n.href)&&E(ht(n.state),ht(this.latestLocation.state)),a=this._commitPromise,o,s=new Promise(e=>{o=e});if(s.resolve=()=>{o(),a?.resolve()},this._commitPromise=s,i)this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t}),this.history.subscribers.size||this.load({action:{type:r}})}return this._scroll.next=n.resetScroll??!0,this._commitPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,...a}={})=>{let o=this.buildLocation({...a,_includeValidateSearch:!0});this._pendingLocation=o;let s=this.commitLocation({...o,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return queueMicrotask(()=>{this._pendingLocation===o&&(this._pendingLocation=void 0)}),s},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(o(t,this.protocolAllowlist))return;if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return}i.replace?window.location.replace(t):window.location.href=t;return}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.load=async e=>{this.updateLatestLocation(),e?.action&&(this._scroll.hash=e.action.type===`PUSH`||e.action.type===`REPLACE`),await rn(this,e)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&window.CSS?.supports?.(`selector(:active-view-transition-type(a))`)){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(mt(r,i)):t.types;if(a===!1)return e();n={update:e,types:a}}else n=e;return document.startViewTransition(n).updateCallbackDone}return e()},this.invalidate=e=>{let t=this._committed,n=e?.filter,r=this._preloads,i=new Set([...t,...this._cache.values(),...[...r?.values()??[]].flat(),...this._tx?.[3]??[]].filter(e=>!n||n(e)).map(e=>e.id)),a=[];for(let[e,t]of r??[])t.some(e=>i.has(e.id))&&(r.delete(e),a.push(e));let o=t=>{if(i.has(t.id)){let n=this.routesById[t.routeId],r={...t,invalid:!0,...(e?.forcePending||t.status===`error`||t.status===`notFound`)&&pt(n)?{status:`pending`,error:void 0}:void 0};return t._flight=void 0,r}return t};this._committed=t.map(o);for(let[t,n]of this._cache)i.has(t)&&(n.invalid=!0,e?.forcePending&&(n.status=`pending`));for(let e of i)this._flights?.delete(e);for(let e of a)e.abort();return this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href){let t=this.buildLocation(e.options).publicHref||`/`;e.options.href=t,e.headers.set(`Location`,t)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&o(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=this._cache,n=this._preloads,r=e?.filter,i=[],a=[];for(let[e,n]of t)(!r||r(n))&&(a.push(e),i.push(n));let o=[];for(let[e,t]of n??[])(!r||t.some(r))&&(o.push(e),i.push(...t));for(let e of a)t.delete(e);for(let e of o)n.delete(e);for(let e of i){let t=e._flight;e._flight=void 0,t&&!--t[2]&&(this._flights?.get(e.id)===t&&this._flights.delete(e.id),o.push(t[1]))}for(let e of o)e.abort()},this.loadRouteChunk=z,this.preloadRoute=e=>an(this,e),this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n),i=this.stores.status.get()===`pending`;if(t?.pending&&!i)return!1;let a=t?.pending??!i?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),o=T(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,a.pathname,this.processedTree);return!o||e.params&&!E(o.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?E(a.search,r.search,{partial:!0})?o.rawParams:!1:o.rawParams},this.getStoreConfig=n,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??Ze,parseSearch:e.parseSearch??Xe,protocolAllowlist:e.protocolAllowlist??g}),self.__TSR_ROUTER__=this}isShell(){return!!this.options.isShell}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=C(e),this.routeBranchCache.set(e,t)),t}matchRoutesInternal(e,n){let[r,i,a]=this.getMatchedRoutes(e.pathname),o=r,c=!1;(a?a.path!==`/`&&i[`**`]:b(e.pathname))&&(this.options.notFoundRoute?o=[...o,this.options.notFoundRoute]:c=!0);let l=c?St(this.options.notFoundMode,o):void 0,u=Array(o.length),d=this._committed,f=(e,t)=>{let n=d[t];return n?.routeId===e.id?n:e===this.options.notFoundRoute?d.find(t=>t.routeId===e.id):void 0},p;for(let r=0;r<o.length;r++){let a=o[r],c=u[r-1],d,m,h;{let t=c?.search??e.search,r=c?._strictSearch??void 0;try{let e=bt(a.options.validateSearch,{...t})??void 0;d={...t,...e},m={...r,...e}}catch(e){let r=e;if(e instanceof vt||(r=new vt(e.message,{cause:e})),n?.throwOnError)throw r;d=t,m={},h=r}}let g=``,_=``;try{g=a.options.loaderDeps?.({search:d})??``,_=g&&JSON.stringify(g)||``}catch(e){if(n?.throwOnError)throw e;h??=e}let{interpolatedPath:v,usedParams:y}=w({path:a.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),b=a.id+v+_,x=f(a,r),S=this._cache.get(b)??(x?.id===b?x:void 0);p=S?._strictParams??Object.assign(y,p);let C;if(!S)try{wt(a,p)}catch(e){if(C=I(e)||ae(e)?e:new yt(e.message,{cause:e}),n?.throwOnError)throw C}let T=x?`stay`:`enter`,E;if(S)E={...S,cause:T,search:s(x?x.search:S.search,d),_strictSearch:m,searchError:h};else{let e=pt(a)?`pending`:`success`;E={id:b,ssr:a.options.ssr,index:r,routeId:a.id,params:x?.params??p,_strictParams:p,pathname:v,updatedAt:Date.now(),search:x?s(x.search,d):d,_strictSearch:m,searchError:h,status:e,isFetching:!1,error:void 0,paramsError:C,context:{},abortController:n?._controller??new AbortController,cause:T,loaderDeps:x?t(x.loaderDeps,g):g,invalid:!1,preload:!1,staticData:a.options.staticData||{},fullPath:a.fullPath}}let D=l===a.id;E._notFound&&!D&&(E.error=void 0),E._notFound=D,u[r]=E}for(let e=0;e<u.length;e++){let t=u[e];t.params=t.cause===`stay`?s(t.params,p):p,n?._controller&&(t.context={})}return u}matchRoutesLightweight(e){let t=D(this.stores.ids.get()),n=t?this.stores.byRoute.get(t).get():void 0,r=n?.id,i=this.lightweightCache.get(e);if(i&&i[0]===r)return i[1];let[a,o]=this.getMatchedRoutes(e.pathname),s=D(a),c={...e.search};for(let e of a)try{Object.assign(c,bt(e.options.validateSearch,c))}catch{}let l=n&&n.routeId===s.id&&n.pathname===e.pathname,u;if(l)u=n.params;else{let e=Object.assign(Object.create(null),o);for(let t of a)try{wt(t,e)}catch{}u=e}let d=[a,s.fullPath,c,u];return this.lightweightCache.set(e,[r,d]),d}},vt=class extends Error{},yt=class extends Error{};function bt(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new vt(`Async validation not supported`);if(n.issues)throw new vt(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function xt(e,t,n,r){let i=[];for(let e of n){let t=e.options;`search`in t?t.search?.middlewares&&i.push(...t.search.middlewares):(t.preSearchFilters||t.postSearchFilters)&&i.push(({search:e,next:n})=>{let r=n(t.preSearchFilters?t.preSearchFilters.reduce((e,t)=>t(e),e):e);return t.postSearchFilters?t.postSearchFilters.reduce((e,t)=>t(e),r):r});let n=t.validateSearch;r&&n&&i.push(({search:e,next:t,meta:r})=>{let i=t(e);try{let e=bt(n,i);if(r&&e)for(let t in e)t in i||(r.defaulted||=new Map).set(t,e[t]);return{...i,...e}}catch{}return i})}let a=(e,n,r)=>{if(e>=i.length){if(!t.search)return{};if(t.search===!0)return n;let e=u(t.search,n);return r&&(r.explicit=e),e}return i[e]({search:n,next:(t,n)=>{if(n){let n=r||{};return{search:a(e+1,t,n),meta:n}}return a(e+1,t,r)},meta:r})};return a(0,e)}function St(e,t){if(e!==`root`){let e;for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.options.notFoundComponent)return r.id;e||=r.children&&r.id}if(e)return e}return re}function Ct(e,t){if(e===!1||e===null)return Object.create(null);if((e??!0)===!0)return t;let n=Object.assign(Object.create(null),t);return Object.assign(n,u(e,n))}function wt(e,t){let n=e.options.params?.parse??e.options.parseParams;n&&Object.assign(t,n(t))}function Tt(e,t){return e.options[t]?.preload?.()}function Et(e,t){let n=Tt(e,`component`),r=Tt(e,`pendingComponent`);return t&&(r?r=r.then(t):t()),n&&r?Promise.all([n,r]).then(()=>{}):n??r}function z(e,t,n){let r=()=>t===!1?void 0:t?Tt(e,t):Et(e,n),i=e._lazy;if(i)return i===!0?r():i.then(r);if(!e.lazyFn)return r();let a=e.lazyFn().then(t=>{{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazy=!0}},t=>{throw e._lazy=void 0,t});return e._lazy=a,a.then(r)}function Dt(e){let t=e.findIndex(e=>e.status!==`success`||e._notFound)+1;return t&&t<e.length?e.slice(0,t):e}var B=0,V=1,Ot=2,H=3,U=[4];function W(e){return typeof e[0]==`number`}function G(e,t){return t.aborted?Promise.race([Promise.reject(t),e]):new Promise((n,r)=>{let i=()=>r(t);t.addEventListener(`abort`,i,{once:!0}),Promise.resolve(e).then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}function K(e,t){return e.routesById[t.routeId]}function kt(e,t,n){return ae(e)?[H,e]:I(e)?(e.routeId||=n,[Ot,e]):t?(typeof e?.then==`function`&&(e=Error(`A Promise was thrown`,{cause:e})),[V,e]):[B,e]}function At(e,t){let n=kt(t,!0,e.id);if(n[0]!==V)return n;try{e.options.onError?.(n[1])}catch(t){n=kt(t,!0,e.id)}return n}function jt(e,t,n,r,i){return i[0].signal.aborted?U:Wt(e,t,n,At(n,r),i)}async function Mt(e,t,n,r,i,a){let[o,s]=t,c=n[0].signal,l=!!n[3];for(let i=n[6]??0;i<r;i++){let r=s[i],u=K(e,r);r.abortController=n[0];let d=s[i-1]?.context??e.options.context??{},f={params:r.params,location:o,navigate:t=>e.navigate({...t,_fromLocation:o}),buildLocation:e.buildLocation,cause:l?`preload`:r.cause,abortController:n[0],preload:l,matches:s,routeId:u.id};try{let e=r._ctx||=u.options.context?u.options.context({...f,deps:r.loaderDeps,context:d})||{}:void 0;r.context={...d,...e}}catch(a){return q(e,r),[i,jt(e,t,u,a,n)]}if(c.aborted)return[i,U];let p=r.paramsError??r.searchError;if(p!==void 0)return q(e,r),[i,jt(e,t,u,p,n)];let m=u.options.beforeLoad;if(!m)continue;let h=r.status;i>=a&&(r.status=`pending`,n[7]?.());try{Ft(e,r,`beforeLoad`,n[0]);let a=await G(m({...f,search:r.search,context:r.context,...e.options.additionalContext}),c);if(c.aborted)return[i,U];let o=Wt(e,t,u,kt(a,!1,u.id),n);if(o[0]!==B)return q(e,r),[i,o];r.context={...r.context,...a}}catch(a){return q(e,r),[i,jt(e,t,u,a,n)]}finally{r.status=h,Ft(e,r,!1,n[0])}}i()}function Nt(e,t,n){if(!(!n||--n[2])){if(e._flights?.get(t.id)===n){let n=e._tx;if(n&&!n[0].signal.aborted&&!n[3].includes(t)&&n[3].some(e=>e.id===t.id)&&n[3].some(e=>e.isFetching===`beforeLoad`))return;e._flights.delete(t.id)}return n[1]}}function q(e,t){let n=t._flight;t._flight=void 0,Nt(e,t,n)?.abort()}function J(e,t,n,r){let i=[];for(let a of t)if(!n?.includes(a)){let t=a._flight;if(a._flight=void 0,r&&t?.[2]===1&&e._flights?.get(a.id)===t&&n?.some(e=>e.id===a.id))t[2]=0;else{let n=Nt(e,a,t);n&&i.push(n)}}for(let e of i)e.abort()}function Pt(e){for(let t of e){let e=t._flight;e&&e[2]++}}function Ft(e,t,n,r){if(t.isFetching=n,r&&e._tx?.[0]!==r)return;let i=e.stores.byRoute.get(t.routeId),a=i?.get();a?.id===t.id&&i.set({...a,isFetching:n})}function It(e,t,n,r,i,a,o){let s=t[0];return{params:n.params,location:s,navigate:t=>e.navigate({...t,_fromLocation:s}),cause:o?`preload`:n.cause,abortController:i,preload:o,deps:n.loaderDeps,parentMatchPromise:a,context:n.context,route:r,...e.options.additionalContext}}async function Lt(e,t,n,r,i,a,o){let s=o[0],c=s.signal;if(c.aborted)return U;if(!i)return[B,void 0];let l=n._flight;Ft(e,n,`loader`,s);try{if(!l){let s=new AbortController;l=[Promise.resolve().then(()=>i(It(e,t,n,r,s,a,!!o[3]))).then(e=>kt(e,!1,r.id),e=>kt(e,!0,r.id)).then(t=>(t[0]!==B&&e._flights?.get(n.id)===l&&(e._flights.delete(n.id),l[2]||s.abort()),t[0]===V&&l[2]?At(r,t[1]):t)),s,1],(e._flights??=new Map).set(n.id,l)}return n._flight=l,n.abortController=l[1],Wt(e,t,r,await G(l[0],c),o)}catch(t){if(t!==c||!c.aborted)throw t;return q(e,n),U}finally{Ft(e,n,!1,s)}}function Rt(e,t,n){t[0]!==H&&(e.status=`success`,e.error=void 0,t[0]===B?(e.loaderData=t[1],e.invalid=!1,e.updatedAt=Date.now(),e.preload=n):e.invalid=!0)}function zt(e,t,n){let r=e._cache.get(t.id);if(r!==n||e._committed.some(e=>e.id===t.id&&e._flight===t._flight))return;let i={...t,_notFound:void 0,context:{}};i._flight&&i._flight[2]++,e._cache.set(t.id,i),r&&q(e,r)}function Bt(e,t){return t[0]===V||t[0]===Ot?{...e,status:t[0]===V?`error`:`notFound`,error:t[1],_flight:void 0}:e}function Vt(e,t,n,r,i,a,o){let s=t[1][n],c=K(e,s),l=!!a[3],u=e._cache.get(s.id),d,f=!1,p;try{if(s.status===`success`&&(d=c.options.shouldReload,typeof d==`function`&&(d=d(It(e,t,s,c,a[0],i,l))),a[0].signal.aborted&&(p=U)),!p){if(s.status!==`success`)f=!0;else{let t=l||s.preload?c.options.preloadStaleTime??e.options.defaultPreloadStaleTime??3e4:c.options.staleTime??e.options.defaultStaleTime??0;f=!!(s.invalid||d||d===void 0&&Date.now()-s.updatedAt>=t&&(a[5]||s.cause===`enter`||a[2].some(e=>e.routeId===s.routeId&&e.id!==s.id)))}}}catch(n){s.invalid=!0,q(e,s),p=jt(e,t,c,n,a)}let m=c.options.loader,h=typeof m==`function`,g=h?m:m?.handler,_=!l||c.options.preload!==!1,v=_&&m?e._flights?.get(s.id):void 0;v===s._flight||p?v=void 0:v&&!f&&!l&&d===void 0?f=!0:f||(v=void 0);let y=!(!m||!f||s.status!==`success`||l||a[4]||((h?void 0:m.staleReloadMode)??e.options.defaultStaleReloadMode)===`blocking`),b=f&&_,x=b&&!y&&(s.status!==`success`||!!m),S=n>=o?a[7]:void 0,C=c.lazyFn&&c._lazy!==!0?S:void 0;if(b&&!m&&(s.invalid=!1,s.updatedAt=Date.now()),v&&v[2]++,x){let t=s._flight;s._flight=v,Nt(e,s,t)?.abort(),n>=o&&(s.status=`pending`),S?.()}b||(s.isFetching=!1);let w=(p?Promise.resolve(p):x?Lt(e,t,s,c,g,i,a):Promise.resolve([B,s.loaderData])).then(t=>(x&&(Rt(s,t,l),t[0]===B&&(m&&!a[0].signal.aborted&&zt(e,s,u),n>=o&&(s.status=`pending`))),t)),T=G(Promise.resolve().then(()=>z(c,void 0,C)),a[0].signal).then(()=>void 0,r=>t[1].some((e,t)=>t<=n&&(e.status===`error`||e.status===`notFound`||e._notFound))?void 0:[n,jt(e,t,c,r,a)]).then(e=>w.then(t=>(x&&!e&&t[0]===B&&s.status===`pending`&&!a[0].signal.aborted&&(s.status=`success`,S?.()),e)));if(r.push([n,w,T]),!y)return w.then(e=>Bt(s,e));let E={...s,status:`pending`,preload:!1,_flight:v};s.invalid=!1,s.isFetching=`loader`;let D=Lt(e,t,E,c,g,i,a).then(e=>(s.isFetching=!1,Rt(E,e,!1),e));return(t[2]??=[]).push([n,D,T,E]),D.then(e=>Bt(E,e))}async function Ht(e,t,n,r,i=0){let a=n?.[1][1],o=a?.routeId?t.findIndex(e=>e.routeId===a.routeId):n?.[0]??t.length-1;o<0&&(o=0);for(let n=o;n>=0;n--){let i=K(e,t[n]);try{let e=z(i,!1);e&&await G(e,r)}catch(e){if(e===r&&r.aborted)throw e}if(i.options.notFoundComponent)return n}return a?.routeId?o:i}function Y(e,t){t[2]&&=(J(e,t[2].map(e=>e[3])),void 0)}async function Ut(e,t,n,r){let i;try{await Promise.all(e.map(e=>e[1].then(async t=>{let a=e[0];if(!(r&&a>=await r)){if(t[0]>=H)throw[a,t];!i&&t[0]!==B&&(i=[a,t],await Promise.all((n??[]).map(e=>{if(!(e[0]<=a))return e[1].then(t=>{if(t[0]===H)throw[e[0],t]})})))}})))}catch(e){return e}return t??i}function Wt(e,t,n,r,i,a){for(;r[0]===H;){let o=r[1],s=o.options;if(s.reloadDocument?i[3]:i[1]>=20)return r;try{return s.href&&s.reloadDocument?(e.resolveRedirect(o),r):[H,o,e.buildLocation({...s,_fromLocation:t[0],_includeValidateSearch:!0})]}catch(e){r=a?[V,e]:At(n,e),a=!0}}return r}async function Gt(e,t,n,r,i,a){let o=t[1],s=await i,c=!1,l=o.findIndex(e=>e._notFound),u=t=>t[1][0]===Ot?Ht(e,o,t,r.signal):t[0],d=l<0?o.length:l;if((s?.[1][0]??0)>=H)d=0;else if(s){d=s[2]??=await u(s);for(let e of n){if(e[0]>=d)break;let t=await e[1];if(t[0]!==B&&t[0]<H&&!(`loaderData`in o[e[0]])){s=[e[0],t],d=s[2]=await u(s);break}}}for(let e of n){if(e[0]>=d)break;let t=await e[2];if(t){s=t;break}}if((s?.[1][0]??0)>=H){let n=s[1];if(n[0]!==H||n[1].options.reloadDocument||n[2])return Y(e,t),n;c=!0,s=[0,[V,Error(`Too many redirects`)]]}let f=s?s[2]??await u(s):l;if(f>=0){let i=s?.[1],l=i?.[0],u=o[f],d=i?.[1],p=()=>{i&&(u._notFound=void 0,l===V?u.status=`error`:(d.routeId=u.routeId,u.routeId===e.routeTree.id?(u.status=`success`,u._notFound=!0):u.status=`notFound`),u.error=d,u.isFetching=!1)};p(),i||a?.();let m=K(e,u);try{await G(i?Promise.resolve().then(()=>z(m,l===V?`errorComponent`:`notFoundComponent`)):Promise.all([z(m),z(m,`notFoundComponent`)]),r.signal)}catch(n){if(n===r.signal&&r.signal.aborted)return Y(e,t),U}i?c&&(r.abort(),await Promise.all([...n.map(e=>e[1]),...n.map(e=>e[2]),...(t[2]??[]).map(e=>e[1])]),Y(e,t),J(e,o),p()):u.status=`success`}return t}async function Kt(e,t,n,r=0,i=t[1].length){let a=t[1];for(let t=r;t<i;t++){let r=a[t],i=K(e,r).options;if(i.head||i.scripts)try{let t={ssr:e.options.ssr,matches:a,match:r,params:r.params,loaderData:r.loaderData},[o,s]=await G(Promise.all([i.head?.(t),i.scripts?.(t)]),n);r.meta=o?.meta,r.links=o?.links,r.headScripts=o?.scripts,r.styles=o?.styles,r.scripts=s}catch(e){if(e===n&&n.aborted)break;console.error(e)}if(r.status!==`success`||r._notFound)break}return t}async function qt(e,t,n,r){let i=[t,n],a=r[0].signal,o;try{let t=e.stores.matches.get(),s=n.findIndex(e=>e._notFound);if(e.options.notFoundMode!==`root`&&s>=0){let t=await Ht(e,n,void 0,a,s);n[s]._notFound=void 0,n[t]._notFound=!0,s=t}let c=s<0?n.length:s+1,l=0;for(;l<c&&l!==s;){let e=n[l],i=r[2][l],a=t[l];if(i?.id!==e.id||i.status!==`success`||i._notFound||e.preload||a?.id!==e.id||a.status!==`success`||a._notFound)break;l++}let u=[],d=r[6]??0,f=d?Promise.resolve(n[d-1]):void 0,p=()=>{for(let t=d;t<c&&!a.aborted;t++)f=Vt(e,i,t,u,f,r,l)},m=await Mt(e,i,r,c,p,l);if(m){if(r[4]=!0,c=m[0],m[1][0]===Ot){let t=await Ht(e,n,m,a);m[2]=t,c=Math.min(c,t+1)}else m[1][0]>=H&&(c=0);p()}if(!a.aborted&&!r[3]){let t=[];for(let[n,r]of e._flights??[])r[2]||(e._flights.delete(n),t.push(r[1]));for(let e of t)e.abort()}let h=Gt(e,i,u,r[0],Ut(u,m,i[2]),r[7]);i[2]?.length&&(i[3]=Ut(i[2],void 0,void 0,h.then(e=>W(e)?0:Dt(n).length,()=>0))),o=await h}catch(t){if(Y(e,i),t===a&&a.aborted)return U;throw t}return W(o)?o:Kt(e,o,a,r[6]===n.length?r[6]:0)}function Jt(e,t){if(e._tx!==t)return;let n=t[3],r=e.stores.matches.get(),i=e._pending;for(let a=0;a<n.length;a++){let o=n[a],s=o.status===`success`&&!o._notFound,c=r[a]?.id===o.id&&r[a]?.status===`pending`;if(s&&!c)continue;let l=K(e,o),u=s||o.invalid?0:l.options.pendingMs??e.options.defaultPendingMs,d=l.options.pendingComponent??e.options.defaultPendingComponent;if(!d||typeof u!=`number`||u===1/0){i&&(i[0]=t,i[2]=0,i[4]=!0);return}let f=l.options.pendingMinMs??e.options.defaultPendingMinMs??0,p=!1;if(i?.[1]===o.id?(p=i[0]!==t,i[0]=t):(clearTimeout(i?.[3]),e._pending=i=void 0),i||(e._pending=i=[t,o.id,c?Date.now()+f:t[4]+u,void 0,c||void 0,d]),i[4]&&!p&&i[5]===d)return;if(i[5]=d,!i[4]){clearTimeout(i[3]);let n=i[2]-Date.now();if(n>0){i[3]=setTimeout(()=>Jt(e,t),n);return}i[2]=0}let m=n.map(e=>({...e,_flight:void 0}));m[a].status=`pending`;let h=i[4]=e.startTransition(()=>e.stores.setMatches(m),m).then(t=>(t&&e._pending===i&&i[4]===h&&!i[2]&&(i[2]=Date.now()+f),t));return}}function Yt(e,t){let n=e._pending;(e._tx===t||!e._tx?.[3].some(e=>e.id===n?.[1]))&&(clearTimeout(n?.[3]),e._pending=void 0)}async function Xt(e,t){let n=e._pending;if(!n)return;clearTimeout(n[3]);let r=n[2]-Date.now();if(!n[4]||r<=0||!Dt(t[3]).some(e=>e.id===n[1]))return;let i;try{await G(new Promise(e=>{i=setTimeout(e,r)}),t[0].signal)}catch{}clearTimeout(i)}function Zt(e,t){e._committed=t,e.stores.setMatches(t)}function Qt(e,t,n,r){let i=e._committed,a=e._cache;for(let e of n)e.preload=!1,r&&(e._assetEnd=void 0);let o=Dt(n).length,s=new Map;{let t=Date.now();for(let r of[...i,...a.values()]){if(r.status!==`success`||n.some((e,t)=>e.id===r.id&&(t<o||e.status===`success`)))continue;let i=K(e,r);!i.options.loader||t-r.updatedAt>=(r.preload?i.options.preloadGcTime??e.options.defaultPreloadGcTime??3e5:i.options.gcTime??e.options.defaultGcTime??3e5)||s.set(r.id,a.get(r.id)===r?r:{...r,_flight:void 0,isFetching:!1,context:{}})}}t[3]=[],e._cache=s,Zt(e,n),J(e,[...a.values(),...i],[...n,...s.values()]),gt(e,i,n,t)}async function $t(e,t){let n=e._tx;for(;n&&n!==t;){if(await n[5],e._tx===n)return;n=e._tx}}function en(e,t,n){let r=n[1].options,i=n[2];if(!i)return e.navigate({...r,replace:!0,ignoreBlocker:!0});if(r.reloadDocument)return e.navigate({href:i.publicHref,reloadDocument:!0,replace:!0,ignoreBlocker:!0});i._redirects=t[1]+1,e._pendingLocation=i;let a=e.commitLocation({...i,viewTransition:r.viewTransition,replace:!0,resetScroll:r.resetScroll,hashScrollIntoView:r.hashScrollIntoView,ignoreBlocker:!0});return queueMicrotask(()=>{e._pendingLocation===i&&(e._pendingLocation=void 0)}),a}async function tn(e,t,n,r,i){let a=n.map(e=>({...e}));Pt(a);for(let t of r)q(e,a[t[0]]),a[t[0]]=t[3];let o=[t[2],a],s;try{s=await Gt(e,o,r,t[0],i)}catch(t){throw J(e,a),t}if(W(s)){J(e,a),s[0]===H&&e._tx===t&&e._committed===n&&await en(e,t,s);return}if(await Kt(e,s,t[0].signal),e._tx!==t||e._committed!==n){J(e,a);return}for(let t of a){let n=e._cache.get(t.id);n?._flight&&n._flight===t._flight&&(e._cache.delete(t.id),q(e,n))}Zt(e,a),J(e,n,a)}async function nn(e,t,n,r,i,a){let o=await qt(e,t[2],t[3],[t[0],t[1],e._committed,void 0,i,n,a,r]);if(W(o)){let n=o[0]===H&&e._tx===t;if((!n||o[1].options.reloadDocument)&&Yt(e,t),J(e,t[3]),t[3]=[],!n)return;if(e._tx!==t){Yt(e,t);return}await en(e,t,o);return}let s=o[1];if(e._tx===t&&await Xt(e,t),e._tx!==t){Yt(e,t),J(e,s),Y(e,o);return}let c=t[2],l=mt(c,e.stores.resolvedLocation.get()),u=o[2];await e.startViewTransition(async()=>{if(e._tx===t&&await Xt(e,t),e._tx!==t){Yt(e,t),J(e,s),Y(e,o);return}let n=await e.startTransition(()=>{Yt(e,t),Qt(e,t,s,a),e._tx===t&&(e.emit({type:`onLoad`,...l}),e._tx===t&&e.emit({type:`onBeforeRouteMount`,...l}))},s);if(e._tx!==t){Y(e,o);return}u?.length&&tn(e,t,s,u,o[3]).catch(console.error),e.batch(()=>{e.stores.resolvedLocation.set(c),e.stores.status.set(`idle`),e._tx===t&&e.emit({type:`onResolved`,...l}),n&&e._tx===t&&e.emit({type:`onRendered`,...l})}),e._tx===t&&(e._commitPromise?.resolve(),e._commitPromise=void 0)})}async function rn(e,t){let n=e._tx,r=e.stores.resolvedLocation.get(),i=r??e.stores.location.get(),a=e.latestLocation,o=e._pendingLocation,s=o?.href===a.href?o._redirects??0:0,c=e._handoff,l=c?.[0](),u=new AbortController,d=e._preflight;if(e._preflight=u,l||c?.[1](),d?.abort(),!u.signal.aborted){let t=mt(a,r);e.emit({type:`onBeforeNavigate`,...t}),u.signal.aborted||e.emit({type:`onBeforeLoad`,...t})}if(u.signal.aborted){await $t(e,n);return}let f=i.href===a.href,p=u,m=e.matchRoutes(a,{_controller:u});Pt(m);let h=l?c[1](m):void 0;if(h?p=l:l?.abort(),u.signal.aborted){J(e,m),await $t(e,n);return}e._preflight=void 0;let g,_=()=>nn(e,y,f,()=>Jt(e,y),t?.sync,h),v=t?.sync?new Promise(e=>g=e):Promise.resolve().then(_).then(),y=[p,s,a,m,Date.now(),v];if(e._tx=y,n){for(let t of e.stores.matches.get()){if(e._tx!==y)break;t.isFetching&&Ft(e,t,!1)}n[0].abort(),J(e,n[3],y[3],!0)}if(e._tx!==y){J(e,y[3]),y[3]=[],g?.(),await $t(e,y);return}e.batch(()=>{e.stores.status.set(`pending`),e.stores.location.set(a)}),(h||!e._committed.length&&m[0]?.status!==`success`&&!m.some(e=>e._notFound))&&Jt(e,y),g?.(_()),await v,await $t(e,y)}async function an(e,t){let n=e.buildLocation(t);for(let t=0;;t++){let r=e._committed,i=new AbortController,a,o,s;try{try{a=e.matchRoutes(n,{_controller:i}),Pt(a),o=(e._preloads??=new Map).set(i,a),s=await qt(e,n,a,[i,t,r,!0])}finally{o&&(o=o.delete(i),J(e,a)),i.abort()}if(!W(s))return s[1];if(!o||s.length<3)return;n=s[2]}catch(e){I(e)||console.error(e);return}}}var on=class extends M.Component{constructor(...e){super(...e),this.state={error:null},this.reset=()=>{this.setState({error:null})}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onCatch?.(e,t)}render(){let e=this.state.error;return e?M.createElement(this.props.errorComponent??sn,{error:e,reset:this.reset}):this.props.children}};function sn({error:e}){let[t,n]=M.useState(!1);return F(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[F(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[P(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),P(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),P(`div`,{style:{height:`.25rem`}}),t?P(`div`,{children:P(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?P(`code`,{children:e.message}):null})}):null]})}var X=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(X||{});function cn({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(1)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(1)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function ln(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var un=[],dn=0,{link:fn,unlink:pn,propagate:mn,checkDirty:hn,shallowPropagate:gn}=cn({update(e){return e._update()},notify(e){un[vn++]=e,e.flags&=~X.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=X.Mutable|X.Dirty,xn(e))}}),_n=0,vn=0,Z,yn=0;function bn(e){try{++yn,e()}finally{--yn||Sn()}}function xn(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=pn(n,e)}function Sn(){if(!(yn>0)){for(;_n<vn;){let e=un[_n];un[_n++]=void 0,e.notify()}_n=0,vn=0}}function Cn(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?X.None:X.Mutable,get(){return Z!==void 0&&fn(i,Z,dn),i._snapshot},subscribe(e){let t=ln(e),n={current:!1},r=wn(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=Z,o=t?.compare??Object.is;if(n)Z=i,++dn,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=X.Mutable|X.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{Z=a,n&&(i.flags&=~X.RecursedCheck),xn(i)}}};return n?(i.flags=X.Mutable|X.Dirty,i.get=function(){let e=i.flags;if(e&X.Dirty||e&X.Pending&&hn(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&gn(e)}}else e&X.Pending&&(i.flags=e&~X.Pending);return Z!==void 0&&fn(i,Z,dn),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(mn(e),gn(e),Sn())}},i}function wn(e){let t=()=>{let t=Z;Z=n,++dn,n.depsTail=void 0,n.flags=X.Watching|X.RecursedCheck;try{return e()}finally{Z=t,n.flags&=~X.RecursedCheck,xn(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:X.Watching|X.RecursedCheck,notify(){let e=this.flags;e&X.Dirty||e&X.Pending&&hn(this.deps,this)?t():this.flags=X.Watching},stop(){this.flags=X.None,this.depsTail=void 0,xn(this)}};return t(),n}function Tn(e){let t=j(),n=`not-found-${c(t.stores.location,e=>e.pathname)}-${c(t.stores.status,e=>e)}`;return P(on,{getResetKey:()=>n,onCatch:(t,n)=>{if(I(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(I(t))return e.fallback?.(t);throw t},children:e.children})}function En(){return P(`p`,{children:`Not Found`})}function Q(e){return P(Ae,{children:e.children})}function Dn(e,t,n){return t.options.notFoundComponent?P(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?P(e.options.defaultNotFoundComponent,{...n}):P(En,{})}function On(e,t){let n=t?.options.pendingComponent??e.options.defaultPendingComponent;return n?P(n,{}):null}var kn=(e,t)=>e[0]===t[0]&&e[1]===t[1],An=(e,t,n)=>!t.isRoot||t.options.shellComponent||t.options.wrapInSuspense||n===!1||n===`data-only`||!e.ssr,jn=M.memo(function({routeId:e}){let t=j();return P(Mn,{router:t,match:c(t.stores.getMatchStore(e),e=>e)})});function Mn({router:t,match:n}){let r=t.routesById[n.routeId],i=On(t,r),a=r.options.errorComponent??t.options.defaultErrorComponent,o=r.options.onCatch??t.options.defaultOnCatch,s=r.isRoot?r.options.notFoundComponent??t.options.notFoundRoute?.options.component:r.options.notFoundComponent,c=n.ssr===!1||n.ssr===`data-only`,l=An(t,r,n.ssr)&&(r.options.wrapInSuspense??i??(r.options.errorComponent?.preload||c))?M.Suspense:Q,u=a?on:Q,d=s?Tn:Q;return F(r.isRoot?r.options.shellComponent??Q:Q,{children:[P(ne.Provider,{value:n.routeId,children:P(l,{fallback:i,children:P(u,{getResetKey:()=>n,errorComponent:a,onCatch:(e,t)=>{if(I(e))throw e.routeId??=n.routeId,e;o?.(e,t)},children:P(d,{fallback:e=>{if(e.routeId??=n.routeId,e.routeId!==n.routeId)throw e;return M.createElement(s,e)},children:c?P(e,{fallback:i,children:P(Nn,{match:n})}):P(Nn,{match:n})})})})}),null]})}var Nn=M.memo(function({match:e}){let t=j(),n=e.routeId,r=t.routesById[n],i=M.useMemo(()=>{let i=(r.options.remountDeps??t.options.defaultRemountDeps)?.({routeId:n,loaderDeps:e.loaderDeps,params:e._strictParams,search:e._strictSearch});return i?JSON.stringify(i):void 0},[n,e.loaderDeps,e._strictParams,e._strictSearch,r.options.remountDeps,t.options.defaultRemountDeps]),a=M.useMemo(()=>{let e=r.options.component??t.options.defaultComponent;return e?P(e,{},i):P(Pn,{})},[i,r.options.component,t.options.defaultComponent]);if(e.status===`pending`){if(t.ssr&&!An(t,r,e.ssr))return a;if(t._tx)throw t._tx[5];return On(t,r)}if(e.status===`notFound`)return Dn(t,r,e.error);if(e.status===`error`)throw e.error;return a}),Pn=M.memo(function(){let e=j(),t=M.useContext(ne),n,r,i;{let a=e.stores.getMatchStore(t);[n,r]=c(a,e=>[!!e._notFound,e.error],kn),i=c(e.stores.ids,e=>e[e.indexOf(t)+1])}if(n)return Dn(e,e.routesById[t],r);if(!i)return null;let a=P(jn,{routeId:i});return t===`__root__`?P(M.Suspense,{fallback:On(e),children:a}):a});function Fn(e,t){let n=e[1];e.length=0,n?.(t)}function In({t:e}){let t=j(),n=t._rendered??=[];return t.startTransition=(r,i)=>new Promise(a=>{Fn(n,!1),n.push(i,a),e(t),M.startTransition(r)}),i(()=>{let e=t.history.subscribe(t.load);t.updateLatestLocation();let r=t.latestLocation,i=t.buildLocation({to:r.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});if(b(r.publicHref)!==b(i.publicHref))return t.commitLocation({...i,replace:!0,ignoreBlocker:!0}),e;let a=t.stores.resolvedLocation.get();return a?.href===r.href&&a.state.__TSR_key===r.state.__TSR_key?n.push(t.stores.matches.get(),e=>{e&&t.emit({type:`onRendered`,...mt(a,a)})}):t._tx||t.load({sync:!0}).catch(console.error),e},[t,t.history]),null}function Ln(){let e=j(),t=e.routesById[re],n=On(e,t),r=e.ssr?Q:M.Suspense,i=F(Ae,{children:[P(In,{t:M.useState()[1]}),P(r,{fallback:n,children:P(Rn,{})})]});return e.options.InnerWrap?P(e.options.InnerWrap,{children:i}):i}function Rn(){let e=j(),t=e._rendered,n=c(e.stores.matches,e=>t[0]??e),r=n[0],a=r?.routeId;i(()=>{t[0]===n&&Fn(t,!0)},[t,n]);let o=a?P(jn,{routeId:a}):null;return P(ne.Provider,{value:a,children:e.options.disableGlobalCatchBoundary?o:P(on,{getResetKey:()=>r,onCatch:void 0,children:o})})}var zn=e=>({createMutableStore:Cn,createReadonlyStore:Cn,batch:bn}),Bn=e=>new Vn(e),Vn=class extends _t{constructor(e){super(e,zn)}};function Hn({router:e,children:t,...n}){ee(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=P(se.Provider,{value:e,children:t});return e.options.Wrap?P(e.options.Wrap,{children:r}):r}function Un({router:e,...t}){return P(Hn,{router:e,...t,children:P(Ln,{})})}var Wn=Me.div`
3
+ display: flex;
4
+ align-items: center;
5
+ justify-content: center;
6
+ min-height: 100vh;
7
+ padding: ${({theme:e})=>e.space(4)};
8
+ text-align: center;
9
+ `,Gn=Me.p`
10
+ font-size: 13px;
11
+ color: ${({theme:e})=>e.color.inkDim};
12
+ max-width: 48ch;
13
+ `,Kn=ie()({component:Pn,notFoundComponent:()=>P(Wn,{children:F(ce,{$gap:3,style:{alignItems:`center`},children:[P(ue,{children:`Not found`}),P(Gn,{children:`This console has no screen at that address.`}),P(le,{as:`a`,href:`/`,$variant:`primary`,$size:`sm`,children:`Back to the rack`})]})})}),qn=`stream:console`,Jn={"res:usage":{predicate:e=>e.queryKey[0]===`usage`||e.queryKey[0]===`client`&&(e.queryKey[1]===`usage`||e.queryKey[1]===`summary`)},"res:logs":{predicate:e=>e.queryKey[0]===`logs`&&e.queryKey[1]!==`body`||e.queryKey[0]===`client`&&e.queryKey[1]===`logs`},"res:credentials":{queryKey:n.credentials},"res:keys":{queryKey:n.keys},"res:settings":{queryKey:n.settings},"res:models":{queryKey:n.models},"res:quota":{queryKey:[`quota-history`]},[qn]:{queryKey:[`console`]}},Yn=Object.keys(Jn),Xn=Yn.filter(e=>e.startsWith(`res:`)),Zn=Yn.filter(e=>e.startsWith(`stream:`));function Qn(e,t){if(t===`res:*`){er(e);return}let n=Jn[t];n!==void 0&&e.invalidateQueries(n)}function $n(e){for(let t of Yn)Qn(e,t)}function er(e){e.invalidateQueries()}var tr=4401,nr=500,rr=3e4,ir=new Set([...Xn,...Zn]),ar=3,or=6e4,sr=(e,t)=>{let n=setTimeout(e,t);return()=>clearTimeout(n)};function cr(){let{protocol:e,host:t}=window.location;return`${e===`https:`?`wss:`:`ws:`}//${t}/api/stream`}function lr(e){if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t||Array.isArray(t))return null;let n=t,{type:r,topic:i,seq:a}=n;return typeof r!=`string`||i!==void 0&&typeof i!=`string`||a!==void 0&&typeof a!=`number`?null:{type:r,...typeof i==`string`?{topic:i}:{},...typeof a==`number`?{seq:a}:{},...`payload`in n?{payload:n.payload}:{}}}function ur(e){let t=new Set,n=new Set,r=new Map,i=new Map,a=new Map,o=e=>a.has(e)||ir.has(e),s=[],c=null,l=!1,u=!1,d=!1,f=!1,p=!1,m=0,h=null,g={status:`poll`,pushed:()=>!1};function _(){let e=p?`offline`:u&&!f?`push`:`poll`,r=e===`push`;g={status:e,pushed:e=>r&&n.has(e)};for(let e of t)e()}function v(e){c?.send(JSON.stringify(e))}function y(e,t){let n=i.get(e);if(n===void 0||n.size===0)return!1;for(let e of[...n])e(t);return!0}function b(){for(let e of Xn)v({type:`subscribe`,topic:e});for(let e of Zn){let t=r.get(e);v(t===void 0?{type:`subscribe`,topic:e}:{type:`subscribe`,topic:e,sinceSeq:t})}for(let e of a.keys())v({type:`subscribe`,topic:e})}function x(){u=!0,m=0,n.clear(),d&&$n(e.client),d=!0,b(),_()}function S(t){let i=lr(t.data);if(i===null)return;let{topic:a}=i;if(i.type===`ack`){a!==void 0&&o(a)&&(n.add(a),y(a,{kind:`open`}),_());return}if(i.type===`error`){a!==void 0&&(n.delete(a)&&_(),y(a,{kind:`refused`}));return}if(a!==void 0){if(i.type===`gap`){i.seq!==void 0&&r.set(a,i.seq),y(a,{kind:`gap`}),Qn(e.client,a);return}if(i.type===`event`){if(a===`res:*`){er(e.client);return}if(i.seq!==void 0){let t=r.get(a);if(r.set(a,i.seq),t!==void 0&&i.seq>t+1){y(a,{kind:`gap`}),Qn(e.client,a);return}}i.payload!==void 0&&y(a,{kind:`frame`,payload:i.payload})||Qn(e.client,a)}}}function C(t){let r=u;u=!1,c=null,n.clear();for(let e of[...i.keys()])y(e,{kind:`closed`});if(l){if(t.code===tr){p=!0,l=!1,_(),er(e.client);return}if(!r)f=!0;else{let t=e.now();s=[...s.filter(e=>e>t-or),t],s.length>=ar&&(f=!0)}_(),w()}}function w(){let t=Math.min(rr,nr*2**m);m+=1,h=e.timer(()=>{h=null,l&&T()},t)}function T(){let t=new WebSocket(e.url());c=t,t.addEventListener(`open`,x),t.addEventListener(`message`,S),t.addEventListener(`close`,C)}function E(e,t){let n=i.get(e)??new Set;return i.set(e,n),n.add(t),()=>{n.delete(t),n.size===0&&i.delete(e)}}return{subscribe(e){return t.add(e),()=>{t.delete(e)}},snapshot:()=>g,hold(e,t){let r=E(e,t),i=(a.get(e)??0)+1;a.set(e,i),i===1&&u&&v({type:`subscribe`,topic:e}),n.has(e)&&t({kind:`open`});let o=!1;return()=>{if(o)return;o=!0,r();let t=(a.get(e)??1)-1;if(t>0){a.set(e,t);return}a.delete(e),n.delete(e)&&_(),u&&v({type:`unsubscribe`,topic:e})}},publish(e,t){return!u||!n.has(e)?!1:(v({type:`send`,topic:e,payload:t}),!0)},onStream:E,start(){return l=!0,T(),()=>{l=!1,h?.(),h=null;let e=c;c=null,u=!1,e?.close()}}}}var dr=Te(null),fr=Te(null),pr=Te(null),mr={status:`poll`,pushed:()=>!1};function hr({children:e,enabled:t=!0,timer:n=sr,now:r=Date.now,url:i=cr}){let a=Ce(),[o]=Oe(()=>ur({client:a,timer:n,now:r,url:i})),[s]=Oe(()=>({subscribe:(e,t)=>o.hold(e,e=>{if(e.kind===`gap`){t({kind:`closed`});return}t(e)}),send:o.publish}));N(()=>{if(t)return o.start()},[o,t]);let c=ke(o.subscribe,o.snapshot,o.snapshot);return P(dr,{value:c,children:P(fr,{value:o.onStream,children:P(pr,{value:s,children:e})})})}function gr(){return Ee(dr)??mr}function _r(e,t){let n=Ee(fr),r=De(t);N(()=>{r.current=t}),N(()=>{if(n!==null)return n(e,e=>r.current(e))},[n,e])}function vr(e,t){let n=Ee(pr),r=De(t);N(()=>{r.current=t}),N(()=>{if(n!==null&&e!==null)return n.subscribe(e,e=>r.current(e))},[n,e])}function yr({children:e}){let t=gr(),n=Ee(pr);return P(he,{connection:t,...n===null?{}:{channels:n},children:e})}async function br(e){return e.queryClient.ensureQueryData({queryKey:n.status,queryFn:()=>fe(`/api/status`),revalidateIfStale:!0})}function xr(e){let t=e.principal;return e.authenticated!==!0||t==null?`/login`:t.kind===`client`?`/client`:t.kind===`admin`||t.kind===`viewer`?`/`:`/login`}function Sr(e,t){let n=xr(e);if(n===`/login`)throw oe({to:`/login`,search:{next:t}});if(n!==`/`)throw oe({to:n})}function Cr(e,t){let n=xr(e);if(n===`/login`)throw oe({to:`/login`,search:{next:t}});if(n!==`/client`)throw oe({to:n})}var wr=k(`/_app`)({beforeLoad:async({context:e,location:t})=>{Sr(await br(e),t.href),await e.queryClient.ensureQueryData(r)},pendingComponent:Tr,pendingMs:200,errorComponent:O(()=>A(()=>import(`./_app-CWXzHdhc.js`),__vite__mapDeps([0,1])),`errorComponent`),component:Er});function Tr(){return P(me,{legend:`Console`,children:P(de,{rows:6})})}function Er(){let e=a().data??[];return P(hr,{children:F(yr,{children:[P(ge,{$providers:e}),P(_e,{children:P(Pn,{})})]})})}var Dr=k(`/client`)({beforeLoad:async({context:e,location:t})=>{Cr(await br(e),t.href)},component:O(()=>A(()=>import(`./client-DIfYMjPd.js`),__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15])),`component`)}),Or=k(`/login`)({validateSearch:e=>({...typeof e.next==`string`?{next:e.next}:{},...typeof e.reason==`string`?{reason:e.reason}:{}}),component:O(()=>A(()=>import(`./login-CCLJgPoH.js`),__vite__mapDeps([16,4,1,7,17])),`component`)}),kr=k(`/_app/`)({component:O(()=>A(()=>import(`./_app.index-C_jGPDHc.js`),__vite__mapDeps([18,4,1,5,12,13,8,9,15])),`component`)}),Ar=k(`/_app/accounts`)({component:O(()=>A(()=>import(`./_app.accounts-wJdiS7Ue.js`),__vite__mapDeps([19,4,1,5,20,6,21,22,23,13,7,8,9,10,3])),`component`)}),jr=k(`/_app/console`)({component:O(()=>A(()=>import(`./_app.console-DPuEIJl7.js`),__vite__mapDeps([24,4,1,5,7])),`component`)}),Mr=k(`/_app/database`)({component:O(()=>A(()=>import(`./_app.database-BWxxqrNy.js`),__vite__mapDeps([25,4,1,5,22,7,8,9,15,17])),`component`)}),Nr=k(`/_app/keys`)({component:O(()=>A(()=>import(`./_app.keys-vLOZaX9s.js`),__vite__mapDeps([26,4,1,5,20,6,21,23,13,7,8,9])),`component`)}),Pr=k(`/_app/logs`)({component:O(()=>A(()=>import(`./_app.logs-4fRTXz5H.js`),__vite__mapDeps([27,4,1,5,13,7,11,12,9])),`component`)}),Fr=k(`/_app/models`)({component:O(()=>A(()=>import(`./_app.models-BFWk7FBf.js`),__vite__mapDeps([28,4,1,5,21,22,23,13,7,8])),`component`)}),Ir=k(`/_app/settings`)({component:O(()=>A(()=>import(`./_app.settings-BKUhzFsw.js`),__vite__mapDeps([29,4,1,5,23,7,8,17])),`component`)}),Lr=k(`/_app/usage`)({component:O(()=>A(()=>import(`./_app.usage-Dme4K70C.js`),__vite__mapDeps([30,3,4,1,5,9,14,15])),`component`)}),Rr=k(`/_app/plugins/$pluginId`)({component:O(()=>A(()=>import(`./_app.plugins._pluginId-B2R5TEp9.js`),__vite__mapDeps([31,4,1,32,5])),`component`)}),$=wr.update({id:`/_app`,getParentRoute:()=>Kn}),zr=Dr.update({id:`/client`,path:`/client`,getParentRoute:()=>Kn}),Br=Or.update({id:`/login`,path:`/login`,getParentRoute:()=>Kn}),Vr=kr.update({id:`/`,path:`/`,getParentRoute:()=>$}),Hr={AppAccountsRoute:Ar.update({id:`/accounts`,path:`/accounts`,getParentRoute:()=>$}),AppConsoleRoute:jr.update({id:`/console`,path:`/console`,getParentRoute:()=>$}),AppDatabaseRoute:Mr.update({id:`/database`,path:`/database`,getParentRoute:()=>$}),AppKeysRoute:Nr.update({id:`/keys`,path:`/keys`,getParentRoute:()=>$}),AppLogsRoute:Pr.update({id:`/logs`,path:`/logs`,getParentRoute:()=>$}),AppModelsRoute:Fr.update({id:`/models`,path:`/models`,getParentRoute:()=>$}),AppSettingsRoute:Ir.update({id:`/settings`,path:`/settings`,getParentRoute:()=>$}),AppUsageRoute:Lr.update({id:`/usage`,path:`/usage`,getParentRoute:()=>$}),AppIndexRoute:Vr,AppPluginsPluginIdRoute:Rr.update({id:`/plugins/$pluginId`,path:`/plugins/$pluginId`,getParentRoute:()=>$})},Ur={AppRoute:$._addFileChildren(Hr),ClientRoute:zr,LoginRoute:Br},Wr=Kn._addFileChildren(Ur)._addFileTypes();function Gr(e){return{isLoginRoute:()=>e().state.location.pathname===`/login`,onUnauthenticated:()=>void e().navigate({to:`/login`,search:{next:e().state.location.href}})}}function Kr(e){let t=t=>{t instanceof pe&&t.isUnauthenticated&&(e.isLoginRoute()||e.onUnauthenticated())};return new xe({queryCache:new be({onError:t}),mutationCache:new ye({onError:t}),defaultOptions:{queries:{retry:(e,t)=>t instanceof pe&&t.isUnauthenticated?!1:e<2,staleTime:5e3,refetchOnWindowFocus:!0},mutations:{retry:!1}}})}var qr,Jr=Kr(Gr(()=>qr));qr=Bn({routeTree:Wr,context:{queryClient:Jr}});var Yr=document.getElementById(`root`);if(Yr===null)throw Error(`#root is missing from index.html`);je(Yr).render(P(we,{children:P(ve,{children:P(Se,{client:Jr,children:P(Un,{router:qr})})})}));export{vr as a,Qn as c,yr as i,Or as n,_r as o,hr as r,qn as s,Rr as t};
@@ -1,4 +1,4 @@
1
- import{Kt as e,Rt as t,Vt as n,t as r,yt as i}from"./Lamp-C2Q3t5Mn.js";import{C as a,D as o,E as s,_ as c,b as l,n as u,o as d}from"./Panel-BlNr9j6-.js";import{n as f}from"./index-pZbadEun.js";import{n as p,t as m}from"./Field-DcNu4yw-.js";import{t as h}from"./reasons-Du1OBWAM.js";import{useState as g}from"react";import{jsx as _,jsxs as v}from"react/jsx-runtime";import y from"styled-components";var b=y.div`
1
+ import{Gt as e,Ht as t,St as n,Xt as r,t as i}from"./Lamp-CosPf-gw.js";import{C as a,D as o,E as s,_ as c,b as l,n as u,o as d}from"./Panel-BlNr9j6-.js";import{n as f}from"./index-teScS3wF.js";import{n as p,t as m}from"./Field-DcNu4yw-.js";import{t as h}from"./reasons-Du1OBWAM.js";import{useState as g}from"react";import{jsx as _,jsxs as v}from"react/jsx-runtime";import y from"styled-components";var b=y.div`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -42,4 +42,4 @@ import{Kt as e,Rt as t,Vt as n,t as r,yt as i}from"./Lamp-C2Q3t5Mn.js";import{C
42
42
  font: inherit;
43
43
  font-size: 12px;
44
44
  cursor: pointer;
45
- `;function O(){let s=e(),{next:u,reason:y}=f.useSearch(),O=n(),k=i(),A=t(),[j,M]=g(``),[N,P]=g(``),[F,I]=g(null),[L,R]=g(`admin`),z=O.data?.configured===!1,B=[{id:`admin`,label:`Operator`,blurb:`This console is for the operator of this gateway.`},...O.data?.viewerConfigured===!0?[{id:`viewer`,label:`Read-only`,blurb:`Everything the operator can see, and nothing they can change.`}]:[],{id:`client`,label:`API key`,blurb:`Your own usage, limits and requests. Sign in with a gateway API key.`}],V=L===`client`,H=h(y),U=k.isPending||A.isPending||O.isLoading,W=()=>{if(V){s({to:`/client`});return}s({to:u?.startsWith(`/`)===!0?u:`/`})};return _(b,{children:v(x,{children:[v(S,{children:[_(r,{state:O.isError?`down`:`ok`,label:O.isError?`gateway unreachable`:`gateway reachable`}),`Omnigateway`]}),v(C,{onSubmit:e=>{if(e.preventDefault(),I(null),z){if(j!==N){I(`The two passwords do not match.`);return}A.mutate(j,{onSuccess:W,onError:e=>I(d(e))});return}k.mutate({mode:L,secret:j},{onSuccess:W,onError:()=>I(V?`That API key was not accepted. It may have been revoked.`:`That password does not match. Try again.`)})},children:[O.isError?_(T,{children:`The gateway is not answering. Check that it is running, then reload.`}):null,H===null?null:_(E,{role:`status`,children:H}),v(a,{$gap:1,children:[_(c,{children:z?`First run`:`Sign in`}),_(w,{children:z?`Set the operator password for this gateway. It is the only account, and it is stored hashed.`:B.find(e=>e.id===L)?.blurb??``})]}),z||B.length<2?null:_(l,{$gap:1,$wrap:!0,role:`tablist`,"aria-label":`Sign in as`,children:B.map(e=>_(D,{type:`button`,role:`tab`,"aria-selected":e.id===L,$on:e.id===L,onClick:()=>{R(e.id),M(``),I(null)},children:e.label},e.id))}),_(m,{label:V?`API key`:`Password`,children:e=>_(p,{...e,type:`password`,autoFocus:!0,autoComplete:z?`new-password`:V?`off`:`current-password`,value:j,onChange:e=>M(e.target.value)})}),z?_(m,{label:`Confirm password`,children:e=>_(p,{...e,type:`password`,autoComplete:`new-password`,value:N,onChange:e=>P(e.target.value)})}):null,F===null?null:_(T,{role:`alert`,children:F}),_(l,{children:_(o,{type:`submit`,$variant:`primary`,disabled:U||j.length===0,children:z?`Set password and sign in`:`Sign in`})})]})]})})}export{O as component};
45
+ `;function O(){let s=r(),{next:u,reason:y}=f.useSearch(),O=e(),k=n(),A=t(),[j,M]=g(``),[N,P]=g(``),[F,I]=g(null),[L,R]=g(`admin`),z=O.data?.configured===!1,B=[{id:`admin`,label:`Operator`,blurb:`This console is for the operator of this gateway.`},...O.data?.viewerConfigured===!0?[{id:`viewer`,label:`Read-only`,blurb:`Everything the operator can see, and nothing they can change.`}]:[],{id:`client`,label:`API key`,blurb:`Your own usage, limits and requests. Sign in with a gateway API key.`}],V=L===`client`,H=h(y),U=k.isPending||A.isPending||O.isLoading,W=()=>{if(V){s({to:`/client`});return}s({to:u?.startsWith(`/`)===!0?u:`/`})};return _(b,{children:v(x,{children:[v(S,{children:[_(i,{state:O.isError?`down`:`ok`,label:O.isError?`gateway unreachable`:`gateway reachable`}),`Omnigateway`]}),v(C,{onSubmit:e=>{if(e.preventDefault(),I(null),z){if(j!==N){I(`The two passwords do not match.`);return}A.mutate(j,{onSuccess:W,onError:e=>I(d(e))});return}k.mutate({mode:L,secret:j},{onSuccess:W,onError:()=>I(V?`That API key was not accepted. It may have been revoked.`:`That password does not match. Try again.`)})},children:[O.isError?_(T,{children:`The gateway is not answering. Check that it is running, then reload.`}):null,H===null?null:_(E,{role:`status`,children:H}),v(a,{$gap:1,children:[_(c,{children:z?`First run`:`Sign in`}),_(w,{children:z?`Set the operator password for this gateway. It is the only account, and it is stored hashed.`:B.find(e=>e.id===L)?.blurb??``})]}),z||B.length<2?null:_(l,{$gap:1,$wrap:!0,role:`tablist`,"aria-label":`Sign in as`,children:B.map(e=>_(D,{type:`button`,role:`tab`,"aria-selected":e.id===L,$on:e.id===L,onClick:()=>{R(e.id),M(``),I(null)},children:e.label},e.id))}),_(m,{label:V?`API key`:`Password`,children:e=>_(p,{...e,type:`password`,autoFocus:!0,autoComplete:z?`new-password`:V?`off`:`current-password`,value:j,onChange:e=>M(e.target.value)})}),z?_(m,{label:`Confirm password`,children:e=>_(p,{...e,type:`password`,autoComplete:`new-password`,value:N,onChange:e=>P(e.target.value)})}):null,F===null?null:_(T,{role:`alert`,children:F}),_(l,{children:_(o,{type:`submit`,$variant:`primary`,disabled:U||j.length===0,children:z?`Set password and sign in`:`Sign in`})})]})]})})}export{O as component};
@@ -0,0 +1 @@
1
+ import{b as e}from"./Rack-BGrdPQRN.js";var t=e(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]);export{t};
@@ -1 +1 @@
1
- import{Cn as e,Gt as t,Kt as n,Qt as r,Sn as i,nn as a,qt as o,tn as s,un as c,yn as l}from"./Lamp-C2Q3t5Mn.js";import{k as u}from"./Panel-BlNr9j6-.js";import*as d from"react";import f from"react";import{jsx as p}from"react/jsx-runtime";var m=`__root__`;function h(e){if(e.statusCode=e.statusCode||e.code||307,!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function g(e){return e instanceof Response&&!!e.options}var _=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=m:this.parentRoute||c();let i=n?m:t?.path;i&&i!==`/`&&(i=s(i));let o=t?.id||i,l=n?m:r([this.parentRoute.id===`__root__`?``:this.parentRoute.id,o]);i===`__root__`&&(i=`/`),l!==`__root__`&&(l=r([`/`,l]));let u=l===`__root__`?`/`:r([this.parentRoute.fullPath,i]);this._path=i,this._id=l,this._fullPath=u,this._to=a(u)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>h({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},v=class extends _{constructor(e){super(e)}},y=d.createContext(void 0),b=d.createContext(void 0),x={};function S(e,t){let n=d.useRef();return r=>{let a=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=i(n.current,a):a}}function C(e){let t=u(),n=d.useContext(e.from?b:y),r=e.from??n,i=t.stores.getMatchStore(r),a=S(e,t),s=o(i,e=>e?a(e):x);if(s!==x)return s;(e.shouldThrow??!0)&&c()}function w(e){return C({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function T(e){let{select:t,...n}=e;return C({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function E(e){return C({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function D(e){return C({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function O(e){return C({...e,select:t=>e.select?e.select(t.context):t.context})}var k=class extends _{constructor(e){super(e),this.useMatch=e=>C({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>E({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>n({from:this.fullPath}),this.Link=f.forwardRef((e,n)=>p(t,{ref:n,from:this.fullPath,...e}))}};function A(e){return new k(e)}function j(){return e=>N(e)}var M=class extends v{constructor(e){super(e),this.useMatch=e=>C({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>E({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>n({from:this.fullPath}),this.Link=f.forwardRef((e,n)=>p(t,{ref:n,from:this.fullPath,...e}))}};function N(e){return new M(e)}function P(e){return e=>{let t=A(e);return t.isRoot=!1,t}}function F(t,n){let r,i,a,o=()=>(r||=(a=void 0,t().then(e=>{r=void 0,s.preload=void 0,i=e[n??`default`]}).catch(e=>{r=void 0,a=e})),r),s=function(t){if(a){if(l(a)&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${a.message}`;if(!sessionStorage.getItem(e))throw sessionStorage.setItem(e,`1`),window.location.reload(),new Promise(()=>{})}throw a}if(!i){if(e)e(o());else throw o()}return d.createElement(i,t)};return s.preload=o,s}var I=`modulepreload`,L=function(e){return`/`+e},R={},z=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=L(t,n),t=s(t),t in R)return;R[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:I,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};export{y as a,m as c,j as i,F as n,g as o,P as r,h as s,z as t};
1
+ import{Cn as e,Dn as t,En as n,Xt as r,Yt as i,Zt as a,an as o,mn as s,nn as c,on as l}from"./Lamp-CosPf-gw.js";import{k as u}from"./Panel-BlNr9j6-.js";import*as d from"react";import f from"react";import{jsx as p}from"react/jsx-runtime";var m=`__root__`;function h(e){if(e.statusCode=e.statusCode||e.code||307,!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function g(e){return e instanceof Response&&!!e.options}var _=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=m:this.parentRoute||s();let r=n?m:t?.path;r&&r!==`/`&&(r=o(r));let i=t?.id||r,a=n?m:c([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=c([`/`,a]));let u=a===`__root__`?`/`:c([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=u,this._to=l(u)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>h({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},v=class extends _{constructor(e){super(e)}},y=d.createContext(void 0),b=d.createContext(void 0),x={};function S(e,t){let r=d.useRef();return i=>{let a=e?.select?e.select(i):i;return e?.structuralSharing??t.options.defaultStructuralSharing?r.current=n(r.current,a):a}}function C(e){let t=u(),n=d.useContext(e.from?b:y),r=e.from??n,i=t.stores.getMatchStore(r),o=S(e,t),c=a(i,e=>e?o(e):x);if(c!==x)return c;(e.shouldThrow??!0)&&s()}function w(e){return C({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function T(e){let{select:t,...n}=e;return C({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function E(e){return C({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function D(e){return C({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function O(e){return C({...e,select:t=>e.select?e.select(t.context):t.context})}var k=class extends _{constructor(e){super(e),this.useMatch=e=>C({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>E({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>r({from:this.fullPath}),this.Link=f.forwardRef((e,t)=>p(i,{ref:t,from:this.fullPath,...e}))}};function A(e){return new k(e)}function j(){return e=>N(e)}var M=class extends v{constructor(e){super(e),this.useMatch=e=>C({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>E({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>r({from:this.fullPath}),this.Link=f.forwardRef((e,t)=>p(i,{ref:t,from:this.fullPath,...e}))}};function N(e){return new M(e)}function P(e){return e=>{let t=A(e);return t.isRoot=!1,t}}function F(n,r){let i,a,o,s=()=>(i||=(o=void 0,n().then(e=>{i=void 0,c.preload=void 0,a=e[r??`default`]}).catch(e=>{i=void 0,o=e})),i),c=function(n){if(o){if(e(o)&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${o.message}`;if(!sessionStorage.getItem(e))throw sessionStorage.setItem(e,`1`),window.location.reload(),new Promise(()=>{})}throw o}if(!a){if(t)t(s());else throw s()}return d.createElement(a,n)};return c.preload=s,c}var I=`modulepreload`,L=function(e){return`/`+e},R={},z=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=L(t,n),t=s(t),t in R)return;R[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:I,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};export{y as a,m as c,j as i,F as n,g as o,P as r,h as s,z as t};