codesesh 1.0.9 → 1.0.10

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 (37) hide show
  1. package/README.md +3 -0
  2. package/dist/{chunk-MOZLVHCC.js → chunk-2LXZFMSH.js} +10 -2
  3. package/dist/{chunk-MOZLVHCC.js.map → chunk-2LXZFMSH.js.map} +1 -1
  4. package/dist/{chunk-5YY675UR.js → chunk-543OWZIC.js} +2 -2
  5. package/dist/{chunk-CIMPLUT6.js → chunk-56FKVL5K.js} +5 -5
  6. package/dist/{chunk-QFG33PKR.js → chunk-CYZ6OC6J.js} +2 -2
  7. package/dist/{chunk-RDTQ2WPR.js → chunk-DWY4HWVI.js} +2 -2
  8. package/dist/{chunk-ZLU7ODBV.js → chunk-R6QKSHPH.js} +2 -2
  9. package/dist/{chunk-ZDH2BKQK.js → chunk-WRVILHZR.js} +366 -25
  10. package/dist/chunk-WRVILHZR.js.map +1 -0
  11. package/dist/{discovery-MS2ZSMZ5.js → discovery-NTMSA6UE.js} +5 -5
  12. package/dist/index.js +36 -9
  13. package/dist/index.js.map +1 -1
  14. package/dist/project-identity-worker.js +4 -4
  15. package/dist/scan-refresh-worker.js +6 -6
  16. package/dist/search-index-worker.js +6 -6
  17. package/dist/session-detail-worker.js +6 -6
  18. package/dist/smart-tag-worker.js +3 -3
  19. package/dist/web/assets/{DetailLanding-Dgb2Qg8H.js → DetailLanding-D1FLK4EW.js} +1 -1
  20. package/dist/web/assets/{InteractiveReceipt-SckXLiPB.js → InteractiveReceipt-C7FJhzdv.js} +1 -1
  21. package/dist/web/assets/{OverviewScreen-D44AMeDu.js → OverviewScreen-DX7F_6dH.js} +1 -1
  22. package/dist/web/assets/{PrismHighlighter-D7JLjKja.js → PrismHighlighter-DZ2CWVc0.js} +1 -1
  23. package/dist/web/assets/{Projects-DVHOqH2Z.js → Projects-B_7w5TDw.js} +1 -1
  24. package/dist/web/assets/{SearchResultsPanel-B1WEw9Q5.js → SearchResultsPanel-BMBhKuPS.js} +1 -1
  25. package/dist/web/assets/SessionDetail-wJYzzF0i.js +53 -0
  26. package/dist/web/assets/{index-BIpTq_7T.js → index-DUcpWdzX.js} +2 -2
  27. package/dist/web/icon/agent/minimax-code.svg +1 -0
  28. package/dist/web/index.html +1 -1
  29. package/package.json +1 -1
  30. package/dist/chunk-ZDH2BKQK.js.map +0 -1
  31. package/dist/web/assets/SessionDetail-J00I4QfE.js +0 -53
  32. /package/dist/{chunk-5YY675UR.js.map → chunk-543OWZIC.js.map} +0 -0
  33. /package/dist/{chunk-CIMPLUT6.js.map → chunk-56FKVL5K.js.map} +0 -0
  34. /package/dist/{chunk-QFG33PKR.js.map → chunk-CYZ6OC6J.js.map} +0 -0
  35. /package/dist/{chunk-RDTQ2WPR.js.map → chunk-DWY4HWVI.js.map} +0 -0
  36. /package/dist/{chunk-ZLU7ODBV.js.map → chunk-R6QKSHPH.js.map} +0 -0
  37. /package/dist/{discovery-MS2ZSMZ5.js.map → discovery-NTMSA6UE.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-5YY675UR.js";
3
- import "./chunk-QFG33PKR.js";
2
+ import "./chunk-543OWZIC.js";
3
+ import "./chunk-CYZ6OC6J.js";
4
4
  import {
5
5
  computeIdentityProjection
6
- } from "./chunk-RDTQ2WPR.js";
7
- import "./chunk-MOZLVHCC.js";
6
+ } from "./chunk-DWY4HWVI.js";
7
+ import "./chunk-2LXZFMSH.js";
8
8
 
9
9
  // src/project-identity-worker.ts
10
10
  import { parentPort } from "worker_threads";
@@ -4,11 +4,11 @@ import {
4
4
  } from "./chunk-RF3EEWPH.js";
5
5
  import {
6
6
  acknowledgeWorkerLogDrain
7
- } from "./chunk-ZLU7ODBV.js";
7
+ } from "./chunk-R6QKSHPH.js";
8
8
  import "./chunk-QH2HOXJH.js";
9
9
  import {
10
10
  appLogger
11
- } from "./chunk-QFG33PKR.js";
11
+ } from "./chunk-CYZ6OC6J.js";
12
12
  import {
13
13
  attachMissingProjectIdentities,
14
14
  buildAgentCacheMeta,
@@ -18,14 +18,14 @@ import {
18
18
  hasStaleSessionTags,
19
19
  planAgentScan,
20
20
  sortSessions
21
- } from "./chunk-CIMPLUT6.js";
22
- import "./chunk-RDTQ2WPR.js";
21
+ } from "./chunk-56FKVL5K.js";
22
+ import "./chunk-DWY4HWVI.js";
23
23
  import {
24
24
  createRegisteredAgents
25
- } from "./chunk-ZDH2BKQK.js";
25
+ } from "./chunk-WRVILHZR.js";
26
26
  import {
27
27
  synchronizePricingGeneration
28
- } from "./chunk-MOZLVHCC.js";
28
+ } from "./chunk-2LXZFMSH.js";
29
29
 
30
30
  // src/scan-refresh-worker.ts
31
31
  import { parentPort, workerData } from "worker_threads";
@@ -1,25 +1,25 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  acknowledgeWorkerLogDrain
4
- } from "./chunk-ZLU7ODBV.js";
4
+ } from "./chunk-R6QKSHPH.js";
5
5
  import "./chunk-QH2HOXJH.js";
6
6
  import {
7
7
  appLogger
8
- } from "./chunk-QFG33PKR.js";
8
+ } from "./chunk-CYZ6OC6J.js";
9
9
  import {
10
10
  commitDurableSessionPublication,
11
11
  markAgentCacheInitialized,
12
12
  sessionDetailVersion,
13
13
  syncSessionSearchIndex,
14
14
  syncSessionSearchIndexChanges
15
- } from "./chunk-CIMPLUT6.js";
16
- import "./chunk-RDTQ2WPR.js";
15
+ } from "./chunk-56FKVL5K.js";
16
+ import "./chunk-DWY4HWVI.js";
17
17
  import {
18
18
  createRegisteredAgents
19
- } from "./chunk-ZDH2BKQK.js";
19
+ } from "./chunk-WRVILHZR.js";
20
20
  import {
21
21
  synchronizePricingGeneration
22
- } from "./chunk-MOZLVHCC.js";
22
+ } from "./chunk-2LXZFMSH.js";
23
23
 
24
24
  // src/search-index-worker.ts
25
25
  import { randomUUID } from "crypto";
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  acknowledgeWorkerLogDrain
4
- } from "./chunk-ZLU7ODBV.js";
4
+ } from "./chunk-R6QKSHPH.js";
5
5
  import "./chunk-QH2HOXJH.js";
6
6
  import {
7
7
  appLogger
8
- } from "./chunk-QFG33PKR.js";
8
+ } from "./chunk-CYZ6OC6J.js";
9
9
  import {
10
10
  closeCacheStorage,
11
11
  materializeSessionDetailResponse
12
- } from "./chunk-CIMPLUT6.js";
13
- import "./chunk-RDTQ2WPR.js";
12
+ } from "./chunk-56FKVL5K.js";
13
+ import "./chunk-DWY4HWVI.js";
14
14
  import {
15
15
  createRegisteredAgents
16
- } from "./chunk-ZDH2BKQK.js";
16
+ } from "./chunk-WRVILHZR.js";
17
17
  import {
18
18
  synchronizePricingGeneration
19
- } from "./chunk-MOZLVHCC.js";
19
+ } from "./chunk-2LXZFMSH.js";
20
20
 
21
21
  // src/session-detail-worker.ts
22
22
  import { parentPort, workerData } from "worker_threads";
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import "./chunk-QH2HOXJH.js";
3
- import "./chunk-QFG33PKR.js";
3
+ import "./chunk-CYZ6OC6J.js";
4
4
  import {
5
5
  createRegisteredAgents
6
- } from "./chunk-ZDH2BKQK.js";
6
+ } from "./chunk-WRVILHZR.js";
7
7
  import {
8
8
  classifySessionTags,
9
9
  getSmartTagSourceTimestamp,
10
10
  synchronizePricingGeneration
11
- } from "./chunk-MOZLVHCC.js";
11
+ } from "./chunk-2LXZFMSH.js";
12
12
 
13
13
  // src/smart-tag-worker.ts
14
14
  import { parentPort, workerData } from "worker_threads";
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{E as r,i,j as a,n as o,t as s,w as c}from"./translate-CLoII3EO.js";import{t as l}from"./SmartTagChips-BMP9pPRw.js";import{o as u}from"./session-indexes-3LjxBYNe.js";import{F as d,H as f,Q as p,W as m,ct as h,et as g,q as _,rt as v}from"./index-BIpTq_7T.js";import{n as y,t as b}from"./panel-B-5dVddJ.js";var x=e(t(),1),S=n();function C({active:e,onToggle:t,className:n=``}){return o(),(0,S.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":s(e?`Remove bookmark`:`Add bookmark`),title:s(e?`Remove bookmark`:`Add bookmark`),className:`motion-hover motion-press inline-flex size-6 shrink-0 items-center justify-center rounded-sm border focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none ${n} ${e?`border-[var(--brand-line)] bg-[var(--brand-soft)] text-[var(--brand)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,S.jsx)(d,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function w(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function T({label:e,value:t,hint:n}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,S.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function E({label:e,value:t}){return o(),(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function D({code:e,title:t,description:n,aside:r,iconSrc:i,iconColored:a,iconAlt:c}){return o(),(0,S.jsx)(b,{className:`p-5 md:p-6`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,S.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,S.jsx)(`span`,{className:`console-eyebrow inline-flex rounded-full border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2.5 py-1`,children:e}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,S.jsx)(f,{icon:i,iconColored:a,alt:c||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,S.jsx)(`h2`,{className:`console-display text-2xl leading-tight font-semibold text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,S.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,S.jsxs)(`div`,{className:`min-w-0 rounded-md border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`STATUS NOTE`)}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function O({agentItems:e}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Agents`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(u,{to:c(e.key),className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)]`,children:[e.icon?(0,S.jsx)(f,{icon:e.icon,iconColored:e.iconColored,alt:e.name,className:`size-4 object-contain`}):null,(0,S.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,S.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function k({sessions:e,isBookmarked:t,onToggleBookmark:n}){return o(),e.length===0?(0,S.jsx)(b,{className:`p-4 text-sm text-[var(--console-muted)]`,children:s(`No sessions yet`)}):(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Recent Sessions`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>{let i=t(e.reference.agentName,e.reference.sessionId);return(0,S.jsx)(`li`,{children:(0,S.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,S.jsxs)(u,{to:a({agentName:e.reference.agentName,sessionId:e.reference.sessionId}),className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:m(e)}),(0,S.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,r(e.reference),` ·`,` `,v(e.time_updated||e.time_created)]}),(0,S.jsx)(l,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,S.jsx)(C,{active:i,onToggle:()=>n(e)})]})},r(e.reference))})})]})}var A=(0,x.memo)(function({type:e,agentCatalog:t,sessions:n,agentItems:r,activeAgentKey:a,attemptedAgentKey:c,attemptedSessionId:l,loadFailureMessage:u,isBookmarked:d,onToggleBookmark:m,onRetry:y}){o();let{recentSessions:C,totalMessages:A,totalTokens:j,totalCost:M,costSource:N,latestUpdatedAt:P}=(0,x.useMemo)(()=>{let e=n.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),t=0,r=0,i=0,a=!1;for(let e of n)t+=e.stats.message_count,r+=w(e.stats),i+=e.stats.total_cost,a||=e.stats.cost_source===`estimated`;return{recentSessions:e.slice(0,5),totalMessages:t,totalTokens:r,totalCost:i,costSource:i>0?a?`estimated`:`recorded`:void 0,latestUpdatedAt:e[0]?.time_updated||e[0]?.time_created}},[n]);if(e===`missing-agent`){let e=`/${c||`unknown`}${l?`/${l}`:``}`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / AGENT`),title:s(`This agent isn't on the roster.`),description:s(`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`),aside:s(`Choose one of the available agents to continue.`)}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(E,{label:s(`Requested Agent`),value:c||`unknown`}),(0,S.jsx)(E,{label:s(`Requested Path`),value:e}),l?(0,S.jsx)(E,{label:s(`Requested Session`),value:l}):null]}),(0,S.jsx)(O,{agentItems:r})]})}if(e===`missing-session`){let e=a?h(t,a):void 0,n=e?.displayName??a??s(`Unknown Agent`),r=e?.icon,i=l||`unknown-session`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / SESSION`),title:s(`This session isn't in the index.`),description:s(`{0} is available, but the session you're looking for does not exist in the current index. The session ID may be incorrect, or the record may never have been part of this dataset.`,[n]),aside:s(`We checked the current path, but nothing matched. The session list on the left is still available.`),iconSrc:r,iconColored:e?.iconColored,iconAlt:n}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`Agent`)}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[r?(0,S.jsx)(f,{icon:r,iconColored:e?.iconColored,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,S.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,S.jsx)(E,{label:s(`Session`),value:i})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]})}if(e===`load-failed`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`LOAD / SESSION`),title:s(`We couldn't load this session.`),description:s(`The session request failed before we could determine whether the record exists. It may still be available once the connection or server recovers.`),aside:s(`Retry this request without leaving the current session path.`)}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(E,{label:s(`Request Error`),value:u??s(`Unable to load this session.`)})}),(0,S.jsx)(`button`,{type:`button`,onClick:y,className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-1.5 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:s(`Retry`)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]});if(e===`global`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(T,{label:s(`Total Sessions`),value:g(n.length)}),(0,S.jsx)(T,{label:s(`Total Messages`),value:g(A)}),(0,S.jsx)(T,{label:s(`Latest Activity`),value:v(P),hint:P?new Date(P).toLocaleString(i()):void 0})]}),(0,S.jsx)(O,{agentItems:r}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]});let F=a?h(t,a):void 0,I=F?.displayName??s(`Unknown Agent`);return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(b,{className:`p-4`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[F?.icon?(0,S.jsx)(f,{icon:F.icon,iconColored:F.iconColored,alt:I,className:`size-6 object-contain`}):null,(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:I}),(0,S.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:s(`Select a session from the left to view details`)})]})]})}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,S.jsx)(T,{label:s(`Sessions`),value:g(n.length)}),(0,S.jsx)(T,{label:s(`Messages`),value:g(A)}),(0,S.jsx)(T,{label:s(`Tokens`),value:g(j)}),(0,S.jsx)(T,{label:s(`Total Cost`),value:p(M),hint:_(N)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]})});export{A as DetailLanding};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{E as r,i,j as a,n as o,t as s,w as c}from"./translate-CLoII3EO.js";import{t as l}from"./SmartTagChips-BMP9pPRw.js";import{o as u}from"./session-indexes-3LjxBYNe.js";import{F as d,H as f,Q as p,W as m,ct as h,et as g,q as _,rt as v}from"./index-DUcpWdzX.js";import{n as y,t as b}from"./panel-B-5dVddJ.js";var x=e(t(),1),S=n();function C({active:e,onToggle:t,className:n=``}){return o(),(0,S.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":s(e?`Remove bookmark`:`Add bookmark`),title:s(e?`Remove bookmark`:`Add bookmark`),className:`motion-hover motion-press inline-flex size-6 shrink-0 items-center justify-center rounded-sm border focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none ${n} ${e?`border-[var(--brand-line)] bg-[var(--brand-soft)] text-[var(--brand)]`:`border-transparent text-[var(--console-muted)] opacity-70 hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] hover:text-[var(--console-text)] hover:opacity-100`}`,children:(0,S.jsx)(d,{className:`size-3`,strokeWidth:1.8,fill:e?`currentColor`:`none`})})}function w(e){return e.total_tokens??e.total_input_tokens+e.total_output_tokens}function T({label:e,value:t,hint:n}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 text-xl font-semibold text-[var(--console-text)]`,children:t}),n?(0,S.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:n}):null]})}function E({label:e,value:t}){return o(),(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,S.jsx)(`p`,{className:`console-mono mt-2 break-all text-sm leading-6 text-[var(--console-text)]`,children:t})]})}function D({code:e,title:t,description:n,aside:r,iconSrc:i,iconColored:a,iconAlt:c}){return o(),(0,S.jsx)(b,{className:`p-5 md:p-6`,children:(0,S.jsxs)(`div`,{className:`flex flex-col gap-5 md:flex-row md:items-start md:justify-between`,children:[(0,S.jsxs)(`div`,{className:`max-w-2xl`,children:[(0,S.jsx)(`span`,{className:`console-eyebrow inline-flex rounded-full border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2.5 py-1`,children:e}),(0,S.jsxs)(`div`,{className:`mt-4 flex items-start gap-3`,children:[i?(0,S.jsx)(f,{icon:i,iconColored:a,alt:c||``,className:`mt-1 size-8 shrink-0 object-contain`}):null,(0,S.jsx)(`h2`,{className:`console-display text-2xl leading-tight font-semibold text-[var(--console-text)] md:text-[2rem]`,children:t})]}),(0,S.jsx)(`p`,{className:`mt-3 max-w-[42rem] text-sm leading-7 text-[var(--console-muted)]`,children:n})]}),(0,S.jsxs)(`div`,{className:`min-w-0 rounded-md border border-dashed border-[var(--console-border)] bg-[var(--console-surface-muted)] px-4 py-3 md:max-w-xs`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`STATUS NOTE`)}),(0,S.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-[var(--console-text)]`,children:r})]})]})})}function O({agentItems:e}){return o(),(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Agents`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:e.map(e=>(0,S.jsx)(`li`,{children:(0,S.jsxs)(u,{to:c(e.key),className:`flex min-h-11 items-center gap-2 rounded-sm border border-transparent px-3 py-2 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)]`,children:[e.icon?(0,S.jsx)(f,{icon:e.icon,iconColored:e.iconColored,alt:e.name,className:`size-4 object-contain`}):null,(0,S.jsx)(`span`,{className:`console-mono flex-1 text-xs text-[var(--console-text)]`,children:e.name}),(0,S.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:e.count})]})},e.key))})]})}function k({sessions:e,isBookmarked:t,onToggleBookmark:n}){return o(),e.length===0?(0,S.jsx)(b,{className:`p-4 text-sm text-[var(--console-muted)]`,children:s(`No sessions yet`)}):(0,S.jsxs)(b,{className:`p-4`,children:[(0,S.jsx)(y,{title:s(`Recent Sessions`),meta:s(`{0} items`,[e.length])}),(0,S.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>{let i=t(e.reference.agentName,e.reference.sessionId);return(0,S.jsx)(`li`,{children:(0,S.jsxs)(`div`,{className:`flex items-start gap-2 rounded-sm border border-transparent px-2 py-1.5 motion-hover hover:border-[var(--console-border)] hover:bg-[var(--console-surface-muted)]`,children:[(0,S.jsxs)(u,{to:a({agentName:e.reference.agentName,sessionId:e.reference.sessionId}),className:`min-w-0 flex-1`,children:[(0,S.jsx)(`p`,{className:`line-clamp-1 text-sm text-[var(--console-text)]`,children:m(e)}),(0,S.jsxs)(`p`,{className:`console-mono mt-0.5 text-[11px] text-[var(--console-muted)]`,children:[`/`,r(e.reference),` ·`,` `,v(e.time_updated||e.time_created)]}),(0,S.jsx)(l,{tags:e.smart_tags,className:`mt-1.5`})]}),(0,S.jsx)(C,{active:i,onToggle:()=>n(e)})]})},r(e.reference))})})]})}var A=(0,x.memo)(function({type:e,agentCatalog:t,sessions:n,agentItems:r,activeAgentKey:a,attemptedAgentKey:c,attemptedSessionId:l,loadFailureMessage:u,isBookmarked:d,onToggleBookmark:m,onRetry:y}){o();let{recentSessions:C,totalMessages:A,totalTokens:j,totalCost:M,costSource:N,latestUpdatedAt:P}=(0,x.useMemo)(()=>{let e=n.toSorted((e,t)=>(t.time_updated||t.time_created||0)-(e.time_updated||e.time_created||0)),t=0,r=0,i=0,a=!1;for(let e of n)t+=e.stats.message_count,r+=w(e.stats),i+=e.stats.total_cost,a||=e.stats.cost_source===`estimated`;return{recentSessions:e.slice(0,5),totalMessages:t,totalTokens:r,totalCost:i,costSource:i>0?a?`estimated`:`recorded`:void 0,latestUpdatedAt:e[0]?.time_updated||e[0]?.time_created}},[n]);if(e===`missing-agent`){let e=`/${c||`unknown`}${l?`/${l}`:``}`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / AGENT`),title:s(`This agent isn't on the roster.`),description:s(`The path you requested is valid in shape, but there is no matching agent in the current registry. It may not be connected yet, or its name may not match what the system recognizes.`),aside:s(`Choose one of the available agents to continue.`)}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(E,{label:s(`Requested Agent`),value:c||`unknown`}),(0,S.jsx)(E,{label:s(`Requested Path`),value:e}),l?(0,S.jsx)(E,{label:s(`Requested Session`),value:l}):null]}),(0,S.jsx)(O,{agentItems:r})]})}if(e===`missing-session`){let e=a?h(t,a):void 0,n=e?.displayName??a??s(`Unknown Agent`),r=e?.icon,i=l||`unknown-session`;return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`404 / SESSION`),title:s(`This session isn't in the index.`),description:s(`{0} is available, but the session you're looking for does not exist in the current index. The session ID may be incorrect, or the record may never have been part of this dataset.`,[n]),aside:s(`We checked the current path, but nothing matched. The session list on the left is still available.`),iconSrc:r,iconColored:e?.iconColored,iconAlt:n}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,S.jsxs)(`div`,{className:`rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`p`,{className:`console-eyebrow`,children:s(`Agent`)}),(0,S.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[r?(0,S.jsx)(f,{icon:r,iconColored:e?.iconColored,alt:n,className:`size-4 shrink-0 object-contain`}):null,(0,S.jsx)(`p`,{className:`console-mono break-all text-sm leading-6 text-[var(--console-text)]`,children:n})]})]}),(0,S.jsx)(E,{label:s(`Session`),value:i})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]})}if(e===`load-failed`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(D,{code:s(`LOAD / SESSION`),title:s(`We couldn't load this session.`),description:s(`The session request failed before we could determine whether the record exists. It may still be available once the connection or server recovers.`),aside:s(`Retry this request without leaving the current session path.`)}),(0,S.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 rounded-md border border-[var(--console-border)] bg-[var(--console-surface-muted)] p-3`,children:[(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,S.jsx)(E,{label:s(`Request Error`),value:u??s(`Unable to load this session.`)})}),(0,S.jsx)(`button`,{type:`button`,onClick:y,className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] bg-[var(--console-surface)] px-3 py-1.5 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:s(`Retry`)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]});if(e===`global`)return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-3`,children:[(0,S.jsx)(T,{label:s(`Total Sessions`),value:g(n.length)}),(0,S.jsx)(T,{label:s(`Total Messages`),value:g(A)}),(0,S.jsx)(T,{label:s(`Latest Activity`),value:v(P),hint:P?new Date(P).toLocaleString(i()):void 0})]}),(0,S.jsx)(O,{agentItems:r}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]});let F=a?h(t,a):void 0,I=F?.displayName??s(`Unknown Agent`);return(0,S.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-4`,children:[(0,S.jsx)(b,{className:`p-4`,children:(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[F?.icon?(0,S.jsx)(f,{icon:F.icon,iconColored:F.iconColored,alt:I,className:`size-6 object-contain`}):null,(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h3`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:I}),(0,S.jsx)(`p`,{className:`console-mono text-xs text-[var(--console-muted)]`,children:s(`Select a session from the left to view details`)})]})]})}),(0,S.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,S.jsx)(T,{label:s(`Sessions`),value:g(n.length)}),(0,S.jsx)(T,{label:s(`Messages`),value:g(A)}),(0,S.jsx)(T,{label:s(`Tokens`),value:g(j)}),(0,S.jsx)(T,{label:s(`Total Cost`),value:p(M),hint:_(N)})]}),(0,S.jsx)(k,{sessions:C,isBookmarked:d,onToggleBookmark:m})]})});export{A as DetailLanding};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{D as r,i,n as a,t as o}from"./translate-CLoII3EO.js";import{W as s}from"./index-BIpTq_7T.js";var c=e(t(),1);function l(e,t){return t===0||e-t>=15.666666666666668}function u(e,t,n){return!e&&t<=.12?n+1:0}function d(e,t){return e?0:t+1}function f(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function p(e,t,n){return e>=2&&(t>=8||n>=300)}function m(e,t){return!e||Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5}var h=18,g=42,ee=5,_=270,v=500,y=2,b=.035;function te(e){let t=window.getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{paperTop:n(`--console-surface`,`white`),paperBottom:n(`--console-surface-sunken`,`whitesmoke`),ink:n(`--console-text`,`black`),inkMuted:n(`--console-text-secondary`,`dimgray`),line:n(`--console-border-strong`,`silver`),shadow:n(`--scrim`,`gray`)}}function ne(e){return window.getComputedStyle(e).getPropertyValue(`--font-mono`).trim()||`monospace`}function x(e){return Math.round(e??0).toLocaleString(i())}function S(e){return`$${(e??0).toFixed(4)}`}function C(e){return new Date(e).toLocaleString(i(),{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function w(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function T(e){let t=e||1;return()=>(t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296)}function E(e,t,n,r,i){let a=t.toUpperCase(),o=n.toUpperCase();e.fillText(a,18,r),e.fillText(o,i-18-e.measureText(o).width,r)}function D(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}...`).width>n;)r=r.slice(0,-1);return`${r}...`}function O(e,t,n,r){let i=t.toUpperCase().split(/\s+/).filter(Boolean),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n){o=i;continue}if(o?(a.push(o),o=t):(a.push(D(e,t,n)),o=``),a.length===r)break}return a.length<r&&o&&a.push(o),a.length>0&&a.length===r&&(a[a.length-1]=D(e,a[a.length-1]??``,n)),a.slice(0,r)}function re(e,t,n){let r=document.createElement(`canvas`);r.width=_*y,r.height=v*y;let i=r.getContext(`2d`);if(!i)return r;i.scale(y,y);let a=e=>`${e} ${n}`,s=i.createLinearGradient(0,0,_,v);s.addColorStop(0,t.paperTop),s.addColorStop(1,t.paperBottom),i.fillStyle=s,i.fillRect(0,0,_,v);let c=T(w(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=b*(.12+c()*.14),i.fillRect(c()*_,c()*v,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,_/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(D(i,e.subtitle.toUpperCase(),234),_/2,51),i.strokeStyle=t.line,i.lineWidth=1,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,66),i.lineTo(252,66),i.stroke(),i.setLineDash([]),i.textAlign=`left`,i.fillStyle=t.ink,i.font=a(`11px`),E(i,o(`Agent`),e.agent,88,_),E(i,o(`Updated`),C(e.updatedAt),104,_),E(i,o(`Session`),`#${e.id.slice(0,8)}`,120,_),i.setLineDash([2,3]),i.beginPath(),i.moveTo(18,140),i.lineTo(252,140),i.stroke(),i.setLineDash([]),i.font=a(`700 12px`),i.fillText(o(`SESSION TOC RECEIPT LIST`),18,163),i.font=a(`11px`);let l=185;for(let t of e.items){let e=x(t.count);i.fillText(D(i,t.label,168),18,l),i.fillText(e,252-i.measureText(e).width,l),l+=17}return i.strokeStyle=t.line,i.lineWidth=1.5,i.beginPath(),i.moveTo(18,l+5),i.lineTo(252,l+5),i.stroke(),l+=26,E(i,o(`Input tokens`),x(e.inputTokens),l,_),l+=16,E(i,o(`Output tokens`),x(e.outputTokens),l,_),l+=16,E(i,o(`Messages`),x(e.messageCount),l,_),l+=22,i.font=a(`700 13px`),E(i,o(`TOTAL COST`),S(e.totalCost),l,_),i.strokeStyle=t.line,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,l+18),i.lineTo(252,l+18),i.stroke(),i.setLineDash([]),i.font=a(`10px`),i.textAlign=`center`,i.fillStyle=t.inkMuted,O(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,_/2,l+38+t*13)}),r}function k(e,t){return e*h+t}function A(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=r+t*a,c=i+e*o;s.push({x:n,y:c,oldX:n,oldY:c,fixedX:e===0?n:null,fixedY:e===0?c:null})}let l=(e,t,n)=>{let r=s[e],i=s[t];r&&i&&c.push({a:e,b:t,length:Math.hypot(i.x-r.x,i.y-r.y),stiffness:n})};for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=k(e,t);t<17&&l(n,k(e,t+1),.98),e<41&&l(n,k(e+1,t),.92),e<41&&t<17&&(l(n,k(e+1,t+1),.46),l(k(e+1,t),k(e,t+1),.46)),t<16&&l(n,k(e,t+2),.35),e<40&&l(n,k(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function ie(e,t){let n=t.receiptWidth/17;for(let r=0;r<h;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function j(e){for(let t=0;t<h;t+=1){let n=e[t];n&&n.fixedX!=null&&n.fixedY!=null&&(n.x=n.fixedX,n.y=n.fixedY,n.oldX=n.fixedX,n.oldY=n.fixedY)}}function ae(e,t){let n=e[t.a],r=e[t.b];if(!n||!r)return;let i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<1e-4)return;let s=(o-t.length)/o*t.stiffness,c=n.fixedX!=null&&n.fixedY!=null,l=r.fixedX!=null&&r.fixedY!=null,u=c?0:l?1:.5,d=l?0:c?1:.5,f=i*s,p=a*s;c||(n.x+=f*u,n.y+=p*u),l||(r.x-=f*d,r.y-=p*d)}function M(e,t,n,r,i,a){let o=r[k(i,a)],s=r[k(i,a+1)],c=r[k(i+1,a)],l=r[k(i+1,a+1)];if(!o||!s||!c||!l)return;let u=a/17*t.width,d=i/41*t.height,f=t.width/17,p=t.height/41;e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.clip(),e.transform((s.x-o.x)/f,(s.y-o.y)/f,(c.x-o.x)/p,(c.y-o.y)/p,o.x,o.y),e.drawImage(t,u,d,f+1,p+1,0,0,f+1,p+1),e.restore();let m=Math.atan2(s.y-o.y,s.x-o.x),h=Math.hypot(c.x-o.x,c.y-o.y)/(v/41),g=Math.sin(m)*.08+(h-1)*.16;Math.abs(g)<.01||(e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.globalAlpha=Math.abs(g),e.fillStyle=g>0?n.paperTop:n.shadow,e.fill(),e.restore())}function N(e,t,n){let r=null,i=44;for(let a=h;a<e.length;a+=1){let o=e[a];if(!o)continue;let s=Math.hypot(o.x-t,o.y-n);s<i&&(i=s,r=a)}return r}function oe(e){let t=0;for(let n=h;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function P({canvas:e,anchor:t,hitSurface:n,payload:r,minWidthQuery:i}){let a=e.getContext(`2d`,{alpha:!0});if(!a)return null;let o=r,s={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},c=null,g=!1,y=0,b=0,x=0,S=A({receiptWidth:_,receiptHeight:v,startX:0,startY:32}),C=performance.now(),w=null,T=0,E=0,D=0,O=0,k=!1,P=!1,F=window.matchMedia(i),I=window.matchMedia(`(prefers-reduced-motion: reduce)`),L=()=>c!=null&&F.matches&&document.visibilityState===`visible`,R=()=>{let e=te(t);c={texture:re(o,e,ne(t)),palette:e}},z=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(_,n-34);return{receiptWidth:r,receiptHeight:Math.min(v,Math.max(320,x-42)),startX:(n-r)/2,startY:32}},B=t=>{k!==t&&(k=t,e.style.visibility=t?`visible`:`hidden`,n.style.visibility=t&&!I.matches?`visible`:`hidden`)},V=()=>{P=!1,y&&=(window.cancelAnimationFrame(y),0),B(!1)},H=(e,t=performance.now())=>{S=A(e),w=e,C=t},U=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();b=Math.max(1,r.width),x=Math.max(1,r.height),e.width=Math.floor(b*n),e.height=Math.floor(x*n),a.setTransform(n,0,0,n,0,0),T=0,E=0,D=0,O=0,B(!1),H(z()),L()&&W()},W=()=>{!P&&L()&&(P=!0,y=window.requestAnimationFrame(Z))},G=()=>{L()?U():V()},K=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},q=e=>{if(e.button!==0||I.matches)return;let t=K(e),r=N(S.particles,t.x,t.y);r!=null&&(e.preventDefault(),n.setPointerCapture(e.pointerId),s.id=e.pointerId,s.x=t.x,s.y=t.y,s.prevX=t.x,s.prevY=t.y,s.vx=0,s.vy=0,s.grabbedIndex=r,E=0,D=0,W())},J=e=>{if(s.id!==e.pointerId)return;let t=K(e);s.vx=t.x-s.prevX,s.vy=t.y-s.prevY,s.prevX=t.x,s.prevY=t.y,s.x=t.x,s.y=t.y},Y=e=>{if(s.id!==e.pointerId)return;let t=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];t&&(t.oldX=t.x-s.vx*.9,t.oldY=t.y-s.vy*.9),s.id=null,s.grabbedIndex=null},se=e=>{let t=(e-C)/1e3;for(let e=h;e<S.particles.length;e+=1){let n=S.particles[e];if(!n)continue;let r=(n.x-n.oldX)*.985,i=(n.y-n.oldY)*.985;n.oldX=n.x,n.oldY=n.y,n.x+=r+Math.sin(t*1.7+e*.19)*.018,n.y+=i+.22}let n=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];n&&(n.x+=(s.x-n.x)*.72,n.y+=(s.y-n.y)*.72)},ce=()=>{for(let e=0;e<ee;e+=1){j(S.particles);for(let e of S.constraints)ae(S.particles,e)}j(S.particles)},le=()=>{let e=1/0,t=1/0,r=-1/0,i=-1/0;for(let n of S.particles)e=Math.min(e,n.x),t=Math.min(t,n.y),r=Math.max(r,n.x),i=Math.max(i,n.y);n.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,n.style.width=`${r-e+40}px`,n.style.height=`${i-t+40}px`},ue=e=>{let t=S.particles[0],n=S.particles[17],r=S.particles[755],i=S.particles[738];t&&n&&r&&i&&(a.save(),a.shadowColor=e.shadow,a.shadowBlur=24,a.shadowOffsetY=16,a.fillStyle=e.shadow,a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(n.x,n.y),a.lineTo(r.x,r.y),a.lineTo(i.x,i.y),a.closePath(),a.fill(),a.restore())},de=e=>{let t=S.particles[0],n=S.particles[17];t&&n&&(a.save(),a.strokeStyle=e.ink,a.lineWidth=4,a.lineCap=`round`,a.beginPath(),a.moveTo(t.x-10,t.y-3),a.lineTo(n.x+10,n.y-3),a.stroke(),a.strokeStyle=e.paperTop,a.lineWidth=1,a.beginPath(),a.moveTo(t.x-8,t.y-5),a.lineTo(n.x+8,n.y-5),a.stroke(),a.restore())},X=()=>{if(c){a.clearRect(0,0,b,x),ue(c.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)M(a,c.texture,c.palette,S.particles,e,t);de(c.palette),le()}},Z=e=>{if(!P)return;if(!L()){V();return}if(!l(e,O)){y=window.requestAnimationFrame(Z);return}O=e;let t=z();m(w,t)&&s.id==null?(T=0,B(!1),H(t,e)):(T+=1,w=t),ie(S.particles,t),I.matches||(se(e),ce()),X();let n=s.id!=null;E=u(n,oe(S.particles),E),D=d(n,D);let r=I.matches;if((r||T>=2)&&B(!0),r||p(T,E,D)){r||(H(t,e),X()),P=!1,y=0;return}y=window.requestAnimationFrame(Z)};B(!1),f().then(()=>{g||(R(),G())});let Q=new ResizeObserver(U);Q.observe(t);let $=new MutationObserver(()=>{R(),X()});return $.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),F.addEventListener(`change`,G),I.addEventListener(`change`,G),document.addEventListener(`visibilitychange`,G),window.addEventListener(`resize`,G),n.addEventListener(`pointerdown`,q),n.addEventListener(`pointermove`,J),n.addEventListener(`pointerup`,Y),n.addEventListener(`pointercancel`,Y),{updatePayload(e){o=e,!g&&c&&(R(),X())},destroy(){g||(g=!0,V(),Q.disconnect(),$.disconnect(),F.removeEventListener(`change`,G),I.removeEventListener(`change`,G),document.removeEventListener(`visibilitychange`,G),window.removeEventListener(`resize`,G),n.removeEventListener(`pointerdown`,q),n.removeEventListener(`pointermove`,J),n.removeEventListener(`pointerup`,Y),n.removeEventListener(`pointercancel`,Y))}}}var F=n();function I(e){let t=[{label:o(`User`),count:e.counts.user},{label:o(`Agent Responses`),count:e.counts.agent_message},{label:o(`Thinking`),count:e.counts.thinking},{label:o(`Plans`),count:e.counts.plan},{label:o(`Tools`),count:e.counts.tools_all}].filter(e=>e.count>0),n=e.tools.map(e=>({label:e.label,count:e.count})),r=Math.max(0,9-t.length),i=n.length>r?n.slice(0,Math.max(0,r-1)):n,a=n.slice(i.length).reduce((e,t)=>e+t.count,0);return a>0&&i.push({label:o(`Other tools`),count:a}),[...t,...i].slice(0,9)}function L(e){return!e||e.length===0?o(`SESSION ACTIVITY RECEIPT`):e.map(e=>o(e)).join(` / `)}function R(e,t){return{id:e.reference.sessionId,title:s(e)||o(`Untitled session`),agent:r(e),updatedAt:e.time_updated??e.time_created,subtitle:L(e.smart_tags),inputTokens:e.stats.total_input_tokens??0,outputTokens:e.stats.total_output_tokens??0,messageCount:e.stats.message_count??0,totalCost:e.stats.total_cost??0,items:I(t)}}function z({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=a(),i=(0,c.useRef)(null),s=(0,c.useRef)(null),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useMemo)(()=>R(e,t),[r,e,t]),f=(0,c.useRef)(d);return(0,c.useLayoutEffect)(()=>{let e=i.current,t=s.current,r=l.current;if(!e||!t||!r)return;let a=P({canvas:e,anchor:t,hitSurface:r,payload:f.current,minWidthQuery:n});return u.current=a,()=>{a?.destroy(),u.current===a&&(u.current=null)}},[n]),(0,c.useLayoutEffect)(()=>{f.current=d,u.current?.updatePayload(d)},[d]),(0,F.jsxs)(`div`,{ref:s,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,F.jsx)(`canvas`,{ref:i,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{ref:l,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":o(`Interactive thermal receipt with Verlet paper simulation`)})]})}export{z as InteractiveReceipt};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{D as r,i,n as a,t as o}from"./translate-CLoII3EO.js";import{W as s}from"./index-DUcpWdzX.js";var c=e(t(),1);function l(e,t){return t===0||e-t>=15.666666666666668}function u(e,t,n){return!e&&t<=.12?n+1:0}function d(e,t){return e?0:t+1}function f(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function p(e,t,n){return e>=2&&(t>=8||n>=300)}function m(e,t){return!e||Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5}var h=18,g=42,ee=5,_=270,v=500,y=2,b=.035;function te(e){let t=window.getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{paperTop:n(`--console-surface`,`white`),paperBottom:n(`--console-surface-sunken`,`whitesmoke`),ink:n(`--console-text`,`black`),inkMuted:n(`--console-text-secondary`,`dimgray`),line:n(`--console-border-strong`,`silver`),shadow:n(`--scrim`,`gray`)}}function ne(e){return window.getComputedStyle(e).getPropertyValue(`--font-mono`).trim()||`monospace`}function x(e){return Math.round(e??0).toLocaleString(i())}function S(e){return`$${(e??0).toFixed(4)}`}function C(e){return new Date(e).toLocaleString(i(),{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function w(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function T(e){let t=e||1;return()=>(t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296)}function E(e,t,n,r,i){let a=t.toUpperCase(),o=n.toUpperCase();e.fillText(a,18,r),e.fillText(o,i-18-e.measureText(o).width,r)}function D(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}...`).width>n;)r=r.slice(0,-1);return`${r}...`}function O(e,t,n,r){let i=t.toUpperCase().split(/\s+/).filter(Boolean),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n){o=i;continue}if(o?(a.push(o),o=t):(a.push(D(e,t,n)),o=``),a.length===r)break}return a.length<r&&o&&a.push(o),a.length>0&&a.length===r&&(a[a.length-1]=D(e,a[a.length-1]??``,n)),a.slice(0,r)}function re(e,t,n){let r=document.createElement(`canvas`);r.width=_*y,r.height=v*y;let i=r.getContext(`2d`);if(!i)return r;i.scale(y,y);let a=e=>`${e} ${n}`,s=i.createLinearGradient(0,0,_,v);s.addColorStop(0,t.paperTop),s.addColorStop(1,t.paperBottom),i.fillStyle=s,i.fillRect(0,0,_,v);let c=T(w(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=b*(.12+c()*.14),i.fillRect(c()*_,c()*v,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,_/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(D(i,e.subtitle.toUpperCase(),234),_/2,51),i.strokeStyle=t.line,i.lineWidth=1,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,66),i.lineTo(252,66),i.stroke(),i.setLineDash([]),i.textAlign=`left`,i.fillStyle=t.ink,i.font=a(`11px`),E(i,o(`Agent`),e.agent,88,_),E(i,o(`Updated`),C(e.updatedAt),104,_),E(i,o(`Session`),`#${e.id.slice(0,8)}`,120,_),i.setLineDash([2,3]),i.beginPath(),i.moveTo(18,140),i.lineTo(252,140),i.stroke(),i.setLineDash([]),i.font=a(`700 12px`),i.fillText(o(`SESSION TOC RECEIPT LIST`),18,163),i.font=a(`11px`);let l=185;for(let t of e.items){let e=x(t.count);i.fillText(D(i,t.label,168),18,l),i.fillText(e,252-i.measureText(e).width,l),l+=17}return i.strokeStyle=t.line,i.lineWidth=1.5,i.beginPath(),i.moveTo(18,l+5),i.lineTo(252,l+5),i.stroke(),l+=26,E(i,o(`Input tokens`),x(e.inputTokens),l,_),l+=16,E(i,o(`Output tokens`),x(e.outputTokens),l,_),l+=16,E(i,o(`Messages`),x(e.messageCount),l,_),l+=22,i.font=a(`700 13px`),E(i,o(`TOTAL COST`),S(e.totalCost),l,_),i.strokeStyle=t.line,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,l+18),i.lineTo(252,l+18),i.stroke(),i.setLineDash([]),i.font=a(`10px`),i.textAlign=`center`,i.fillStyle=t.inkMuted,O(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,_/2,l+38+t*13)}),r}function k(e,t){return e*h+t}function A(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=r+t*a,c=i+e*o;s.push({x:n,y:c,oldX:n,oldY:c,fixedX:e===0?n:null,fixedY:e===0?c:null})}let l=(e,t,n)=>{let r=s[e],i=s[t];r&&i&&c.push({a:e,b:t,length:Math.hypot(i.x-r.x,i.y-r.y),stiffness:n})};for(let e=0;e<g;e+=1)for(let t=0;t<h;t+=1){let n=k(e,t);t<17&&l(n,k(e,t+1),.98),e<41&&l(n,k(e+1,t),.92),e<41&&t<17&&(l(n,k(e+1,t+1),.46),l(k(e+1,t),k(e,t+1),.46)),t<16&&l(n,k(e,t+2),.35),e<40&&l(n,k(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function ie(e,t){let n=t.receiptWidth/17;for(let r=0;r<h;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function j(e){for(let t=0;t<h;t+=1){let n=e[t];n&&n.fixedX!=null&&n.fixedY!=null&&(n.x=n.fixedX,n.y=n.fixedY,n.oldX=n.fixedX,n.oldY=n.fixedY)}}function ae(e,t){let n=e[t.a],r=e[t.b];if(!n||!r)return;let i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<1e-4)return;let s=(o-t.length)/o*t.stiffness,c=n.fixedX!=null&&n.fixedY!=null,l=r.fixedX!=null&&r.fixedY!=null,u=c?0:l?1:.5,d=l?0:c?1:.5,f=i*s,p=a*s;c||(n.x+=f*u,n.y+=p*u),l||(r.x-=f*d,r.y-=p*d)}function M(e,t,n,r,i,a){let o=r[k(i,a)],s=r[k(i,a+1)],c=r[k(i+1,a)],l=r[k(i+1,a+1)];if(!o||!s||!c||!l)return;let u=a/17*t.width,d=i/41*t.height,f=t.width/17,p=t.height/41;e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.clip(),e.transform((s.x-o.x)/f,(s.y-o.y)/f,(c.x-o.x)/p,(c.y-o.y)/p,o.x,o.y),e.drawImage(t,u,d,f+1,p+1,0,0,f+1,p+1),e.restore();let m=Math.atan2(s.y-o.y,s.x-o.x),h=Math.hypot(c.x-o.x,c.y-o.y)/(v/41),g=Math.sin(m)*.08+(h-1)*.16;Math.abs(g)<.01||(e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.globalAlpha=Math.abs(g),e.fillStyle=g>0?n.paperTop:n.shadow,e.fill(),e.restore())}function N(e,t,n){let r=null,i=44;for(let a=h;a<e.length;a+=1){let o=e[a];if(!o)continue;let s=Math.hypot(o.x-t,o.y-n);s<i&&(i=s,r=a)}return r}function oe(e){let t=0;for(let n=h;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function P({canvas:e,anchor:t,hitSurface:n,payload:r,minWidthQuery:i}){let a=e.getContext(`2d`,{alpha:!0});if(!a)return null;let o=r,s={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},c=null,g=!1,y=0,b=0,x=0,S=A({receiptWidth:_,receiptHeight:v,startX:0,startY:32}),C=performance.now(),w=null,T=0,E=0,D=0,O=0,k=!1,P=!1,F=window.matchMedia(i),I=window.matchMedia(`(prefers-reduced-motion: reduce)`),L=()=>c!=null&&F.matches&&document.visibilityState===`visible`,R=()=>{let e=te(t);c={texture:re(o,e,ne(t)),palette:e}},z=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(_,n-34);return{receiptWidth:r,receiptHeight:Math.min(v,Math.max(320,x-42)),startX:(n-r)/2,startY:32}},B=t=>{k!==t&&(k=t,e.style.visibility=t?`visible`:`hidden`,n.style.visibility=t&&!I.matches?`visible`:`hidden`)},V=()=>{P=!1,y&&=(window.cancelAnimationFrame(y),0),B(!1)},H=(e,t=performance.now())=>{S=A(e),w=e,C=t},U=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();b=Math.max(1,r.width),x=Math.max(1,r.height),e.width=Math.floor(b*n),e.height=Math.floor(x*n),a.setTransform(n,0,0,n,0,0),T=0,E=0,D=0,O=0,B(!1),H(z()),L()&&W()},W=()=>{!P&&L()&&(P=!0,y=window.requestAnimationFrame(Z))},G=()=>{L()?U():V()},K=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},q=e=>{if(e.button!==0||I.matches)return;let t=K(e),r=N(S.particles,t.x,t.y);r!=null&&(e.preventDefault(),n.setPointerCapture(e.pointerId),s.id=e.pointerId,s.x=t.x,s.y=t.y,s.prevX=t.x,s.prevY=t.y,s.vx=0,s.vy=0,s.grabbedIndex=r,E=0,D=0,W())},J=e=>{if(s.id!==e.pointerId)return;let t=K(e);s.vx=t.x-s.prevX,s.vy=t.y-s.prevY,s.prevX=t.x,s.prevY=t.y,s.x=t.x,s.y=t.y},Y=e=>{if(s.id!==e.pointerId)return;let t=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];t&&(t.oldX=t.x-s.vx*.9,t.oldY=t.y-s.vy*.9),s.id=null,s.grabbedIndex=null},se=e=>{let t=(e-C)/1e3;for(let e=h;e<S.particles.length;e+=1){let n=S.particles[e];if(!n)continue;let r=(n.x-n.oldX)*.985,i=(n.y-n.oldY)*.985;n.oldX=n.x,n.oldY=n.y,n.x+=r+Math.sin(t*1.7+e*.19)*.018,n.y+=i+.22}let n=s.grabbedIndex==null?null:S.particles[s.grabbedIndex];n&&(n.x+=(s.x-n.x)*.72,n.y+=(s.y-n.y)*.72)},ce=()=>{for(let e=0;e<ee;e+=1){j(S.particles);for(let e of S.constraints)ae(S.particles,e)}j(S.particles)},le=()=>{let e=1/0,t=1/0,r=-1/0,i=-1/0;for(let n of S.particles)e=Math.min(e,n.x),t=Math.min(t,n.y),r=Math.max(r,n.x),i=Math.max(i,n.y);n.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,n.style.width=`${r-e+40}px`,n.style.height=`${i-t+40}px`},ue=e=>{let t=S.particles[0],n=S.particles[17],r=S.particles[755],i=S.particles[738];t&&n&&r&&i&&(a.save(),a.shadowColor=e.shadow,a.shadowBlur=24,a.shadowOffsetY=16,a.fillStyle=e.shadow,a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(n.x,n.y),a.lineTo(r.x,r.y),a.lineTo(i.x,i.y),a.closePath(),a.fill(),a.restore())},de=e=>{let t=S.particles[0],n=S.particles[17];t&&n&&(a.save(),a.strokeStyle=e.ink,a.lineWidth=4,a.lineCap=`round`,a.beginPath(),a.moveTo(t.x-10,t.y-3),a.lineTo(n.x+10,n.y-3),a.stroke(),a.strokeStyle=e.paperTop,a.lineWidth=1,a.beginPath(),a.moveTo(t.x-8,t.y-5),a.lineTo(n.x+8,n.y-5),a.stroke(),a.restore())},X=()=>{if(c){a.clearRect(0,0,b,x),ue(c.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)M(a,c.texture,c.palette,S.particles,e,t);de(c.palette),le()}},Z=e=>{if(!P)return;if(!L()){V();return}if(!l(e,O)){y=window.requestAnimationFrame(Z);return}O=e;let t=z();m(w,t)&&s.id==null?(T=0,B(!1),H(t,e)):(T+=1,w=t),ie(S.particles,t),I.matches||(se(e),ce()),X();let n=s.id!=null;E=u(n,oe(S.particles),E),D=d(n,D);let r=I.matches;if((r||T>=2)&&B(!0),r||p(T,E,D)){r||(H(t,e),X()),P=!1,y=0;return}y=window.requestAnimationFrame(Z)};B(!1),f().then(()=>{g||(R(),G())});let Q=new ResizeObserver(U);Q.observe(t);let $=new MutationObserver(()=>{R(),X()});return $.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),F.addEventListener(`change`,G),I.addEventListener(`change`,G),document.addEventListener(`visibilitychange`,G),window.addEventListener(`resize`,G),n.addEventListener(`pointerdown`,q),n.addEventListener(`pointermove`,J),n.addEventListener(`pointerup`,Y),n.addEventListener(`pointercancel`,Y),{updatePayload(e){o=e,!g&&c&&(R(),X())},destroy(){g||(g=!0,V(),Q.disconnect(),$.disconnect(),F.removeEventListener(`change`,G),I.removeEventListener(`change`,G),document.removeEventListener(`visibilitychange`,G),window.removeEventListener(`resize`,G),n.removeEventListener(`pointerdown`,q),n.removeEventListener(`pointermove`,J),n.removeEventListener(`pointerup`,Y),n.removeEventListener(`pointercancel`,Y))}}}var F=n();function I(e){let t=[{label:o(`User`),count:e.counts.user},{label:o(`Agent Responses`),count:e.counts.agent_message},{label:o(`Thinking`),count:e.counts.thinking},{label:o(`Plans`),count:e.counts.plan},{label:o(`Tools`),count:e.counts.tools_all}].filter(e=>e.count>0),n=e.tools.map(e=>({label:e.label,count:e.count})),r=Math.max(0,9-t.length),i=n.length>r?n.slice(0,Math.max(0,r-1)):n,a=n.slice(i.length).reduce((e,t)=>e+t.count,0);return a>0&&i.push({label:o(`Other tools`),count:a}),[...t,...i].slice(0,9)}function L(e){return!e||e.length===0?o(`SESSION ACTIVITY RECEIPT`):e.map(e=>o(e)).join(` / `)}function R(e,t){return{id:e.reference.sessionId,title:s(e)||o(`Untitled session`),agent:r(e),updatedAt:e.time_updated??e.time_created,subtitle:L(e.smart_tags),inputTokens:e.stats.total_input_tokens??0,outputTokens:e.stats.total_output_tokens??0,messageCount:e.stats.message_count??0,totalCost:e.stats.total_cost??0,items:I(t)}}function z({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=a(),i=(0,c.useRef)(null),s=(0,c.useRef)(null),l=(0,c.useRef)(null),u=(0,c.useRef)(null),d=(0,c.useMemo)(()=>R(e,t),[r,e,t]),f=(0,c.useRef)(d);return(0,c.useLayoutEffect)(()=>{let e=i.current,t=s.current,r=l.current;if(!e||!t||!r)return;let a=P({canvas:e,anchor:t,hitSurface:r,payload:f.current,minWidthQuery:n});return u.current=a,()=>{a?.destroy(),u.current===a&&(u.current=null)}},[n]),(0,c.useLayoutEffect)(()=>{f.current=d,u.current?.updatePayload(d)},[d]),(0,F.jsxs)(`div`,{ref:s,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,F.jsx)(`canvas`,{ref:i,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,F.jsx)(`div`,{ref:l,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":o(`Interactive thermal receipt with Verlet paper simulation`)})]})}export{z as InteractiveReceipt};
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,f as i,l as a,o,t as s}from"./CustomTimeWindowDialog-CGPvUFkc.js";import{n as c,t as l}from"./translate-CLoII3EO.js";import{$ as u,H as d,J as f,K as p,Y as m,at as h,nt as g,ot as _,tt as v}from"./index-BIpTq_7T.js";import{t as y}from"./utils-BuYa9y6l.js";import{n as b,t as x}from"./panel-B-5dVddJ.js";var S=e(t(),1);function C(e,t){let n=e!==null,r=i({...a(e??{},t),enabled:n}),o=r.refetch,s=(0,S.useCallback)(async()=>{await o()},[o]);return{dashboard:n?r.data??null:null,loading:n&&r.isPending,error:n&&r.isError?r.error instanceof Error?r.error.message:l(`Unable to load dashboard.`):null,retry:s}}var w=n();function T({index:e,count:t,position:n=(e+.5)/t*100,children:r}){return(0,w.jsx)(`div`,{role:`tooltip`,className:`console-mono pointer-events-none absolute top-2 z-10 w-max max-w-full rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] break-words text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,style:{left:`${n}%`,transform:`translateX(-${n}%)`},children:r})}var E=Math.PI*2;function D(e){return e<0?0:e>1?1:e}function O(e){let t=D(e);return t*t*(3-2*t)}function k(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function A(e,t,n){return O((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function j(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var M=/^var\((--[\w-]+)\)$/;function N(e,t){let n=M.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function P(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var F=50;function ee(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{e&&t!==null&&!n&&(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},F))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function I(e,t){let[n]=(0,S.useState)(ee);return(0,S.useEffect)(()=>{let r=e.current;if(!r||t){n.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>n.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(r),document.addEventListener(`visibilitychange`,s),o(),()=>{n.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[n,t,e]),n.api}var te=2,L=5,ne=8,re=7,ie=620,ae=.05,oe=.8,se=.0018,ce=.3,le=.48,ue={barRatio:.62,barMax:76,bandGap:4,minBand:6};function de(e,t,n){let r=Math.max(1,t-1),i=Math.min(ae,oe/r),a=1-(t-1)*i;return 1-(1-D((n-e*i)/a))**3}function fe(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:s,reducedMotion:c}){let l=(0,S.useContext)(o),u=I(e,c),d=r.join(`\0`),f=(0,S.useRef)({values:t,axisMax:n,hovered:a,layout:s}),p=(0,S.useRef)(new Map),m=(0,S.useRef)(new Map),h=(0,S.useRef)({startedAt:0,running:!1}),g=(0,S.useRef)({w:0,h:0}),_=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{f.current={values:t,axisMax:n,hovered:a,layout:s},c?_.current():u.requestFrame()},[n,u,a,s,c,t]),(0,S.useEffect)(()=>{m.current=new Map(p.current),c?(h.current.running=!1,_.current()):(h.current={startedAt:performance.now(),running:!0},u.requestFrame())},[n,u,c,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(d?d.split(`\0`):[]).map(e=>N(a,e)),s=N(a,i),l=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(te,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),g.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!h.current.running)return 1;let r=D((n-h.current.startedAt)/ie);return r>=1&&(h.current.running=!1),de(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?ne:L,l?ne:L,u?re:L,u?re:L],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=O(1-(e-t)/i),o=A(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*k(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*se;let{w:t,h:n}=g.current;if(!t||!n)return;let i=f.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){h.current.running=!1;return}let{barRatio:a,barMax:c,bandGap:l,minBand:u}=i.layout,d=i.values.length,_=t/d,x=Math.min(_*a,c),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,d,e),a=r*_+(_-x)/2,c=n;t.forEach((e,n)=>{let d=`${r}:${n}`,f=e>0?Math.max(u,e*C):0,h=m.current.get(d)??0,g=h+(f-h)*i;p.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:le:ce;g>0&&b(a,c-g,x,g,o[n]??o[0]??s,s,v,_,n===t.length-1,n===0,S),c-=g+l})})};_.current=()=>{l(),x(performance.now())},u.setFrameHandler(e=>(x(e),h.current.running?`active`:f.current.hovered===null?`stop`:`idle`)),l();let S=new ResizeObserver(()=>{l(),c?x(performance.now()):u.requestFrame()});return S.observe(n),c&&x(performance.now()),()=>{u.setFrameHandler(null),S.disconnect()}},[e,d,u,i,c,l]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=g.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=f.current,d=l.length,m=i/d,h=Math.floor(s/m);if(h<0||h>=d)return null;let _=Math.min(m*u.barRatio,u.barMax),v=h*m+(m-_)/2;if(s<v||s>v+_)return{column:h,band:null};let y=a;for(let e=0;e<l[h].length;e++){let t=p.current.get(`${h}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:h,band:e};y-=t+u.bandGap}return{column:h,band:null}}}}var pe=`(prefers-reduced-motion: reduce)`;function R(){let[e,t]=(0,S.useState)(()=>globalThis.matchMedia?.(pe).matches??!1);return(0,S.useEffect)(()=>{let e=globalThis.matchMedia?.(pe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function me(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function he({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,S.useRef)([]),[o,s]=(0,S.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=me(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:y(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,w.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:y(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,w.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var ge=[1,.75,.5,.25,0];function _e(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function ve({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:d}){let f=(0,S.useRef)(null),p=(0,S.useRef)(i),m=R(),{hitTest:h}=fe(f,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...ue,...o},reducedMotion:m});(0,S.useEffect)(()=>{p.current=i},[i]);let g=e=>{_e(p.current,e)||(p.current=e,a(e))};return(0,w.jsxs)(`div`,{className:y(`flex`,d),children:[c?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:ge.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>g(h(e.clientX,e.clientY)),onPointerLeave:()=>g(null),children:[ge.map(e=>(0,w.jsx)(`span`,{"aria-hidden":!0,className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,w.jsx)(`canvas`,{ref:f,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,w.jsx)(he,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>g(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var z=6,ye=118,be={barRatio:.52,barMax:34,bandGap:0,minBand:4},xe=[`var(--brand)`];function Se({perAgent:e}){let t=c(),[n,r]=(0,S.useState)(null),{byCost:i,visible:a,values:o,axisMax:s,itemLabels:u}=(0,S.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,z),i=r.map(e=>[n(e)]),a=r.map(e=>t?l(`{0}: {1}, {2} sessions`,[e.displayName,h(e.cost),m(e.sessions)]):l(`{0}: {1} sessions`,[e.displayName,m(e.sessions)]));return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:a}},[t,e]),f=n===null?void 0:a[n.column];return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Agents`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Agents`),meta:l(`{0} · {1} total`,[l(i?`by cost`:`by sessions`),e.length])}),a.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No data`)}):(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:o,axisMax:s,colors:xe,hovered:n,onHover:r,layout:be,height:ye,ariaLabel:l(`Agent distribution chart`),itemLabels:u}),f&&n?(0,w.jsxs)(T,{index:n.column,count:a.length,children:[(0,w.jsx)(`div`,{children:f.displayName}),(0,w.jsxs)(`div`,{children:[p(f.tokens),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:h(f.cost)})]}),(0,w.jsxs)(`div`,{children:[m(f.sessions),` `,l(`sessions ·`),` `,m(f.messages),` `,l(`messages`)]})]}):null,(0,w.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((e,t)=>(0,w.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,w.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,w.jsx)(d,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,w.jsx)(`span`,{className:y(`console-mono max-w-full truncate text-[9.5px]`,n?.column===t?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:i?h(e.cost):m(e.sessions)}),i?(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:m(e.sessions)}):null]},e.name))})]}),e.length>z?(0,w.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-z,` `,l(`more`)]}):null]})}function Ce(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return`oklch(0.65 0.16 ${(t>>>0)%360})`}function we(e,t){let n=e.filter(e=>e.tokens>0).toSorted((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>({key:e.model,label:e.model,value:e.tokens,color:Ce(e.model),display:p(e.tokens)})),i=n.slice(5).reduce((e,t)=>e+t.tokens,0);i>0&&r.push({key:`__other`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:p(i)});let a=t-n.reduce((e,t)=>e+t.tokens,0);return a>0&&r.push({key:`__unknown`,label:l(`Unknown model`),value:a,color:`var(--console-muted)`,display:p(a)}),r}var B=200,V=100,H=100,U=86,W=55,Te=-Math.PI/2,Ee=.07,De=6,G=4.6,Oe=2,ke=.0018,Ae=500,je=6,Me=.72,Ne=.3,Pe=(()=>{let e=[];for(let t=14;t<=186;t+=G)for(let n=14;n<=186;n+=G){let r=t-V,i=n-H,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*O((a-W)/31),jitter:k(t,n)})}return e})();function Fe(e,{a0:t,a1:n}){let r=n-t,i=Math.min(De,31*.45,W*r*.45),a=i/U,o=i/W,s=(e,t)=>[V+Math.cos(t)*e,H+Math.sin(t)*e],[c,l]=s(U,t+a);e.beginPath(),e.moveTo(c,l),e.arc(V,H,U,t+a,n-a),e.arcTo(...s(U,n),...s(W,n),i),e.arcTo(...s(W,n),...s(W,n-o),i),e.arc(V,H,W,n-o,t+o,!0),e.arcTo(...s(W,t),...s(U,t),i),e.arcTo(...s(U,t),c,l,i),e.closePath()}function Ie(e){let t=Te;return e.map(e=>{let n=e*E,r={a0:t+Ee/2,a1:t+n-Ee/2};return t+=n,r})}function Le(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,S.useContext)(o),s=I(e,i),c=n.join(`\0`),l=(0,S.useRef)(r),u=(0,S.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),d=(0,S.useRef)(Ie(t)),f=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{let e=u.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,f.current()):(e.startedAt=performance.now(),e.running=!0,s.requestFrame())},[s,i,t]),(0,S.useEffect)(()=>{l.current=r,i?f.current():s.requestFrame()},[s,r,i]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(c?c.split(`\0`):[]).map(e=>N(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(Oe,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/B*r},h=0,g=e=>{let t=u.current;if(!t.running)return;let n=D((e-t.startedAt)/Ae),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*je,Math.sin(n)*je),r.shadowColor=P(e,.55),r.shadowBlur=5}Fe(r,t),r.clip(),r.globalAlpha=i?n?1:Ne*Me:Me,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of Pe){let t=e.angle;for(;t<o;)t+=E;for(;t>=o+E;)t-=E;if(t>s)continue;let n=A(e.x,e.y,h),i=G*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*ke,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,B,B);let t=Ie(u.current.displayed);d.current=t;let n=l.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(o[t]??o[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(o[n]??``,a,!0,!0)};f.current=()=>{m(),v(performance.now())},s.setFrameHandler(e=>(g(e),v(e),u.current.running?`active`:l.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):s.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{s.setFrameHandler(null),y.disconnect()}},[e,c,s,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*B-V,o=(n-i.top)/i.height*B-H,s=Math.hypot(a,o);if(s<W||s>U)return null;let c=Math.atan2(o,a);for(let e=0;e<d.current.length;e++){let{a0:t,a1:n}=d.current[e],r=c;for(;r<t;)r+=E;for(;r>=t+E;)r-=E;if(r<=n)return e}return null}}}function Re({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,S.useRef)(null),{hitTest:l}=Le(c,{shares:e,colors:t,hovered:n,reducedMotion:R()});return(0,w.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,w.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,w.jsx)(he,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var ze=5,Be=142,Ve=.01;function He(e){return e!==null&&e.some(e=>e.cost>0)}function Ue(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,ze),r=n.map(e=>({key:e.model,label:e.model,value:e.cost,color:Ce(e.model),display:_(e.cost)})),i=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&i>t*Ve&&r.push({key:`__remainder`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:_(i)}),r}function We({modelCost:e,modelDistribution:t,totals:n}){let r=c(),[i,a]=(0,S.useState)(null),{byCost:o,entries:s}=(0,S.useMemo)(()=>{let r=He(e);return{byCost:r,entries:r?Ue(e,n.cost):we(t,n.tokens)}},[r,e,t,n.cost,n.tokens]),u=s.reduce((e,t)=>e+t.value,0),d=(0,S.useMemo)(()=>s.map(e=>u>0?e.value/u:1/s.length),[s,u]),f=l(o?`Cost by Model`:`Models`),m=s.map(e=>`${e.label}: ${v(u>0?e.value/u:0)}, ${e.display}`);return(0,w.jsxs)(x,{role:`region`,"aria-label":f,className:`p-4`,children:[(0,w.jsx)(b,{title:f,meta:l(o?`by cost`:`by tokens`)}),s.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No model data`)}):(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,w.jsxs)(Re,{shares:d,colors:s.map(e=>e.color),hovered:i,onHover:a,size:Be,ariaLabel:l(`{0} chart`,[f]),itemLabels:m,children:[(0,w.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:o?_(n.cost):p(n.tokens)}),(0,w.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l(o?`total cost`:`total tokens`)})]}),(0,w.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:s.map((e,t)=>(0,w.jsxs)(`li`,{className:y(`flex min-w-0 items-center gap-2 transition-opacity`,i!==null&&i!==t?`opacity-45`:null),onPointerEnter:()=>a(t),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,w.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,w.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:v(u>0?e.value/u:0)}),(0,w.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,w.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:o?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:l(`Estimated`)}),h(n.costEstimated),` `,l(`from model unit price,`),` `,h(n.costRecorded),` `,l(`from agent records`)]}):l(`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`)})]})}var Ge=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function Ke({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:u}){c();let[d,f]=(0,S.useState)(!1);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,w.jsxs)(`select`,{"aria-label":l(`Filter by agent`),value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,w.jsx)(`option`,{value:K,children:l(`All agents`)}),n.active.map(e=>(0,w.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,w.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:l(`{0} projects · {1} agents in scope`,[r.projects,r.agents])}):null,(0,w.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ge.map(e=>{let t=e.value===a;return(0,w.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?f(!0):o(e.value)},className:y(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:l(e.label)},e.value)})})]}),(0,w.jsx)(s,{open:d,onOpenChange:f,window:i,onSelectCustom:u})]})}function qe(e){return e.toFixed(1)}var Je={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return c(),(0,w.jsxs)(x,{className:y(`min-w-0 px-4 py-[14px] last:col-span-2 md:last:col-span-1`,a?`border-[var(--brand-line)]`:null),children:[(0,w.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,w.jsx)(`p`,{className:y(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,w.jsxs)(`div`,{className:`mt-[7px] flex items-start gap-[7px]`,children:[n===void 0?null:(0,w.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:y(`console-mono shrink-0 text-xs`,Je[r]),children:n}),i===void 0?null:(0,w.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-words text-xs text-[var(--console-muted)]`,children:i})]})]})}function Ye(e){return e.costEstimated===0?l(`All recorded by agents`):e.costEstimated===e.cost&&e.cost>0?l(`All estimated from unit price`):l(`{0} estimated`,[h(e.costEstimated)])}function Xe(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function Ze({totals:e,rangeDays:t}){c();let n=e.previous,r=(e,t)=>t===void 0?null:f(e,t),i=r(e.sessions,n?.sessions),a=r(e.messages,n?.messages),o=r(e.tokens,n?.tokens),s=r(e.cost,n?.cost),u=n?.cost!==void 0&&e.cost>n.cost;return(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,w.jsx)(q,{label:l(`Sessions`),value:m(e.sessions),trend:i??void 0,hint:t?l(`{0}/day`,[qe(e.sessions/t)]):void 0}),(0,w.jsx)(q,{label:l(`Messages`),value:m(e.messages),trend:a??void 0,hint:e.sessions>0?l(`{0}/session`,[qe(e.messages/e.sessions)]):void 0}),(0,w.jsx)(q,{label:l(`Tokens`),value:p(e.tokens),trend:o??void 0,hint:l(`Cache hit {0}`,[v(e.cacheReadTokens/e.tokens)])}),(0,w.jsx)(q,{label:l(`Cost`),value:h(e.cost),trend:s??void 0,trendTone:u?`warning`:`positive`,hint:Ye(e),emphasis:!0}),(0,w.jsx)(q,{label:l(`Last activity`),value:e.latestActivity===void 0?l(`No activity`):g(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Xe(e)})]})}var J=32,Y=4;function Qe({shares:e,colors:t,hovered:n,onHover:r,ariaLabel:i,itemLabels:a}){let s=(0,S.useRef)(null),c=R(),l=(0,S.useContext)(o),u=I(s,c),d=(0,S.useRef)(n),f=(0,S.useRef)(()=>{}),p=e.join(`,`),m=t.join(`\0`);return(0,S.useEffect)(()=>{d.current=n,c?f.current():u.requestFrame()},[u,n,c]),(0,S.useEffect)(()=>{let e=s.current,t=e?.parentElement,n=e?.getContext(`2d`);if(!e||!t||!n)return;let r=getComputedStyle(e),i=m.split(`\0`).map(e=>N(r,e)),a=p.split(`,`).map(Number),o=0,l=()=>{o=t.clientWidth;let r=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(o*r),e.height=J*r,n.setTransform(r,0,0,r,0,0)},h=e=>{n.clearRect(0,0,o,J);let t=0;a.forEach((r,a)=>{let s=r*o,c=Math.min(1,s/6),l=t+c,u=s-c*2;if(t+=s,u<=0)return;let f=d.current===a;n.save(),n.beginPath(),n.roundRect(l,0,u,J,Math.min(4,u/2)),n.clip(),n.fillStyle=i[a]??``,n.globalAlpha=d.current===null?.72:f?1:.3,n.beginPath();for(let t=l+Math.min(Y,u)/2;t<l+u;t+=Y)for(let r=Y/2;r<J;r+=Y){let i=O(1-r/J),a=A(t,r,e*.0018),o=Y*((f?.46:.34)+.36*i+.26*a)*(.78+.42*k(t,r));n.rect(t-o/2,r-o/2,o,o)}n.fill(),n.restore()})};f.current=()=>h(performance.now());let g=()=>{l(),c?f.current():u.requestFrame()};u.setFrameHandler(e=>(h(e),d.current===null?`stop`:`idle`));let _=new ResizeObserver(g);return _.observe(t),g(),()=>{_.disconnect(),u.setFrameHandler(null)}},[m,u,c,p,l]),(0,w.jsxs)(`div`,{className:`chart-hatch relative rounded-sm`,style:{height:J},onPointerMove:t=>{let n=t.currentTarget.getBoundingClientRect(),i=(t.clientX-n.left)/n.width,a=0,o=e.findIndex(e=>(a+=e,i<a));r(o<0?null:o)},onPointerLeave:e=>{e.pointerType!==`touch`&&r(null)},children:[(0,w.jsx)(`canvas`,{ref:s,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(he,{label:i,itemLabels:a,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}function $e({models:e,totalTokens:t}){let n=c(),[r,i]=(0,S.useState)(null),a=(0,S.useMemo)(()=>we(e,t),[n,e,t]),o=a.map(e=>e.value/t),s=o.map(e=>e>0&&e<.001?`<0.1%`:e.toLocaleString(n,{style:`percent`,maximumFractionDigits:1})),u=a.map((e,t)=>`${e.label}: ${m(e.value)} ${l(`tokens`)}, ${s[t]}`),d=a.findIndex(e=>e.key===r),f=a[d],h=(o.slice(0,d).reduce((e,t)=>e+t,0)+(o[d]??0)/2)*100;return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Tokens by Model`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Tokens by Model`),meta:`${p(t)} ${l(`total tokens`)}`}),(0,w.jsx)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:l(`Token share in the selected range, including cache tokens.`)}),t<=0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`relative mt-3`,children:[(0,w.jsx)(Qe,{shares:o,colors:a.map(e=>e.color),hovered:d<0?null:d,onHover:e=>i(e===null?null:a[e]?.key??null),ariaLabel:l(`Model token distribution chart`),itemLabels:u}),f?(0,w.jsxs)(T,{index:d,count:a.length,position:h,children:[(0,w.jsx)(`div`,{className:`font-semibold`,children:f.label}),(0,w.jsxs)(`div`,{children:[m(f.value),` `,l(`tokens`),` · `,s[d]]})]}):null]}),(0,w.jsx)(`ul`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-2`,children:a.map((e,t)=>(0,w.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,w.jsxs)(`button`,{type:`button`,"aria-label":u[t],className:y(`console-mono flex max-w-full items-center gap-1.5 rounded-sm text-[10.5px] text-[var(--console-text)] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-[var(--brand)]`,f&&f.key!==e.key?`opacity-45`:null),onPointerEnter:()=>i(e.key),onPointerLeave:()=>i(null),onFocus:()=>i(e.key),onBlur:()=>i(null),onClick:()=>i(e.key),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:[(0,w.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color}}),(0,w.jsx)(`span`,{className:`truncate`,children:e.label}),(0,w.jsxs)(`span`,{className:`shrink-0 text-[var(--console-muted)]`,children:[e.display,` · `,s[t]]})]})},e.key))})]})]})}var et=[0,1,2,3,4];function X({className:e}){return c(),(0,w.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Z({bodyClassName:e}){return c(),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-3 ${e}`})]})}function tt(){return c(),(0,w.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:et.map(e=>(0,w.jsxs)(x,{className:`px-4 py-[14px]`,children:[(0,w.jsx)(X,{className:`h-[10px] w-16`}),(0,w.jsx)(X,{className:`mt-[9px] h-[27px] w-24`}),(0,w.jsx)(X,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,w.jsx)(Z,{bodyClassName:`h-[68px] w-full`}),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-[14px] h-[168px] w-full`})]}),(0,w.jsx)(Z,{bodyClassName:`h-[428px] w-full`}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[248px] w-full`}),(0,w.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[116px] w-full`}),(0,w.jsx)(Z,{bodyClassName:`h-[100px] w-full`})]})]})]})}function nt(e){return`${String(e*2).padStart(2,`0`)}:00–${String(e*2+2).padStart(2,`0`)}:00`}function rt({count:e,peak:t}){let n=(0,S.useId)(),r=t>0?Math.sqrt(e/t):0,i=12*r;return(0,w.jsx)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 28 28`,"aria-hidden":`true`,style:{color:`color-mix(in oklab, var(--activity-high) ${r*100}%, var(--activity-low))`},children:e>0?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`pattern`,{id:n,width:`3`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,w.jsx)(`rect`,{width:`2`,height:`2`,fill:`currentColor`})})}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`currentColor`,opacity:`0.2`}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`url(#${n})`})]}):null})}function it({activity:e}){let t=c(),n=[l(`Overnight`),l(`Morning`),l(`Afternoon`),l(`Evening`)],[r,i]=(0,S.useState)(null),a=t===`zh-CN`?[1,2,3,4,5,6,0]:[0,1,2,3,4,5,6],o=new Intl.DateTimeFormat(t,{weekday:`short`,timeZone:`UTC`}),s=a.map(e=>o.format(Date.UTC(2026,8,6+e))),u=Math.max(0,...e?.counts??[]),d=e?.counts.reduce((e,t)=>e+t,0)??0;return(0,w.jsxs)(x,{className:`p-4`,"aria-label":l(`Active hours`),children:[(0,w.jsx)(b,{title:l(`Active hours`)}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:l(`User messages by weekday and two-hour period. Counts are cumulative within the selected range.`)}),e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2 console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`span`,{children:l(`Time zone: {0}`,[e.timeZone])}),(0,w.jsx)(`span`,{children:l(`{0} user messages`,[m(d)])})]}),(0,w.jsxs)(`table`,{className:`mt-[14px] w-full table-fixed border-collapse console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`caption`,{className:`sr-only`,children:l(`Active hours`)}),(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{scope:`col`,className:t===`en`?`w-16`:`w-9`,children:(0,w.jsx)(`span`,{className:`sr-only`,children:l(`Day period`)})}),(0,w.jsx)(`th`,{scope:`col`,className:`w-11 pb-2 text-left font-normal`,children:l(`Time`)}),s.map(e=>(0,w.jsx)(`th`,{scope:`col`,className:`pb-2 font-normal`,children:e},e))]})}),n.map((t,n)=>(0,w.jsx)(`tbody`,{className:`chart-hatch`,children:Array.from({length:3},(o,c)=>{let d=n*3+c;return(0,w.jsxs)(`tr`,{className:c===0&&n>0?`border-t border-solid border-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`,children:[c===0?(0,w.jsx)(`th`,{scope:`rowgroup`,rowSpan:3,className:`bg-[var(--console-surface)] pr-2 text-left align-middle font-normal`,children:t}):null,(0,w.jsx)(`th`,{scope:`row`,className:`h-8 bg-[var(--console-surface)] text-left font-normal tabular-nums`,children:`${String(d*2).padStart(2,`0`)}:00`}),a.map((t,n)=>{let a=t*12+d,o=e.counts[a]??0,c=`${s[n]} · ${nt(d)} · ${l(`{0} user messages`,[m(o)])}`;return(0,w.jsxs)(`td`,{className:`relative p-0 text-center`,children:[(0,w.jsx)(`button`,{type:`button`,"aria-label":c,className:`flex h-8 w-full items-center justify-center rounded-sm outline-none hover:bg-[var(--brand-soft)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]`,onMouseEnter:()=>i(a),onMouseLeave:()=>i(null),onFocus:()=>i(a),onBlur:()=>i(null),onClick:()=>i(a),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:(0,w.jsx)(rt,{count:o,peak:u})}),r===a?(0,w.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-full z-10 w-max max-w-[180px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-left text-[var(--console-text)] shadow-[var(--shadow-overlay)] ${n<3?`left-0`:`right-0`}`,children:[`${s[n]} · ${nt(d)} · `,(0,w.jsx)(`span`,{className:`font-semibold text-[var(--brand)]`,children:l(`{0} user messages`,[m(o)])})]}):null]},t)})]},d)})},t))]}),(0,w.jsx)(`div`,{className:`mt-3 flex min-h-7 flex-wrap items-center justify-end gap-4 console-mono text-[10.5px] text-[var(--console-muted)]`,children:u===0?(0,w.jsx)(`span`,{children:l(`No user messages in this range.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-1.5`,"aria-label":l(`Size reference (messages)`),children:[l(`Less`),[1,4,9].map(e=>(0,w.jsx)(rt,{count:e,peak:9},e)),l(`More`)]}),(0,w.jsx)(`span`,{children:l(`Peak: {0}`,[m(u)])})]})})]}):(0,w.jsx)(`p`,{className:`py-8 text-center text-sm text-[var(--console-muted)]`,children:l(`Activity data is unavailable.`)})]})}var at=.16;function ot(e){return e*e*(3-2*e)}function st(e,t,n){return e<t?t:e>n?n:e}function Q(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=st(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=ot(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function ct(e,t){let n=st(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function lt(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var ut=2,dt=460,ft=180,pt=32,mt=.06,ht=.24,gt=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function _t(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function vt(e,t){let n=gt.exec(e),r=gt.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/pt,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function yt(e,{values:t,max:n,reducedMotion:r}){let i=(0,S.useContext)(o),a=I(e,r),s=(0,S.useRef)({from:Q(t),to:Q(t),current:Q(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),c=(0,S.useRef)(null),l=(0,S.useRef)(()=>{}),u=(0,S.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,S.useEffect)(()=>{let e=s.current;e.from.set(e.current),e.fromMax=e.currentMax,Q(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:dt,r?l.current():a.requestFrame()},[a,n,r,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let o=u.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=vt(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(ut,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let s=Math.max(3,Math.round(e/ft)),l=Math.ceil(e/s),u=Math.ceil(r/s),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(_t(e)<mt);c.current={cell:s,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=s.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=u.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=c.current;if(!n)return!1;let a=s.current,{cell:o,cols:l,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(o*.34)),x=y((o-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<l;e++){let t=e*o+x;for(let e=0;e<d;e++)i.fillRect(t,e*o+x,b,b)}let S=u.current,C=h*(ht+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,D=e*.0018,O=-1,k=!1;for(let t=0;t<l;t++){let n=l>1?(t+.5)/l:.5,s=lt(ct(a.current,n),a.currentMax),c=Math.max(.001,1-s),u=t*o,m=u+o/2;for(let n=0;n<d;n++){let a=t*d+n,l=n*o,b=(l+o/2)/h,x=0;b>=s&&(x=1-.55*((b-s)/c));let A=_[a];if(w){let e=Math.hypot(m-S.smoothX,l+o/2-S.smoothY),t=e<C?1-e/C:0;A+=(t-A)*(t>A?T:E),_[a]=A}else A>0&&(A*=1-E,_[a]=A<.002?0:A);_[a]>0&&(k=!0);let j=Math.min(1,x+A*.5);if(j<=.02)continue;let M=j;r||(M*=1+.07*Math.sin(b*Math.PI*3-D),v[a]&&A>.02&&(M*=1+.25*A*Math.sin(e*.012+a)),M=Math.min(1,M));let N=Math.max(g,y(o*(.28+.42*j))),P=y((o-N)/2),F=Math.round(M*pt);F!==O&&(O=F,i.fillStyle=p[O]??p[pt]??f),i.fillRect(u+P,l+P,N,N)}}return k},v=()=>{m(),h(performance.now()),_(performance.now())};l.current=v;let y=e=>{let t=c.current;if(!t)return;let r=u.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{u.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:u.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),o.inside=!1}},[e,a,r,i])}var bt=[1,.66,.33,0],xt=e=>`${(1-e*(1-at))*100}%`,St=(e,t)=>(e+.5)/t*100;function Ct({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,S.useState)(null),o=(0,S.useRef)(null),s=R(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,d=e[u]??0,f=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,w.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,transition:f}}),(0,w.jsxs)(`div`,{className:y(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,top:`${lt(d,t)*100}%`,transition:f},children:[(0,w.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,w.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,w.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(d)})]})]})]})}function wt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,S.useRef)(null);return yt(s,{values:e,max:t,reducedMotion:R()}),(0,w.jsxs)(`div`,{className:y(`flex`,o),"aria-hidden":!0,children:[a?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:bt.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:xt(e)},children:a(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[bt.map(e=>(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:xt(e)}},e)),(0,w.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,w.jsx)(Ct,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var Tt=168,Et=132,Dt=6,Ot={barRatio:.86,barMax:46,bandGap:2,minBand:3},kt=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],At=kt.map(e=>e.color);function jt(e){return e===0?`$0`:e>=1e3?`$${p(e)}`:e>=1?`$${Number(e.toFixed(2))}`:`$${Number(e.toPrecision(2))}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function Mt(e){return l(`{0}: {1} tokens, {2}, {3} sessions, {4} messages, input {5}, output {6}, cache read {7}, cache write {8}`,[u(e.date),p($(e)),h(e.cost),m(e.sessions),m(e.messages),p(e.input),p(e.output),p(e.cache_read),p(e.cache_create)])}function Nt({daily:e}){c();let t=(0,S.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,S.useMemo)(()=>e.map(e=>u(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,w.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:l(`Daily cost`)}),(0,w.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[l(`Peak`),` `,h(i),` `,l(`· Avg`),` `,h(r/e.length),` `,l(`· Total`),` `,h(r)]})]}),(0,w.jsx)(wt,{values:t,max:i,labels:n,height:Et,formatValue:h,formatTick:jt,className:`mt-[7px]`})]})}function Pt({bucket:e,index:t,count:n}){return c(),(0,w.jsxs)(T,{index:t,count:n,children:[(0,w.jsx)(`div`,{children:u(e.date)}),(0,w.jsxs)(`div`,{children:[p($(e)),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:h(e.cost)})]}),(0,w.jsxs)(`div`,{children:[m(e.sessions),` `,l(`sessions ·`),` `,m(e.messages),` `,l(`messages`)]}),(0,w.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[l(`In`),` `,p(e.input),` `,l(`· Out`),` `,p(e.output),` `,l(`· Read`),` `,p(e.cache_read),` `,l(`· Write`),` `,p(e.cache_create)]})]})}function Ft({daily:e}){let t=c(),[n,r]=(0,S.useState)(null),i=(0,S.useMemo)(()=>e.map(e=>kt.map(t=>e[t.key])),[e]),a=(0,S.useMemo)(()=>e.map(Mt),[t,e]),o=(0,S.useMemo)(()=>j(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),s=n===null?void 0:e[n.column];return(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:i,axisMax:o,colors:At,hovered:n,onHover:r,layout:Ot,height:Tt,formatTick:p,ariaLabel:l(`Daily usage chart`),itemLabels:a}),s&&n?(0,w.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,w.jsx)(Pt,{bucket:s,index:n.column,count:e.length})}):null]})}function It({daily:e}){c();let t=e[0],n=e[e.length-1],r=t&&n?` · ${u(t.date)} → ${u(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/Dt));return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Daily usage`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Daily usage`),action:(0,w.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:kt.map(e=>(0,w.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),l(e.label)]},e.key))})}),(0,w.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[l(`Stacked bars = token mix · Area below = daily cost`),r]}),e.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ft,{daily:e}),(0,w.jsx)(Nt,{daily:e}),(0,w.jsx)(`div`,{style:{paddingLeft:38},children:(0,w.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,w.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?u(t.date):``},t.date))})})]}),(0,w.jsxs)(`table`,{className:`sr-only`,"aria-label":l(`Daily usage data`),children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{children:l(`Date`)}),(0,w.jsx)(`th`,{children:l(`Sessions`)}),(0,w.jsx)(`th`,{children:l(`Messages`)}),(0,w.jsx)(`th`,{children:l(`Tokens`)}),(0,w.jsx)(`th`,{children:l(`Cost`)})]})}),(0,w.jsx)(`tbody`,{children:e.map(e=>(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`td`,{children:u(e.date)}),(0,w.jsx)(`td`,{children:m(e.sessions)}),(0,w.jsx)(`td`,{children:m(e.messages)}),(0,w.jsx)(`td`,{children:m($(e))}),(0,w.jsx)(`td`,{children:h(e.cost)})]},e.date))})]})]})}function Lt({project:e,agent:t,onAgentChange:n,window:i,agentCatalog:a,rangePreset:o,onRangeChange:s,onSelectCustom:u,children:d}){c();let[f,p]=(0,S.useState)(void 0),m=n?t:f,{dashboard:h,error:g,retry:_}=C(i,{project:e,agent:m});return(0,w.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,w.jsx)(Ke,{agent:m,onAgentChange:n?void 0:p,agentCatalog:a,scopeCounts:h?.scopeCounts,window:i,rangePreset:o,onRangeChange:s,onSelectCustom:u}),g?(0,w.jsx)(r,{title:l(`Couldn't load the dashboard.`),message:g,onRetry:()=>void _()}):null,h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ze,{totals:h.totals,rangeDays:h.window.days}),d,(0,w.jsx)($e,{models:h.modelDistribution,totalTokens:h.totals.tokens}),(0,w.jsx)(It,{daily:h.dailyActivity}),(0,w.jsx)(it,{activity:h.activeHours}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,w.jsx)(Se,{perAgent:h.perAgent}),(0,w.jsx)(We,{modelCost:h.modelCost,modelDistribution:h.modelDistribution,totals:h.totals})]})]}):g?null:(0,w.jsx)(tt,{}),h?null:d]})}export{Lt as OverviewScreen};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,f as i,l as a,o,t as s}from"./CustomTimeWindowDialog-CGPvUFkc.js";import{n as c,t as l}from"./translate-CLoII3EO.js";import{$ as u,H as d,J as f,K as p,Y as m,at as h,nt as g,ot as _,tt as v}from"./index-DUcpWdzX.js";import{t as y}from"./utils-BuYa9y6l.js";import{n as b,t as x}from"./panel-B-5dVddJ.js";var S=e(t(),1);function C(e,t){let n=e!==null,r=i({...a(e??{},t),enabled:n}),o=r.refetch,s=(0,S.useCallback)(async()=>{await o()},[o]);return{dashboard:n?r.data??null:null,loading:n&&r.isPending,error:n&&r.isError?r.error instanceof Error?r.error.message:l(`Unable to load dashboard.`):null,retry:s}}var w=n();function T({index:e,count:t,position:n=(e+.5)/t*100,children:r}){return(0,w.jsx)(`div`,{role:`tooltip`,className:`console-mono pointer-events-none absolute top-2 z-10 w-max max-w-full rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] break-words text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,style:{left:`${n}%`,transform:`translateX(-${n}%)`},children:r})}var E=Math.PI*2;function D(e){return e<0?0:e>1?1:e}function O(e){let t=D(e);return t*t*(3-2*t)}function k(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function A(e,t,n){return O((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function j(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var M=/^var\((--[\w-]+)\)$/;function N(e,t){let n=M.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function P(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var F=50;function ee(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{e&&t!==null&&!n&&(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},F))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function I(e,t){let[n]=(0,S.useState)(ee);return(0,S.useEffect)(()=>{let r=e.current;if(!r||t){n.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>n.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(r),document.addEventListener(`visibilitychange`,s),o(),()=>{n.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[n,t,e]),n.api}var te=2,L=5,ne=8,re=7,ie=620,ae=.05,oe=.8,se=.0018,ce=.3,le=.48,ue={barRatio:.62,barMax:76,bandGap:4,minBand:6};function de(e,t,n){let r=Math.max(1,t-1),i=Math.min(ae,oe/r),a=1-(t-1)*i;return 1-(1-D((n-e*i)/a))**3}function fe(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:s,reducedMotion:c}){let l=(0,S.useContext)(o),u=I(e,c),d=r.join(`\0`),f=(0,S.useRef)({values:t,axisMax:n,hovered:a,layout:s}),p=(0,S.useRef)(new Map),m=(0,S.useRef)(new Map),h=(0,S.useRef)({startedAt:0,running:!1}),g=(0,S.useRef)({w:0,h:0}),_=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{f.current={values:t,axisMax:n,hovered:a,layout:s},c?_.current():u.requestFrame()},[n,u,a,s,c,t]),(0,S.useEffect)(()=>{m.current=new Map(p.current),c?(h.current.running=!1,_.current()):(h.current={startedAt:performance.now(),running:!0},u.requestFrame())},[n,u,c,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(d?d.split(`\0`):[]).map(e=>N(a,e)),s=N(a,i),l=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(te,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),g.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!h.current.running)return 1;let r=D((n-h.current.startedAt)/ie);return r>=1&&(h.current.running=!1),de(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?ne:L,l?ne:L,u?re:L,u?re:L],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=O(1-(e-t)/i),o=A(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*k(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*se;let{w:t,h:n}=g.current;if(!t||!n)return;let i=f.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){h.current.running=!1;return}let{barRatio:a,barMax:c,bandGap:l,minBand:u}=i.layout,d=i.values.length,_=t/d,x=Math.min(_*a,c),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,d,e),a=r*_+(_-x)/2,c=n;t.forEach((e,n)=>{let d=`${r}:${n}`,f=e>0?Math.max(u,e*C):0,h=m.current.get(d)??0,g=h+(f-h)*i;p.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:le:ce;g>0&&b(a,c-g,x,g,o[n]??o[0]??s,s,v,_,n===t.length-1,n===0,S),c-=g+l})})};_.current=()=>{l(),x(performance.now())},u.setFrameHandler(e=>(x(e),h.current.running?`active`:f.current.hovered===null?`stop`:`idle`)),l();let S=new ResizeObserver(()=>{l(),c?x(performance.now()):u.requestFrame()});return S.observe(n),c&&x(performance.now()),()=>{u.setFrameHandler(null),S.disconnect()}},[e,d,u,i,c,l]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=g.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=f.current,d=l.length,m=i/d,h=Math.floor(s/m);if(h<0||h>=d)return null;let _=Math.min(m*u.barRatio,u.barMax),v=h*m+(m-_)/2;if(s<v||s>v+_)return{column:h,band:null};let y=a;for(let e=0;e<l[h].length;e++){let t=p.current.get(`${h}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:h,band:e};y-=t+u.bandGap}return{column:h,band:null}}}}var pe=`(prefers-reduced-motion: reduce)`;function R(){let[e,t]=(0,S.useState)(()=>globalThis.matchMedia?.(pe).matches??!1);return(0,S.useEffect)(()=>{let e=globalThis.matchMedia?.(pe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function me(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function he({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,S.useRef)([]),[o,s]=(0,S.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=me(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:y(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,w.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:y(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,w.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var ge=[1,.75,.5,.25,0];function _e(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function ve({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:d}){let f=(0,S.useRef)(null),p=(0,S.useRef)(i),m=R(),{hitTest:h}=fe(f,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...ue,...o},reducedMotion:m});(0,S.useEffect)(()=>{p.current=i},[i]);let g=e=>{_e(p.current,e)||(p.current=e,a(e))};return(0,w.jsxs)(`div`,{className:y(`flex`,d),children:[c?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:ge.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>g(h(e.clientX,e.clientY)),onPointerLeave:()=>g(null),children:[ge.map(e=>(0,w.jsx)(`span`,{"aria-hidden":!0,className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,w.jsx)(`canvas`,{ref:f,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,w.jsx)(he,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>g(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var z=6,ye=118,be={barRatio:.52,barMax:34,bandGap:0,minBand:4},xe=[`var(--brand)`];function Se({perAgent:e}){let t=c(),[n,r]=(0,S.useState)(null),{byCost:i,visible:a,values:o,axisMax:s,itemLabels:u}=(0,S.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,z),i=r.map(e=>[n(e)]),a=r.map(e=>t?l(`{0}: {1}, {2} sessions`,[e.displayName,h(e.cost),m(e.sessions)]):l(`{0}: {1} sessions`,[e.displayName,m(e.sessions)]));return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:a}},[t,e]),f=n===null?void 0:a[n.column];return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Agents`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Agents`),meta:l(`{0} · {1} total`,[l(i?`by cost`:`by sessions`),e.length])}),a.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No data`)}):(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:o,axisMax:s,colors:xe,hovered:n,onHover:r,layout:be,height:ye,ariaLabel:l(`Agent distribution chart`),itemLabels:u}),f&&n?(0,w.jsxs)(T,{index:n.column,count:a.length,children:[(0,w.jsx)(`div`,{children:f.displayName}),(0,w.jsxs)(`div`,{children:[p(f.tokens),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:h(f.cost)})]}),(0,w.jsxs)(`div`,{children:[m(f.sessions),` `,l(`sessions ·`),` `,m(f.messages),` `,l(`messages`)]})]}):null,(0,w.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${a.length}, minmax(0, 1fr))`},children:a.map((e,t)=>(0,w.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,w.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,w.jsx)(d,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,w.jsx)(`span`,{className:y(`console-mono max-w-full truncate text-[9.5px]`,n?.column===t?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:i?h(e.cost):m(e.sessions)}),i?(0,w.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:m(e.sessions)}):null]},e.name))})]}),e.length>z?(0,w.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-z,` `,l(`more`)]}):null]})}function Ce(e){let t=2166136261;for(let n of e)t=Math.imul(t^n.charCodeAt(0),16777619);return`oklch(0.65 0.16 ${(t>>>0)%360})`}function we(e,t){let n=e.filter(e=>e.tokens>0).toSorted((e,t)=>t.tokens-e.tokens),r=n.slice(0,5).map(e=>({key:e.model,label:e.model,value:e.tokens,color:Ce(e.model),display:p(e.tokens)})),i=n.slice(5).reduce((e,t)=>e+t.tokens,0);i>0&&r.push({key:`__other`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:p(i)});let a=t-n.reduce((e,t)=>e+t.tokens,0);return a>0&&r.push({key:`__unknown`,label:l(`Unknown model`),value:a,color:`var(--console-muted)`,display:p(a)}),r}var B=200,V=100,H=100,U=86,W=55,Te=-Math.PI/2,Ee=.07,De=6,G=4.6,Oe=2,ke=.0018,Ae=500,je=6,Me=.72,Ne=.3,Pe=(()=>{let e=[];for(let t=14;t<=186;t+=G)for(let n=14;n<=186;n+=G){let r=t-V,i=n-H,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*O((a-W)/31),jitter:k(t,n)})}return e})();function Fe(e,{a0:t,a1:n}){let r=n-t,i=Math.min(De,31*.45,W*r*.45),a=i/U,o=i/W,s=(e,t)=>[V+Math.cos(t)*e,H+Math.sin(t)*e],[c,l]=s(U,t+a);e.beginPath(),e.moveTo(c,l),e.arc(V,H,U,t+a,n-a),e.arcTo(...s(U,n),...s(W,n),i),e.arcTo(...s(W,n),...s(W,n-o),i),e.arc(V,H,W,n-o,t+o,!0),e.arcTo(...s(W,t),...s(U,t),i),e.arcTo(...s(U,t),c,l,i),e.closePath()}function Ie(e){let t=Te;return e.map(e=>{let n=e*E,r={a0:t+Ee/2,a1:t+n-Ee/2};return t+=n,r})}function Le(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,S.useContext)(o),s=I(e,i),c=n.join(`\0`),l=(0,S.useRef)(r),u=(0,S.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),d=(0,S.useRef)(Ie(t)),f=(0,S.useRef)(()=>{});return(0,S.useEffect)(()=>{let e=u.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,f.current()):(e.startedAt=performance.now(),e.running=!0,s.requestFrame())},[s,i,t]),(0,S.useEffect)(()=>{l.current=r,i?f.current():s.requestFrame()},[s,r,i]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(c?c.split(`\0`):[]).map(e=>N(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(Oe,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/B*r},h=0,g=e=>{let t=u.current;if(!t.running)return;let n=D((e-t.startedAt)/Ae),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*je,Math.sin(n)*je),r.shadowColor=P(e,.55),r.shadowBlur=5}Fe(r,t),r.clip(),r.globalAlpha=i?n?1:Ne*Me:Me,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of Pe){let t=e.angle;for(;t<o;)t+=E;for(;t>=o+E;)t-=E;if(t>s)continue;let n=A(e.x,e.y,h),i=G*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*ke,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,B,B);let t=Ie(u.current.displayed);d.current=t;let n=l.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(o[t]??o[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(o[n]??``,a,!0,!0)};f.current=()=>{m(),v(performance.now())},s.setFrameHandler(e=>(g(e),v(e),u.current.running?`active`:l.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):s.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{s.setFrameHandler(null),y.disconnect()}},[e,c,s,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*B-V,o=(n-i.top)/i.height*B-H,s=Math.hypot(a,o);if(s<W||s>U)return null;let c=Math.atan2(o,a);for(let e=0;e<d.current.length;e++){let{a0:t,a1:n}=d.current[e],r=c;for(;r<t;)r+=E;for(;r>=t+E;)r-=E;if(r<=n)return e}return null}}}function Re({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,S.useRef)(null),{hitTest:l}=Le(c,{shares:e,colors:t,hovered:n,reducedMotion:R()});return(0,w.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,w.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,w.jsx)(he,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var ze=5,Be=142,Ve=.01;function He(e){return e!==null&&e.some(e=>e.cost>0)}function Ue(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,ze),r=n.map(e=>({key:e.model,label:e.model,value:e.cost,color:Ce(e.model),display:_(e.cost)})),i=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&i>t*Ve&&r.push({key:`__remainder`,label:l(`Other`),value:i,color:`var(--console-border-strong)`,display:_(i)}),r}function We({modelCost:e,modelDistribution:t,totals:n}){let r=c(),[i,a]=(0,S.useState)(null),{byCost:o,entries:s}=(0,S.useMemo)(()=>{let r=He(e);return{byCost:r,entries:r?Ue(e,n.cost):we(t,n.tokens)}},[r,e,t,n.cost,n.tokens]),u=s.reduce((e,t)=>e+t.value,0),d=(0,S.useMemo)(()=>s.map(e=>u>0?e.value/u:1/s.length),[s,u]),f=l(o?`Cost by Model`:`Models`),m=s.map(e=>`${e.label}: ${v(u>0?e.value/u:0)}, ${e.display}`);return(0,w.jsxs)(x,{role:`region`,"aria-label":f,className:`p-4`,children:[(0,w.jsx)(b,{title:f,meta:l(o?`by cost`:`by tokens`)}),s.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No model data`)}):(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,w.jsxs)(Re,{shares:d,colors:s.map(e=>e.color),hovered:i,onHover:a,size:Be,ariaLabel:l(`{0} chart`,[f]),itemLabels:m,children:[(0,w.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:o?_(n.cost):p(n.tokens)}),(0,w.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l(o?`total cost`:`total tokens`)})]}),(0,w.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:s.map((e,t)=>(0,w.jsxs)(`li`,{className:y(`flex min-w-0 items-center gap-2 transition-opacity`,i!==null&&i!==t?`opacity-45`:null),onPointerEnter:()=>a(t),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,w.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,w.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:v(u>0?e.value/u:0)}),(0,w.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,w.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:o?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:l(`Estimated`)}),h(n.costEstimated),` `,l(`from model unit price,`),` `,h(n.costRecorded),` `,l(`from agent records`)]}):l(`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`)})]})}var Ge=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function Ke({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:u}){c();let[d,f]=(0,S.useState)(!1);return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,w.jsxs)(`select`,{"aria-label":l(`Filter by agent`),value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,w.jsx)(`option`,{value:K,children:l(`All agents`)}),n.active.map(e=>(0,w.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,w.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:l(`{0} projects · {1} agents in scope`,[r.projects,r.agents])}):null,(0,w.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ge.map(e=>{let t=e.value===a;return(0,w.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?f(!0):o(e.value)},className:y(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:l(e.label)},e.value)})})]}),(0,w.jsx)(s,{open:d,onOpenChange:f,window:i,onSelectCustom:u})]})}function qe(e){return e.toFixed(1)}var Je={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return c(),(0,w.jsxs)(x,{className:y(`min-w-0 px-4 py-[14px] last:col-span-2 md:last:col-span-1`,a?`border-[var(--brand-line)]`:null),children:[(0,w.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,w.jsx)(`p`,{className:y(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,w.jsxs)(`div`,{className:`mt-[7px] flex items-start gap-[7px]`,children:[n===void 0?null:(0,w.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:y(`console-mono shrink-0 text-xs`,Je[r]),children:n}),i===void 0?null:(0,w.jsx)(`span`,{className:`console-mono min-w-0 flex-1 break-words text-xs text-[var(--console-muted)]`,children:i})]})]})}function Ye(e){return e.costEstimated===0?l(`All recorded by agents`):e.costEstimated===e.cost&&e.cost>0?l(`All estimated from unit price`):l(`{0} estimated`,[h(e.costEstimated)])}function Xe(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function Ze({totals:e,rangeDays:t}){c();let n=e.previous,r=(e,t)=>t===void 0?null:f(e,t),i=r(e.sessions,n?.sessions),a=r(e.messages,n?.messages),o=r(e.tokens,n?.tokens),s=r(e.cost,n?.cost),u=n?.cost!==void 0&&e.cost>n.cost;return(0,w.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,w.jsx)(q,{label:l(`Sessions`),value:m(e.sessions),trend:i??void 0,hint:t?l(`{0}/day`,[qe(e.sessions/t)]):void 0}),(0,w.jsx)(q,{label:l(`Messages`),value:m(e.messages),trend:a??void 0,hint:e.sessions>0?l(`{0}/session`,[qe(e.messages/e.sessions)]):void 0}),(0,w.jsx)(q,{label:l(`Tokens`),value:p(e.tokens),trend:o??void 0,hint:l(`Cache hit {0}`,[v(e.cacheReadTokens/e.tokens)])}),(0,w.jsx)(q,{label:l(`Cost`),value:h(e.cost),trend:s??void 0,trendTone:u?`warning`:`positive`,hint:Ye(e),emphasis:!0}),(0,w.jsx)(q,{label:l(`Last activity`),value:e.latestActivity===void 0?l(`No activity`):g(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Xe(e)})]})}var J=32,Y=4;function Qe({shares:e,colors:t,hovered:n,onHover:r,ariaLabel:i,itemLabels:a}){let s=(0,S.useRef)(null),c=R(),l=(0,S.useContext)(o),u=I(s,c),d=(0,S.useRef)(n),f=(0,S.useRef)(()=>{}),p=e.join(`,`),m=t.join(`\0`);return(0,S.useEffect)(()=>{d.current=n,c?f.current():u.requestFrame()},[u,n,c]),(0,S.useEffect)(()=>{let e=s.current,t=e?.parentElement,n=e?.getContext(`2d`);if(!e||!t||!n)return;let r=getComputedStyle(e),i=m.split(`\0`).map(e=>N(r,e)),a=p.split(`,`).map(Number),o=0,l=()=>{o=t.clientWidth;let r=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(o*r),e.height=J*r,n.setTransform(r,0,0,r,0,0)},h=e=>{n.clearRect(0,0,o,J);let t=0;a.forEach((r,a)=>{let s=r*o,c=Math.min(1,s/6),l=t+c,u=s-c*2;if(t+=s,u<=0)return;let f=d.current===a;n.save(),n.beginPath(),n.roundRect(l,0,u,J,Math.min(4,u/2)),n.clip(),n.fillStyle=i[a]??``,n.globalAlpha=d.current===null?.72:f?1:.3,n.beginPath();for(let t=l+Math.min(Y,u)/2;t<l+u;t+=Y)for(let r=Y/2;r<J;r+=Y){let i=O(1-r/J),a=A(t,r,e*.0018),o=Y*((f?.46:.34)+.36*i+.26*a)*(.78+.42*k(t,r));n.rect(t-o/2,r-o/2,o,o)}n.fill(),n.restore()})};f.current=()=>h(performance.now());let g=()=>{l(),c?f.current():u.requestFrame()};u.setFrameHandler(e=>(h(e),d.current===null?`stop`:`idle`));let _=new ResizeObserver(g);return _.observe(t),g(),()=>{_.disconnect(),u.setFrameHandler(null)}},[m,u,c,p,l]),(0,w.jsxs)(`div`,{className:`chart-hatch relative rounded-sm`,style:{height:J},onPointerMove:t=>{let n=t.currentTarget.getBoundingClientRect(),i=(t.clientX-n.left)/n.width,a=0,o=e.findIndex(e=>(a+=e,i<a));r(o<0?null:o)},onPointerLeave:e=>{e.pointerType!==`touch`&&r(null)},children:[(0,w.jsx)(`canvas`,{ref:s,"aria-hidden":!0,className:`block size-full`}),(0,w.jsx)(he,{label:i,itemLabels:a,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}function $e({models:e,totalTokens:t}){let n=c(),[r,i]=(0,S.useState)(null),a=(0,S.useMemo)(()=>we(e,t),[n,e,t]),o=a.map(e=>e.value/t),s=o.map(e=>e>0&&e<.001?`<0.1%`:e.toLocaleString(n,{style:`percent`,maximumFractionDigits:1})),u=a.map((e,t)=>`${e.label}: ${m(e.value)} ${l(`tokens`)}, ${s[t]}`),d=a.findIndex(e=>e.key===r),f=a[d],h=(o.slice(0,d).reduce((e,t)=>e+t,0)+(o[d]??0)/2)*100;return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Tokens by Model`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Tokens by Model`),meta:`${p(t)} ${l(`total tokens`)}`}),(0,w.jsx)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:l(`Token share in the selected range, including cache tokens.`)}),t<=0?(0,w.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`relative mt-3`,children:[(0,w.jsx)(Qe,{shares:o,colors:a.map(e=>e.color),hovered:d<0?null:d,onHover:e=>i(e===null?null:a[e]?.key??null),ariaLabel:l(`Model token distribution chart`),itemLabels:u}),f?(0,w.jsxs)(T,{index:d,count:a.length,position:h,children:[(0,w.jsx)(`div`,{className:`font-semibold`,children:f.label}),(0,w.jsxs)(`div`,{children:[m(f.value),` `,l(`tokens`),` · `,s[d]]})]}):null]}),(0,w.jsx)(`ul`,{className:`mt-3 flex flex-wrap gap-x-5 gap-y-2`,children:a.map((e,t)=>(0,w.jsx)(`li`,{className:`min-w-0 max-w-full`,children:(0,w.jsxs)(`button`,{type:`button`,"aria-label":u[t],className:y(`console-mono flex max-w-full items-center gap-1.5 rounded-sm text-[10.5px] text-[var(--console-text)] focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-[var(--brand)]`,f&&f.key!==e.key?`opacity-45`:null),onPointerEnter:()=>i(e.key),onPointerLeave:()=>i(null),onFocus:()=>i(e.key),onBlur:()=>i(null),onClick:()=>i(e.key),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:[(0,w.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color}}),(0,w.jsx)(`span`,{className:`truncate`,children:e.label}),(0,w.jsxs)(`span`,{className:`shrink-0 text-[var(--console-muted)]`,children:[e.display,` · `,s[t]]})]})},e.key))})]})]})}var et=[0,1,2,3,4];function X({className:e}){return c(),(0,w.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Z({bodyClassName:e}){return c(),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-3 ${e}`})]})}function tt(){return c(),(0,w.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:et.map(e=>(0,w.jsxs)(x,{className:`px-4 py-[14px]`,children:[(0,w.jsx)(X,{className:`h-[10px] w-16`}),(0,w.jsx)(X,{className:`mt-[9px] h-[27px] w-24`}),(0,w.jsx)(X,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,w.jsx)(Z,{bodyClassName:`h-[68px] w-full`}),(0,w.jsxs)(x,{className:`p-4`,children:[(0,w.jsx)(X,{className:`h-[15px] w-28`}),(0,w.jsx)(X,{className:`mt-[14px] h-[168px] w-full`})]}),(0,w.jsx)(Z,{bodyClassName:`h-[428px] w-full`}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[248px] w-full`}),(0,w.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,w.jsx)(Z,{bodyClassName:`h-[116px] w-full`}),(0,w.jsx)(Z,{bodyClassName:`h-[100px] w-full`})]})]})]})}function nt(e){return`${String(e*2).padStart(2,`0`)}:00–${String(e*2+2).padStart(2,`0`)}:00`}function rt({count:e,peak:t}){let n=(0,S.useId)(),r=t>0?Math.sqrt(e/t):0,i=12*r;return(0,w.jsx)(`svg`,{width:`28`,height:`28`,viewBox:`0 0 28 28`,"aria-hidden":`true`,style:{color:`color-mix(in oklab, var(--activity-high) ${r*100}%, var(--activity-low))`},children:e>0?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`defs`,{children:(0,w.jsx)(`pattern`,{id:n,width:`3`,height:`3`,patternUnits:`userSpaceOnUse`,children:(0,w.jsx)(`rect`,{width:`2`,height:`2`,fill:`currentColor`})})}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`currentColor`,opacity:`0.2`}),(0,w.jsx)(`circle`,{cx:`14`,cy:`14`,r:i,fill:`url(#${n})`})]}):null})}function it({activity:e}){let t=c(),n=[l(`Overnight`),l(`Morning`),l(`Afternoon`),l(`Evening`)],[r,i]=(0,S.useState)(null),a=t===`zh-CN`?[1,2,3,4,5,6,0]:[0,1,2,3,4,5,6],o=new Intl.DateTimeFormat(t,{weekday:`short`,timeZone:`UTC`}),s=a.map(e=>o.format(Date.UTC(2026,8,6+e))),u=Math.max(0,...e?.counts??[]),d=e?.counts.reduce((e,t)=>e+t,0)??0;return(0,w.jsxs)(x,{className:`p-4`,"aria-label":l(`Active hours`),children:[(0,w.jsx)(b,{title:l(`Active hours`)}),(0,w.jsx)(`p`,{className:`mt-1 text-xs text-[var(--console-muted)]`,children:l(`User messages by weekday and two-hour period. Counts are cumulative within the selected range.`)}),e?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-2 console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`span`,{children:l(`Time zone: {0}`,[e.timeZone])}),(0,w.jsx)(`span`,{children:l(`{0} user messages`,[m(d)])})]}),(0,w.jsxs)(`table`,{className:`mt-[14px] w-full table-fixed border-collapse console-mono text-[10.5px] text-[var(--console-muted)]`,children:[(0,w.jsx)(`caption`,{className:`sr-only`,children:l(`Active hours`)}),(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{scope:`col`,className:t===`en`?`w-16`:`w-9`,children:(0,w.jsx)(`span`,{className:`sr-only`,children:l(`Day period`)})}),(0,w.jsx)(`th`,{scope:`col`,className:`w-11 pb-2 text-left font-normal`,children:l(`Time`)}),s.map(e=>(0,w.jsx)(`th`,{scope:`col`,className:`pb-2 font-normal`,children:e},e))]})}),n.map((t,n)=>(0,w.jsx)(`tbody`,{className:`chart-hatch`,children:Array.from({length:3},(o,c)=>{let d=n*3+c;return(0,w.jsxs)(`tr`,{className:c===0&&n>0?`border-t border-solid border-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`,children:[c===0?(0,w.jsx)(`th`,{scope:`rowgroup`,rowSpan:3,className:`bg-[var(--console-surface)] pr-2 text-left align-middle font-normal`,children:t}):null,(0,w.jsx)(`th`,{scope:`row`,className:`h-8 bg-[var(--console-surface)] text-left font-normal tabular-nums`,children:`${String(d*2).padStart(2,`0`)}:00`}),a.map((t,n)=>{let a=t*12+d,o=e.counts[a]??0,c=`${s[n]} · ${nt(d)} · ${l(`{0} user messages`,[m(o)])}`;return(0,w.jsxs)(`td`,{className:`relative p-0 text-center`,children:[(0,w.jsx)(`button`,{type:`button`,"aria-label":c,className:`flex h-8 w-full items-center justify-center rounded-sm outline-none hover:bg-[var(--brand-soft)] focus-visible:ring-2 focus-visible:ring-[var(--brand)]`,onMouseEnter:()=>i(a),onMouseLeave:()=>i(null),onFocus:()=>i(a),onBlur:()=>i(null),onClick:()=>i(a),onKeyDown:e=>{e.key===`Escape`&&i(null)},children:(0,w.jsx)(rt,{count:o,peak:u})}),r===a?(0,w.jsxs)(`span`,{role:`tooltip`,className:`pointer-events-none absolute bottom-full z-10 w-max max-w-[180px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-left text-[var(--console-text)] shadow-[var(--shadow-overlay)] ${n<3?`left-0`:`right-0`}`,children:[`${s[n]} · ${nt(d)} · `,(0,w.jsx)(`span`,{className:`font-semibold text-[var(--brand)]`,children:l(`{0} user messages`,[m(o)])})]}):null]},t)})]},d)})},t))]}),(0,w.jsx)(`div`,{className:`mt-3 flex min-h-7 flex-wrap items-center justify-end gap-4 console-mono text-[10.5px] text-[var(--console-muted)]`,children:u===0?(0,w.jsx)(`span`,{children:l(`No user messages in this range.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-1.5`,"aria-label":l(`Size reference (messages)`),children:[l(`Less`),[1,4,9].map(e=>(0,w.jsx)(rt,{count:e,peak:9},e)),l(`More`)]}),(0,w.jsx)(`span`,{children:l(`Peak: {0}`,[m(u)])})]})})]}):(0,w.jsx)(`p`,{className:`py-8 text-center text-sm text-[var(--console-muted)]`,children:l(`Activity data is unavailable.`)})]})}var at=.16;function ot(e){return e*e*(3-2*e)}function st(e,t,n){return e<t?t:e>n?n:e}function Q(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=st(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=ot(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function ct(e,t){let n=st(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function lt(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var ut=2,dt=460,ft=180,pt=32,mt=.06,ht=.24,gt=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function _t(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function vt(e,t){let n=gt.exec(e),r=gt.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/pt,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function yt(e,{values:t,max:n,reducedMotion:r}){let i=(0,S.useContext)(o),a=I(e,r),s=(0,S.useRef)({from:Q(t),to:Q(t),current:Q(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),c=(0,S.useRef)(null),l=(0,S.useRef)(()=>{}),u=(0,S.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,S.useEffect)(()=>{let e=s.current;e.from.set(e.current),e.fromMax=e.currentMax,Q(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:dt,r?l.current():a.requestFrame()},[a,n,r,t]),(0,S.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let o=u.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=vt(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(ut,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let s=Math.max(3,Math.round(e/ft)),l=Math.ceil(e/s),u=Math.ceil(r/s),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(_t(e)<mt);c.current={cell:s,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=s.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=u.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=c.current;if(!n)return!1;let a=s.current,{cell:o,cols:l,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(o*.34)),x=y((o-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<l;e++){let t=e*o+x;for(let e=0;e<d;e++)i.fillRect(t,e*o+x,b,b)}let S=u.current,C=h*(ht+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,D=e*.0018,O=-1,k=!1;for(let t=0;t<l;t++){let n=l>1?(t+.5)/l:.5,s=lt(ct(a.current,n),a.currentMax),c=Math.max(.001,1-s),u=t*o,m=u+o/2;for(let n=0;n<d;n++){let a=t*d+n,l=n*o,b=(l+o/2)/h,x=0;b>=s&&(x=1-.55*((b-s)/c));let A=_[a];if(w){let e=Math.hypot(m-S.smoothX,l+o/2-S.smoothY),t=e<C?1-e/C:0;A+=(t-A)*(t>A?T:E),_[a]=A}else A>0&&(A*=1-E,_[a]=A<.002?0:A);_[a]>0&&(k=!0);let j=Math.min(1,x+A*.5);if(j<=.02)continue;let M=j;r||(M*=1+.07*Math.sin(b*Math.PI*3-D),v[a]&&A>.02&&(M*=1+.25*A*Math.sin(e*.012+a)),M=Math.min(1,M));let N=Math.max(g,y(o*(.28+.42*j))),P=y((o-N)/2),F=Math.round(M*pt);F!==O&&(O=F,i.fillStyle=p[O]??p[pt]??f),i.fillRect(u+P,l+P,N,N)}}return k},v=()=>{m(),h(performance.now()),_(performance.now())};l.current=v;let y=e=>{let t=c.current;if(!t)return;let r=u.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{u.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:u.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),o.inside=!1}},[e,a,r,i])}var bt=[1,.66,.33,0],xt=e=>`${(1-e*(1-at))*100}%`,St=(e,t)=>(e+.5)/t*100;function Ct({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,S.useState)(null),o=(0,S.useRef)(null),s=R(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,d=e[u]??0,f=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,w.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,transition:f}}),(0,w.jsxs)(`div`,{className:y(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${St(u,e.length)}%`,top:`${lt(d,t)*100}%`,transition:f},children:[(0,w.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,w.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,w.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,w.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(d)})]})]})]})}function wt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,S.useRef)(null);return yt(s,{values:e,max:t,reducedMotion:R()}),(0,w.jsxs)(`div`,{className:y(`flex`,o),"aria-hidden":!0,children:[a?(0,w.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:bt.map(e=>(0,w.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:xt(e)},children:a(t*e)},e))}):null,(0,w.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[bt.map(e=>(0,w.jsx)(`span`,{className:y(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:xt(e)}},e)),(0,w.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,w.jsx)(Ct,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var Tt=168,Et=132,Dt=6,Ot={barRatio:.86,barMax:46,bandGap:2,minBand:3},kt=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],At=kt.map(e=>e.color);function jt(e){return e===0?`$0`:e>=1e3?`$${p(e)}`:e>=1?`$${Number(e.toFixed(2))}`:`$${Number(e.toPrecision(2))}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function Mt(e){return l(`{0}: {1} tokens, {2}, {3} sessions, {4} messages, input {5}, output {6}, cache read {7}, cache write {8}`,[u(e.date),p($(e)),h(e.cost),m(e.sessions),m(e.messages),p(e.input),p(e.output),p(e.cache_read),p(e.cache_create)])}function Nt({daily:e}){c();let t=(0,S.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,S.useMemo)(()=>e.map(e=>u(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,w.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:l(`Daily cost`)}),(0,w.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[l(`Peak`),` `,h(i),` `,l(`· Avg`),` `,h(r/e.length),` `,l(`· Total`),` `,h(r)]})]}),(0,w.jsx)(wt,{values:t,max:i,labels:n,height:Et,formatValue:h,formatTick:jt,className:`mt-[7px]`})]})}function Pt({bucket:e,index:t,count:n}){return c(),(0,w.jsxs)(T,{index:t,count:n,children:[(0,w.jsx)(`div`,{children:u(e.date)}),(0,w.jsxs)(`div`,{children:[p($(e)),` `,l(`tok ·`),` `,(0,w.jsx)(`span`,{className:`text-[var(--brand)]`,children:h(e.cost)})]}),(0,w.jsxs)(`div`,{children:[m(e.sessions),` `,l(`sessions ·`),` `,m(e.messages),` `,l(`messages`)]}),(0,w.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[l(`In`),` `,p(e.input),` `,l(`· Out`),` `,p(e.output),` `,l(`· Read`),` `,p(e.cache_read),` `,l(`· Write`),` `,p(e.cache_create)]})]})}function Ft({daily:e}){let t=c(),[n,r]=(0,S.useState)(null),i=(0,S.useMemo)(()=>e.map(e=>kt.map(t=>e[t.key])),[e]),a=(0,S.useMemo)(()=>e.map(Mt),[t,e]),o=(0,S.useMemo)(()=>j(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),s=n===null?void 0:e[n.column];return(0,w.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,w.jsx)(ve,{values:i,axisMax:o,colors:At,hovered:n,onHover:r,layout:Ot,height:Tt,formatTick:p,ariaLabel:l(`Daily usage chart`),itemLabels:a}),s&&n?(0,w.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,w.jsx)(Pt,{bucket:s,index:n.column,count:e.length})}):null]})}function It({daily:e}){c();let t=e[0],n=e[e.length-1],r=t&&n?` · ${u(t.date)} → ${u(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/Dt));return(0,w.jsxs)(x,{role:`region`,"aria-label":l(`Daily usage`),className:`p-4`,children:[(0,w.jsx)(b,{title:l(`Daily usage`),action:(0,w.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:kt.map(e=>(0,w.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,w.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),l(e.label)]},e.key))})}),(0,w.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[l(`Stacked bars = token mix · Area below = daily cost`),r]}),e.length===0?(0,w.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:l(`No usage data`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ft,{daily:e}),(0,w.jsx)(Nt,{daily:e}),(0,w.jsx)(`div`,{style:{paddingLeft:38},children:(0,w.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,w.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?u(t.date):``},t.date))})})]}),(0,w.jsxs)(`table`,{className:`sr-only`,"aria-label":l(`Daily usage data`),children:[(0,w.jsx)(`thead`,{children:(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`th`,{children:l(`Date`)}),(0,w.jsx)(`th`,{children:l(`Sessions`)}),(0,w.jsx)(`th`,{children:l(`Messages`)}),(0,w.jsx)(`th`,{children:l(`Tokens`)}),(0,w.jsx)(`th`,{children:l(`Cost`)})]})}),(0,w.jsx)(`tbody`,{children:e.map(e=>(0,w.jsxs)(`tr`,{children:[(0,w.jsx)(`td`,{children:u(e.date)}),(0,w.jsx)(`td`,{children:m(e.sessions)}),(0,w.jsx)(`td`,{children:m(e.messages)}),(0,w.jsx)(`td`,{children:m($(e))}),(0,w.jsx)(`td`,{children:h(e.cost)})]},e.date))})]})]})}function Lt({project:e,agent:t,onAgentChange:n,window:i,agentCatalog:a,rangePreset:o,onRangeChange:s,onSelectCustom:u,children:d}){c();let[f,p]=(0,S.useState)(void 0),m=n?t:f,{dashboard:h,error:g,retry:_}=C(i,{project:e,agent:m});return(0,w.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,w.jsx)(Ke,{agent:m,onAgentChange:n?void 0:p,agentCatalog:a,scopeCounts:h?.scopeCounts,window:i,rangePreset:o,onRangeChange:s,onSelectCustom:u}),g?(0,w.jsx)(r,{title:l(`Couldn't load the dashboard.`),message:g,onRetry:()=>void _()}):null,h?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Ze,{totals:h.totals,rangeDays:h.window.days}),d,(0,w.jsx)($e,{models:h.modelDistribution,totalTokens:h.totals.tokens}),(0,w.jsx)(It,{daily:h.dailyActivity}),(0,w.jsx)(it,{activity:h.activeHours}),(0,w.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,w.jsx)(Se,{perAgent:h.perAgent}),(0,w.jsx)(We,{modelCost:h.modelCost,modelDistribution:h.modelDistribution,totals:h.totals})]})]}):g?null:(0,w.jsx)(tt,{}),h?null:d]})}export{Lt as OverviewScreen};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./SessionDetail-J00I4QfE.js";function d(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 f(e,t){if(e==null)return{};var n,r,i=d(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 p(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e){if(Array.isArray(e))return p(e)}function h(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function g(e,t){if(e){if(typeof e==`string`)return p(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function _(){throw TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,c as i,i as a,n as o,o as s,r as c,s as l,t as u}from"./SessionDetail-wJYzzF0i.js";function d(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 f(e,t){if(e==null)return{};var n,r,i=d(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 p(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e){if(Array.isArray(e))return p(e)}function h(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function g(e,t){if(e){if(typeof e==`string`)return p(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function _(){throw TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function v(e){return m(e)||h(e)||g(e)||_()}function y(e){"@babel/helpers - typeof";return y=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},y(e)}function b(e,t){if(y(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(y(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return y(t)==`symbol`?t:t+``}function S(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C=e(t());function w(){return w=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},w.apply(null,arguments)}function T(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 E(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?T(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):T(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function D(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],`${e[0]}.${e[1]}`,`${e[1]}.${e[0]}`];if(t===3)return[e[0],e[1],e[2],`${e[0]}.${e[1]}`,`${e[0]}.${e[2]}`,`${e[1]}.${e[0]}`,`${e[1]}.${e[2]}`,`${e[2]}.${e[0]}`,`${e[2]}.${e[1]}`,`${e[0]}.${e[1]}.${e[2]}`,`${e[0]}.${e[2]}.${e[1]}`,`${e[1]}.${e[0]}.${e[2]}`,`${e[1]}.${e[2]}.${e[0]}`,`${e[2]}.${e[0]}.${e[1]}`,`${e[2]}.${e[1]}.${e[0]}`];if(t>=4)return[e[0],e[1],e[2],e[3],`${e[0]}.${e[1]}`,`${e[0]}.${e[2]}`,`${e[0]}.${e[3]}`,`${e[1]}.${e[0]}`,`${e[1]}.${e[2]}`,`${e[1]}.${e[3]}`,`${e[2]}.${e[0]}`,`${e[2]}.${e[1]}`,`${e[2]}.${e[3]}`,`${e[3]}.${e[0]}`,`${e[3]}.${e[1]}`,`${e[3]}.${e[2]}`,`${e[0]}.${e[1]}.${e[2]}`,`${e[0]}.${e[1]}.${e[3]}`,`${e[0]}.${e[2]}.${e[1]}`,`${e[0]}.${e[2]}.${e[3]}`,`${e[0]}.${e[3]}.${e[1]}`,`${e[0]}.${e[3]}.${e[2]}`,`${e[1]}.${e[0]}.${e[2]}`,`${e[1]}.${e[0]}.${e[3]}`,`${e[1]}.${e[2]}.${e[0]}`,`${e[1]}.${e[2]}.${e[3]}`,`${e[1]}.${e[3]}.${e[0]}`,`${e[1]}.${e[3]}.${e[2]}`,`${e[2]}.${e[0]}.${e[1]}`,`${e[2]}.${e[0]}.${e[3]}`,`${e[2]}.${e[1]}.${e[0]}`,`${e[2]}.${e[1]}.${e[3]}`,`${e[2]}.${e[3]}.${e[0]}`,`${e[2]}.${e[3]}.${e[1]}`,`${e[3]}.${e[0]}.${e[1]}`,`${e[3]}.${e[0]}.${e[2]}`,`${e[3]}.${e[1]}.${e[0]}`,`${e[3]}.${e[1]}.${e[2]}`,`${e[3]}.${e[2]}.${e[0]}`,`${e[3]}.${e[2]}.${e[1]}`,`${e[0]}.${e[1]}.${e[2]}.${e[3]}`,`${e[0]}.${e[1]}.${e[3]}.${e[2]}`,`${e[0]}.${e[2]}.${e[1]}.${e[3]}`,`${e[0]}.${e[2]}.${e[3]}.${e[1]}`,`${e[0]}.${e[3]}.${e[1]}.${e[2]}`,`${e[0]}.${e[3]}.${e[2]}.${e[1]}`,`${e[1]}.${e[0]}.${e[2]}.${e[3]}`,`${e[1]}.${e[0]}.${e[3]}.${e[2]}`,`${e[1]}.${e[2]}.${e[0]}.${e[3]}`,`${e[1]}.${e[2]}.${e[3]}.${e[0]}`,`${e[1]}.${e[3]}.${e[0]}.${e[2]}`,`${e[1]}.${e[3]}.${e[2]}.${e[0]}`,`${e[2]}.${e[0]}.${e[1]}.${e[3]}`,`${e[2]}.${e[0]}.${e[3]}.${e[1]}`,`${e[2]}.${e[1]}.${e[0]}.${e[3]}`,`${e[2]}.${e[1]}.${e[3]}.${e[0]}`,`${e[2]}.${e[3]}.${e[0]}.${e[1]}`,`${e[2]}.${e[3]}.${e[1]}.${e[0]}`,`${e[3]}.${e[0]}.${e[1]}.${e[2]}`,`${e[3]}.${e[0]}.${e[2]}.${e[1]}`,`${e[3]}.${e[1]}.${e[0]}.${e[2]}`,`${e[3]}.${e[1]}.${e[2]}.${e[0]}`,`${e[3]}.${e[2]}.${e[0]}.${e[1]}`,`${e[3]}.${e[2]}.${e[1]}.${e[0]}`]}var O={};function k(e){if(e.length===0||e.length===1)return e;var t=e.join(`.`);return O[t]||(O[t]=D(e)),O[t]}function A(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return k(e.filter(function(e){return e!==`token`})).reduce(function(e,t){return E(E({},e),n[t])},t)}function j(e){return e.join(` `)}function M(e,t){var n=0;return function(r){return n+=1,r.map(function(r,i){return N({node:r,stylesheet:e,useInlineStyles:t,key:`code-segment-${n}-${i}`})})}}function N(e){var t=e.node,n=e.stylesheet,r=e.style,i=r===void 0?{}:r,a=e.useInlineStyles,o=e.key,s=t.properties,c=t.type,l=t.tagName,u=t.value;if(c===`text`)return u;if(l){var d=M(n,a),f;if(!a)f=E(E({},s),{},{className:j(s.className)});else{var p=Object.keys(n).reduce(function(e,t){return t.split(`.`).forEach(function(t){e.includes(t)||e.push(t)}),e},[]),m=s.className&&s.className.includes(`token`)?[`token`]:[],h=s.className&&m.concat(s.className.filter(function(e){return!p.includes(e)}));f=E(E({},s),{},{className:j(h)||void 0,style:A(s.className,Object.assign({},s.style,i),n)})}var g=d(t.children);return C.createElement(l,w({key:o},f),g)}}var ee=(function(e,t){return e.listLanguages().indexOf(t)!==-1}),te=[`language`,`children`,`style`,`customStyle`,`codeTagProps`,`useInlineStyles`,`showLineNumbers`,`showInlineLineNumbers`,`startingLineNumber`,`lineNumberContainerStyle`,`lineNumberStyle`,`wrapLines`,`wrapLongLines`,`lineProps`,`renderer`,`PreTag`,`CodeTag`,`code`,`astGenerator`];function P(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 F(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?P(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var I=/\n/g;function L(e){return e.match(I)}function ne(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(e,t){var i=t+n;return C.createElement(`span`,{key:`line-${t}`,className:`react-syntax-highlighter-line-number`,style:typeof r==`function`?r(i):r},`${i}
3
3
  `)})}function re(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,i=r===void 0?{float:`left`,paddingRight:`10px`}:r,a=e.numberStyle,o=a===void 0?{}:a,s=e.startingLineNumber;return C.createElement(`code`,{style:Object.assign({},n,i)},ne({lines:t.replace(/\n$/,``).split(`
4
4
  `),style:o,startingLineNumber:s}))}function ie(e){return`${e.toString().length}.25em`}function R(e,t){return{type:`element`,tagName:`span`,properties:{key:`line-number--${e}`,className:[`comment`,`linenumber`,`react-syntax-highlighter-line-number`],style:t},children:[{type:`text`,value:e}]}}function z(e,t,n){var r={display:`inline-block`,minWidth:ie(n),paddingRight:`1em`,textAlign:`right`,userSelect:`none`},i=typeof e==`function`?e(t):e;return F(F({},r),i)}function B(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,i=e.largestLineNumber,a=e.showInlineLineNumbers,o=e.lineProps,s=o===void 0?{}:o,c=e.className,l=c===void 0?[]:c,u=e.showLineNumbers,d=e.wrapLongLines,f=e.wrapLines,p=f!==void 0&&f?F({},typeof s==`function`?s(n):s):{};if(p.className=p.className?[].concat(v(p.className.trim().split(/\s+/)),v(l)):l,n&&a){var m=z(r,n,i);t.unshift(R(n,m))}return d&u&&(p.style=F({display:`flex`},p.style)),{type:`element`,tagName:`span`,properties:p,children:t}}function V(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];e.length===void 0&&(e=[e]);for(var r=0;r<e.length;r++){var i=e[r];if(i.type===`text`)n.push(B({children:[i],className:v(new Set(t))}));else if(i.children){var a=t.concat(i.properties?.className||[]);V(i.children,a).forEach(function(e){return n.push(e)})}}return n}function ae(e,t,n,r,i,a,o,s,c){var l,u=V(e.value),d=[],f=-1,p=0;function m(e,a){return B({children:e,lineNumber:a,lineNumberStyle:s,largestLineNumber:o,showInlineLineNumbers:i,lineProps:n,className:arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function h(e,t){if(r&&t&&i){var n=z(s,t,o);e.unshift(R(t,n))}return e}function g(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||r.length>0?m(e,n,r):h(e,n)}for(var _=function(){var e=u[p],t=e.children[0].value;if(L(t)){var n=t.split(`
@@ -1 +1 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r}from"./CustomTimeWindowDialog-CGPvUFkc.js";import{S as i,_ as a,c as o,j as s,n as c,t as l,u,v as d}from"./translate-CLoII3EO.js";import{a as f,o as p,p as m}from"./session-indexes-3LjxBYNe.js";import{$ as h,G as g,H as _,K as v,Q as y,U as b,W as x,Y as S,at as C,ct as w,et as T,rt as E,st as D}from"./index-BIpTq_7T.js";import{t as O}from"./utils-BuYa9y6l.js";import{t as k}from"./panel-B-5dVddJ.js";import{OverviewScreen as A}from"./OverviewScreen-D44AMeDu.js";var j=e(t(),1);function M(e){return e.time_updated??e.time_created}function N(e){return e.reference}function P(e,t){let n=i(t);if(e===n)return l(`Today`);if(e===o(n,-1))return l(`Yesterday`);let r=new Date(e);return h(r.getTime())}function F(e){let{session:t}=e,n=N(t);return{routeKey:a(n.agentName,n.sessionId),reference:n,time:M(t),title:x(t),messageCount:t.stats.message_count,cost:t.stats.total_cost??0}}function I(e,t){if(t.length===1){e.push(t[0]);return}let n=t.toSorted((e,t)=>M(e.session)-M(t.session));for(let t=n.length-1;t>=0;--t)e.push(n[t])}function L(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`page total must be a non-negative safe integer`);if(!Number.isSafeInteger(n)||n<=0)throw RangeError(`page limit must be a positive safe integer`);if(e===0)return{offset:0,end:0};let r=Number.isSafeInteger(t)&&t>0?t:0,i=r-r%n,a=Math.floor((e-1)/n)*n,o=Math.min(i,a);return{offset:o,end:o+Math.min(n,e-o)}}function R(e,t){let{session:n,inclusiveStats:r}=e,i=N(n);return{routeKey:a(i.agentName,i.sessionId),reference:i,time:M(n),title:x(n),agentKey:i.agentName,childCount:e.descendantCount,childRoots:e.children,messageCount:r.messageCount,tokens:r.totalTokens,cost:r.cost,isOrphan:t}}function z(e,t=0,n=40){let{offset:r,end:i}=L(e.childCount,t,n),a=[],o=[];I(o,e.childRoots);let s=0;for(;o.length>0&&s<i;){let e=o.pop();s>=r&&a.push(F(e)),s+=1,I(o,e.children)}return{rows:a,offset:r,pageNumber:Math.floor(r/n)+1,hasPrevious:r>0,hasNext:i<e.childCount}}function B(e,t=0,n=40){let{offset:r,end:i}=L(e.mainCount,t,n),a=i-r,o=[],s=0,c=0;for(let t of e.days){if(c===a)break;let e=Math.max(0,r-s);if(s+=t.nodes.length,e>=t.nodes.length)continue;let n=t.nodes.slice(e,e+a-c);if(n.length===0)continue;let i=n.map(e=>R(e,e.session.parent_reference!=null));o.push({dayKey:t.dayKey,dayStart:t.dayStart,label:t.label,mainCount:t.mainCount,subCount:t.subCount,rows:i}),c+=i.length}return{days:o,offset:r,pageNumber:Math.floor(r/n)+1,shown:c,hasPrevious:r>0,hasNext:i<e.mainCount}}function V(e,t){let n=u(e),r=t?.now??Date.now();return{days:d(n.entries).map(e=>({dayKey:e.dayKey,dayStart:e.dayStart,label:P(e.dayStart,r),mainCount:e.mainCount,subCount:e.subCount,nodes:e.nodes})),orphanCount:n.orphans.length,mainCount:n.entries.length,subCount:n.entries.reduce((e,t)=>e+t.descendantCount,0),totalTokens:n.entries.reduce((e,t)=>e+t.inclusiveStats.totalTokens,0)}}function H(e,t,n){return t===`hidden`||e.childCount===0?!1:t===`expanded`||n.has(e.routeKey)}var U=n(),W={sm:`px-2 py-[3px] text-[10.5px]`,md:`px-3 py-[5px] text-xs`};function G({options:e,value:t,onChange:n,size:r=`md`,ariaLabel:i}){let a=b(),o=(0,j.useRef)([]),s=e.findIndex(e=>e.value===t),c=s<0?0:s,l=(t,r)=>{let i=(t+r+e.length)%e.length;n(e[i].value),o.current[i]?.focus()};return(0,U.jsx)(`div`,{ref:a,"data-fluid-hover":`x`,role:`radiogroup`,"aria-label":i,className:`inline-flex rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[3px]`,children:e.map((e,t)=>{let i=t===s;return(0,U.jsx)(`button`,{"data-fluid-item":!0,ref:e=>{o.current[t]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:t===c?0:-1,onClick:()=>n(e.value),onKeyDown:e=>{e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),l(t,1)):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(e.preventDefault(),l(t,-1))},className:O(`console-mono motion-hover rounded-sm border border-transparent whitespace-nowrap focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,W[r],i?`bg-[var(--brand)] text-[var(--brand-fg)]`:`text-[var(--console-muted)] hover:text-[var(--console-text)]`),children:e.label},e.value)})})}var K=[{value:`collapsed`,label:`Collapsed`},{value:`expanded`,label:`Expand all`},{value:`hidden`,label:`Hidden`}];function q({mode:e,onChange:t}){return c(),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Sub-sessions`)}),(0,U.jsx)(G,{options:K.map(e=>({...e,label:l(e.label)})),value:e,onChange:t,size:`sm`,ariaLabel:l(`Sub-session display`)})]})}function J({id:e,row:t,onOpen:n}){c();let[r,i]=(0,j.useState)(0),a=(0,j.useMemo)(()=>z(t,r),[r,t]);return(0,U.jsxs)(`div`,{id:e,className:`border-t border-dashed border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] p-[10px_16px_12px_66px]`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Sub-sessions · derived from this session`)}),t.childCount>40?(0,U.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:l(`Page {0} · {1} shown`,[a.pageNumber,a.rows.length])}):null]}),(0,U.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5 border-l border-dashed border-[var(--console-border-strong)] pl-[14px]`,children:a.rows.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.reference),className:`motion-hover flex items-center gap-[11px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[9px_12px] text-left hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-[10px] text-[var(--console-muted)]`,children:g(e.time)}),e.kind==null?null:(0,U.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:e.kind}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-[var(--console-text)]`,children:e.title}),(0,U.jsxs)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:[S(e.messageCount),` `,l(`msgs ·`),` `,C(e.cost)]})]},e.routeKey))}),a.hasPrevious||a.hasNext?(0,U.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Previous sub-session page`),disabled:!a.hasPrevious,onClick:()=>i(a.offset-40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Next sub-session page`),disabled:!a.hasNext,onClick:()=>i(a.offset+40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]}):null]})}function Y({row:e,mode:t,expanded:n,agentCatalog:r,onToggle:i,onOpen:a}){c();let o=(0,j.useId)(),s=w(r,e.agentKey),u=s?.displayName??e.agentKey,d=e.childCount>0;return(0,U.jsxs)(`article`,{className:`overflow-hidden rounded-lg border bg-[var(--console-surface)] shadow-[var(--shadow-raised)] ${n?`border-[var(--brand-line)]`:`border-[var(--console-border)]`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-[13px] p-[13px_16px]`,children:[(0,U.jsx)(`span`,{className:`console-mono w-[38px] shrink-0 text-[11px] text-[var(--console-muted)]`,children:g(e.time)}),e.isOrphan?(0,U.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:l(`Unmounted`)}):null,(0,U.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:s?.icon?(0,U.jsx)(_,{icon:s.icon,iconColored:s.iconColored,alt:u,className:`size-[13px] object-contain`}):null}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(e.reference),className:`min-w-0 flex-1 text-left focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[13.5px] font-medium text-[var(--console-text)]`,children:e.title}),(0,U.jsxs)(`span`,{className:`console-mono mt-[3px] block truncate text-[10.5px] text-[var(--console-muted)]`,children:[u,` · `,S(e.messageCount),` `,l(`msgs ·`),` `,v(e.tokens),` `,l(`tok`),` `,d?l(` · {0} sub-sessions`,[e.childCount]):``]})]}),d&&t!==`hidden`?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":o,onClick:()=>i(e.routeKey),className:`console-mono motion-hover inline-flex shrink-0 items-center gap-1.5 rounded-full border border-[var(--brand-line)] bg-[var(--brand-soft)] px-2.5 py-[3px] text-[10.5px] text-[var(--brand)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`text-[11px]`,children:`⑂`}),e.childCount,` `,l(`sub`),` `,(0,U.jsx)(`span`,{className:`opacity-70`,children:n?`▾`:`▸`})]}):null,(0,U.jsxs)(`span`,{className:`console-mono w-[76px] shrink-0 text-right text-[11px] text-[var(--console-muted)]`,children:[C(e.cost),d?l(` incl. sub`):``]})]}),n?(0,U.jsx)(J,{id:o,row:e,onOpen:a}):null]})}function X({day:e,mode:t,openIds:n,agentCatalog:r,onToggle:i,onOpen:a}){return c(),(0,U.jsxs)(`div`,{className:`flex gap-5`,children:[(0,U.jsxs)(`div`,{className:`w-[84px] shrink-0 pt-[14px] text-right`,children:[(0,U.jsx)(`div`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e.label}),(0,U.jsxs)(`div`,{className:`console-mono mt-0.5 text-[10px] text-[var(--console-muted)]`,children:[e.mainCount,` `,l(`main ·`),` `,e.subCount,` `,l(`sub`)]})]}),(0,U.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col gap-2.5 border-l border-[var(--console-border)] py-2.5 pr-0 pl-[22px]`,children:[(0,U.jsx)(`span`,{className:`absolute top-[18px] -left-[4px] size-[7px] rounded-full bg-[var(--brand)]`}),e.rows.map(e=>(0,U.jsx)(Y,{row:e,mode:t,expanded:H(e,t,n),agentCatalog:r,onToggle:i,onOpen:a},e.routeKey))]})]})}function Z({sessions:e,projectName:t,agentCatalog:n,onOpenSession:r}){let i=c(),[a,o]=(0,j.useState)(`collapsed`),[s,u]=(0,j.useState)(()=>new Set),[d,f]=(0,j.useState)(0),p=(0,j.useMemo)(()=>V(e),[i,e]),m=(0,j.useMemo)(()=>B(p,d),[d,p]),h=(0,j.useCallback)(e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return(0,U.jsxs)(`section`,{"aria-label":l(`{0} timeline`,[t]),className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:l(`{0} sessions · {1} sub-sessions · {2} tokens`,[p.mainCount,p.subCount,v(p.totalTokens)])}),(0,U.jsx)(`div`,{className:`ml-auto`,children:(0,U.jsx)(q,{mode:a,onChange:o})})]}),p.mainCount>40?(0,U.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,U.jsx)(`span`,{children:l(`Page {0} · {1} shown`,[m.pageNumber,m.shown])}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Previous timeline page`),disabled:!m.hasPrevious,onClick:()=>f(m.offset-40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Next timeline page`),disabled:!m.hasNext,onClick:()=>f(m.offset+40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]})]}):null,(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:m.days.map(e=>(0,U.jsx)(X,{day:e,mode:a,openIds:s,agentCatalog:n,onToggle:h,onOpen:r},e.dayKey))}),p.orphanCount>0?(0,U.jsxs)(`p`,{className:`console-mono text-[10.5px] text-[var(--console-muted)]`,children:[p.orphanCount,` `,l(`unmounted sub-sessions · parent file is gone`)]}):null]})}function Q({label:e,value:t,hint:n}){return c(),(0,U.jsxs)(k,{className:`p-[14px_16px]`,children:[(0,U.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,U.jsx)(`p`,{className:`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em] text-[var(--console-text)]`,children:t}),n?(0,U.jsx)(`p`,{className:`console-mono mt-[7px] text-[10.5px] text-[var(--console-muted)]`,children:n}):null]})}function $({agents:e,agentCatalog:t}){return c(),e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let n=w(t,e.name);return(0,U.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,U.jsx)(_,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)})})}function ee({project:e,agentCatalog:t}){return c(),(0,U.jsx)(`li`,{children:(0,U.jsxs)(p,{to:f({kind:e.identityKind,key:e.identityKey}),className:`block rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--brand-line)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`line-clamp-1 text-[13px] font-medium text-[var(--console-text)]`,children:e.displayName}),(0,U.jsx)(`p`,{className:`console-mono mt-[5px] break-all text-[10.5px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,U.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-text-secondary)]`,children:[(0,U.jsxs)(`span`,{children:[T(e.sessionCount),` `,l(`sessions`)]}),(0,U.jsxs)(`span`,{children:[v(e.tokens),` `,l(`tokens`)]}),(0,U.jsx)(`span`,{className:`text-[var(--brand)]`,children:y(e.cost)}),(0,U.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:E(e.lastActivity)})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,U.jsx)($,{agents:e.agentStats,agentCatalog:t}),(0,U.jsx)(`span`,{className:`console-eyebrow`,children:e.identityKind})]})]})})}function te({initialPage:e,window:t,agentCatalog:n,loading:i,error:a,onRetry:o}){c();let s=D(t,e),u=s.page??e,d=u.projects.slice(0,250),f=s.error??a,p=s.error?()=>void s.retry():o;return u.summary.projects===0?f?(0,U.jsx)(`div`,{className:`mx-auto max-w-6xl`,children:(0,U.jsx)(r,{title:l(`Couldn't load projects.`),message:f,onRetry:p})}):i||s.loading?(0,U.jsx)(k,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:l(`Loading projects...`)}):(0,U.jsx)(k,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:l(`No projects found`)}):(0,U.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[f?(0,U.jsx)(r,{title:l(`Couldn't refresh projects.`),message:f,onRetry:p}):null,(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,U.jsx)(Q,{label:l(`Projects`),value:T(u.summary.projects)}),(0,U.jsx)(Q,{label:l(`Sessions`),value:T(u.summary.sessions)}),(0,U.jsx)(Q,{label:l(`Tokens`),value:v(u.summary.tokens)}),(0,U.jsx)(Q,{label:l(`Total Cost`),value:y(u.summary.cost),hint:u.summary.latestActivity?l(`Latest {0}`,[E(u.summary.latestActivity)]):void 0})]}),(0,U.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,U.jsx)(`span`,{children:l(`Page {0} · {1} shown`,[s.pageNumber,T(d.length)])}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!s.canPrevious,onClick:s.previous,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!s.canNext,onClick:s.next,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]})]}),(0,U.jsx)(`ul`,{className:`grid gap-3`,children:d.map(e=>(0,U.jsx)(ee,{project:e,agentCatalog:n},`${e.identityKind}:${e.identityKey}`))})]})}function ne({agents:e,agentCatalog:t,activeAgent:n,onChange:r}){c();let i=e=>`console-mono inline-flex items-center gap-1 rounded-full border px-[13px] py-[5px] text-[11px] motion-hover focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none ${e?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)] hover:border-[var(--brand-line)]`}`;return(0,U.jsx)(k,{className:`p-3`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Agent`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(void 0),className:i(!n),children:l(`All Agents`)}),e.map(e=>{let a=w(t,e.name),o=n===e.name;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(o?void 0:e.name),className:i(o),children:[a?.icon?(0,U.jsx)(_,{icon:a.icon,iconColored:a.iconColored,alt:a.displayName,className:`size-3 object-contain`}):null,a?.displayName??e.name,` · `,e.sessions]},e.name)})]})})}function re({project:e}){return c(),(0,U.jsxs)(`p`,{className:`console-mono break-all text-xs text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})}function ie({project:e,loading:t,error:n,onRetry:i,agentCatalog:a,projectKey:o,sessions:u,activeAgent:d,onChangeAgent:f,timeWindow:h,rangePreset:g,onRangeChange:_,onSelectCustom:v}){c();let y=m();if(t)return(0,U.jsx)(k,{className:`mx-auto max-w-4xl p-6 text-sm text-[var(--console-muted)]`,children:l(`Loading project...`)});if(n)return(0,U.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,U.jsx)(r,{title:l(`Couldn't load project.`),message:n,onRetry:i})});if(!e)return(0,U.jsxs)(k,{className:`mx-auto max-w-4xl p-6`,children:[(0,U.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:l(`Project Not Found`)}),(0,U.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:o}),(0,U.jsx)(p,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:l(`Back to Projects`)})]});let b=d?u.filter(e=>e.reference.agentName===d):u;return(0,U.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[(0,U.jsx)(re,{project:e}),(0,U.jsx)(ne,{agents:e.agentStats,agentCatalog:a,activeAgent:d,onChange:f}),(0,U.jsx)(A,{project:{kind:e.identityKind,key:e.identityKey},agent:d,onAgentChange:f,window:h,agentCatalog:a,rangePreset:g,onRangeChange:_,onSelectCustom:v,children:(0,U.jsx)(Z,{sessions:b,projectName:e.displayName,agentCatalog:a,onOpenSession:e=>y(s(e))},`${e.identityKind}:${e.identityKey}:${d??`all`}`)},`${e.identityKind}:${e.identityKey}`)]})}export{ie as ProjectDashboardView,te as ProjectsOverview};
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r}from"./CustomTimeWindowDialog-CGPvUFkc.js";import{S as i,_ as a,c as o,j as s,n as c,t as l,u,v as d}from"./translate-CLoII3EO.js";import{a as f,o as p,p as m}from"./session-indexes-3LjxBYNe.js";import{$ as h,G as g,H as _,K as v,Q as y,U as b,W as x,Y as S,at as C,ct as w,et as T,rt as E,st as D}from"./index-DUcpWdzX.js";import{t as O}from"./utils-BuYa9y6l.js";import{t as k}from"./panel-B-5dVddJ.js";import{OverviewScreen as A}from"./OverviewScreen-DX7F_6dH.js";var j=e(t(),1);function M(e){return e.time_updated??e.time_created}function N(e){return e.reference}function P(e,t){let n=i(t);if(e===n)return l(`Today`);if(e===o(n,-1))return l(`Yesterday`);let r=new Date(e);return h(r.getTime())}function F(e){let{session:t}=e,n=N(t);return{routeKey:a(n.agentName,n.sessionId),reference:n,time:M(t),title:x(t),messageCount:t.stats.message_count,cost:t.stats.total_cost??0}}function I(e,t){if(t.length===1){e.push(t[0]);return}let n=t.toSorted((e,t)=>M(e.session)-M(t.session));for(let t=n.length-1;t>=0;--t)e.push(n[t])}function L(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`page total must be a non-negative safe integer`);if(!Number.isSafeInteger(n)||n<=0)throw RangeError(`page limit must be a positive safe integer`);if(e===0)return{offset:0,end:0};let r=Number.isSafeInteger(t)&&t>0?t:0,i=r-r%n,a=Math.floor((e-1)/n)*n,o=Math.min(i,a);return{offset:o,end:o+Math.min(n,e-o)}}function R(e,t){let{session:n,inclusiveStats:r}=e,i=N(n);return{routeKey:a(i.agentName,i.sessionId),reference:i,time:M(n),title:x(n),agentKey:i.agentName,childCount:e.descendantCount,childRoots:e.children,messageCount:r.messageCount,tokens:r.totalTokens,cost:r.cost,isOrphan:t}}function z(e,t=0,n=40){let{offset:r,end:i}=L(e.childCount,t,n),a=[],o=[];I(o,e.childRoots);let s=0;for(;o.length>0&&s<i;){let e=o.pop();s>=r&&a.push(F(e)),s+=1,I(o,e.children)}return{rows:a,offset:r,pageNumber:Math.floor(r/n)+1,hasPrevious:r>0,hasNext:i<e.childCount}}function B(e,t=0,n=40){let{offset:r,end:i}=L(e.mainCount,t,n),a=i-r,o=[],s=0,c=0;for(let t of e.days){if(c===a)break;let e=Math.max(0,r-s);if(s+=t.nodes.length,e>=t.nodes.length)continue;let n=t.nodes.slice(e,e+a-c);if(n.length===0)continue;let i=n.map(e=>R(e,e.session.parent_reference!=null));o.push({dayKey:t.dayKey,dayStart:t.dayStart,label:t.label,mainCount:t.mainCount,subCount:t.subCount,rows:i}),c+=i.length}return{days:o,offset:r,pageNumber:Math.floor(r/n)+1,shown:c,hasPrevious:r>0,hasNext:i<e.mainCount}}function V(e,t){let n=u(e),r=t?.now??Date.now();return{days:d(n.entries).map(e=>({dayKey:e.dayKey,dayStart:e.dayStart,label:P(e.dayStart,r),mainCount:e.mainCount,subCount:e.subCount,nodes:e.nodes})),orphanCount:n.orphans.length,mainCount:n.entries.length,subCount:n.entries.reduce((e,t)=>e+t.descendantCount,0),totalTokens:n.entries.reduce((e,t)=>e+t.inclusiveStats.totalTokens,0)}}function H(e,t,n){return t===`hidden`||e.childCount===0?!1:t===`expanded`||n.has(e.routeKey)}var U=n(),W={sm:`px-2 py-[3px] text-[10.5px]`,md:`px-3 py-[5px] text-xs`};function G({options:e,value:t,onChange:n,size:r=`md`,ariaLabel:i}){let a=b(),o=(0,j.useRef)([]),s=e.findIndex(e=>e.value===t),c=s<0?0:s,l=(t,r)=>{let i=(t+r+e.length)%e.length;n(e[i].value),o.current[i]?.focus()};return(0,U.jsx)(`div`,{ref:a,"data-fluid-hover":`x`,role:`radiogroup`,"aria-label":i,className:`inline-flex rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[3px]`,children:e.map((e,t)=>{let i=t===s;return(0,U.jsx)(`button`,{"data-fluid-item":!0,ref:e=>{o.current[t]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:t===c?0:-1,onClick:()=>n(e.value),onKeyDown:e=>{e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),l(t,1)):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(e.preventDefault(),l(t,-1))},className:O(`console-mono motion-hover rounded-sm border border-transparent whitespace-nowrap focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,W[r],i?`bg-[var(--brand)] text-[var(--brand-fg)]`:`text-[var(--console-muted)] hover:text-[var(--console-text)]`),children:e.label},e.value)})})}var K=[{value:`collapsed`,label:`Collapsed`},{value:`expanded`,label:`Expand all`},{value:`hidden`,label:`Hidden`}];function q({mode:e,onChange:t}){return c(),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Sub-sessions`)}),(0,U.jsx)(G,{options:K.map(e=>({...e,label:l(e.label)})),value:e,onChange:t,size:`sm`,ariaLabel:l(`Sub-session display`)})]})}function J({id:e,row:t,onOpen:n}){c();let[r,i]=(0,j.useState)(0),a=(0,j.useMemo)(()=>z(t,r),[r,t]);return(0,U.jsxs)(`div`,{id:e,className:`border-t border-dashed border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] p-[10px_16px_12px_66px]`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Sub-sessions · derived from this session`)}),t.childCount>40?(0,U.jsx)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:l(`Page {0} · {1} shown`,[a.pageNumber,a.rows.length])}):null]}),(0,U.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5 border-l border-dashed border-[var(--console-border-strong)] pl-[14px]`,children:a.rows.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(e.reference),className:`motion-hover flex items-center gap-[11px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[9px_12px] text-left hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-[10px] text-[var(--console-muted)]`,children:g(e.time)}),e.kind==null?null:(0,U.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:e.kind}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-[var(--console-text)]`,children:e.title}),(0,U.jsxs)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:[S(e.messageCount),` `,l(`msgs ·`),` `,C(e.cost)]})]},e.routeKey))}),a.hasPrevious||a.hasNext?(0,U.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Previous sub-session page`),disabled:!a.hasPrevious,onClick:()=>i(a.offset-40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Next sub-session page`),disabled:!a.hasNext,onClick:()=>i(a.offset+40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]}):null]})}function Y({row:e,mode:t,expanded:n,agentCatalog:r,onToggle:i,onOpen:a}){c();let o=(0,j.useId)(),s=w(r,e.agentKey),u=s?.displayName??e.agentKey,d=e.childCount>0;return(0,U.jsxs)(`article`,{className:`overflow-hidden rounded-lg border bg-[var(--console-surface)] shadow-[var(--shadow-raised)] ${n?`border-[var(--brand-line)]`:`border-[var(--console-border)]`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-[13px] p-[13px_16px]`,children:[(0,U.jsx)(`span`,{className:`console-mono w-[38px] shrink-0 text-[11px] text-[var(--console-muted)]`,children:g(e.time)}),e.isOrphan?(0,U.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:l(`Unmounted`)}):null,(0,U.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:s?.icon?(0,U.jsx)(_,{icon:s.icon,iconColored:s.iconColored,alt:u,className:`size-[13px] object-contain`}):null}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(e.reference),className:`min-w-0 flex-1 text-left focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[13.5px] font-medium text-[var(--console-text)]`,children:e.title}),(0,U.jsxs)(`span`,{className:`console-mono mt-[3px] block truncate text-[10.5px] text-[var(--console-muted)]`,children:[u,` · `,S(e.messageCount),` `,l(`msgs ·`),` `,v(e.tokens),` `,l(`tok`),` `,d?l(` · {0} sub-sessions`,[e.childCount]):``]})]}),d&&t!==`hidden`?(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":o,onClick:()=>i(e.routeKey),className:`console-mono motion-hover inline-flex shrink-0 items-center gap-1.5 rounded-full border border-[var(--brand-line)] bg-[var(--brand-soft)] px-2.5 py-[3px] text-[10.5px] text-[var(--brand)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsx)(`span`,{className:`text-[11px]`,children:`⑂`}),e.childCount,` `,l(`sub`),` `,(0,U.jsx)(`span`,{className:`opacity-70`,children:n?`▾`:`▸`})]}):null,(0,U.jsxs)(`span`,{className:`console-mono w-[76px] shrink-0 text-right text-[11px] text-[var(--console-muted)]`,children:[C(e.cost),d?l(` incl. sub`):``]})]}),n?(0,U.jsx)(J,{id:o,row:e,onOpen:a}):null]})}function X({day:e,mode:t,openIds:n,agentCatalog:r,onToggle:i,onOpen:a}){return c(),(0,U.jsxs)(`div`,{className:`flex gap-5`,children:[(0,U.jsxs)(`div`,{className:`w-[84px] shrink-0 pt-[14px] text-right`,children:[(0,U.jsx)(`div`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e.label}),(0,U.jsxs)(`div`,{className:`console-mono mt-0.5 text-[10px] text-[var(--console-muted)]`,children:[e.mainCount,` `,l(`main ·`),` `,e.subCount,` `,l(`sub`)]})]}),(0,U.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col gap-2.5 border-l border-[var(--console-border)] py-2.5 pr-0 pl-[22px]`,children:[(0,U.jsx)(`span`,{className:`absolute top-[18px] -left-[4px] size-[7px] rounded-full bg-[var(--brand)]`}),e.rows.map(e=>(0,U.jsx)(Y,{row:e,mode:t,expanded:H(e,t,n),agentCatalog:r,onToggle:i,onOpen:a},e.routeKey))]})]})}function Z({sessions:e,projectName:t,agentCatalog:n,onOpenSession:r}){let i=c(),[a,o]=(0,j.useState)(`collapsed`),[s,u]=(0,j.useState)(()=>new Set),[d,f]=(0,j.useState)(0),p=(0,j.useMemo)(()=>V(e),[i,e]),m=(0,j.useMemo)(()=>B(p,d),[d,p]),h=(0,j.useCallback)(e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return(0,U.jsxs)(`section`,{"aria-label":l(`{0} timeline`,[t]),className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:l(`{0} sessions · {1} sub-sessions · {2} tokens`,[p.mainCount,p.subCount,v(p.totalTokens)])}),(0,U.jsx)(`div`,{className:`ml-auto`,children:(0,U.jsx)(q,{mode:a,onChange:o})})]}),p.mainCount>40?(0,U.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,U.jsx)(`span`,{children:l(`Page {0} · {1} shown`,[m.pageNumber,m.shown])}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Previous timeline page`),disabled:!m.hasPrevious,onClick:()=>f(m.offset-40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,"aria-label":l(`Next timeline page`),disabled:!m.hasNext,onClick:()=>f(m.offset+40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]})]}):null,(0,U.jsx)(`div`,{className:`flex flex-col gap-3`,children:m.days.map(e=>(0,U.jsx)(X,{day:e,mode:a,openIds:s,agentCatalog:n,onToggle:h,onOpen:r},e.dayKey))}),p.orphanCount>0?(0,U.jsxs)(`p`,{className:`console-mono text-[10.5px] text-[var(--console-muted)]`,children:[p.orphanCount,` `,l(`unmounted sub-sessions · parent file is gone`)]}):null]})}function Q({label:e,value:t,hint:n}){return c(),(0,U.jsxs)(k,{className:`p-[14px_16px]`,children:[(0,U.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,U.jsx)(`p`,{className:`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em] text-[var(--console-text)]`,children:t}),n?(0,U.jsx)(`p`,{className:`console-mono mt-[7px] text-[10.5px] text-[var(--console-muted)]`,children:n}):null]})}function $({agents:e,agentCatalog:t}){return c(),e.length===0?null:(0,U.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let n=w(t,e.name);return(0,U.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,U.jsx)(_,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)})})}function ee({project:e,agentCatalog:t}){return c(),(0,U.jsx)(`li`,{children:(0,U.jsxs)(p,{to:f({kind:e.identityKind,key:e.identityKey}),className:`block rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--brand-line)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h2`,{className:`line-clamp-1 text-[13px] font-medium text-[var(--console-text)]`,children:e.displayName}),(0,U.jsx)(`p`,{className:`console-mono mt-[5px] break-all text-[10.5px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,U.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-text-secondary)]`,children:[(0,U.jsxs)(`span`,{children:[T(e.sessionCount),` `,l(`sessions`)]}),(0,U.jsxs)(`span`,{children:[v(e.tokens),` `,l(`tokens`)]}),(0,U.jsx)(`span`,{className:`text-[var(--brand)]`,children:y(e.cost)}),(0,U.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:E(e.lastActivity)})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,U.jsx)($,{agents:e.agentStats,agentCatalog:t}),(0,U.jsx)(`span`,{className:`console-eyebrow`,children:e.identityKind})]})]})})}function te({initialPage:e,window:t,agentCatalog:n,loading:i,error:a,onRetry:o}){c();let s=D(t,e),u=s.page??e,d=u.projects.slice(0,250),f=s.error??a,p=s.error?()=>void s.retry():o;return u.summary.projects===0?f?(0,U.jsx)(`div`,{className:`mx-auto max-w-6xl`,children:(0,U.jsx)(r,{title:l(`Couldn't load projects.`),message:f,onRetry:p})}):i||s.loading?(0,U.jsx)(k,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:l(`Loading projects...`)}):(0,U.jsx)(k,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:l(`No projects found`)}):(0,U.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[f?(0,U.jsx)(r,{title:l(`Couldn't refresh projects.`),message:f,onRetry:p}):null,(0,U.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,U.jsx)(Q,{label:l(`Projects`),value:T(u.summary.projects)}),(0,U.jsx)(Q,{label:l(`Sessions`),value:T(u.summary.sessions)}),(0,U.jsx)(Q,{label:l(`Tokens`),value:v(u.summary.tokens)}),(0,U.jsx)(Q,{label:l(`Total Cost`),value:y(u.summary.cost),hint:u.summary.latestActivity?l(`Latest {0}`,[E(u.summary.latestActivity)]):void 0})]}),(0,U.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,U.jsx)(`span`,{children:l(`Page {0} · {1} shown`,[s.pageNumber,T(d.length)])}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!s.canPrevious,onClick:s.previous,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Previous`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!s.canNext,onClick:s.next,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:l(`Next`)})]})]}),(0,U.jsx)(`ul`,{className:`grid gap-3`,children:d.map(e=>(0,U.jsx)(ee,{project:e,agentCatalog:n},`${e.identityKind}:${e.identityKey}`))})]})}function ne({agents:e,agentCatalog:t,activeAgent:n,onChange:r}){c();let i=e=>`console-mono inline-flex items-center gap-1 rounded-full border px-[13px] py-[5px] text-[11px] motion-hover focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none ${e?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)] hover:border-[var(--brand-line)]`}`;return(0,U.jsx)(k,{className:`p-3`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`console-eyebrow`,children:l(`Agent`)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(void 0),className:i(!n),children:l(`All Agents`)}),e.map(e=>{let a=w(t,e.name),o=n===e.name;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(o?void 0:e.name),className:i(o),children:[a?.icon?(0,U.jsx)(_,{icon:a.icon,iconColored:a.iconColored,alt:a.displayName,className:`size-3 object-contain`}):null,a?.displayName??e.name,` · `,e.sessions]},e.name)})]})})}function re({project:e}){return c(),(0,U.jsxs)(`p`,{className:`console-mono break-all text-xs text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})}function ie({project:e,loading:t,error:n,onRetry:i,agentCatalog:a,projectKey:o,sessions:u,activeAgent:d,onChangeAgent:f,timeWindow:h,rangePreset:g,onRangeChange:_,onSelectCustom:v}){c();let y=m();if(t)return(0,U.jsx)(k,{className:`mx-auto max-w-4xl p-6 text-sm text-[var(--console-muted)]`,children:l(`Loading project...`)});if(n)return(0,U.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,U.jsx)(r,{title:l(`Couldn't load project.`),message:n,onRetry:i})});if(!e)return(0,U.jsxs)(k,{className:`mx-auto max-w-4xl p-6`,children:[(0,U.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:l(`Project Not Found`)}),(0,U.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:o}),(0,U.jsx)(p,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:l(`Back to Projects`)})]});let b=d?u.filter(e=>e.reference.agentName===d):u;return(0,U.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[(0,U.jsx)(re,{project:e}),(0,U.jsx)(ne,{agents:e.agentStats,agentCatalog:a,activeAgent:d,onChange:f}),(0,U.jsx)(A,{project:{kind:e.identityKind,key:e.identityKey},agent:d,onAgentChange:f,window:h,agentCatalog:a,rangePreset:g,onRangeChange:_,onSelectCustom:v,children:(0,U.jsx)(Z,{sessions:b,projectName:e.displayName,agentCatalog:a,onOpenSession:e=>y(s(e))},`${e.identityKind}:${e.identityKey}:${d??`all`}`)},`${e.identityKind}:${e.identityKey}`)]})}export{ie as ProjectDashboardView,te as ProjectsOverview};