claude-session-dashboard 0.1.0
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.
- package/LICENSE +21 -0
- package/bin/cli.mjs +212 -0
- package/dist/client/assets/_dashboard-Oaur6UHf.js +1 -0
- package/dist/client/assets/_sessionId-CWavmGnC.js +12 -0
- package/dist/client/assets/createServerFn-Bmn60lX_.js +1 -0
- package/dist/client/assets/format-Bf-cSf6L.js +1 -0
- package/dist/client/assets/index-CN4cqOcf.js +1 -0
- package/dist/client/assets/main-Bssrw_E_.js +18 -0
- package/dist/client/assets/settings-Buc0ndXk.js +1 -0
- package/dist/client/assets/settings.types-4U9-Yxq3.js +1 -0
- package/dist/client/assets/stats-BEUCPbcP.js +4 -0
- package/dist/client/assets/useSessionCost-C7ox6YwA.js +61 -0
- package/dist/server/assets/_dashboard-CG6ub7j3.js +97 -0
- package/dist/server/assets/_sessionId-CcWGJarz.js +1582 -0
- package/dist/server/assets/_tanstack-start-manifest_v-DidrnaMJ.js +4 -0
- package/dist/server/assets/claude-path-CkuljM34.js +25 -0
- package/dist/server/assets/createServerRpc-Bd3B-Ah9.js +12 -0
- package/dist/server/assets/createSsrRpc-CVg2UDl0.js +17 -0
- package/dist/server/assets/format-CGmJnuhZ.js +57 -0
- package/dist/server/assets/index-DjrI63_C.js +409 -0
- package/dist/server/assets/router-ByIey__S.js +208 -0
- package/dist/server/assets/session-detail.server-azkRfON2.js +70 -0
- package/dist/server/assets/session-parser-CAEXxF1D.js +413 -0
- package/dist/server/assets/sessions.server-B8zbmvSM.js +187 -0
- package/dist/server/assets/settings-ko61yfVs.js +202 -0
- package/dist/server/assets/settings.queries-DSQd324O.js +33 -0
- package/dist/server/assets/settings.server-6B2PvLgf.js +89 -0
- package/dist/server/assets/settings.types-DntadCHo.js +111 -0
- package/dist/server/assets/start-HYkvq4Ni.js +4 -0
- package/dist/server/assets/stats-DItsFPp5.js +266 -0
- package/dist/server/assets/stats.server-BZWxV-mC.js +85 -0
- package/dist/server/assets/useSessionCost-EB0VxklP.js +76 -0
- package/dist/server/server.js +1428 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dmytro Lupiak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/cli.mjs
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
import { readFile, access, stat } from 'node:fs/promises';
|
|
5
|
+
import { resolve, join, extname } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { exec } from 'node:child_process';
|
|
8
|
+
import { homedir } from 'node:os';
|
|
9
|
+
|
|
10
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
11
|
+
const distDir = resolve(__dirname, '..', 'dist');
|
|
12
|
+
const clientDir = join(distDir, 'client');
|
|
13
|
+
const pkg = JSON.parse(await readFile(resolve(__dirname, '..', 'package.json'), 'utf-8'));
|
|
14
|
+
|
|
15
|
+
// --- Argument parsing ---
|
|
16
|
+
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
function getArg(name, short) {
|
|
20
|
+
for (let i = 0; i < args.length; i++) {
|
|
21
|
+
if (args[i] === `--${name}` || (short && args[i] === `-${short}`)) {
|
|
22
|
+
return args[i + 1] || true;
|
|
23
|
+
}
|
|
24
|
+
if (args[i].startsWith(`--${name}=`)) {
|
|
25
|
+
return args[i].split('=')[1];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const hasFlag = (name, short) => args.includes(`--${name}`) || (short && args.includes(`-${short}`));
|
|
32
|
+
|
|
33
|
+
if (hasFlag('help', 'h')) {
|
|
34
|
+
console.log(`
|
|
35
|
+
Claude Session Dashboard v${pkg.version}
|
|
36
|
+
|
|
37
|
+
Usage: claude-dashboard [options]
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
-p, --port <number> Port to listen on (default: 3000)
|
|
41
|
+
--host <hostname> Host to bind to (default: localhost)
|
|
42
|
+
-o, --open Open browser after starting
|
|
43
|
+
-v, --version Show version number
|
|
44
|
+
-h, --help Show this help message
|
|
45
|
+
`);
|
|
46
|
+
process.exit(0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (hasFlag('version', 'v')) {
|
|
50
|
+
console.log(pkg.version);
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const port = Number(getArg('port', 'p')) || 3000;
|
|
55
|
+
const host = getArg('host') || 'localhost';
|
|
56
|
+
const shouldOpen = hasFlag('open', 'o');
|
|
57
|
+
|
|
58
|
+
// --- Pre-flight checks ---
|
|
59
|
+
|
|
60
|
+
const claudeDir = join(homedir(), '.claude');
|
|
61
|
+
try {
|
|
62
|
+
await access(claudeDir);
|
|
63
|
+
} catch {
|
|
64
|
+
console.warn(`\nWarning: ~/.claude directory not found. The dashboard may not show any sessions.\n`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
await access(join(distDir, 'server', 'server.js'));
|
|
69
|
+
} catch {
|
|
70
|
+
console.error(`\nError: Built files not found at ${distDir}/server/server.js`);
|
|
71
|
+
console.error('Run "npm run build" first, then try again.\n');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// --- MIME types ---
|
|
76
|
+
|
|
77
|
+
const MIME_TYPES = {
|
|
78
|
+
'.html': 'text/html; charset=utf-8',
|
|
79
|
+
'.js': 'application/javascript; charset=utf-8',
|
|
80
|
+
'.mjs': 'application/javascript; charset=utf-8',
|
|
81
|
+
'.css': 'text/css; charset=utf-8',
|
|
82
|
+
'.json': 'application/json; charset=utf-8',
|
|
83
|
+
'.png': 'image/png',
|
|
84
|
+
'.jpg': 'image/jpeg',
|
|
85
|
+
'.svg': 'image/svg+xml',
|
|
86
|
+
'.ico': 'image/x-icon',
|
|
87
|
+
'.woff': 'font/woff',
|
|
88
|
+
'.woff2': 'font/woff2',
|
|
89
|
+
'.map': 'application/json',
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// --- Server setup ---
|
|
93
|
+
|
|
94
|
+
process.env.NODE_ENV = 'production';
|
|
95
|
+
|
|
96
|
+
const serverModule = await import(join(distDir, 'server', 'server.js'));
|
|
97
|
+
const appServer = serverModule.default;
|
|
98
|
+
|
|
99
|
+
async function tryServeStatic(pathname) {
|
|
100
|
+
const filePath = join(clientDir, pathname);
|
|
101
|
+
|
|
102
|
+
// Prevent directory traversal
|
|
103
|
+
if (!filePath.startsWith(clientDir)) return null;
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const fileStat = await stat(filePath);
|
|
107
|
+
if (!fileStat.isFile()) return null;
|
|
108
|
+
const content = await readFile(filePath);
|
|
109
|
+
const ext = extname(filePath);
|
|
110
|
+
return { content, contentType: MIME_TYPES[ext] || 'application/octet-stream' };
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const server = createServer(async (req, res) => {
|
|
117
|
+
try {
|
|
118
|
+
const url = new URL(req.url, `http://${host}:${port}`);
|
|
119
|
+
|
|
120
|
+
// Try static files first (client assets)
|
|
121
|
+
const staticFile = await tryServeStatic(url.pathname);
|
|
122
|
+
if (staticFile) {
|
|
123
|
+
res.writeHead(200, {
|
|
124
|
+
'Content-Type': staticFile.contentType,
|
|
125
|
+
'Content-Length': staticFile.content.byteLength,
|
|
126
|
+
'Cache-Control': url.pathname.includes('/assets/') ? 'public, max-age=31536000, immutable' : 'no-cache',
|
|
127
|
+
});
|
|
128
|
+
res.end(staticFile.content);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Build a standard Request from the Node.js request
|
|
133
|
+
const headers = new Headers();
|
|
134
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
135
|
+
if (value) headers.set(key, Array.isArray(value) ? value.join(', ') : value);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const body = req.method !== 'GET' && req.method !== 'HEAD'
|
|
139
|
+
? await new Promise((resolve) => {
|
|
140
|
+
const chunks = [];
|
|
141
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
142
|
+
req.on('end', () => resolve(Buffer.concat(chunks)));
|
|
143
|
+
})
|
|
144
|
+
: undefined;
|
|
145
|
+
|
|
146
|
+
const request = new Request(url.href, {
|
|
147
|
+
method: req.method,
|
|
148
|
+
headers,
|
|
149
|
+
body,
|
|
150
|
+
duplex: body ? 'half' : undefined,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Delegate to the TanStack Start server
|
|
154
|
+
const response = await appServer.fetch(request);
|
|
155
|
+
|
|
156
|
+
// Write the response back
|
|
157
|
+
res.writeHead(response.status, Object.fromEntries(response.headers.entries()));
|
|
158
|
+
|
|
159
|
+
if (response.body) {
|
|
160
|
+
const reader = response.body.getReader();
|
|
161
|
+
const pump = async () => {
|
|
162
|
+
while (true) {
|
|
163
|
+
const { done, value } = await reader.read();
|
|
164
|
+
if (done) { res.end(); break; }
|
|
165
|
+
res.write(value);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
await pump();
|
|
169
|
+
} else {
|
|
170
|
+
res.end();
|
|
171
|
+
}
|
|
172
|
+
} catch (err) {
|
|
173
|
+
console.error('Request error:', err);
|
|
174
|
+
if (!res.headersSent) {
|
|
175
|
+
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
176
|
+
res.end('Internal Server Error');
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
server.on('error', (err) => {
|
|
182
|
+
if (err.code === 'EADDRINUSE') {
|
|
183
|
+
console.error(`\nError: Port ${port} is already in use.`);
|
|
184
|
+
console.error(`Try a different port: claude-dashboard --port ${port + 1}\n`);
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
console.error('Server error:', err);
|
|
188
|
+
process.exit(1);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
server.listen(port, host, () => {
|
|
192
|
+
const url = `http://${host}:${port}`;
|
|
193
|
+
|
|
194
|
+
console.log(`
|
|
195
|
+
Claude Session Dashboard v${pkg.version}
|
|
196
|
+
Running at ${url}
|
|
197
|
+
Reading sessions from ~/.claude
|
|
198
|
+
|
|
199
|
+
Press Ctrl+C to stop
|
|
200
|
+
`);
|
|
201
|
+
|
|
202
|
+
if (shouldOpen) {
|
|
203
|
+
const cmd = process.platform === 'darwin'
|
|
204
|
+
? `open "${url}"`
|
|
205
|
+
: process.platform === 'win32'
|
|
206
|
+
? `start "" "${url}"`
|
|
207
|
+
: `xdg-open "${url}"`;
|
|
208
|
+
exec(cmd, (err) => {
|
|
209
|
+
if (err) console.log(` Open ${url} in your browser`);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as n,j as e,a as c,L as r,O as i}from"./main-Bssrw_E_.js";function x(){const{privacyMode:s,togglePrivacyMode:a}=n();return e.jsxs("button",{type:"button",onClick:a,title:s?"Privacy mode on":"Privacy mode off",className:`flex items-center gap-2 rounded-lg px-3 py-1.5 text-xs transition-colors ${s?"bg-blue-600 text-white":"bg-gray-800 text-gray-400 hover:text-gray-200"}`,children:[e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",className:"h-3.5 w-3.5",children:[s?e.jsx("path",{fillRule:"evenodd",d:"M3.28 2.22a.75.75 0 00-1.06 1.06l14.5 14.5a.75.75 0 101.06-1.06l-1.745-1.745a10.029 10.029 0 003.3-4.38 1.651 1.651 0 000-1.185A10.004 10.004 0 009.999 3a9.956 9.956 0 00-4.744 1.194L3.28 2.22zM7.752 6.69l1.092 1.092a2.5 2.5 0 013.374 3.373l1.092 1.092a4 4 0 00-5.558-5.558z",clipRule:"evenodd"}):e.jsx("path",{d:"M10 12.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5z"}),s?e.jsx("path",{d:"M10.748 13.93l2.523 2.523a9.987 9.987 0 01-3.27.547c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186A10.007 10.007 0 012.839 6.02L6.07 9.252a4 4 0 004.678 4.678z"}):e.jsx("path",{fillRule:"evenodd",d:"M.458 10a9.996 9.996 0 019.542-6c4.258 0 7.894 2.66 9.337 6.41a1.651 1.651 0 010 1.186A10.004 10.004 0 0110 17.5c-4.258 0-7.894-2.66-9.337-6.41a1.651 1.651 0 010-1.186L.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z",clipRule:"evenodd"})]}),"Privacy"]})}const d=[{to:"/sessions",label:"Sessions",icon:">"},{to:"/stats",label:"Stats",icon:"#"},{to:"/settings",label:"Settings",icon:"*"}];function h({children:s}){const a=c(),l=a[a.length-1]?.pathname??"";return e.jsxs("div",{className:"flex min-h-screen",children:[e.jsxs("aside",{className:"flex w-56 shrink-0 flex-col border-r border-gray-800 bg-gray-950",children:[e.jsx("div",{className:"flex h-14 items-center border-b border-gray-800 px-4",children:e.jsxs(r,{to:"/sessions",className:"text-sm font-bold text-white",children:[e.jsx("span",{className:"text-blue-400",children:"Claude"})," Dashboard"]})}),e.jsx("nav",{className:"flex-1 p-3",children:d.map(t=>{const o=l.startsWith(t.to);return e.jsxs(r,{to:t.to,className:`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors ${o?"bg-gray-800 text-white":"text-gray-400 hover:bg-gray-800/50 hover:text-gray-200"}`,children:[e.jsx("span",{className:"font-mono text-xs text-gray-500",children:t.icon}),t.label]},t.to)})}),e.jsxs("div",{className:"border-t border-gray-800 p-3",children:[e.jsx(x,{}),e.jsx("p",{className:"mt-2 text-xs text-gray-600",children:"Read-only observer"})]})]}),e.jsx("main",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"mx-auto max-w-5xl px-6 py-6",children:s})})]})}function m(){return e.jsx(h,{children:e.jsx(i,{})})}export{m as component};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{R as w,r as S,c as Se,j as e,L as se,f as de,u as De}from"./main-Bssrw_E_.js";import{c as Pe,q as Oe,u as be}from"./createServerFn-Bmn60lX_.js";import{f as I,c as re,a as C,g as ve,b as H}from"./format-Bf-cSf6L.js";import{f as U,L as q,Z as Q,o as X,C as ee,A as Ie,m as W,j as xe,_ as Ee,n as me,c as je,$ as Le,q as Re,u as $e,i as ae,G as _e,k as ue,a0 as pe,D as Ue,N as We,X as Be,Y as Ne,P as Fe,R as Xe,U as ze,a1 as he,a2 as He,a3 as Ge,W as ke}from"./useSessionCost-C7ox6YwA.js";import{s as Ve}from"./settings.types-4U9-Yxq3.js";var Ye=["layout","type","stroke","connectNulls","isRange","ref"],qe=["key"],we;function G(t){"@babel/helpers - typeof";return G=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(s){return typeof s}:function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},G(t)}function Te(t,s){if(t==null)return{};var r=Ke(t,s),a,n;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)a=c[n],!(s.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(t,a)&&(r[a]=t[a])}return r}function Ke(t,s){if(t==null)return{};var r={};for(var a in t)if(Object.prototype.hasOwnProperty.call(t,a)){if(s.indexOf(a)>=0)continue;r[a]=t[a]}return r}function _(){return _=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var r=arguments[s];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(t[a]=r[a])}return t},_.apply(this,arguments)}function fe(t,s){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);s&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),r.push.apply(r,a)}return r}function R(t){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?fe(Object(r),!0).forEach(function(a){D(t,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fe(Object(r)).forEach(function(a){Object.defineProperty(t,a,Object.getOwnPropertyDescriptor(r,a))})}return t}function Qe(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function ge(t,s){for(var r=0;r<s.length;r++){var a=s[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,Me(a.key),a)}}function Ze(t,s,r){return s&&ge(t.prototype,s),r&&ge(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Je(t,s,r){return s=J(s),et(t,Ae()?Reflect.construct(s,r||[],J(t).constructor):s.apply(t,r))}function et(t,s){if(s&&(G(s)==="object"||typeof s=="function"))return s;if(s!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tt(t)}function tt(t){if(t===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function Ae(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ae=function(){return!!t})()}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},J(t)}function st(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(s&&s.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),s&&ne(t,s)}function ne(t,s){return ne=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},ne(t,s)}function D(t,s,r){return s=Me(s),s in t?Object.defineProperty(t,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[s]=r,t}function Me(t){var s=at(t,"string");return G(s)=="symbol"?s:s+""}function at(t,s){if(G(t)!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var a=r.call(t,s);if(G(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}var $=(function(t){function s(){var r;Qe(this,s);for(var a=arguments.length,n=new Array(a),c=0;c<a;c++)n[c]=arguments[c];return r=Je(this,s,[].concat(n)),D(r,"state",{isAnimationFinished:!0}),D(r,"id",$e("recharts-area-")),D(r,"handleAnimationEnd",function(){var x=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),ae(x)&&x()}),D(r,"handleAnimationStart",function(){var x=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),ae(x)&&x()}),r}return st(s,t),Ze(s,[{key:"renderDots",value:function(a,n,c){var x=this.props.isAnimationActive,d=this.state.isAnimationFinished;if(x&&!d)return null;var o=this.props,p=o.dot,i=o.points,l=o.dataKey,f=U(this.props,!1),j=U(p,!0),N=i.map(function(h,u){var v=R(R(R({key:"dot-".concat(u),r:3},f),j),{},{index:u,cx:h.x,cy:h.y,dataKey:l,value:h.value,payload:h.payload,points:i});return s.renderDotItem(p,v)}),m={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(c,")"):null};return w.createElement(q,_({className:"recharts-area-dots"},m),N)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,c=n.baseLine,x=n.points,d=n.strokeWidth,o=x[0].x,p=x[x.length-1].x,i=a*Math.abs(o-p),l=Q(x.map(function(f){return f.y||0}));return X(c)&&typeof c=="number"?l=Math.max(c,l):c&&Array.isArray(c)&&c.length&&(l=Math.max(Q(c.map(function(f){return f.y||0})),l)),X(l)?w.createElement("rect",{x:o<p?o:o-i,y:0,width:i,height:Math.floor(l+(d?parseInt("".concat(d),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,c=n.baseLine,x=n.points,d=n.strokeWidth,o=x[0].y,p=x[x.length-1].y,i=a*Math.abs(o-p),l=Q(x.map(function(f){return f.x||0}));return X(c)&&typeof c=="number"?l=Math.max(c,l):c&&Array.isArray(c)&&c.length&&(l=Math.max(Q(c.map(function(f){return f.x||0})),l)),X(l)?w.createElement("rect",{x:0,y:o<p?o:o-i,width:l+(d?parseInt("".concat(d),10):1),height:Math.floor(i)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,c,x){var d=this.props,o=d.layout,p=d.type,i=d.stroke,l=d.connectNulls,f=d.isRange;d.ref;var j=Te(d,Ye);return w.createElement(q,{clipPath:c?"url(#clipPath-".concat(x,")"):null},w.createElement(ee,_({},U(j,!0),{points:a,connectNulls:l,type:p,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),i!=="none"&&w.createElement(ee,_({},U(this.props,!1),{className:"recharts-area-curve",layout:o,type:p,connectNulls:l,fill:"none",points:a})),i!=="none"&&f&&w.createElement(ee,_({},U(this.props,!1),{className:"recharts-area-curve",layout:o,type:p,connectNulls:l,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var c=this,x=this.props,d=x.points,o=x.baseLine,p=x.isAnimationActive,i=x.animationBegin,l=x.animationDuration,f=x.animationEasing,j=x.animationId,N=this.state,m=N.prevPoints,h=N.prevBaseLine;return w.createElement(Ie,{begin:i,duration:l,isActive:p,easing:f,from:{t:0},to:{t:1},key:"area-".concat(j),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(u){var v=u.t;if(m){var g=m.length/d.length,b=d.map(function(M,E){var P=Math.floor(E*g);if(m[P]){var L=m[P],V=W(L.x,M.x),Y=W(L.y,M.y);return R(R({},M),{},{x:V(v),y:Y(v)})}return M}),y;if(X(o)&&typeof o=="number"){var k=W(h,o);y=k(v)}else if(xe(o)||Ee(o)){var A=W(h,0);y=A(v)}else y=o.map(function(M,E){var P=Math.floor(E*g);if(h[P]){var L=h[P],V=W(L.x,M.x),Y=W(L.y,M.y);return R(R({},M),{},{x:V(v),y:Y(v)})}return M});return c.renderAreaStatically(b,y,a,n)}return w.createElement(q,null,w.createElement("defs",null,w.createElement("clipPath",{id:"animationClipPath-".concat(n)},c.renderClipRect(v))),w.createElement(q,{clipPath:"url(#animationClipPath-".concat(n,")")},c.renderAreaStatically(d,o,a,n)))})}},{key:"renderArea",value:function(a,n){var c=this.props,x=c.points,d=c.baseLine,o=c.isAnimationActive,p=this.state,i=p.prevPoints,l=p.prevBaseLine,f=p.totalLength;return o&&x&&x.length&&(!i&&f>0||!me(i,x)||!me(l,d))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(x,d,a,n)}},{key:"render",value:function(){var a,n=this.props,c=n.hide,x=n.dot,d=n.points,o=n.className,p=n.top,i=n.left,l=n.xAxis,f=n.yAxis,j=n.width,N=n.height,m=n.isAnimationActive,h=n.id;if(c||!d||!d.length)return null;var u=this.state.isAnimationFinished,v=d.length===1,g=je("recharts-area",o),b=l&&l.allowDataOverflow,y=f&&f.allowDataOverflow,k=b||y,A=xe(h)?this.id:h,M=(a=U(x,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},E=M.r,P=E===void 0?3:E,L=M.strokeWidth,V=L===void 0?2:L,Y=Le(x)?x:{},oe=Y.clipDot,ce=oe===void 0?!0:oe,K=P*2+V;return w.createElement(q,{className:g},b||y?w.createElement("defs",null,w.createElement("clipPath",{id:"clipPath-".concat(A)},w.createElement("rect",{x:b?i:i-j/2,y:y?p:p-N/2,width:b?j:j*2,height:y?N:N*2})),!ce&&w.createElement("clipPath",{id:"clipPath-dots-".concat(A)},w.createElement("rect",{x:i-K/2,y:p-K/2,width:j+K,height:N+K}))):null,v?null:this.renderArea(k,A),(x||v)&&this.renderDots(k,ce,A),(!m||u)&&Re.renderCallByParent(this.props,d))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])})(S.PureComponent);we=$;D($,"displayName","Area");D($,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!_e.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});D($,"getBaseValue",function(t,s,r,a){var n=t.layout,c=t.baseValue,x=s.props.baseValue,d=x??c;if(X(d)&&typeof d=="number")return d;var o=n==="horizontal"?a:r,p=o.scale.domain();if(o.type==="number"){var i=Math.max(p[0],p[1]),l=Math.min(p[0],p[1]);return d==="dataMin"?l:d==="dataMax"||i<0?i:Math.max(Math.min(p[0],p[1]),0)}return d==="dataMin"?p[0]:d==="dataMax"?p[1]:p[0]});D($,"getComposedData",function(t){var s=t.props,r=t.item,a=t.xAxis,n=t.yAxis,c=t.xAxisTicks,x=t.yAxisTicks,d=t.bandSize,o=t.dataKey,p=t.stackedData,i=t.dataStartIndex,l=t.displayedData,f=t.offset,j=s.layout,N=p&&p.length,m=we.getBaseValue(s,r,a,n),h=j==="horizontal",u=!1,v=l.map(function(b,y){var k;N?k=p[i+y]:(k=ue(b,o),Array.isArray(k)?u=!0:k=[m,k]);var A=k[1]==null||N&&ue(b,o)==null;return h?{x:pe({axis:a,ticks:c,bandSize:d,entry:b,index:y}),y:A?null:n.scale(k[1]),value:k,payload:b}:{x:A?null:a.scale(k[1]),y:pe({axis:n,ticks:x,bandSize:d,entry:b,index:y}),value:k,payload:b}}),g;return N||u?g=v.map(function(b){var y=Array.isArray(b.value)?b.value[0]:null;return h?{x:b.x,y:y!=null&&b.y!=null?n.scale(y):null}:{x:y!=null?a.scale(y):null,y:b.y}}):g=h?n.scale(m):a.scale(m),R({points:v,baseLine:g,layout:j,isRange:u},f)});D($,"renderDotItem",function(t,s){var r;if(w.isValidElement(t))r=w.cloneElement(t,s);else if(ae(t))r=t(s);else{var a=je("recharts-area-dot",typeof t!="boolean"?t.className:""),n=s.key,c=Te(s,qe);r=w.createElement(Ue,_({},c,{key:n,className:a}))}return r});var nt=We({chartName:"AreaChart",GraphicalChild:$,axisComponents:[{axisType:"xAxis",AxisComp:Be},{axisType:"yAxis",AxisComp:Ne}],formatAxisMap:Fe});const rt=Pe({method:"GET"}).handler(Se("ff8a3161afdfa175e9c519e4146a56ab5bce6e80745e99cfc2191ebbb7a859bb"));function it(t,s){return Oe({queryKey:["session","detail",t],queryFn:()=>rt({data:{sessionId:t,projectPath:s}}),staleTime:3e4})}function lt(t,s,r,a){const n=[];for(const m of t)if(m.timestamp){const h=new Date(m.timestamp).getTime();isNaN(h)||n.push(h)}for(const m of s)if(m.timestamp){const h=new Date(m.timestamp).getTime();isNaN(h)||n.push(h)}for(const m of r)if(m.timestamp){const h=new Date(m.timestamp).getTime();isNaN(h)||n.push(h)}if(n.length===0)return{startMs:0,endMs:0,durationMs:0,mainLane:[],agentLanes:[],skillMarkers:[],errorMarkers:[]};const c=Math.min(...n),x=Math.max(...n),d=Math.max(x-c,1);function o(m){return(m-c)/d}const p=new Set(s.map(m=>m.toolUseId)),i=new Set(r.map(m=>m.toolUseId)),l=[];for(const m of t){if(m.type!=="assistant"||m.toolCalls.length===0)continue;const h=new Date(m.timestamp).getTime();if(!isNaN(h))for(const u of m.toolCalls)p.has(u.toolUseId)||i.has(u.toolUseId)||l.push({timestampMs:h,toolName:u.toolName,toolUseId:u.toolUseId,relativeX:o(h)})}const f=s.map(m=>{const h=new Date(m.timestamp).getTime(),u=m.durationMs?h+m.durationMs:h+d*.02,v=[];if(m.toolCalls){const g=Object.entries(m.toolCalls).sort(([,k],[,A])=>A-k),b=g.reduce((k,[,A])=>k+A,0);let y=0;for(const[k,A]of g)for(let M=0;M<A;M++){const E=b>1?y/(b-1):.5,P=h+(u-h)*E;v.push({toolName:k,count:1,relativeX:o(P)}),y++}}return{subagentType:m.subagentType,description:m.description,startMs:h,endMs:u,startX:o(h),endX:o(u),durationMs:m.durationMs??null,totalTokens:m.totalTokens??null,totalToolUseCount:m.totalToolUseCount??null,toolDots:v}}),j=r.map(m=>{const h=new Date(m.timestamp).getTime();return isNaN(h)?null:{skill:m.skill,args:m.args,timestampMs:h,relativeX:o(h)}}).filter(m=>m!==null),N=a.map(m=>{const h=new Date(m.timestamp).getTime();return isNaN(h)?null:{message:m.message,type:m.type,timestampMs:h,relativeX:o(h)}}).filter(m=>m!==null);return{startMs:c,endMs:x,durationMs:d,mainLane:l,agentLanes:f,skillMarkers:j,errorMarkers:N}}function ie(t){const s=t.match(/^mcp__[^_]+_[^_]+_[^_]+__(.+)$/);return s?s[1]:t}const ot={Read:"#60a5fa",Grep:"#60a5fa",Glob:"#60a5fa",Write:"#34d399",Edit:"#34d399",NotebookEdit:"#34d399",Bash:"#fbbf24",Task:"#818cf8",TaskCreate:"#c084fc",TaskUpdate:"#c084fc",TaskList:"#c084fc",TaskGet:"#c084fc",Skill:"#fcd34d",WebSearch:"#22d3ee",WebFetch:"#22d3ee",EnterPlanMode:"#f472b6",ExitPlanMode:"#f472b6",AskUserQuestion:"#a78bfa"},ct="#9ca3af";function le(t){return ot[t]??ct}const O=90,z=16,B=24,T=32,te=8,Ce=4;function dt(t,s,r){const a=s-t;if(a<=0)return[];const n=Math.max(3,Math.round(r/120)),c=a/n,x=[5e3,1e4,15e3,3e4,6e4,2*6e4,5*6e4,10*6e4,15*6e4,30*6e4,60*6e4,120*6e4],d=x.find(f=>f>=c)??x[x.length-1],p=a<5*6e4?"HH:mm:ss":"HH:mm",i=Math.ceil(t/d)*d,l=[];for(let f=i;f<=s;f+=d){const j=(f-t)/a;l.push({ms:f,label:I(new Date(f),p),x:O+j*(r-O-z)})}return l}function xt({data:t,width:s,onHover:r}){const a=S.useRef(null),n=s,c=n-O-z,x=t.skillMarkers.length>0,d=t.errorMarkers.length>0;let o=B;const p=o;o+=T;const i=[];for(let u=0;u<t.agentLanes.length;u++)o+=te,i.push(o),o+=T;let l=0;x&&(o+=te,l=o,o+=T);let f=0;d&&(o+=te,f=o,o+=T);const j=Math.max(o+8,80);function N(u){return O+u*c}const m=S.useCallback(u=>{if(!a.current)return{x:0,y:0};const v=a.current.getBoundingClientRect();return{x:u.clientX-v.left,y:u.clientY-v.top}},[]),h=dt(t.startMs,t.endMs,n);return e.jsxs("svg",{ref:a,width:n,height:j,className:"select-none",role:"img","aria-label":"Session timeline showing tool calls, agent runs, and skill invocations",onMouseLeave:()=>r(null,{x:0,y:0}),children:[e.jsx("line",{x1:O,y1:B-4,x2:n-z,y2:B-4,stroke:"#374151",strokeWidth:1}),h.map(u=>e.jsxs("g",{children:[e.jsx("line",{x1:u.x,y1:B-8,x2:u.x,y2:B-4,stroke:"#4b5563",strokeWidth:1}),e.jsx("text",{x:u.x,y:B-12,textAnchor:"middle",className:"fill-gray-500 text-[10px]",children:u.label})]},u.ms)),e.jsx("text",{x:4,y:p+T/2+4,className:"fill-gray-500 text-[11px] font-medium",children:"Main"}),e.jsx("line",{x1:O,y1:p+T/2,x2:n-z,y2:p+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.mainLane.map(u=>e.jsx("circle",{cx:N(u.relativeX),cy:p+T/2,r:Ce,fill:le(u.toolName),opacity:.85,className:"cursor-pointer transition-transform hover:opacity-100",onMouseEnter:v=>r({kind:"tool",toolName:u.toolName,timestamp:new Date(u.timestampMs).toISOString(),toolUseId:u.toolUseId},m(v)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsx("title",{children:u.toolName})},u.toolUseId)),t.agentLanes.map((u,v)=>e.jsx(mt,{lane:u,y:i[v],toX:N,laneHeight:T,leftMargin:O,onHover:r,getPosition:m},`${u.subagentType}-${v}`)),x&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:l+T/2+4,className:"fill-amber-400/70 text-[11px] font-medium",children:"Skills"}),e.jsx("line",{x1:O,y1:l+T/2,x2:n-z,y2:l+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.skillMarkers.map((u,v)=>{const g=N(u.relativeX),b=l+T/2,y=5;return e.jsx("polygon",{points:`${g},${b-y} ${g+y},${b} ${g},${b+y} ${g-y},${b}`,fill:"#fbbf24",opacity:.85,className:"cursor-pointer hover:opacity-100",onMouseEnter:k=>r({kind:"skill",skill:u.skill,args:u.args,timestamp:new Date(u.timestampMs).toISOString()},m(k)),onMouseLeave:()=>r(null,{x:0,y:0}),children:e.jsxs("title",{children:["/",u.skill]})},`${u.skill}-${v}`)})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:4,y:f+T/2+4,className:"fill-red-400/70 text-[11px] font-medium",children:"Errors"}),e.jsx("line",{x1:O,y1:f+T/2,x2:n-z,y2:f+T/2,stroke:"#1f2937",strokeWidth:1,strokeDasharray:"2,4"}),t.errorMarkers.map((u,v)=>{const g=N(u.relativeX),b=f+T/2,y=5;return e.jsxs("g",{className:"cursor-pointer hover:opacity-100",opacity:.85,onMouseEnter:k=>r({kind:"error",message:u.message,type:u.type,timestamp:new Date(u.timestampMs).toISOString()},m(k)),onMouseLeave:()=>r(null,{x:0,y:0}),children:[e.jsx("line",{x1:g-y,y1:b-y,x2:g+y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsx("line",{x1:g+y,y1:b-y,x2:g-y,y2:b+y,stroke:"#f87171",strokeWidth:2,strokeLinecap:"round"}),e.jsxs("title",{children:[u.type,": ",u.message]})]},`err-${v}`)})]})]})}function mt({lane:t,y:s,toX:r,laneHeight:a,leftMargin:n,onHover:c,getPosition:x}){const d=r(t.startX),o=Math.max(r(t.endX)-d,8),p=s+a/2,i=t.subagentType.length>10?t.subagentType.slice(0,10)+"...":t.subagentType;return e.jsxs("g",{children:[e.jsx("text",{x:4,y:p+4,className:"fill-indigo-400/70 text-[11px] font-medium",children:i}),e.jsx("rect",{x:d,y:s+2,width:o,height:a-4,rx:6,fill:"rgba(99, 102, 241, 0.08)",stroke:"rgba(99, 102, 241, 0.2)",strokeWidth:1,className:"cursor-pointer hover:fill-indigo-500/15",onMouseEnter:l=>c({kind:"agent",agent:t},x(l)),onMouseLeave:()=>c(null,{x:0,y:0}),children:e.jsxs("title",{children:[t.subagentType,": ",t.description]})}),e.jsx("line",{x1:d+4,y1:p,x2:d+o-4,y2:p,stroke:"rgba(99, 102, 241, 0.15)",strokeWidth:1}),t.toolDots.map((l,f)=>e.jsx("circle",{cx:r(l.relativeX),cy:p,r:Ce-.5,fill:le(l.toolName),opacity:.75,className:"cursor-pointer hover:opacity-100",onMouseEnter:j=>c({kind:"tool",toolName:l.toolName,timestamp:new Date(t.startMs+(l.relativeX-t.startX)/(t.endX-t.startX)*(t.endMs-t.startMs)).toISOString(),toolUseId:`${t.subagentType}-${l.toolName}-${f}`},x(j)),onMouseLeave:()=>c(null,{x:0,y:0}),children:e.jsxs("title",{children:[l.toolName," (",t.subagentType,")"]})},`${l.toolName}-${f}`))]})}function ut({item:t,position:s}){return e.jsxs("div",{className:"pointer-events-none absolute z-50 rounded-lg border border-gray-700 bg-gray-900 px-3 py-2 text-xs shadow-xl",style:{left:s.x,top:s.y,transform:"translate(-50%, -100%) translateY(-8px)"},children:[t.kind==="tool"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-gray-100",children:ie(t.toolName)}),e.jsx("div",{className:"text-gray-400",children:I(new Date(t.timestamp),"HH:mm:ss")}),e.jsxs("div",{className:"font-mono text-[10px] text-gray-600",children:[t.toolUseId.slice(0,16),"..."]})]}),t.kind==="agent"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-indigo-300",children:t.agent.subagentType}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.agent.description}),e.jsx("div",{className:"mt-1 flex items-center gap-2 text-gray-500",children:t.agent.durationMs!=null&&e.jsxs("span",{children:[I(new Date(t.agent.startMs),"HH:mm")," -"," ",I(new Date(t.agent.endMs),"HH:mm")," (",re(t.agent.durationMs),")"]})}),e.jsxs("div",{className:"flex items-center gap-2 text-gray-500",children:[t.agent.totalTokens!=null&&e.jsxs("span",{children:[C(t.agent.totalTokens)," tokens"]}),t.agent.totalToolUseCount!=null&&e.jsxs("span",{children:[t.agent.totalToolUseCount," tools"]})]})]}),t.kind==="skill"&&e.jsxs("div",{children:[e.jsxs("div",{className:"font-semibold text-amber-300",children:["/",t.skill]}),t.args&&e.jsx("div",{className:"text-gray-400",children:t.args}),e.jsx("div",{className:"text-gray-500",children:I(new Date(t.timestamp),"HH:mm:ss")})]}),t.kind==="error"&&e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-red-400",children:t.type}),e.jsx("div",{className:"max-w-48 truncate text-gray-400",children:t.message}),e.jsx("div",{className:"text-gray-500",children:I(new Date(t.timestamp),"HH:mm:ss")})]})]})}function pt({toolNames:t}){const s=[...new Set(t)].slice(0,12);return s.length===0?null:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-1 text-[10px] text-gray-500",children:[s.map(r=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:le(r)}}),e.jsx("span",{children:ie(r)})]},r)),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rotate-45 bg-amber-400"}),e.jsx("span",{children:"Skill"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-red-400 font-bold leading-none",children:"×"}),e.jsx("span",{children:"Error"})]})]})}function ht({turns:t,agents:s,skills:r,errors:a}){const n=S.useRef(null),[c,x]=S.useState(0),[d,o]=S.useState(1),[p,i]=S.useState(null);S.useEffect(()=>{if(!n.current)return;const g=new ResizeObserver(b=>{const y=b[0];y&&x(y.contentRect.width)});return g.observe(n.current),()=>g.disconnect()},[]);const l=S.useMemo(()=>lt(t,s,r,a),[t,s,r,a]),f=S.useMemo(()=>{const g=l.mainLane.map(y=>y.toolName);for(const y of l.agentLanes)for(const k of y.toolDots)g.push(k.toolName);const b={};for(const y of g)b[y]=(b[y]??0)+1;return Object.entries(b).sort(([,y],[,k])=>k-y).map(([y])=>y)},[l]),j=(g,b)=>{i(g?{item:g,position:b}:null)};if(t.length===0)return e.jsx("div",{className:"py-8 text-center text-sm text-gray-500",children:"No timeline data available"});const N=new Set(s.map(g=>g.toolUseId)),m=new Set(r.map(g=>g.toolUseId));let h=0,u=0,v=0;for(const g of t)if(g.type==="user"&&g.message?.trim()&&h++,g.type==="assistant"){u++;for(const b of g.toolCalls)!N.has(b.toolUseId)&&!m.has(b.toolUseId)&&v++}return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-4",children:[e.jsx(F,{label:"User commands",value:h,color:"blue"}),e.jsx(F,{label:"AI responses",value:u,color:"purple"}),v>0&&e.jsx(F,{label:"Tool calls",value:v,color:"gray"}),s.length>0&&e.jsx(F,{label:"Agents",value:s.length,color:"indigo"}),r.length>0&&e.jsx(F,{label:"Skills",value:r.length,color:"amber"}),a.length>0&&e.jsx(F,{label:"Errors",value:a.length,color:"red"})]}),e.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[e.jsx("div",{className:"flex-1",children:f.length>0&&e.jsx(pt,{toolNames:f})}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>o(g=>Math.max(1,g-.5)),disabled:d<=1,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom out",children:"−"}),e.jsx("span",{className:"min-w-[3rem] text-center text-[10px] tabular-nums text-gray-500",children:d===1?"Fit":`${d.toFixed(1)}x`}),e.jsx("button",{type:"button",onClick:()=>o(g=>Math.min(8,g+.5)),disabled:d>=8,className:"rounded bg-gray-800 px-2 py-0.5 text-xs text-gray-300 transition-colors hover:bg-gray-700 disabled:opacity-30",title:"Zoom in",children:"+"}),d>1&&e.jsx("button",{type:"button",onClick:()=>o(1),className:"ml-1 rounded bg-gray-800 px-2 py-0.5 text-[10px] text-gray-400 transition-colors hover:bg-gray-700",title:"Reset zoom",children:"Reset"})]})]}),e.jsx("div",{ref:n,className:"relative overflow-x-auto",children:c>0&&e.jsxs(e.Fragment,{children:[e.jsx(xt,{data:l,width:Math.max(c*d,400),onHover:j}),p&&e.jsx(ut,{item:p.item,position:p.position})]})})]})}function F({label:t,value:s,color:r}){const a={blue:"bg-blue-500/15 text-blue-400",purple:"bg-purple-500/15 text-purple-400",gray:"bg-gray-800 text-gray-300",indigo:"bg-indigo-500/15 text-indigo-400",amber:"bg-amber-500/15 text-amber-400",red:"bg-red-500/15 text-red-400"};return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`rounded-md px-2 py-1 text-sm font-bold tabular-nums ${a[r]}`,children:s}),e.jsx("span",{className:"text-[11px] text-gray-500",children:t})]})}function ft({contextWindow:t,tokens:s}){const[r,a]=S.useState(!1);if(!t)return e.jsx(yt,{tokens:s});const{contextLimit:n,modelName:c,systemOverhead:x,currentContextSize:d,messagesEstimate:o,freeSpace:p,autocompactBuffer:i,usagePercent:l,snapshots:f}=t,j=x/n*100,N=o/n*100,m=i/n*100,h=Math.max(0,100-j-N),u=c.replace(/^claude-/,"").split("-202")[0],v=f.map(g=>({turn:g.turnIndex,context:g.contextSize}));return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Context Window"}),e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:u})]}),e.jsxs("div",{className:"mt-1 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-2xl font-bold text-white",children:C(d)}),e.jsxs("span",{className:"text-sm text-gray-500",children:["/ ",C(n)]}),e.jsxs("span",{className:"text-sm text-gray-400",children:["(",l,"%)"]})]}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"~estimated from token usage"}),e.jsxs("div",{className:"mt-3 flex h-3 overflow-hidden rounded-full bg-gray-800",children:[e.jsx("div",{className:"bg-purple-500",style:{width:`${j}%`},title:`System: ~${C(x)}`}),e.jsx("div",{className:"bg-blue-500",style:{width:`${N}%`},title:`Messages: ~${C(o)}`}),h>0&&e.jsx(e.Fragment,{children:h>m?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-gray-700",style:{width:`${h-m}%`}}),e.jsx("div",{className:"autocompact-stripe",style:{width:`${Math.min(m,h)}%`}})]}):e.jsx("div",{className:"autocompact-stripe",style:{width:`${h}%`}})})]}),e.jsxs("div",{className:"mt-1 flex gap-3 text-[10px] text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-purple-500"}),"system"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-blue-500"}),"messages"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-sm bg-gray-700"}),"free"]})]}),e.jsxs("div",{className:"mt-3 space-y-1.5",children:[e.jsx(Z,{label:"System overhead",value:x,total:n,color:"bg-purple-500",prefix:"~"}),e.jsx(Z,{label:"Messages",value:o,total:n,color:"bg-blue-500",prefix:"~"}),e.jsx(Z,{label:"Autocompact buffer",value:i,total:n,color:"bg-amber-500"}),e.jsx(Z,{label:"Free space",value:p,total:n,color:"bg-gray-600"})]}),v.length>1&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1 text-[10px] text-gray-500",children:"Context growth"}),e.jsx(Xe,{width:"100%",height:96,children:e.jsxs(nt,{data:v,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"contextGrad",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#3b82f6",stopOpacity:.3}),e.jsx("stop",{offset:"100%",stopColor:"#3b82f6",stopOpacity:.05})]})}),e.jsx(Ne,{domain:[0,n],hide:!0}),e.jsx(ze,{contentStyle:{background:"#1f2937",border:"1px solid #374151",borderRadius:"8px",fontSize:"11px"},labelFormatter:g=>`Turn ${g}`,formatter:g=>[C(g),"Context"]}),e.jsx(he,{y:n,stroke:"#ef4444",strokeDasharray:"4 4",strokeOpacity:.5}),e.jsx(he,{y:n-i,stroke:"#f59e0b",strokeDasharray:"2 4",strokeOpacity:.3}),e.jsx($,{type:"stepAfter",dataKey:"context",stroke:"#3b82f6",fill:"url(#contextGrad)",strokeWidth:1.5,dot:!1})]})})]}),e.jsxs("button",{onClick:()=>a(!r),className:"mt-3 flex w-full items-center gap-1 text-xs text-gray-400 hover:text-gray-300 transition-colors",children:[e.jsx("span",{className:"text-[10px]",children:r?"▾":"▸"}),"Token Details"]}),r&&e.jsx(gt,{tokens:s}),e.jsx("style",{children:`
|
|
2
|
+
.autocompact-stripe {
|
|
3
|
+
background: repeating-linear-gradient(
|
|
4
|
+
-45deg,
|
|
5
|
+
#78716c,
|
|
6
|
+
#78716c 2px,
|
|
7
|
+
#f59e0b 2px,
|
|
8
|
+
#f59e0b 4px
|
|
9
|
+
);
|
|
10
|
+
opacity: 0.4;
|
|
11
|
+
}
|
|
12
|
+
`})]})}function Z({label:t,value:s,total:r,color:a,prefix:n=""}){const c=Math.max(0,Math.min(100,s/r*100));return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-32 text-xs text-gray-400 shrink-0",children:t}),e.jsxs("span",{className:"w-16 text-right text-xs font-mono text-gray-300 shrink-0",children:[n,C(s)]}),e.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-gray-800 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${a}`,style:{width:`${c}%`,opacity:.7}})})]})}function gt({tokens:t}){const s=t.inputTokens+t.outputTokens+t.cacheReadInputTokens+t.cacheCreationInputTokens,r=[{label:"Input",value:t.inputTokens,color:"bg-blue-400"},{label:"Output",value:t.outputTokens,color:"bg-emerald-400"},{label:"Cache Read",value:t.cacheReadInputTokens,color:"bg-amber-400"},{label:"Cache Create",value:t.cacheCreationInputTokens,color:"bg-purple-400"}];return e.jsxs("div",{className:"mt-2 space-y-1.5",children:[r.map(a=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:a.label}),e.jsx("span",{className:"text-xs font-mono text-gray-300",children:C(a.value)})]},a.label)),s>0&&e.jsx("div",{className:"flex h-2 overflow-hidden rounded-full bg-gray-800",children:r.filter(a=>a.value>0).map(a=>e.jsx("div",{className:`${a.color} opacity-60`,style:{width:`${a.value/s*100}%`}},a.label))})]})}function yt({tokens:t}){const s=t.inputTokens+t.outputTokens,r=s+t.cacheReadInputTokens+t.cacheCreationInputTokens,a=[{label:"Input",value:t.inputTokens,color:"text-blue-400"},{label:"Output",value:t.outputTokens,color:"text-emerald-400"},{label:"Cache Read",value:t.cacheReadInputTokens,color:"text-amber-400"},{label:"Cache Create",value:t.cacheCreationInputTokens,color:"text-purple-400"}];return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Token Usage"}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-white",children:C(s)}),e.jsxs("p",{className:"text-[10px] text-gray-500",children:["input + output (",C(r)," incl. cache)"]}),e.jsx("div",{className:"mt-3 space-y-2",children:a.map(n=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:n.label}),e.jsx("span",{className:`text-xs font-mono ${n.color}`,children:C(n.value)})]},n.label))}),r>0&&e.jsx("div",{className:"mt-3 flex h-2 overflow-hidden rounded-full bg-gray-800",children:a.filter(n=>n.value>0).map(n=>e.jsx("div",{className:`${n.color.replace("text-","bg-")} opacity-60`,style:{width:`${n.value/r*100}%`}},n.label))})]})}function bt({toolFrequency:t}){const s=Object.entries(t).sort(([,a],[,n])=>n-a),r=s[0]?.[1]??1;return s.length===0?e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tool Usage"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"No tools used"})]}):e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tool Usage"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[s.length," tools, ",s.reduce((a,[,n])=>a+n,0)," calls"]}),e.jsx("div",{className:"mt-3 space-y-1.5",children:s.slice(0,15).map(([a,n])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-32 shrink-0 truncate text-xs font-mono text-gray-400",title:a,children:ie(a)}),e.jsx("div",{className:"flex-1",children:e.jsx("div",{className:"h-4 rounded bg-blue-500/20",style:{width:`${n/r*100}%`},children:e.jsx("span",{className:"px-1.5 text-xs text-blue-300",children:n})})})]},a))})]})}function vt({errors:t}){return t.length===0?null:e.jsxs("div",{className:"rounded-xl border border-red-900/50 bg-red-950/20 p-4",children:[e.jsxs("h3",{className:"text-sm font-semibold text-red-400",children:["Errors (",t.length,")"]}),e.jsx("div",{className:"mt-3 space-y-2",children:t.map((s,r)=>e.jsxs("div",{className:"rounded-lg bg-red-950/30 p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-mono text-red-300",children:s.type}),s.timestamp&&e.jsx("span",{className:"text-xs text-gray-500",children:ve(s.timestamp)})]}),e.jsx("p",{className:"mt-1 text-xs text-red-200/80",children:s.message})]},r))})]})}function jt({agents:t,skills:s}){const{data:r}=be(Ve),{agentCosts:a,totalAgentCost:n}=S.useMemo(()=>{if(!r)return{agentCosts:new Map,totalAgentCost:0};const i=He(r),l=new Map;let f=0;for(let j=0;j<t.length;j++){const N=t[j];if(!N.tokens)continue;const h={[N.model??"claude-sonnet-4"]:N.tokens},u=Ge(h,i);l.set(j,u.totalUSD),f+=u.totalUSD}return{agentCosts:l,totalAgentCost:f}},[r,t]);if(t.length===0&&s.length===0)return null;const c=new Map;for(const i of t)c.set(i.subagentType,(c.get(i.subagentType)??0)+1);const x=[...c.entries()].sort(([,i],[,l])=>l-i),d=t.reduce((i,l)=>i+(l.totalTokens??ye(l)??0),0),o=new Map;for(const i of s)o.set(i.skill,(o.get(i.skill)??0)+1);const p=[...o.entries()].sort(([,i],[,l])=>l-i);return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Agents & Skills"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[t.length," agent dispatch",t.length!==1?"es":"",d>0&&e.jsxs("span",{className:"ml-1 text-indigo-400",children:["(",C(d)," tokens",n>0&&` · ~${H(n)}`,")"]}),s.length>0&&`, ${s.length} skill invocation${s.length!==1?"s":""}`]}),x.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:"Agent Types"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.map(([i,l])=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-indigo-500/15 px-2 py-0.5 text-xs text-indigo-300",children:[i,l>1&&e.jsxs("span",{className:"text-indigo-400/60",children:["×",l]})]},i))})]}),p.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:"Skills"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(([i,l])=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md bg-amber-500/15 px-2 py-0.5 text-xs text-amber-300",children:["/",i,l>1&&e.jsxs("span",{className:"text-amber-400/60",children:["×",l]})]},i))})]}),t.length>0&&e.jsxs("div",{className:"mt-3 space-y-1",children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:"Agent Dispatches"}),t.map((i,l)=>{const f=i.totalTokens??ye(i),j=a.get(l);return e.jsxs("div",{className:"flex items-start gap-2 rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsx("span",{className:"shrink-0 rounded bg-indigo-500/20 px-1.5 py-0.5 text-[10px] font-semibold text-indigo-300",children:i.subagentType}),i.model&&e.jsx("span",{className:"shrink-0 rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:i.model.replace(/^claude-/,"").replace(/-\d{8}$/,"")}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs text-gray-400",children:i.description}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[f!=null&&f>0&&e.jsx("span",{className:"text-[10px] font-mono text-indigo-400/80",children:C(f)}),j!=null&&j>0&&e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400/80",children:["~",H(j)]}),i.totalToolUseCount!=null&&e.jsxs("span",{className:"text-[10px] text-gray-500",children:[i.totalToolUseCount," tools"]}),i.durationMs!=null&&e.jsx("span",{className:"text-[10px] text-gray-600",children:re(i.durationMs)}),i.timestamp&&e.jsx("span",{className:"text-[10px] text-gray-600",children:I(new Date(i.timestamp),"HH:mm:ss")})]})]},`a-${l}`)})]}),s.length>0&&e.jsxs("div",{className:"mt-3 space-y-1",children:[e.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-gray-500",children:"Skill Invocations"}),s.map((i,l)=>e.jsxs("div",{className:"flex items-start gap-2 rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsxs("span",{className:"shrink-0 rounded bg-amber-500/20 px-1.5 py-0.5 text-[10px] font-semibold text-amber-300",children:["/",i.skill]}),i.args&&e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs font-mono text-gray-500",children:i.args}),i.timestamp&&e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-gray-600",children:I(new Date(i.timestamp),"HH:mm:ss")})]},`s-${l}`))]})]})}function ye(t){if(t.tokens)return t.tokens.inputTokens+t.tokens.outputTokens}const Nt={pending:{label:"Pending",bg:"bg-gray-500/20",text:"text-gray-400"},in_progress:{label:"In Progress",bg:"bg-blue-500/20",text:"text-blue-400"},completed:{label:"Done",bg:"bg-emerald-500/20",text:"text-emerald-400"},deleted:{label:"Deleted",bg:"bg-red-500/20",text:"text-red-400"}};function kt({tasks:t}){if(t.length===0)return null;const s=t.filter(a=>a.status==="completed").length,r=t.filter(a=>a.status!=="deleted").length;return e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Tasks"}),e.jsxs("p",{className:"mt-1 text-xs text-gray-500",children:[s,"/",r," completed"]}),e.jsx("div",{className:"mt-3 space-y-1",children:t.map((a,n)=>{const c=Nt[a.status];return e.jsxs("div",{className:"flex items-start gap-2 rounded bg-gray-950/40 px-2 py-1.5",children:[e.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold ${c.bg} ${c.text}`,children:c.label}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"text-xs text-gray-300",children:a.subject}),a.description&&e.jsx("p",{className:"mt-0.5 truncate text-[10px] text-gray-500",children:a.description})]}),a.taskId&&e.jsxs("span",{className:"shrink-0 text-[10px] font-mono text-gray-600",children:["#",a.taskId]}),a.timestamp&&e.jsx("span",{className:"shrink-0 text-[10px] text-gray-600",children:I(new Date(a.timestamp),"HH:mm:ss")})]},a.taskId||n)})})]})}function wt({tokensByModel:t}){const{cost:s,isLoading:r}=ke(t);return r?e.jsx("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:e.jsx("div",{className:"h-6 w-32 animate-pulse rounded bg-gray-800"})}):!s||s.totalUSD===0?e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Cost Estimation"}),e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"No token data available"})]}):e.jsxs("div",{className:"rounded-xl border border-gray-800 bg-gray-900/50 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-300",children:"Cost Estimation"}),e.jsxs("span",{className:"font-mono text-lg font-bold text-white",children:["~",H(s.totalUSD)]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-medium text-gray-400",children:"By Category"}),e.jsx(Tt,{cost:s}),e.jsx(At,{cost:s})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-medium text-gray-400",children:"By Model"}),e.jsx(Mt,{cost:s})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between border-t border-gray-800 pt-3",children:[e.jsx("p",{className:"text-[10px] text-gray-600",children:"Estimated based on API pricing. Actual costs may vary."}),e.jsx(se,{to:"/settings",className:"text-[10px] text-gray-500 hover:text-gray-300",children:"Configure pricing"})]})]})}function Tt({cost:t}){const s=[{label:"Input tokens",value:t.byCategory.input,color:"text-blue-400"},{label:"Output tokens",value:t.byCategory.output,color:"text-emerald-400"},{label:"Cache read",value:t.byCategory.cacheRead,color:"text-amber-400"},{label:"Cache write",value:t.byCategory.cacheWrite,color:"text-purple-400"}];return e.jsx("div",{className:"mt-2 space-y-1",children:s.map(r=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-400",children:r.label}),e.jsx("span",{className:`font-mono text-xs ${r.color}`,children:H(r.value)})]},r.label))})}function At({cost:t}){if(t.totalUSD===0)return null;const s=[{key:"input",value:t.byCategory.input,color:"bg-blue-400"},{key:"output",value:t.byCategory.output,color:"bg-emerald-400"},{key:"cacheRead",value:t.byCategory.cacheRead,color:"bg-amber-400"},{key:"cacheWrite",value:t.byCategory.cacheWrite,color:"bg-purple-400"}];return e.jsx("div",{className:"mt-2 flex h-2 overflow-hidden rounded-full bg-gray-800",children:s.map(r=>{const a=r.value/t.totalUSD*100;return a<.5?null:e.jsx("div",{className:`${r.color} opacity-60`,style:{width:`${a}%`}},r.key)})})}function Mt({cost:t}){const s=Object.values(t.byModel).sort((r,a)=>a.totalCost-r.totalCost);return s.length===0?null:e.jsx("div",{className:"mt-2 space-y-1",children:s.map(r=>{const a=t.totalUSD>0?Math.round(r.totalCost/t.totalUSD*100):0;return e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-mono text-xs text-gray-300",children:r.displayName}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs text-gray-300",children:H(r.totalCost)}),e.jsxs("span",{className:"text-[10px] text-gray-500",children:["(",a,"%)"]}),e.jsxs("span",{className:"text-[10px] text-gray-600",children:[C(r.tokens.inputTokens+r.tokens.outputTokens+r.tokens.cacheReadInputTokens+r.tokens.cacheCreationInputTokens)," ","tok"]})]})]},r.modelId)})})}function Ct({tokensByModel:t}){const{cost:s,isLoading:r}=ke(t);return r||!s||s.totalUSD===0?null:e.jsxs("span",{className:"font-mono text-xs text-emerald-400",title:"Estimated cost based on API pricing",children:["~",H(s.totalUSD)]})}function Et(){const{sessionId:t}=de.useParams(),{project:s=""}=de.useSearch(),{privacyMode:r,anonymizeProjectName:a}=De(),{data:n,isLoading:c,error:x}=be(it(t,s));if(c)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"h-8 w-48 animate-pulse rounded bg-gray-800"}),e.jsx("div",{className:"h-64 animate-pulse rounded-xl bg-gray-900/50"})]});if(x||!n)return e.jsxs("div",{className:"py-12 text-center",children:[e.jsxs("p",{className:"text-sm text-red-400",children:["Failed to load session: ",x?.message??"Not found"]}),e.jsx(se,{to:"/sessions",className:"mt-2 inline-block text-sm text-blue-400 hover:underline",children:"Back to sessions"})]});const d=n.turns[0]?.timestamp,o=n.turns[n.turns.length-1]?.timestamp,p=d&&o?new Date(o).getTime()-new Date(d).getTime():0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(se,{to:"/sessions",className:"text-xs text-gray-500 hover:text-gray-300",children:"← Sessions"}),e.jsx("h1",{className:"mt-1 text-xl font-bold text-white",children:r?a(n.projectName):n.projectName}),e.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs text-gray-400",children:[n.branch&&e.jsx("span",{className:"font-mono",children:n.branch}),d&&e.jsx("span",{children:ve(d)}),e.jsx("span",{children:re(p)}),e.jsxs("span",{children:[n.turns.length," turns"]}),e.jsx(Ct,{tokensByModel:n.tokensByModel})]}),n.models.length>0&&e.jsx("div",{className:"mt-1 flex gap-1",children:n.models.map(i=>e.jsx("span",{className:"rounded bg-gray-800 px-1.5 py-0.5 text-[10px] font-mono text-gray-400",children:i.replace(/^claude-/,"").split("-202")[0]},i))})]}),e.jsx("span",{className:"font-mono text-xs text-gray-600",children:t.slice(0,8)})]}),e.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsx(ft,{contextWindow:n.contextWindow,tokens:n.totalTokens}),e.jsx(bt,{toolFrequency:n.toolFrequency})]}),e.jsx("div",{className:"mt-4",children:e.jsx(wt,{tokensByModel:n.tokensByModel})}),(n.agents.length>0||n.skills.length>0)&&e.jsx("div",{className:"mt-4",children:e.jsx(jt,{agents:n.agents,skills:n.skills})}),n.tasks.length>0&&e.jsx("div",{className:"mt-4",children:e.jsx(kt,{tasks:n.tasks})}),e.jsx(vt,{errors:n.errors}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-gray-300",children:"Timeline"}),e.jsx(ht,{turns:n.turns,agents:n.agents,skills:n.skills,errors:n.errors})]})]})}export{Et as component};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as te,z as L,A as v,l as _,B as m,v as F,C as Q,D as V,E as se,F as E,G as re,H as ne,I as k,q as J,r as y,w as Y,t as ie,J as ae,T as B,K as oe,M as ce}from"./main-Bssrw_E_.js";function $(e){if(Array.isArray(e))return e.flatMap(a=>$(a));if(typeof e!="string")return[];const t=[];let s=0,n,i,c,r,o;const d=()=>{for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;return s<e.length},h=()=>(i=e.charAt(s),i!=="="&&i!==";"&&i!==",");for(;s<e.length;){for(n=s,o=!1;d();)if(i=e.charAt(s),i===","){for(c=s,s+=1,d(),r=s;s<e.length&&h();)s+=1;s<e.length&&e.charAt(s)==="="?(o=!0,s=r,t.push(e.slice(n,c)),n=s):s=c+1}else s+=1;(!o||s>=e.length)&&t.push(e.slice(n))}return t}function he(e){return e instanceof Headers?e:Array.isArray(e)?new Headers(e):typeof e=="object"?new Headers(e):null}function le(...e){return e.reduce((t,s)=>{const n=he(s);if(!n)return t;for(const[i,c]of n.entries())i==="set-cookie"?$(c).forEach(o=>t.append("set-cookie",o)):t.set(i,c);return t},new Headers)}var ue=class extends te{constructor(e,t){super(),this.options=t,this.#s=e,this.#n=null,this.#r=L(),this.bindMethods(),this.setOptions(t)}#s;#e=void 0;#p=void 0;#t=void 0;#a;#l;#r;#n;#v;#u;#d;#o;#c;#i;#f=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#e.addObserver(this),W(this.#e,this.options)?this.#h():this.updateResult(),this.#R())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return P(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return P(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#m(),this.#O(),this.#e.removeObserver(this)}setOptions(e){const t=this.options,s=this.#e;if(this.options=this.#s.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof v(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#g(),this.#e.setOptions(this.options),t._defaulted&&!_(this.options,t)&&this.#s.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const n=this.hasListeners();n&&z(this.#e,s,this.options,t)&&this.#h(),this.updateResult(),n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||m(this.options.staleTime,this.#e)!==m(t.staleTime,this.#e))&&this.#w();const i=this.#y();n&&(this.#e!==s||v(this.options.enabled,this.#e)!==v(t.enabled,this.#e)||i!==this.#i)&&this.#b(i)}getOptimisticResult(e){const t=this.#s.getQueryCache().build(this.#s,e),s=this.createResult(t,e);return fe(this,s)&&(this.#t=s,this.#l=this.options,this.#a=this.#e.state),s}getCurrentResult(){return this.#t}trackResult(e,t){return new Proxy(e,{get:(s,n)=>(this.trackProp(n),t?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#r.status==="pending"&&this.#r.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(s,n))})}trackProp(e){this.#f.add(e)}getCurrentQuery(){return this.#e}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#s.defaultQueryOptions(e),s=this.#s.getQueryCache().build(this.#s,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#t))}#h(e){this.#g();let t=this.#e.fetch(this.options,e);return e?.throwOnError||(t=t.catch(F)),t}#w(){this.#m();const e=m(this.options.staleTime,this.#e);if(Q||this.#t.isStale||!V(e))return;const s=se(this.#t.dataUpdatedAt,e)+1;this.#o=E.setTimeout(()=>{this.#t.isStale||this.updateResult()},s)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#e):this.options.refetchInterval)??!1}#b(e){this.#O(),this.#i=e,!(Q||v(this.options.enabled,this.#e)===!1||!V(this.#i)||this.#i===0)&&(this.#c=E.setInterval(()=>{(this.options.refetchIntervalInBackground||re.isFocused())&&this.#h()},this.#i))}#R(){this.#w(),this.#b(this.#y())}#m(){this.#o&&(E.clearTimeout(this.#o),this.#o=void 0)}#O(){this.#c&&(E.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const s=this.#e,n=this.options,i=this.#t,c=this.#a,r=this.#l,d=e!==s?e.state:this.#p,{state:h}=e;let a={...h},l=!1,u;if(t._optimisticResults){const f=this.hasListeners(),R=!f&&W(e,t),O=f&&z(e,s,t,n);(R||O)&&(a={...a,...ne(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:w,errorUpdatedAt:C,status:p}=a;u=a.data;let D=!1;if(t.placeholderData!==void 0&&u===void 0&&p==="pending"){let f;i?.isPlaceholderData&&t.placeholderData===r?.placeholderData?(f=i.data,D=!0):f=typeof t.placeholderData=="function"?t.placeholderData(this.#d?.state.data,this.#d):t.placeholderData,f!==void 0&&(p="success",u=k(i?.data,f,t),l=!0)}if(t.select&&u!==void 0&&!D)if(i&&u===c?.data&&t.select===this.#v)u=this.#u;else try{this.#v=t.select,u=t.select(u),u=k(i?.data,u,t),this.#u=u,this.#n=null}catch(f){this.#n=f}this.#n&&(w=this.#n,u=this.#u,C=Date.now(),p="error");const M=a.fetchStatus==="fetching",I=p==="pending",x=p==="error",N=I&&M,j=u!==void 0,b={status:p,fetchStatus:a.fetchStatus,isPending:I,isSuccess:p==="success",isError:x,isInitialLoading:N,isLoading:N,data:u,dataUpdatedAt:a.dataUpdatedAt,error:w,errorUpdatedAt:C,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:a.dataUpdateCount>0||a.errorUpdateCount>0,isFetchedAfterMount:a.dataUpdateCount>d.dataUpdateCount||a.errorUpdateCount>d.errorUpdateCount,isFetching:M,isRefetching:M&&!I,isLoadingError:x&&!j,isPaused:a.fetchStatus==="paused",isPlaceholderData:l,isRefetchError:x&&j,isStale:A(e,t),refetch:this.refetch,promise:this.#r,isEnabled:v(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const f=b.data!==void 0,R=b.status==="error"&&!f,O=S=>{R?S.reject(b.error):f&&S.resolve(b.data)},H=()=>{const S=this.#r=b.promise=L();O(S)},g=this.#r;switch(g.status){case"pending":e.queryHash===s.queryHash&&O(g);break;case"fulfilled":(R||b.data!==g.value)&&H();break;case"rejected":(!R||b.error!==g.reason)&&H();break}}return b}updateResult(){const e=this.#t,t=this.createResult(this.#e,this.options);if(this.#a=this.#e.state,this.#l=this.options,this.#a.data!==void 0&&(this.#d=this.#e),_(t,e))return;this.#t=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!this.#f.size)return!0;const c=new Set(i??this.#f);return this.options.throwOnError&&c.add("error"),Object.keys(this.#t).some(r=>{const o=r;return this.#t[o]!==e[o]&&c.has(o)})};this.#S({listeners:s()})}#g(){const e=this.#s.getQueryCache().build(this.#s,this.options);if(e===this.#e)return;const t=this.#e;this.#e=e,this.#p=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#R()}#S(e){J.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#t)}),this.#s.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function de(e,t){return v(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function W(e,t){return de(e,t)||e.state.data!==void 0&&P(e,t,t.refetchOnMount)}function P(e,t,s){if(v(t.enabled,e)!==!1&&m(t.staleTime,e)!=="static"){const n=typeof s=="function"?s(e):s;return n==="always"||n!==!1&&A(e,t)}return!1}function z(e,t,s,n){return(e!==t||v(n.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&A(e,s)}function A(e,t){return v(t.enabled,e)!==!1&&e.isStaleByTime(m(t.staleTime,e))}function fe(e,t){return!_(e.getCurrentResult(),t)}var X=y.createContext(!1),pe=()=>y.useContext(X);X.Provider;function ve(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var we=y.createContext(ve()),ye=()=>y.useContext(we),be=(e,t,s)=>{const n=s?.state.error&&typeof e.throwOnError=="function"?Y(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||n)&&(t.isReset()||(e.retryOnMount=!1))},Re=e=>{y.useEffect(()=>{e.clearReset()},[e])},me=({result:e,errorResetBoundary:t,throwOnError:s,query:n,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&n&&(i&&e.data===void 0||Y(s,[e.error,n])),Oe=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...i)=>s(n(...i)):s(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ge=(e,t)=>e.isLoading&&e.isFetching&&!t,Se=(e,t)=>e?.suspense&&t.isPending,G=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ee(e,t,s){const n=pe(),i=ye(),c=ie(),r=c.defaultQueryOptions(e);c.getDefaultOptions().queries?._experimental_beforeQuery?.(r);const o=c.getQueryCache().get(r.queryHash);r._optimisticResults=n?"isRestoring":"optimistic",Oe(r),be(r,i,o),Re(i);const d=!c.getQueryCache().get(r.queryHash),[h]=y.useState(()=>new t(c,r)),a=h.getOptimisticResult(r),l=!n&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(u=>{const w=l?h.subscribe(J.batchCalls(u)):F;return h.updateResult(),w},[h,l]),()=>h.getCurrentResult(),()=>h.getCurrentResult()),y.useEffect(()=>{h.setOptions(r)},[r,h]),Se(r,a))throw G(r,h,i);if(me({result:a,errorResetBoundary:i,throwOnError:r.throwOnError,query:o,suspense:r.suspense}))throw a.error;return c.getDefaultOptions().queries?._experimental_afterQuery?.(r,a),r.experimental_prefetchInRender&&!Q&&ge(a,n)&&(d?G(r,h,i):o?.promise)?.catch(F).finally(()=>{h.updateResult()}),r.notifyOnChangeProps?a:h.trackResult(a)}function _e(e,t){return Ee(e,ue)}function Fe(e){return e}const Z=()=>{throw new Error("createServerOnlyFn() functions can only be called on the server!")};function K(e){return e!=="__proto__"&&e!=="constructor"&&e!=="prototype"}function U(e,t){const s=Object.create(null);if(e)for(const n of Object.keys(e))K(n)&&(s[n]=e[n]);if(t&&typeof t=="object")for(const n of Object.keys(t))K(n)&&(s[n]=t[n]);return s}function ee(e){return Object.create(null)}const T=(e,t)=>{const s=t||e||{};return typeof s.method>"u"&&(s.method="GET"),Object.assign(c=>{const r={...s,...c};return T(void 0,r)},{options:s,middleware:c=>{const r=[...s.middleware||[]];c.map(h=>{B in h?h.options.middleware&&r.push(...h.options.middleware):r.push(h)});const o={...s,middleware:r},d=T(void 0,o);return d[B]=!0,d},inputValidator:c=>{const r={...s,inputValidator:c};return T(void 0,r)},handler:(...c)=>{const[r,o]=c,d={...s,extractedFn:r,serverFn:o},h=[...d.middleware||[],Ie(d)];return Object.assign(async a=>{const l=await q(h,"client",{...r,...d,data:a?.data,headers:a?.headers,signal:a?.signal,fetch:a?.fetch,context:ee()}),u=ae(l.error);if(u)throw u;if(l.error)throw l.error;return l.result},{...r,__executeServer:async a=>{const l=Z(),u=l.contextAfterGlobalMiddlewares,w={...r,...a,serverFnMeta:r.serverFnMeta,context:U(u,a.context),request:l.request};return await q(h,"server",w).then(p=>({result:p.result,error:p.error,context:p.sendContext}))}})}})};async function q(e,t,s){const n=oe()?.functionMiddleware||[];let i=Ce([...n,...e]);if(t==="server"){const r=Z();r?.executedRequestMiddlewares&&(i=i.filter(o=>!r.executedRequestMiddlewares.has(o)))}const c=async r=>{const o=i.shift();if(!o)return r;try{"inputValidator"in o.options&&o.options.inputValidator&&t==="server"&&(r.data=await Me(o.options.inputValidator,r.data));let d;if(t==="client"?"client"in o.options&&(d=o.options.client):"server"in o.options&&(d=o.options.server),d){const a=await d({...r,next:async(l={})=>{const u={...r,...l,context:U(r.context,l.context),sendContext:U(r.sendContext,l.sendContext),headers:le(r.headers,l.headers),_callSiteFetch:r._callSiteFetch,fetch:r._callSiteFetch??l.fetch??r.fetch,result:l.result!==void 0?l.result:l instanceof Response?l:r.result,error:l.error??r.error},w=await c(u);if(w.error)throw w.error;return w}});if(ce(a))return{...r,error:a};if(a instanceof Response)return{...r,result:a};if(!a)throw new Error("User middleware returned undefined. You must call next() or return a result in your middlewares.");return a}return c(r)}catch(d){return{...r,error:d}}};return c({...s,headers:s.headers||{},sendContext:s.sendContext||{},context:s.context||ee(),_callSiteFetch:s.fetch})}function Ce(e,t=100){const s=new Set,n=[],i=(c,r)=>{if(r>t)throw new Error(`Middleware nesting depth exceeded maximum of ${t}. Check for circular references.`);c.forEach(o=>{o.options.middleware&&i(o.options.middleware,r+1),s.has(o)||(s.add(o),n.push(o))})};return i(e,0),n}async function Me(e,t){if(e==null)return{};if("~standard"in e){const s=await e["~standard"].validate(t);if(s.issues)throw new Error(JSON.stringify(s.issues,void 0,2));return s.value}if("parse"in e)return e.parse(t);if(typeof e=="function")return e(t);throw new Error("Invalid validator type!")}function Ie(e){return{"~types":void 0,options:{inputValidator:e.inputValidator,client:async({next:t,sendContext:s,fetch:n,...i})=>{const c={...i,context:s,fetch:n},r=await e.extractedFn?.(c);return t(r)},server:async({next:t,...s})=>{const n=await e.serverFn?.(s);return t({...s,result:n})}}}}export{T as c,Fe as q,_e as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const F=Symbol.for("constructDateFrom");function g(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&F in t?t[F](e):t instanceof Date?new t.constructor(e):new Date(e)}function m(t,e){return g(e||t,t)}let Q={};function x(){return Q}function P(t,e){const n=x(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,a=m(t,e?.in),o=a.getDay(),s=(o<r?7:0)+o-r;return a.setDate(a.getDate()-s),a.setHours(0,0,0,0),a}function v(t,e){return P(t,{...e,weekStartsOn:1})}function H(t,e){const n=m(t,e?.in),r=n.getFullYear(),a=g(n,0);a.setFullYear(r+1,0,4),a.setHours(0,0,0,0);const o=v(a),s=g(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);const i=v(s);return n.getTime()>=o.getTime()?r+1:n.getTime()>=i.getTime()?r:r-1}function S(t){const e=m(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function W(t,...e){const n=g.bind(null,t||e.find(r=>typeof r=="object"));return e.map(n)}function E(t,e){const n=m(t,e?.in);return n.setHours(0,0,0,0),n}function B(t,e,n){const[r,a]=W(n?.in,t,e),o=E(r),s=E(a),i=+o-S(o),f=+s-S(s);return Math.round((i-f)/864e5)}function L(t,e){const n=H(t,e),r=g(t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),v(r)}function k(t,e){const n=+m(t)-+m(e);return n<0?-1:n>0?1:n}function j(t){return g(t,Date.now())}function G(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function R(t){return!(!G(t)&&typeof t!="number"||isNaN(+m(t)))}function A(t,e,n){const[r,a]=W(n?.in,t,e),o=r.getFullYear()-a.getFullYear(),s=r.getMonth()-a.getMonth();return o*12+s}function V(t){return e=>{const r=(t?Math[t]:Math.trunc)(e);return r===0?0:r}}function J(t,e){return+m(t)-+m(e)}function z(t,e){const n=m(t,e?.in);return n.setHours(23,59,59,999),n}function U(t,e){const n=m(t,e?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function K(t,e){const n=m(t,e?.in);return+z(n,e)==+U(n,e)}function Z(t,e,n){const[r,a,o]=W(n?.in,t,t,e),s=k(a,o),i=Math.abs(A(a,o));if(i<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-s*i);let f=k(a,o)===-s;K(r)&&i===1&&k(r,o)===1&&(f=!1);const l=s*(i-+f);return l===0?0:l}function tt(t,e,n){const r=J(t,e)/1e3;return V(n?.roundingMethod)(r)}function et(t,e){const n=m(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}const nt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},rt=(t,e,n)=>{let r;const a=nt[t];return typeof a=="string"?r=a:e===1?r=a.one:r=a.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function T(t){return(e={})=>{const n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const at={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},ot={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},it={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},st={date:T({formats:at,defaultWidth:"full"}),time:T({formats:ot,defaultWidth:"full"}),dateTime:T({formats:it,defaultWidth:"full"})},ut={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ct=(t,e,n,r)=>ut[t];function p(t){return(e,n)=>{const r=n?.context?String(n.context):"standalone";let a;if(r==="formatting"&&t.formattingValues){const s=t.defaultFormattingWidth||t.defaultWidth,i=n?.width?String(n.width):s;a=t.formattingValues[i]||t.formattingValues[s]}else{const s=t.defaultWidth,i=n?.width?String(n.width):t.defaultWidth;a=t.values[i]||t.values[s]}const o=t.argumentCallback?t.argumentCallback(e):e;return a[o]}}const dt={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},ft={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ht={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},mt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},lt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},gt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},wt=(t,e)=>{const n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},yt={ordinalNumber:wt,era:p({values:dt,defaultWidth:"wide"}),quarter:p({values:ft,defaultWidth:"wide",argumentCallback:t=>t-1}),month:p({values:ht,defaultWidth:"wide"}),day:p({values:mt,defaultWidth:"wide"}),dayPeriod:p({values:lt,defaultWidth:"wide",formattingValues:gt,defaultFormattingWidth:"wide"})};function O(t){return(e,n={})=>{const r=n.width,a=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],o=e.match(a);if(!o)return null;const s=o[0],i=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],f=Array.isArray(i)?Mt(i,d=>d.test(s)):bt(i,d=>d.test(s));let l;l=t.valueCallback?t.valueCallback(f):f,l=n.valueCallback?n.valueCallback(l):l;const c=e.slice(s.length);return{value:l,rest:c}}}function bt(t,e){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Mt(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function Dt(t){return(e,n={})=>{const r=e.match(t.matchPattern);if(!r)return null;const a=r[0],o=e.match(t.parsePattern);if(!o)return null;let s=t.valueCallback?t.valueCallback(o[0]):o[0];s=n.valueCallback?n.valueCallback(s):s;const i=e.slice(a.length);return{value:s,rest:i}}}const pt=/^(\d+)(th|st|nd|rd)?/i,Ot=/\d+/i,Pt={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},xt={any:[/^b/i,/^(a|c)/i]},kt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},vt={any:[/1/i,/2/i,/3/i,/4/i]},St={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Wt={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Yt={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Tt={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ft={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Et={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ct={ordinalNumber:Dt({matchPattern:pt,parsePattern:Ot,valueCallback:t=>parseInt(t,10)}),era:O({matchPatterns:Pt,defaultMatchWidth:"wide",parsePatterns:xt,defaultParseWidth:"any"}),quarter:O({matchPatterns:kt,defaultMatchWidth:"wide",parsePatterns:vt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:O({matchPatterns:St,defaultMatchWidth:"wide",parsePatterns:Wt,defaultParseWidth:"any"}),day:O({matchPatterns:Yt,defaultMatchWidth:"wide",parsePatterns:Tt,defaultParseWidth:"any"}),dayPeriod:O({matchPatterns:Ft,defaultMatchWidth:"any",parsePatterns:Et,defaultParseWidth:"any"})},_={code:"en-US",formatDistance:rt,formatLong:st,formatRelative:ct,localize:yt,match:Ct,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Nt(t,e){const n=m(t,e?.in);return B(n,et(n))+1}function qt(t,e){const n=m(t,e?.in),r=+v(n)-+L(n);return Math.round(r/6048e5)+1}function I(t,e){const n=m(t,e?.in),r=n.getFullYear(),a=x(),o=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=g(e?.in||t,0);s.setFullYear(r+1,0,o),s.setHours(0,0,0,0);const i=P(s,e),f=g(e?.in||t,0);f.setFullYear(r,0,o),f.setHours(0,0,0,0);const l=P(f,e);return+n>=+i?r+1:+n>=+l?r:r-1}function Xt(t,e){const n=x(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=I(t,e),o=g(e?.in||t,0);return o.setFullYear(a,0,r),o.setHours(0,0,0,0),P(o,e)}function Ht(t,e){const n=m(t,e?.in),r=+P(n,e)-+Xt(n,e);return Math.round(r/6048e5)+1}function u(t,e){const n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}const y={y(t,e){const n=t.getFullYear(),r=n>0?n:1-n;return u(e==="yy"?r%100:r,e.length)},M(t,e){const n=t.getMonth();return e==="M"?String(n+1):u(n+1,2)},d(t,e){return u(t.getDate(),e.length)},a(t,e){const n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(t,e){return u(t.getHours()%12||12,e.length)},H(t,e){return u(t.getHours(),e.length)},m(t,e){return u(t.getMinutes(),e.length)},s(t,e){return u(t.getSeconds(),e.length)},S(t,e){const n=e.length,r=t.getMilliseconds(),a=Math.trunc(r*Math.pow(10,n-3));return u(a,e.length)}},D={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},C={G:function(t,e,n){const r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){const r=t.getFullYear(),a=r>0?r:1-r;return n.ordinalNumber(a,{unit:"year"})}return y.y(t,e)},Y:function(t,e,n,r){const a=I(t,r),o=a>0?a:1-a;if(e==="YY"){const s=o%100;return u(s,2)}return e==="Yo"?n.ordinalNumber(o,{unit:"year"}):u(o,e.length)},R:function(t,e){const n=H(t);return u(n,e.length)},u:function(t,e){const n=t.getFullYear();return u(n,e.length)},Q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return u(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){const r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return u(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){const r=t.getMonth();switch(e){case"M":case"MM":return y.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){const r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return u(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){const a=Ht(t,r);return e==="wo"?n.ordinalNumber(a,{unit:"week"}):u(a,e.length)},I:function(t,e,n){const r=qt(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):u(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):y.d(t,e)},D:function(t,e,n){const r=Nt(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):u(r,e.length)},E:function(t,e,n){const r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){const a=t.getDay(),o=(a-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(o);case"ee":return u(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(a,{width:"short",context:"formatting"});default:return n.day(a,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){const a=t.getDay(),o=(a-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(o);case"cc":return u(o,e.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(a,{width:"narrow",context:"standalone"});case"cccccc":return n.day(a,{width:"short",context:"standalone"});default:return n.day(a,{width:"wide",context:"standalone"})}},i:function(t,e,n){const r=t.getDay(),a=r===0?7:r;switch(e){case"i":return String(a);case"ii":return u(a,e.length);case"io":return n.ordinalNumber(a,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){const a=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(t,e,n){const r=t.getHours();let a;switch(r===12?a=D.noon:r===0?a=D.midnight:a=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(t,e,n){const r=t.getHours();let a;switch(r>=17?a=D.evening:r>=12?a=D.afternoon:r>=4?a=D.morning:a=D.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(a,{width:"narrow",context:"formatting"});default:return n.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return y.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):y.H(t,e)},K:function(t,e,n){const r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):u(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):u(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):y.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):y.s(t,e)},S:function(t,e){return y.S(t,e)},X:function(t,e,n){const r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return q(r);case"XXXX":case"XX":return b(r);default:return b(r,":")}},x:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"x":return q(r);case"xxxx":case"xx":return b(r);default:return b(r,":")}},O:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+N(r,":");default:return"GMT"+b(r,":")}},z:function(t,e,n){const r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+N(r,":");default:return"GMT"+b(r,":")}},t:function(t,e,n){const r=Math.trunc(+t/1e3);return u(r,e.length)},T:function(t,e,n){return u(+t,e.length)}};function N(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=Math.trunc(r/60),o=r%60;return o===0?n+String(a):n+String(a)+e+u(o,2)}function q(t,e){return t%60===0?(t>0?"-":"+")+u(Math.abs(t)/60,2):b(t,e)}function b(t,e=""){const n=t>0?"-":"+",r=Math.abs(t),a=u(Math.trunc(r/60),2),o=u(r%60,2);return n+a+e+o}const X=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});default:return e.date({width:"full"})}},$=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});default:return e.time({width:"full"})}},_t=(t,e)=>{const n=t.match(/(P+)(p+)?/)||[],r=n[1],a=n[2];if(!a)return X(t,e);let o;switch(r){case"P":o=e.dateTime({width:"short"});break;case"PP":o=e.dateTime({width:"medium"});break;case"PPP":o=e.dateTime({width:"long"});break;default:o=e.dateTime({width:"full"});break}return o.replace("{{date}}",X(r,e)).replace("{{time}}",$(a,e))},It={p:$,P:_t},$t=/^D+$/,Qt=/^Y+$/,Bt=["D","DD","YY","YYYY"];function Lt(t){return $t.test(t)}function jt(t){return Qt.test(t)}function Gt(t,e,n){const r=Rt(t,e,n);if(console.warn(r),Bt.includes(t))throw new RangeError(r)}function Rt(t,e,n){const r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const At=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Vt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Jt=/^'([^]*?)'?$/,zt=/''/g,Ut=/[a-zA-Z]/;function Kt(t,e,n){const r=x(),a=r.locale??_,o=r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=m(t,n?.in);if(!R(i))throw new RangeError("Invalid time value");let f=e.match(Vt).map(c=>{const d=c[0];if(d==="p"||d==="P"){const h=It[d];return h(c,a.formatLong)}return c}).join("").match(At).map(c=>{if(c==="''")return{isToken:!1,value:"'"};const d=c[0];if(d==="'")return{isToken:!1,value:Zt(c)};if(C[d])return{isToken:!0,value:c};if(d.match(Ut))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:c}});a.localize.preprocessor&&(f=a.localize.preprocessor(i,f));const l={firstWeekContainsDate:o,weekStartsOn:s,locale:a};return f.map(c=>{if(!c.isToken)return c.value;const d=c.value;(jt(d)||Lt(d))&&Gt(d,e,String(t));const h=C[d[0]];return h(i,d,a.localize,l)}).join("")}function Zt(t){const e=t.match(Jt);return e?e[1].replace(zt,"'"):t}function te(t,e,n){const r=x(),a=n?.locale??r.locale??_,o=2520,s=k(t,e);if(isNaN(s))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:s}),[f,l]=W(n?.in,...s>0?[e,t]:[t,e]),c=tt(l,f),d=(S(l)-S(f))/1e3,h=Math.round((c-d)/60);let M;if(h<2)return n?.includeSeconds?c<5?a.formatDistance("lessThanXSeconds",5,i):c<10?a.formatDistance("lessThanXSeconds",10,i):c<20?a.formatDistance("lessThanXSeconds",20,i):c<40?a.formatDistance("halfAMinute",0,i):c<60?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",1,i):h===0?a.formatDistance("lessThanXMinutes",1,i):a.formatDistance("xMinutes",h,i);if(h<45)return a.formatDistance("xMinutes",h,i);if(h<90)return a.formatDistance("aboutXHours",1,i);if(h<1440){const w=Math.round(h/60);return a.formatDistance("aboutXHours",w,i)}else{if(h<o)return a.formatDistance("xDays",1,i);if(h<43200){const w=Math.round(h/1440);return a.formatDistance("xDays",w,i)}else if(h<43200*2)return M=Math.round(h/43200),a.formatDistance("aboutXMonths",M,i)}if(M=Z(l,f),M<12){const w=Math.round(h/43200);return a.formatDistance("xMonths",w,i)}else{const w=M%12,Y=Math.trunc(M/12);return w<3?a.formatDistance("aboutXYears",Y,i):w<9?a.formatDistance("overXYears",Y,i):a.formatDistance("almostXYears",Y+1,i)}}function ee(t,e){return te(t,j(t),e)}function ne(t){if(t<1e3)return"<1s";const e=Math.floor(t/1e3),n=Math.floor(e/60),r=Math.floor(n/60);if(r>0){const a=n%60;return a>0?`${r}h ${a}m`:`${r}h`}if(n>0){const a=e%60;return a>0?`${n}m ${a}s`:`${n}m`}return`${e}s`}function re(t){return ee(new Date(t),{addSuffix:!0})}function ae(t){return Kt(new Date(t),"MMM d, yyyy HH:mm")}function oe(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function ie(t){return t>=1073741824?`${(t/1073741824).toFixed(1)} GB`:t>=1048576?`${(t/1048576).toFixed(1)} MB`:t>=1024?`${(t/1024).toFixed(1)} KB`:`${t} B`}function se(t){return Number.isFinite(t)?t<.005?"<$0.01":t>=100?`$${Math.round(t)}`:`$${t.toFixed(2)}`:"$0.00"}export{oe as a,se as b,ne as c,re as d,ie as e,Kt as f,ae as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as j,o as M,s as N,e as q,n as S,k as $,j as e,r as x,u as A,L as F,b as T,d as I}from"./main-Bssrw_E_.js";import{c as v,q as E,u as w}from"./createServerFn-Bmn60lX_.js";import{c as z,d as G,e as _}from"./format-Bf-cSf6L.js";v({method:"GET"}).handler(j("bf8e4a7901f1843bdc9c46be1ad5ad59c615b8bbe611b73eb3ff28f20e43ee0d"));const B=v({method:"GET"}).handler(j("839d29fe93dfa2a6d506af7b48ca25197190a5ff4c796e970ddfdc6e8c98827f"));M({page:S().int().min(1),pageSize:S().int().min(5).max(100),search:N(),status:q(["all","active","completed"]),project:N()});const K=v({method:"GET"}).handler(j("a3f42f9012fd83586787da8f7cb90649da739dd947d867eb67572f68735ff495")),Q=E({queryKey:["sessions","active"],queryFn:()=>B(),refetchInterval:3e3});function O(t){return E({queryKey:["sessions","paginated",t],queryFn:()=>K({data:t}),placeholderData:$,refetchInterval:3e4})}function V({isActive:t}){return t?e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-0.5 text-xs font-medium text-emerald-400",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-emerald-500"})]}),"Active"]}):e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-gray-500/15 px-2.5 py-0.5 text-xs font-medium text-gray-400",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-gray-500"}),"Completed"]})}function Y({startedAt:t}){const[l,n]=x.useState(()=>Date.now()-new Date(t).getTime());return x.useEffect(()=>{const s=setInterval(()=>{n(Date.now()-new Date(t).getTime())},1e3);return()=>clearInterval(s)},[t]),e.jsx("span",{className:"text-emerald-400",children:z(l)})}function Z({session:t}){const{privacyMode:l,anonymizePath:n,anonymizeProjectName:s}=A(),c=l?s(t.projectName):t.projectName,a=t.cwd?l?n(t.cwd):t.cwd:null;return e.jsxs(F,{to:"/sessions/$sessionId",params:{sessionId:t.sessionId},search:{project:t.projectPath},className:"group block rounded-xl border border-gray-800 bg-gray-900/50 p-4 transition-all hover:border-gray-700 hover:bg-gray-900",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"truncate text-sm font-semibold text-white",children:c}),e.jsx(V,{isActive:t.isActive})]}),t.branch&&e.jsx("p",{className:"mt-1 truncate text-xs text-gray-500",children:e.jsx("span",{className:"font-mono",children:t.branch})})]}),e.jsx("span",{className:"shrink-0 text-xs text-gray-500",children:G(t.lastActiveAt)})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-400",children:[e.jsx("span",{title:"Duration",children:t.isActive?e.jsx(Y,{startedAt:t.startedAt}):z(t.durationMs)}),e.jsxs("span",{title:"Messages",children:[t.messageCount," msgs"]}),t.model&&e.jsx("span",{title:"Model",className:"truncate font-mono text-gray-500",children:t.model.replace(/^claude-/,"").split("-202")[0]}),e.jsx("span",{title:"File size",className:"text-gray-500",children:_(t.fileSizeBytes)})]}),a&&e.jsx("p",{className:"mt-2 truncate text-xs font-mono text-gray-600",children:a})]})}function H({projects:t,activeCount:l}){const n=T(),{search:s,status:c,project:a}=I.useSearch(),{privacyMode:i,anonymizeProjectName:f}=A(),[h,d]=x.useState(s),o=x.useRef(null);x.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),x.useEffect(()=>{d(s)},[s]);function p(r){d(r),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{n({to:"/sessions",search:m=>({...m,search:r,page:1})})},300)}function y(r){n({to:"/sessions",search:m=>({...m,status:r,page:1})})}function b(r){n({to:"/sessions",search:m=>({...m,project:r,page:1})})}return e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"text",placeholder:"Search sessions...",value:h,onChange:r=>p(r.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 placeholder-gray-500 outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500"}),e.jsx("div",{className:"flex rounded-lg border border-gray-700 text-xs",children:["all","active","completed"].map(r=>e.jsxs("button",{onClick:()=>y(r),className:`px-3 py-1.5 capitalize transition-colors ${c===r?"bg-gray-700 text-white":"text-gray-400 hover:text-gray-200"} ${r==="all"?"rounded-l-lg":""} ${r==="completed"?"rounded-r-lg":""}`,children:[r,r==="active"&&l>0&&e.jsxs("span",{className:"ml-1 text-emerald-400",children:["(",l,")"]})]},r))}),t.length>1&&e.jsxs("select",{value:a,onChange:r=>b(r.target.value),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-3 py-1.5 text-sm text-gray-200 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",children:"All projects"}),t.map(r=>e.jsx("option",{value:r,children:i?f(r):r},r))]})]})}const P="claude-dashboard:page-size",k=[5,10,25,50];function C(t){return k.includes(t)}function J(){const[t,l]=x.useState(null);x.useEffect(()=>{try{const s=localStorage.getItem(P);if(s!==null){const c=Number(s);C(c)&&l(c)}}catch{}},[]);const n=x.useCallback(s=>{if(C(s))try{localStorage.setItem(P,String(s)),l(s)}catch{}},[]);return{storedPageSize:t,setPageSize:n}}function U({page:t,totalPages:l,totalCount:n,pageSize:s,onPageChange:c,onPageSizeChange:a}){if(n===0)return null;const i=(t-1)*s+1,f=Math.min(t*s,n),h=l>1,d=h?W(t,l):[];return e.jsxs("div",{className:"flex flex-col items-center gap-3 sm:flex-row sm:justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("select",{value:s,onChange:o=>a(Number(o.target.value)),className:"rounded-lg border border-gray-700 bg-gray-800/50 px-2 py-1 text-xs text-gray-200 outline-none focus:border-blue-500",children:k.map(o=>e.jsxs("option",{value:o,children:[o," / page"]},o))}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Showing"," ",e.jsxs("span",{className:"font-mono text-gray-300",children:[i,"-",f]})," ","of"," ",e.jsx("span",{className:"font-mono text-gray-300",children:n})," sessions"]})]}),h&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>c(t-1),disabled:t<=1,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Previous"}),d.map((o,p)=>o==="ellipsis"?e.jsx("span",{className:"px-1.5 text-xs text-gray-500",children:"..."},`ellipsis-${p}`):e.jsx("button",{onClick:()=>c(o),className:`min-w-[2rem] rounded-lg px-2 py-1.5 text-xs font-mono transition-colors ${o===t?"bg-blue-600 text-white":"border border-gray-700 bg-gray-800 text-gray-400 hover:bg-gray-700 hover:text-gray-200"}`,children:o},o)),e.jsx("button",{onClick:()=>c(t+1),disabled:t>=l,className:"rounded-lg border border-gray-700 bg-gray-800 px-2.5 py-1.5 text-xs text-gray-400 transition-colors hover:bg-gray-700 hover:text-gray-200 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-gray-800 disabled:hover:text-gray-400",children:"Next"})]})]})}function W(t,l){if(l<=7)return Array.from({length:l},(a,i)=>i+1);const n=new Set;n.add(1),n.add(l);for(let a=t-2;a<=t+2;a++)a>=1&&a<=l&&n.add(a);const s=Array.from(n).sort((a,i)=>a-i),c=[];for(let a=0;a<s.length;a++)a>0&&s[a]-s[a-1]>1&&c.push("ellipsis"),c.push(s[a]);return c}function X(){const t=T(),{page:l,pageSize:n,search:s,status:c,project:a}=I.useSearch(),{storedPageSize:i,setPageSize:f}=J(),h=x.useRef(!1);x.useEffect(()=>{i!==null&&!h.current&&i!==n&&(h.current=!0,t({to:"/sessions",search:u=>({...u,pageSize:i,page:1}),replace:!0}))},[i,n,t]);const{data:d,isLoading:o}=w(O({page:l,pageSize:n,search:s,status:c,project:a})),{data:p=[]}=w(Q),y=x.useMemo(()=>{if(!d)return[];const u=new Set(p.map(g=>g.sessionId));return d.sessions.map(g=>({...g,isActive:u.has(g.sessionId)||g.isActive}))},[d,p]);function b(u){t({to:"/sessions",search:g=>({...g,page:u})})}function r(u){f(u),t({to:"/sessions",search:g=>({...g,pageSize:u,page:1})})}if(o)return e.jsx("div",{className:"space-y-3",children:Array.from({length:n}).map((u,g)=>e.jsx("div",{className:"h-28 animate-pulse rounded-xl border border-gray-800 bg-gray-900/50"},g))});const m=d?.totalCount??0,D=d?.totalPages??1,R=d?.projects??[],L=p.length;return e.jsxs("div",{children:[e.jsx(H,{projects:R,activeCount:L}),e.jsx("div",{className:"mt-4 space-y-2",children:y.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-gray-500",children:m===0&&!s&&c==="all"&&!a?"No sessions found in ~/.claude":"No sessions match your filters"}):y.map(u=>e.jsx(Z,{session:u},u.sessionId))}),e.jsx("div",{className:"mt-4",children:e.jsx(U,{page:d?.page??l,totalPages:D,totalCount:m,pageSize:n,onPageChange:b,onPageSizeChange:r})})]})}function ae(){return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Sessions"}),e.jsx("p",{className:"mt-1 text-sm text-gray-400",children:"All Claude Code sessions from ~/.claude"}),e.jsx("div",{className:"mt-6",children:e.jsx(X,{})})]})}export{ae as component};
|