codesesh 1.0.4 → 1.0.6
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/README.md +5 -4
- package/dist/{chunk-W4PZHL2C.js → chunk-4ND6AT6W.js} +154 -92
- package/dist/chunk-4ND6AT6W.js.map +1 -0
- package/dist/chunk-4QFNZCBR.js +1271 -0
- package/dist/chunk-4QFNZCBR.js.map +1 -0
- package/dist/{chunk-MBZ4VV4C.js → chunk-A3MT6L6Z.js} +3 -3
- package/dist/chunk-COZSWVCH.js +89 -0
- package/dist/chunk-COZSWVCH.js.map +1 -0
- package/dist/{chunk-YCUN52HA.js → chunk-L3DDWTYV.js} +81 -115
- package/dist/chunk-L3DDWTYV.js.map +1 -0
- package/dist/{chunk-BYB77UAJ.js → chunk-XQDYKKRC.js} +139 -80
- package/dist/chunk-XQDYKKRC.js.map +1 -0
- package/dist/{chunk-3SXCTDD6.js → chunk-YZ6XCSVQ.js} +4 -3
- package/dist/{discovery-K3GLISI6.js → discovery-ADSQARBV.js} +11 -5
- package/dist/index.js +1538 -1030
- package/dist/index.js.map +1 -1
- package/dist/project-identity-worker.js +4 -4
- package/dist/scan-refresh-worker.js +17 -7
- package/dist/scan-refresh-worker.js.map +1 -1
- package/dist/search-index-worker.js +16 -8
- package/dist/search-index-worker.js.map +1 -1
- package/dist/session-detail-worker.js +79 -0
- package/dist/session-detail-worker.js.map +1 -0
- package/dist/smart-tag-worker.js +3 -3
- package/dist/web/assets/CustomTimeWindowDialog-D2bx7uDv.js +1 -0
- package/dist/web/assets/InteractiveReceipt-BFpIdno8.js +1 -0
- package/dist/web/assets/OverviewScreen-D_KXfiJi.js +1 -0
- package/dist/web/assets/{PrismHighlighter-B1a2dPJO.js → PrismHighlighter-BgVkYu_S.js} +1 -1
- package/dist/web/assets/Projects-CN44UpuR.js +1 -0
- package/dist/web/assets/SearchResultsPanel-CWD01v-a.js +1 -0
- package/dist/web/assets/SessionDetail-D8taQ6Tl.js +53 -0
- package/dist/web/assets/api-B9lJtVbO.js +1 -0
- package/dist/web/assets/index-XpolWMY4.js +1423 -0
- package/dist/web/assets/index-xbEEMszv.css +1 -0
- package/dist/web/assets/session-indexes-fib48ZKn.js +4 -0
- package/dist/web/assets/translate-Dmym1ZDl.js +2 -0
- package/dist/web/assets/utils-Bk66u8b3.js +1 -0
- package/dist/web/index.html +7 -7
- package/package.json +3 -3
- package/dist/chunk-BYB77UAJ.js.map +0 -1
- package/dist/chunk-G4HRD3AR.js +0 -246
- package/dist/chunk-G4HRD3AR.js.map +0 -1
- package/dist/chunk-W4PZHL2C.js.map +0 -1
- package/dist/chunk-YCUN52HA.js.map +0 -1
- package/dist/web/assets/InteractiveReceipt-Dk50TBsH.js +0 -1
- package/dist/web/assets/OverviewScreen-5hvQVp4H.js +0 -1
- package/dist/web/assets/Projects-Cy_v2yep.js +0 -1
- package/dist/web/assets/SearchResultsPanel-DfheEwpz.js +0 -1
- package/dist/web/assets/SessionDetail-DRI8R3st.js +0 -53
- package/dist/web/assets/api-GP9UCedC.js +0 -1
- package/dist/web/assets/contract-xJyW5u7a.js +0 -2
- package/dist/web/assets/index-Bd-YkWkZ.css +0 -1
- package/dist/web/assets/index-DEjvzumm.js +0 -1410
- package/dist/web/assets/panel-ND0J63d3.js +0 -1
- package/dist/web/assets/session-indexes-BsgjUoc1.js +0 -4
- package/dist/web/assets/utils-C7BqyxxV.js +0 -1
- /package/dist/{chunk-MBZ4VV4C.js.map → chunk-A3MT6L6Z.js.map} +0 -0
- /package/dist/{chunk-3SXCTDD6.js.map → chunk-YZ6XCSVQ.js.map} +0 -0
- /package/dist/{discovery-K3GLISI6.js.map → discovery-ADSQARBV.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{v as r}from"./contract-xJyW5u7a.js";import{r as i}from"./index-DEjvzumm.js";var a=e(t(),1);function o(e,t){return t===0||e-t>=15.666666666666668}function s(e,t,n){return!e&&t<=.12?n+1:0}function c(e,t){return e?0:t+1}function l(){let e=typeof document>`u`?void 0:document.fonts;return e?e.ready.then(()=>void 0):Promise.resolve()}function u(e,t,n){return e>=2&&(t>=8||n>=300)}function d(e,t){return!e||Math.abs(e.receiptWidth-t.receiptWidth)>.5||Math.abs(e.receiptHeight-t.receiptHeight)>.5||Math.abs(e.startX-t.startX)>.5||Math.abs(e.startY-t.startY)>.5}var f=18,p=42,m=5,h=270,g=500,_=2,v=.035;function y(e){let t=window.getComputedStyle(e),n=(e,n)=>t.getPropertyValue(e).trim()||n;return{paperTop:n(`--console-surface`,`white`),paperBottom:n(`--console-surface-sunken`,`whitesmoke`),ink:n(`--console-text`,`black`),inkMuted:n(`--console-text-secondary`,`dimgray`),line:n(`--console-border-strong`,`silver`),shadow:n(`--scrim`,`gray`)}}function ee(e){return window.getComputedStyle(e).getPropertyValue(`--font-mono`).trim()||`monospace`}function b(e){return Math.round(e??0).toLocaleString(`en-US`)}function x(e){return`$${(e??0).toFixed(4)}`}function S(e){return new Date(e).toLocaleString(`en-US`,{month:`short`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function C(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function w(e){let t=e||1;return()=>(t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296)}function T(e,t,n,r,i){let a=t.toUpperCase(),o=n.toUpperCase();e.fillText(a,18,r),e.fillText(o,i-18-e.measureText(o).width,r)}function E(e,t,n){if(e.measureText(t).width<=n)return t;let r=t;for(;r.length>1&&e.measureText(`${r}...`).width>n;)r=r.slice(0,-1);return`${r}...`}function D(e,t,n,r){let i=t.toUpperCase().split(/\s+/).filter(Boolean),a=[],o=``;for(let t of i){let i=o?`${o} ${t}`:t;if(e.measureText(i).width<=n){o=i;continue}if(o?(a.push(o),o=t):(a.push(E(e,t,n)),o=``),a.length===r)break}return a.length<r&&o&&a.push(o),a.length>0&&a.length===r&&(a[a.length-1]=E(e,a[a.length-1]??``,n)),a.slice(0,r)}function te(e,t,n){let r=document.createElement(`canvas`);r.width=h*_,r.height=g*_;let i=r.getContext(`2d`);if(!i)return r;i.scale(_,_);let a=e=>`${e} ${n}`,o=i.createLinearGradient(0,0,h,g);o.addColorStop(0,t.paperTop),o.addColorStop(1,t.paperBottom),i.fillStyle=o,i.fillRect(0,0,h,g);let s=w(C(e.id));i.fillStyle=t.ink;for(let e=0;e<1200;e+=1)i.globalAlpha=v*(.12+s()*.14),i.fillRect(s()*h,s()*g,.7,.7);i.globalAlpha=1,i.fillStyle=t.ink,i.font=a(`700 18px`),i.textAlign=`center`,i.fillText(`CODESESH MART`,h/2,34),i.fillStyle=t.inkMuted,i.font=a(`11px`),i.fillText(E(i,e.subtitle.toUpperCase(),234),h/2,51),i.strokeStyle=t.line,i.lineWidth=1,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,66),i.lineTo(252,66),i.stroke(),i.setLineDash([]),i.textAlign=`left`,i.fillStyle=t.ink,i.font=a(`11px`),T(i,`Agent`,e.agent,88,h),T(i,`Updated`,S(e.updatedAt),104,h),T(i,`Session`,`#${e.id.slice(0,8)}`,120,h),i.setLineDash([2,3]),i.beginPath(),i.moveTo(18,140),i.lineTo(252,140),i.stroke(),i.setLineDash([]),i.font=a(`700 12px`),i.fillText(`SESSION TOC RECEIPT LIST`,18,163),i.font=a(`11px`);let c=185;for(let t of e.items){let e=b(t.count);i.fillText(E(i,t.label,168),18,c),i.fillText(e,252-i.measureText(e).width,c),c+=17}return i.strokeStyle=t.line,i.lineWidth=1.5,i.beginPath(),i.moveTo(18,c+5),i.lineTo(252,c+5),i.stroke(),c+=26,T(i,`Input tokens`,b(e.inputTokens),c,h),c+=16,T(i,`Output tokens`,b(e.outputTokens),c,h),c+=16,T(i,`Messages`,b(e.messageCount),c,h),c+=22,i.font=a(`700 13px`),T(i,`TOTAL COST`,x(e.totalCost),c,h),i.strokeStyle=t.line,i.setLineDash([4,4]),i.beginPath(),i.moveTo(18,c+18),i.lineTo(252,c+18),i.stroke(),i.setLineDash([]),i.font=a(`10px`),i.textAlign=`center`,i.fillStyle=t.inkMuted,D(i,e.title,234,2).forEach((e,t)=>{i.fillText(e,h/2,c+38+t*13)}),r}function O(e,t){return e*f+t}function k(e){let{receiptWidth:t,receiptHeight:n,startX:r,startY:i}=e,a=t/17,o=n/41,s=[],c=[];for(let e=0;e<p;e+=1)for(let t=0;t<f;t+=1){let n=r+t*a,c=i+e*o;s.push({x:n,y:c,oldX:n,oldY:c,fixedX:e===0?n:null,fixedY:e===0?c:null})}let l=(e,t,n)=>{let r=s[e],i=s[t];!r||!i||c.push({a:e,b:t,length:Math.hypot(i.x-r.x,i.y-r.y),stiffness:n})};for(let e=0;e<p;e+=1)for(let t=0;t<f;t+=1){let n=O(e,t);t<17&&l(n,O(e,t+1),.98),e<41&&l(n,O(e+1,t),.92),e<41&&t<17&&(l(n,O(e+1,t+1),.46),l(O(e+1,t),O(e,t+1),.46)),t<16&&l(n,O(e,t+2),.35),e<40&&l(n,O(e+2,t),.28)}return{particles:s,constraints:c,receiptWidth:t,receiptHeight:n}}function ne(e,t){let n=t.receiptWidth/17;for(let r=0;r<f;r+=1){let i=e[r];i&&(i.fixedX=t.startX+r*n,i.fixedY=t.startY)}}function A(e){for(let t=0;t<f;t+=1){let n=e[t];!n||n.fixedX==null||n.fixedY==null||(n.x=n.fixedX,n.y=n.fixedY,n.oldX=n.fixedX,n.oldY=n.fixedY)}}function re(e,t){let n=e[t.a],r=e[t.b];if(!n||!r)return;let i=r.x-n.x,a=r.y-n.y,o=Math.hypot(i,a);if(o<1e-4)return;let s=(o-t.length)/o*t.stiffness,c=n.fixedX!=null&&n.fixedY!=null,l=r.fixedX!=null&&r.fixedY!=null,u=c?0:l?1:.5,d=l?0:c?1:.5,f=i*s,p=a*s;c||(n.x+=f*u,n.y+=p*u),l||(r.x-=f*d,r.y-=p*d)}function ie(e,t,n,r,i,a){let o=r[O(i,a)],s=r[O(i,a+1)],c=r[O(i+1,a)],l=r[O(i+1,a+1)];if(!o||!s||!c||!l)return;let u=a/17*t.width,d=i/41*t.height,f=t.width/17,p=t.height/41;e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.clip(),e.transform((s.x-o.x)/f,(s.y-o.y)/f,(c.x-o.x)/p,(c.y-o.y)/p,o.x,o.y),e.drawImage(t,u,d,f+1,p+1,0,0,f+1,p+1),e.restore();let m=Math.atan2(s.y-o.y,s.x-o.x),h=Math.hypot(c.x-o.x,c.y-o.y)/(g/41),_=Math.sin(m)*.08+(h-1)*.16;Math.abs(_)<.01||(e.save(),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(s.x,s.y),e.lineTo(l.x,l.y),e.lineTo(c.x,c.y),e.closePath(),e.globalAlpha=Math.abs(_),e.fillStyle=_>0?n.paperTop:n.shadow,e.fill(),e.restore())}function ae(e,t,n){let r=null,i=44;for(let a=f;a<e.length;a+=1){let o=e[a];if(!o)continue;let s=Math.hypot(o.x-t,o.y-n);s<i&&(i=s,r=a)}return r}function oe(e){let t=0;for(let n=f;n<e.length;n+=1){let r=e[n];r&&(t=Math.max(t,Math.hypot(r.x-r.oldX,r.y-r.oldY)))}return t}function j({canvas:e,anchor:t,hitSurface:n,payload:r,minWidthQuery:i}){let a=e.getContext(`2d`,{alpha:!0});if(!a)return null;let p=r,_={id:null,x:0,y:0,prevX:0,prevY:0,vx:0,vy:0,grabbedIndex:null},v=null,b=!1,x=0,S=0,C=0,w=k({receiptWidth:h,receiptHeight:g,startX:0,startY:32}),T=performance.now(),E=null,D=0,O=0,j=0,M=0,N=!1,P=!1,F=window.matchMedia(i),I=window.matchMedia(`(prefers-reduced-motion: reduce)`),L=()=>v!=null&&F.matches&&document.visibilityState===`visible`,R=()=>{let e=y(t);v={texture:te(p,e,ee(t)),palette:e}},z=()=>{let e=t.getBoundingClientRect(),n=Math.max(280,e.width||320),r=Math.min(h,n-34);return{receiptWidth:r,receiptHeight:Math.min(g,Math.max(320,C-42)),startX:(n-r)/2,startY:32}},B=t=>{N!==t&&(N=t,e.style.visibility=t?`visible`:`hidden`,n.style.visibility=t&&!I.matches?`visible`:`hidden`)},V=()=>{P=!1,x&&=(window.cancelAnimationFrame(x),0),B(!1)},H=(e,t=performance.now())=>{w=k(e),E=e,T=t},U=()=>{let n=window.devicePixelRatio||1,r=t.getBoundingClientRect();S=Math.max(1,r.width),C=Math.max(1,r.height),e.width=Math.floor(S*n),e.height=Math.floor(C*n),a.setTransform(n,0,0,n,0,0),D=0,O=0,j=0,M=0,B(!1),H(z()),L()&&W()},W=()=>{P||!L()||(P=!0,x=window.requestAnimationFrame(Z))},G=()=>{L()?U():V()},K=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},q=e=>{if(e.button!==0||I.matches)return;let t=K(e),r=ae(w.particles,t.x,t.y);r!=null&&(e.preventDefault(),n.setPointerCapture(e.pointerId),_.id=e.pointerId,_.x=t.x,_.y=t.y,_.prevX=t.x,_.prevY=t.y,_.vx=0,_.vy=0,_.grabbedIndex=r,O=0,j=0,W())},J=e=>{if(_.id!==e.pointerId)return;let t=K(e);_.vx=t.x-_.prevX,_.vy=t.y-_.prevY,_.prevX=t.x,_.prevY=t.y,_.x=t.x,_.y=t.y},Y=e=>{if(_.id!==e.pointerId)return;let t=_.grabbedIndex==null?null:w.particles[_.grabbedIndex];t&&(t.oldX=t.x-_.vx*.9,t.oldY=t.y-_.vy*.9),_.id=null,_.grabbedIndex=null},se=e=>{let t=(e-T)/1e3;for(let e=f;e<w.particles.length;e+=1){let n=w.particles[e];if(!n)continue;let r=(n.x-n.oldX)*.985,i=(n.y-n.oldY)*.985;n.oldX=n.x,n.oldY=n.y,n.x+=r+Math.sin(t*1.7+e*.19)*.018,n.y+=i+.22}let n=_.grabbedIndex==null?null:w.particles[_.grabbedIndex];n&&(n.x+=(_.x-n.x)*.72,n.y+=(_.y-n.y)*.72)},ce=()=>{for(let e=0;e<m;e+=1){A(w.particles);for(let e of w.constraints)re(w.particles,e)}A(w.particles)},le=()=>{let e=1/0,t=1/0,r=-1/0,i=-1/0;for(let n of w.particles)e=Math.min(e,n.x),t=Math.min(t,n.y),r=Math.max(r,n.x),i=Math.max(i,n.y);n.style.transform=`translate3d(${e-20}px, ${t-20}px, 0)`,n.style.width=`${r-e+40}px`,n.style.height=`${i-t+40}px`},ue=e=>{let t=w.particles[0],n=w.particles[17],r=w.particles[755],i=w.particles[738];!t||!n||!r||!i||(a.save(),a.shadowColor=e.shadow,a.shadowBlur=24,a.shadowOffsetY=16,a.fillStyle=e.shadow,a.beginPath(),a.moveTo(t.x,t.y),a.lineTo(n.x,n.y),a.lineTo(r.x,r.y),a.lineTo(i.x,i.y),a.closePath(),a.fill(),a.restore())},de=e=>{let t=w.particles[0],n=w.particles[17];!t||!n||(a.save(),a.strokeStyle=e.ink,a.lineWidth=4,a.lineCap=`round`,a.beginPath(),a.moveTo(t.x-10,t.y-3),a.lineTo(n.x+10,n.y-3),a.stroke(),a.strokeStyle=e.paperTop,a.lineWidth=1,a.beginPath(),a.moveTo(t.x-8,t.y-5),a.lineTo(n.x+8,n.y-5),a.stroke(),a.restore())},X=()=>{if(v){a.clearRect(0,0,S,C),ue(v.palette);for(let e=0;e<41;e+=1)for(let t=0;t<17;t+=1)ie(a,v.texture,v.palette,w.particles,e,t);de(v.palette),le()}},Z=e=>{if(!P)return;if(!L()){V();return}if(!o(e,M)){x=window.requestAnimationFrame(Z);return}M=e;let t=z();d(E,t)&&_.id==null?(D=0,B(!1),H(t,e)):(D+=1,E=t),ne(w.particles,t),I.matches||(se(e),ce()),X();let n=_.id!=null;O=s(n,oe(w.particles),O),j=c(n,j);let r=I.matches;if((r||D>=2)&&B(!0),r||u(D,O,j)){r||(H(t,e),X()),P=!1,x=0;return}x=window.requestAnimationFrame(Z)};B(!1),l().then(()=>{b||(R(),G())});let Q=new ResizeObserver(U);Q.observe(t);let $=new MutationObserver(()=>{R(),X()});return $.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),F.addEventListener(`change`,G),I.addEventListener(`change`,G),document.addEventListener(`visibilitychange`,G),window.addEventListener(`resize`,G),n.addEventListener(`pointerdown`,q),n.addEventListener(`pointermove`,J),n.addEventListener(`pointerup`,Y),n.addEventListener(`pointercancel`,Y),{updatePayload(e){p=e,!(b||!v)&&(R(),X())},destroy(){b||(b=!0,V(),Q.disconnect(),$.disconnect(),F.removeEventListener(`change`,G),I.removeEventListener(`change`,G),document.removeEventListener(`visibilitychange`,G),window.removeEventListener(`resize`,G),n.removeEventListener(`pointerdown`,q),n.removeEventListener(`pointermove`,J),n.removeEventListener(`pointerup`,Y),n.removeEventListener(`pointercancel`,Y))}}}var M=n();function N(e){let t=[{label:`User`,count:e.counts.user},{label:`Agent Responses`,count:e.counts.agent_message},{label:`Thinking`,count:e.counts.thinking},{label:`Plans`,count:e.counts.plan},{label:`Tools`,count:e.counts.tools_all}].filter(e=>e.count>0),n=e.tools.map(e=>({label:e.label,count:e.count})),r=Math.max(0,9-t.length),i=n.length>r?n.slice(0,Math.max(0,r-1)):n,a=n.slice(i.length).reduce((e,t)=>e+t.count,0);return a>0&&i.push({label:`Other tools`,count:a}),[...t,...i].slice(0,9)}function P(e){return!e||e.length===0?`SESSION ACTIVITY RECEIPT`:e.join(` / `)}function F(e,t){return{id:e.reference.sessionId,title:i(e)||`Untitled session`,agent:r(e),updatedAt:e.time_updated??e.time_created,subtitle:P(e.smart_tags),inputTokens:e.stats.total_input_tokens??0,outputTokens:e.stats.total_output_tokens??0,messageCount:e.stats.message_count??0,totalCost:e.stats.total_cost??0,items:N(t)}}function I({session:e,toc:t,minWidthQuery:n=`(min-width: 1025px)`}){let r=(0,a.useRef)(null),i=(0,a.useRef)(null),o=(0,a.useRef)(null),s=(0,a.useRef)(null),c=(0,a.useMemo)(()=>F(e,t),[e,t]),l=(0,a.useRef)(c);return(0,a.useLayoutEffect)(()=>{let e=r.current,t=i.current,a=o.current;if(!e||!t||!a)return;let c=j({canvas:e,anchor:t,hitSurface:a,payload:l.current,minWidthQuery:n});return s.current=c,()=>{c?.destroy(),s.current===c&&(s.current=null)}},[n]),(0,a.useLayoutEffect)(()=>{l.current=c,s.current?.updatePayload(c)},[c]),(0,M.jsxs)(`div`,{ref:i,className:`relative h-[calc(100dvh-5.5rem)] min-h-[420px]`,children:[(0,M.jsx)(`canvas`,{ref:r,className:`invisible pointer-events-none absolute inset-0 z-[61] block h-full w-full touch-none`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{ref:o,className:`invisible absolute left-0 top-0 z-[62] cursor-grab touch-none active:cursor-grabbing`,"aria-label":`Interactive thermal receipt with Verlet paper simulation`})]})}export{I as InteractiveReceipt};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{_ as r,f as i,g as a,i as o,n as s,o as c,p as l,s as u,t as d,u as f}from"./utils-C7BqyxxV.js";import{c as p,i as m,m as h,n as g,r as _,s as v,t as y}from"./panel-ND0J63d3.js";var b=e(t(),1);function x(e,t){let n=e!==null,r=h({...v(e??{},t),enabled:n}),i=r.refetch,a=(0,b.useCallback)(async()=>{await i()},[i]);return{dashboard:n?r.data??null:null,loading:n&&r.isPending,error:n&&r.isError?r.error instanceof Error?r.error.message:`Unable to load dashboard.`:null,retry:a}}var S=Math.PI*2;function C(e){return e<0?0:e>1?1:e}function w(e){let t=C(e);return t*t*(3-2*t)}function T(e,t){let n=Math.imul(Math.round(e*16)^2654435769,2246822507);return n=Math.imul(n^n>>>13^Math.round(t*16),3266489909),((n^n>>>16)>>>0)/4294967296}function E(e,t,n){return w((Math.sin(e*.09+n)+Math.sin(t*.075-n*.83)+Math.sin((e+t)*.045+n*1.31)+2)/4)}function ee(e){if(e<=0)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}var D=/^var\((--[\w-]+)\)$/;function O(e,t){let n=D.exec(t)?.[1];return n&&e.getPropertyValue(n).trim()||t}function k(e,t){let n=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e)?.[1];if(!n)return e;let r=n.length===3?n.replace(/./g,e=>e+e):n,i=parseInt(r,16);return`rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${t})`}var A=50;function j(){let e=!1,t=null,n=0,r=0,i=()=>{n&&cancelAnimationFrame(n),r&&window.clearTimeout(r),n=0,r=0},a=()=>{!e||t===null||n||(r&&=(window.clearTimeout(r),0),n=requestAnimationFrame(s))},o=()=>{!e||t===null||r||n||(r=window.setTimeout(()=>{r=0,a()},A))};function s(r){if(n=0,!e||t===null)return;let i=t(r);i===`active`?a():i===`idle`&&o()}return{api:{requestFrame:a,setFrameHandler:e=>{t=e,e===null?i():a()}},setEnabled:t=>{e!==t&&(e=t,e?a():i())}}}function M(e,t){let[n]=(0,b.useState)(j);return(0,b.useEffect)(()=>{let r=e.current;if(!r||t){n.setEnabled(!1);return}let i=!0,a=document.visibilityState===`visible`,o=()=>n.setEnabled(i&&a),s=()=>{a=document.visibilityState===`visible`,o()},c=typeof IntersectionObserver>`u`?null:new IntersectionObserver(([e])=>{i=e?.isIntersecting??!1,o()});return c?.observe(r),document.addEventListener(`visibilitychange`,s),o(),()=>{n.setEnabled(!1),c?.disconnect(),document.removeEventListener(`visibilitychange`,s)}},[n,t,e]),n.api}var N=2,P=5,te=8,ne=7,re=620,ie=.05,ae=.8,oe=.0018,se=.3,ce=.48,le={barRatio:.62,barMax:76,bandGap:4,minBand:6};function ue(e,t,n){let r=Math.max(1,t-1),i=Math.min(ie,ae/r),a=1-(t-1)*i;return 1-(1-C((n-e*i)/a))**3}function de(e,{values:t,axisMax:n,colors:r,highlight:i,hovered:a,layout:o,reducedMotion:s}){let c=(0,b.useContext)(m),l=M(e,s),u=r.join(`\0`),d=(0,b.useRef)({values:t,axisMax:n,hovered:a,layout:o}),f=(0,b.useRef)(new Map),p=(0,b.useRef)(new Map),h=(0,b.useRef)({startedAt:0,running:!1}),g=(0,b.useRef)({w:0,h:0}),_=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{d.current={values:t,axisMax:n,hovered:a,layout:o},s?_.current():l.requestFrame()},[n,l,a,o,s,t]),(0,b.useEffect)(()=>{p.current=new Map(f.current),s?(h.current.running=!1,_.current()):(h.current={startedAt:performance.now(),running:!0},l.requestFrame())},[n,l,s,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),o=(u?u.split(`\0`):[]).map(e=>O(a,e)),c=O(a,i),m=()=>{let e=n.clientWidth,i=n.clientHeight;if(!e||!i)return;let a=Math.min(N,window.devicePixelRatio||1);t.width=Math.round(e*a),t.height=Math.round(i*a),t.style.width=`${e}px`,t.style.height=`${i}px`,r.setTransform(a,0,0,a,0,0),g.current={w:e,h:i}},v=0,y=(e,t,n)=>{if(!h.current.running)return 1;let r=C((n-h.current.startedAt)/re);return r>=1&&(h.current.running=!1),ue(e,t,r)},b=(e,t,n,i,a,o,s,c,l,u,d)=>{let f=[l?te:P,l?te:P,u?ne:P,u?ne:P],p=()=>{r.beginPath(),r.roundRect(e,t,n,i,f)};r.save(),p(),r.clip(),r.globalAlpha=s,r.fillStyle=a;let m=c?.5:.36,h=Math.min(d,i)/2;r.beginPath();for(let a=e+d/2;a<e+n;a+=d)for(let e=t+h;e<t+i;e+=d){let n=w(1-(e-t)/i),o=E(a,e,v),s=d*(m+.34*n+.26*o)*(.8+.4*T(a,e));r.rect(a-s/2,e-s/2,s,s)}r.fill(),r.restore(),c&&(r.save(),p(),r.strokeStyle=o,r.lineWidth=1.75,r.shadowColor=o,r.shadowBlur=10,r.stroke(),r.restore())},x=e=>{v=e*oe;let{w:t,h:n}=g.current;if(!t||!n)return;let i=d.current;if(r.clearRect(0,0,t,n),!i.values.length||i.axisMax<=0){h.current.running=!1;return}let{barRatio:a,barMax:s,bandGap:l,minBand:u}=i.layout,m=i.values.length,_=t/m,x=Math.min(_*a,s),S=Math.max(3,Math.round(t/200)),C=n/i.axisMax,w=i.hovered;i.values.forEach((t,r)=>{let i=y(r,m,e),a=r*_+(_-x)/2,s=n;t.forEach((e,n)=>{let d=`${r}:${n}`,m=e>0?Math.max(u,e*C):0,h=p.current.get(d)??0,g=h+(m-h)*i;f.current.set(d,g);let _=w?.column===r&&w.band===n,v=w==null?1:w.column===r?w.band===null||_?1:ce:se;g>0&&b(a,s-g,x,g,o[n]??o[0]??c,c,v,_,n===t.length-1,n===0,S),s-=g+l})})};_.current=()=>{m(),x(performance.now())},l.setFrameHandler(e=>(x(e),h.current.running?`active`:d.current.hovered===null?`stop`:`idle`)),m();let S=new ResizeObserver(()=>{m(),s?x(performance.now()):l.requestFrame()});return S.observe(n),s&&x(performance.now()),()=>{l.setFrameHandler(null),S.disconnect()}},[e,u,l,i,s,c]),{hitTest:(t,n)=>{let r=e.current,{w:i,h:a}=g.current;if(!r||!i)return null;let o=r.getBoundingClientRect(),s=(t-o.left)/o.width*i,c=(n-o.top)/o.height*a,{values:l,layout:u}=d.current,p=l.length,m=i/p,h=Math.floor(s/m);if(h<0||h>=p)return null;let _=Math.min(m*u.barRatio,u.barMax),v=h*m+(m-_)/2;if(s<v||s>v+_)return{column:h,band:null};let y=a;for(let e=0;e<l[h].length;e++){let t=f.current.get(`${h}:${e}`)??0;if(t>0&&c<=y&&c>=y-t)return{column:h,band:e};y-=t+u.bandGap}return{column:h,band:null}}}}var fe=`(prefers-reduced-motion: reduce)`;function F(){let[e,t]=(0,b.useState)(()=>globalThis.matchMedia?.(fe).matches??!1);return(0,b.useEffect)(()=>{let e=globalThis.matchMedia?.(fe);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var I=n();function pe(e,t,n){return e===`ArrowLeft`?Math.max(0,t-1):e===`ArrowRight`?Math.min(n,t+1):e===`Home`?0:e===`End`?n:null}function me({label:e,itemLabels:t,activeIndex:n,onActiveIndexChange:r,layout:i}){let a=(0,b.useRef)([]),[o,s]=(0,b.useState)(0),c=t.length-1,l=Math.min(o,Math.max(0,c)),u=(e,t)=>{if(e.key===`Escape`){e.preventDefault(),r(null);return}let n=pe(e.key,t,c);n!==null&&(e.preventDefault(),s(n),a.current[n]?.focus())};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{role:`listbox`,"aria-label":e,"aria-orientation":`horizontal`,className:d(`pointer-events-none absolute inset-0 z-[1]`,i===`columns`?`flex`:null),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||r(null)},children:t.map((e,t)=>(0,I.jsx)(`div`,{ref:e=>{a.current[t]=e},role:`option`,"aria-label":e,"aria-selected":n===t,tabIndex:t===l?0:-1,className:d(`pointer-events-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[var(--brand)]`,i===`columns`?`h-full min-w-0 flex-1 rounded-sm`:`absolute inset-0 rounded-full`),onFocus:()=>{s(t),r(t)},onKeyDown:e=>u(e,t)},t))}),(0,I.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,children:n===null?``:t[n]})]})}var he=[1,.75,.5,.25,0];function ge(e,t){return e===t||e!==null&&t!==null&&e.column===t.column&&e.band===t.band}function L({values:e,axisMax:t,colors:n,highlight:r=`var(--brand)`,hovered:i,onHover:a,layout:o,height:s,formatTick:c,ariaLabel:l,itemLabels:u,className:f}){let p=(0,b.useRef)(null),m=(0,b.useRef)(i),h=F(),{hitTest:g}=de(p,{values:e,axisMax:t,colors:n,highlight:r,hovered:i,layout:{...le,...o},reducedMotion:h});(0,b.useEffect)(()=>{m.current=i},[i]);let _=e=>{ge(m.current,e)||(m.current=e,a(e))};return(0,I.jsxs)(`div`,{className:d(`flex`,f),children:[c?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:s,width:38},"aria-hidden":!0,children:he.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:`${(1-e)*100}%`},children:c(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1 touch-none`,style:{height:s},onPointerMove:e=>_(g(e.clientX,e.clientY)),onPointerLeave:()=>_(null),children:[he.map(e=>(0,I.jsx)(`span`,{"aria-hidden":!0,className:d(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:`${(1-e)*100}%`}},e)),(0,I.jsx)(`canvas`,{ref:p,"aria-hidden":!0,className:`absolute inset-0 block`}),(0,I.jsx)(me,{label:l,itemLabels:u,activeIndex:i?.column??null,onActiveIndexChange:e=>_(e===null?null:{column:e,band:null}),layout:`columns`})]})]})}var R=6,_e=118,ve={barRatio:.52,barMax:34,bandGap:0,minBand:4},ye=[`var(--brand)`];function be({perAgent:e}){let[t,n]=(0,b.useState)(null),{byCost:r,visible:i,values:o,axisMax:c,itemLabels:l}=(0,b.useMemo)(()=>{let t=e.some(e=>e.cost>0),n=e=>t?e.cost:e.sessions,r=[...e].sort((e,t)=>n(t)-n(e)).slice(0,R),i=r.map(e=>[n(e)]),o=r.map(e=>t?`${e.displayName}: ${a(e.cost)}, ${u(e.sessions)} sessions`:`${e.displayName}: ${u(e.sessions)} sessions`);return{byCost:t,visible:r,values:i,axisMax:Math.max(...i.flat(),0),itemLabels:o}},[e]);return(0,I.jsxs)(y,{role:`region`,"aria-label":`Agents`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Agents`,meta:`${r?`by cost`:`by sessions`} · ${e.length} total`}),i.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No data`}):(0,I.jsxs)(`div`,{className:`mt-[14px]`,children:[(0,I.jsx)(L,{values:o,axisMax:c,colors:ye,hovered:t,onHover:n,layout:ve,height:_e,ariaLabel:`Agent distribution chart`,itemLabels:l}),(0,I.jsx)(`div`,{className:`mt-2 grid`,style:{gridTemplateColumns:`repeat(${i.length}, minmax(0, 1fr))`},children:i.map((e,n)=>(0,I.jsxs)(`div`,{"data-testid":`overview-agent-row`,className:`flex min-w-0 flex-col items-center gap-[5px]`,children:[(0,I.jsx)(`span`,{className:`flex size-[18px] items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:(0,I.jsx)(s,{icon:e.icon,iconColored:e.iconColored,alt:e.displayName,className:`size-[10px]`})}),(0,I.jsx)(`span`,{className:d(`console-mono max-w-full truncate text-[9.5px]`,t?.column===n?`text-[var(--console-text)]`:`text-[var(--console-muted)]`),children:e.displayName}),(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-text)]`,children:r?a(e.cost):u(e.sessions)}),r?(0,I.jsx)(`span`,{className:`console-mono text-[9.5px] text-[var(--console-muted)]`,children:u(e.sessions)}):null]},e.name))})]}),e.length>R?(0,I.jsxs)(`p`,{className:`console-mono mt-3 text-[10.5px] text-[var(--console-muted)]`,children:[`+ `,e.length-R,` more`]}):null]})}var z=200,B=100,V=100,H=86,U=55,xe=-Math.PI/2,Se=.07,Ce=6,W=4.6,we=2,Te=.0018,Ee=500,G=6,De=.72,Oe=.3,ke=(()=>{let e=[];for(let t=14;t<=186;t+=W)for(let n=14;n<=186;n+=W){let r=t-B,i=n-V,a=Math.hypot(r,i);a<50.4||a>90.6||e.push({x:t,y:n,angle:Math.atan2(i,r),fullness:.62+.38*w((a-U)/31),jitter:T(t,n)})}return e})();function Ae(e,{a0:t,a1:n}){let r=n-t,i=Math.min(Ce,31*.45,U*r*.45),a=i/H,o=i/U,s=(e,t)=>[B+Math.cos(t)*e,V+Math.sin(t)*e],[c,l]=s(H,t+a);e.beginPath(),e.moveTo(c,l),e.arc(B,V,H,t+a,n-a),e.arcTo(...s(H,n),...s(U,n),i),e.arcTo(...s(U,n),...s(U,n-o),i),e.arc(B,V,U,n-o,t+o,!0),e.arcTo(...s(U,t),...s(H,t),i),e.arcTo(...s(H,t),c,l,i),e.closePath()}function je(e){let t=xe;return e.map(e=>{let n=e*S,r={a0:t+Se/2,a1:t+n-Se/2};return t+=n,r})}function Me(e,{shares:t,colors:n,hovered:r,reducedMotion:i}){let a=(0,b.useContext)(m),o=M(e,i),s=n.join(`\0`),c=(0,b.useRef)(r),l=(0,b.useRef)({displayed:t.slice(),from:t.slice(),target:t.slice(),startedAt:0,running:!1}),u=(0,b.useRef)(je(t)),d=(0,b.useRef)(()=>{});return(0,b.useEffect)(()=>{let e=l.current;e.from=e.displayed.slice(),e.target=t.slice(),i?(e.displayed=t.slice(),e.running=!1,d.current()):(e.startedAt=performance.now(),e.running=!0,o.requestFrame())},[o,i,t]),(0,b.useEffect)(()=>{c.current=r,i?d.current():o.requestFrame()},[o,r,i]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,r=t?.getContext(`2d`);if(!t||!n||!r)return;let a=getComputedStyle(t),f=(s?s.split(`\0`):[]).map(e=>O(a,e)),p=1,m=()=>{let e=n.clientWidth;if(!e)return;let r=Math.min(we,window.devicePixelRatio||1);t.width=Math.ceil(e*r),t.height=Math.ceil(e*r),t.style.width=`${e}px`,t.style.height=`${e}px`,p=e/z*r},h=0,g=e=>{let t=l.current;if(!t.running)return;let n=C((e-t.startedAt)/Ee),r=1-2**(-10*n);t.displayed=t.target.map((e,n)=>{let i=t.from[n]??0;return i+(e-i)*r}),n>=1&&(t.displayed=t.target.slice(),t.running=!1)},_=(e,t,n,i)=>{if(t.a1-t.a0<=.004)return;if(r.save(),n){let n=(t.a0+t.a1)/2;r.translate(Math.cos(n)*G,Math.sin(n)*G),r.shadowColor=k(e,.55),r.shadowBlur=5}Ae(r,t),r.clip(),r.globalAlpha=i?n?1:Oe*De:De,r.fillStyle=e;let a=n?.46:.34,o=t.a0-.06,s=t.a1+.06;r.beginPath();for(let e of ke){let t=e.angle;for(;t<o;)t+=S;for(;t>=o+S;)t-=S;if(t>s)continue;let n=E(e.x,e.y,h),i=W*(a+.36*e.fullness+.26*n)*(.78+.42*e.jitter);r.rect(e.x-i/2,e.y-i/2,i,i)}r.fill(),r.restore()},v=e=>{h=e*Te,r.setTransform(p,0,0,p,0,0),r.clearRect(0,0,z,z);let t=je(l.current.displayed);u.current=t;let n=c.current,i=n!==null;t.forEach((e,t)=>{t!==n&&_(f[t]??f[0]??``,e,!1,i)});let a=n===null?void 0:t[n];a&&_(f[n]??``,a,!0,!0)};d.current=()=>{m(),v(performance.now())},o.setFrameHandler(e=>(g(e),v(e),l.current.running?`active`:c.current===null?`stop`:`idle`)),m();let y=new ResizeObserver(()=>{m(),i?v(performance.now()):o.requestFrame()});return y.observe(n),i&&v(performance.now()),()=>{o.setFrameHandler(null),y.disconnect()}},[e,s,o,i,a]),{hitTest:(t,n)=>{let r=e.current;if(!r)return null;let i=r.getBoundingClientRect();if(!i.width)return null;let a=(t-i.left)/i.width*z-B,o=(n-i.top)/i.height*z-V,s=Math.hypot(a,o);if(s<U||s>H)return null;let c=Math.atan2(o,a);for(let e=0;e<u.current.length;e++){let{a0:t,a1:n}=u.current[e],r=c;for(;r<t;)r+=S;for(;r>=t+S;)r-=S;if(r<=n)return e}return null}}}function Ne({shares:e,colors:t,hovered:n,onHover:r,size:i,ariaLabel:a,itemLabels:o,children:s}){let c=(0,b.useRef)(null),{hitTest:l}=Me(c,{shares:e,colors:t,hovered:n,reducedMotion:F()});return(0,I.jsxs)(`div`,{className:`relative shrink-0 touch-none`,style:{width:i,height:i},onPointerMove:e=>r(l(e.clientX,e.clientY)),onPointerLeave:()=>r(null),children:[(0,I.jsx)(`canvas`,{ref:c,"aria-hidden":!0,className:`block size-full`}),(0,I.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center`,children:s}),(0,I.jsx)(me,{label:a,itemLabels:o,activeIndex:n,onActiveIndexChange:r,layout:`surface`})]})}var Pe=5,Fe=142,Ie=.01;function Le(e){return e!==null&&e.some(e=>e.cost>0)}function Re(e,t){let n=[...e].sort((e,t)=>t.cost-e.cost).slice(0,Pe),i=n.map((e,t)=>({key:e.model,label:e.model,value:e.cost,color:`var(--chart-${t+1})`,display:r(e.cost)})),a=t-n.reduce((e,t)=>e+t.cost,0);return t>0&&a>t*Ie&&i.push({key:`__remainder`,label:`Other`,value:a,color:`var(--console-border-strong)`,display:r(a)}),i}function ze(e){return[...e].sort((e,t)=>t.tokens-e.tokens).slice(0,Pe).map((e,t)=>({key:e.model,label:e.model,value:e.tokens,color:`var(--chart-${t+1})`,display:o(e.tokens)}))}function Be({modelCost:e,modelDistribution:t,totals:n}){let[s,c]=(0,b.useState)(null),{byCost:l,entries:u}=(0,b.useMemo)(()=>{let r=Le(e);return{byCost:r,entries:r?Re(e,n.cost):ze(t)}},[e,t,n.cost]),f=u.reduce((e,t)=>e+t.value,0),p=(0,b.useMemo)(()=>u.map(e=>f>0?e.value/f:1/u.length),[u,f]),m=l?`Cost by Model`:`Models`,h=u.map(e=>`${e.label}: ${i(f>0?e.value/f:0)}, ${e.display}`);return(0,I.jsxs)(y,{role:`region`,"aria-label":m,className:`p-4`,children:[(0,I.jsx)(g,{title:m,meta:l?`by cost`:`by tokens`}),u.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-3 text-[11px] text-[var(--console-muted)]`,children:`No model data`}):(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-center gap-[18px]`,children:[(0,I.jsxs)(Ne,{shares:p,colors:u.map(e=>e.color),hovered:s,onHover:c,size:Fe,ariaLabel:`${m} chart`,itemLabels:h,children:[(0,I.jsx)(`span`,{className:`console-mono text-[16px] font-semibold text-[var(--console-text)]`,children:l?r(n.cost):o(n.tokens)}),(0,I.jsx)(`span`,{className:`console-mono mt-0.5 text-[9px] text-[var(--console-muted)]`,children:l?`total cost`:`total tokens`})]}),(0,I.jsx)(`ul`,{className:`flex min-w-0 flex-1 flex-col gap-[7px]`,children:u.map((e,t)=>(0,I.jsxs)(`li`,{className:d(`flex min-w-0 items-center gap-2 transition-opacity`,s!==null&&s!==t?`opacity-45`:null),onPointerEnter:()=>c(t),onPointerLeave:()=>c(null),children:[(0,I.jsx)(`span`,{className:`size-2 shrink-0 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`console-mono min-w-0 flex-1 truncate text-[10.5px] text-[var(--console-text)]`,children:e.label}),(0,I.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-right text-[10.5px] text-[var(--console-muted)]`,children:i(f>0?e.value/f:0)}),(0,I.jsx)(`span`,{className:`console-mono w-[54px] shrink-0 text-right text-[10.5px] text-[var(--console-text)]`,children:e.display})]},e.key))})]}),(0,I.jsx)(`p`,{className:`console-mono mt-3 border-t border-dashed border-[var(--console-border)] pt-3 text-[10.5px] text-[var(--console-muted)]`,children:l?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`mr-1.5 rounded-sm bg-[var(--brand-soft)] px-1.5 py-0.5 text-[var(--brand)]`,children:`Estimated`}),a(n.costEstimated),` from model unit price,`,` `,a(n.costRecorded),` from agent records`]}):`Per-model cost needs the message cache, which is unavailable here; showing token share instead.`})]})}var Ve=[{value:`7d`,label:`7d`},{value:`30d`,label:`30d`},{value:`90d`,label:`90d`},{value:`all`,label:`All`},{value:`custom`,label:`Custom`}],K=`__all__`;function He({agent:e,onAgentChange:t,agentCatalog:n,scopeCounts:r,window:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(!1);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[t?(0,I.jsxs)(`select`,{"aria-label":`Filter by agent`,value:e??K,onChange:e=>t(e.target.value===K?void 0:e.target.value),className:`console-mono max-w-[220px] rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1.5 text-xs text-[var(--console-text)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,I.jsx)(`option`,{value:K,children:`All agents`}),n.active.map(e=>(0,I.jsx)(`option`,{value:e.name.toLowerCase(),children:e.displayName},e.name))]}):null,r?(0,I.jsxs)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:[r.projects,` projects · `,r.agents,` agents in scope`]}):null,(0,I.jsx)(`div`,{className:`ml-auto flex items-center gap-1.5`,children:Ve.map(e=>{let t=e.value===a;return(0,I.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>{e.value===`custom`?l(!0):o(e.value)},className:d(`console-mono motion-hover rounded-full border px-[13px] py-[5px] text-[11px] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,t?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)]`),children:e.label},e.value)})})]}),(0,I.jsx)(p,{open:c,onOpenChange:l,window:i,onSelectCustom:s})]})}function Ue(e){return e.toFixed(1)}var We={neutral:`text-[var(--console-muted)]`,warning:`text-[var(--brand)]`,positive:`text-[var(--positive)]`};function q({label:e,value:t,trend:n,trendTone:r=`neutral`,hint:i,emphasis:a=!1}){return(0,I.jsxs)(y,{className:d(`px-4 py-[14px]`,a?`border-[var(--brand-line)]`:null),children:[(0,I.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,I.jsx)(`p`,{className:d(`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em]`,a?`text-[var(--brand)]`:`text-[var(--console-text)]`),children:t}),(0,I.jsxs)(`div`,{className:`mt-[7px] flex items-center gap-[7px]`,children:[n===void 0?null:(0,I.jsx)(`span`,{"data-testid":`overview-kpi-trend`,className:d(`console-mono text-[10.5px]`,We[r]),children:n}),i===void 0?null:(0,I.jsx)(`span`,{className:`console-mono truncate text-[10.5px] text-[var(--console-muted)]`,children:i})]})]})}function Ge(e){return e.costEstimated===0?`All recorded by agents`:e.costEstimated===e.cost&&e.cost>0?`All estimated from unit price`:`${a(e.costEstimated)} estimated`}function Ke(e){let t=[e.latestActivityProject,e.latestActivityAgent].filter(e=>!!e);return t.length>0?t.join(` · `):void 0}function qe({totals:e,rangeDays:t}){let n=e.previous,r=(e,t)=>t===void 0?null:c(e,t),s=r(e.sessions,n?.sessions),d=r(e.messages,n?.messages),f=r(e.tokens,n?.tokens),p=r(e.cost,n?.cost),m=n?.cost!==void 0&&e.cost>n.cost;return(0,I.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:[(0,I.jsx)(q,{label:`Sessions`,value:u(e.sessions),trend:s??void 0,hint:t?`${Ue(e.sessions/t)}/day`:void 0}),(0,I.jsx)(q,{label:`Messages`,value:u(e.messages),trend:d??void 0,hint:e.sessions>0?`${Ue(e.messages/e.sessions)}/session`:void 0}),(0,I.jsx)(q,{label:`Tokens`,value:o(e.tokens),trend:f??void 0,hint:`Cache hit ${i(e.cacheReadTokens/e.tokens)}`}),(0,I.jsx)(q,{label:`Cost`,value:a(e.cost),trend:p??void 0,trendTone:m?`warning`:`positive`,hint:Ge(e),emphasis:!0}),(0,I.jsx)(q,{label:`Last activity`,value:e.latestActivity===void 0?`No activity`:l(e.latestActivity),trend:e.latestActivity===void 0?void 0:`●`,trendTone:`positive`,hint:e.latestActivity===void 0?void 0:Ke(e)})]})}var Je=[0,1,2,3,4];function J({className:e}){return(0,I.jsx)(`span`,{className:`skeleton-shimmer block rounded-sm ${e}`})}function Y({bodyClassName:e}){return(0,I.jsxs)(y,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-3 ${e}`})]})}function Ye(){return(0,I.jsxs)(`div`,{className:`space-y-4`,"aria-hidden":!0,"data-testid":`overview-skeleton`,children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5`,children:Je.map(e=>(0,I.jsxs)(y,{className:`px-4 py-[14px]`,children:[(0,I.jsx)(J,{className:`h-[10px] w-16`}),(0,I.jsx)(J,{className:`mt-[9px] h-[27px] w-24`}),(0,I.jsx)(J,{className:`mt-[7px] h-[11px] w-20`})]},e))}),(0,I.jsxs)(y,{className:`p-4`,children:[(0,I.jsx)(J,{className:`h-[15px] w-28`}),(0,I.jsx)(J,{className:`mt-[14px] h-[168px] w-full`})]}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.45fr_1fr]`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[248px] w-full`}),(0,I.jsxs)(`div`,{className:`grid content-start gap-4`,children:[(0,I.jsx)(Y,{bodyClassName:`h-[116px] w-full`}),(0,I.jsx)(Y,{bodyClassName:`h-[100px] w-full`})]})]})]})}var Xe=.16;function Ze(e){return e*e*(3-2*e)}function Qe(e,t,n){return e<t?t:e>n?n:e}function X(e,t=new Float32Array(512)){let n=e.length;if(n===0)return t.fill(0),t;for(let r=0;r<512;r++){let i=Qe(r/511*n-.5,0,n-1),a=Math.min(n-2,Math.floor(i));if(a<0){t[r]=e[0];continue}let o=Ze(i-a);t[r]=e[a]*(1-o)+e[a+1]*o}return t}function $e(e,t){let n=Qe(t,0,1)*511,r=Math.min(510,Math.floor(n)),i=n-r;return e[r]*(1-i)+e[r+1]*i}function et(e,t){return 1-(t>0?Math.min(1,e/t):0)*.84}var tt=2,nt=460,rt=180,Z=32,it=.06,at=.24,ot=/oklch\(\s*([\d.]+)\s+([\d.]+)\s+([\d.]+)/;function st(e){let t=Math.imul(e^2654435769,2246822507);return t=Math.imul(t^t>>>13,3266489909),((t^t>>>16)>>>0)/4294967296}function ct(e,t){let n=ot.exec(e),r=ot.exec(t);if(!n||!r)return Array.from({length:33},()=>t);let[i,a,o]=[Number(n[1]),Number(n[2]),Number(n[3])],[s,c,l]=[Number(r[1]),Number(r[2]),Number(r[3])];return Array.from({length:33},(e,t)=>{let n=t/Z,r=i+(s-i)*n,u=a+(c-a)*n,d=o+(l-o)*n;return`oklch(${r.toFixed(3)} ${u.toFixed(3)} ${d.toFixed(1)})`})}function lt(e,{values:t,max:n,reducedMotion:r}){let i=(0,b.useContext)(m),a=M(e,r),o=(0,b.useRef)({from:X(t),to:X(t),current:X(t),fromMax:n,toMax:n,currentMax:n,startedAt:0,duration:0}),s=(0,b.useRef)(null),c=(0,b.useRef)(()=>{}),l=(0,b.useRef)({x:-1e4,y:-1e4,smoothX:-1e4,smoothY:-1e4,speed:0,inside:!1});(0,b.useEffect)(()=>{let e=o.current;e.from.set(e.current),e.fromMax=e.currentMax,X(t,e.to),e.toMax=n,e.startedAt=performance.now(),e.duration=r?0:nt,r?c.current():a.requestFrame()},[a,n,r,t]),(0,b.useEffect)(()=>{let t=e.current,n=t?.parentElement,i=t?.getContext(`2d`);if(!t||!n||!i)return;let u=l.current,d=getComputedStyle(t),f=d.getPropertyValue(`--tile-rest`).trim(),p=ct(d.getPropertyValue(`--tile-wash`).trim(),d.getPropertyValue(`--tile-ink`).trim()),m=()=>{let e=n.clientWidth,r=n.clientHeight;if(!e||!r)return;let a=n.getBoundingClientRect(),o=Math.min(tt,window.devicePixelRatio||1);t.width=Math.round(e*o),t.height=Math.round(r*o),t.style.width=`${e}px`,t.style.height=`${r}px`,i.setTransform(o,0,0,o,0,0),i.imageSmoothingEnabled=!1;let c=Math.max(3,Math.round(e/rt)),l=Math.ceil(e/c),u=Math.ceil(r/c),d=l*u,f=new Uint8Array(d);for(let e=0;e<d;e++)f[e]=+(st(e)<it);s.current={cell:c,cols:l,rows:u,width:e,height:r,left:a.left,top:a.top,step:1/o,glow:new Float32Array(d),spark:f}},h=e=>{let t=o.current,n=t.duration>0?Math.min(1,(e-t.startedAt)/t.duration):1;for(let e=0;e<512;e++)t.current[e]=t.from[e]+(t.to[e]-t.from[e])*n;return t.currentMax=t.fromMax+(t.toMax-t.fromMax)*n,n>=1&&(t.duration=0),n<1},g=e=>{let t=l.current,n=t.smoothX,r=t.smoothY,i=1-.72**e;t.smoothX+=(t.x-n)*i,t.smoothY+=(t.y-r)*i,t.speed=Math.hypot(t.smoothX-n,t.smoothY-r)},_=(e,t=1)=>{let n=s.current;if(!n)return!1;let a=o.current,{cell:c,cols:u,rows:d,width:m,height:h,step:g,glow:_,spark:v}=n,y=e=>Math.round(e/g)*g,b=Math.max(g,y(c*.34)),x=y((c-b)/2);i.clearRect(0,0,m,h),i.fillStyle=f;for(let e=0;e<u;e++){let t=e*c+x;for(let e=0;e<d;e++)i.fillRect(t,e*c+x,b,b)}let S=l.current,C=h*(at+Math.min(1,S.speed/25)*.26),w=!r&&S.inside,T=1-.78**t,E=1-.95**t,ee=e*.0018,D=-1,O=!1;for(let t=0;t<u;t++){let n=u>1?(t+.5)/u:.5,o=et($e(a.current,n),a.currentMax),s=Math.max(.001,1-o),l=t*c,m=l+c/2;for(let n=0;n<d;n++){let a=t*d+n,u=n*c,b=(u+c/2)/h,x=0;b>=o&&(x=1-.55*((b-o)/s));let k=_[a];if(w){let e=Math.hypot(m-S.smoothX,u+c/2-S.smoothY),t=e<C?1-e/C:0;k+=(t-k)*(t>k?T:E),_[a]=k}else k>0&&(k*=1-E,_[a]=k<.002?0:k);_[a]>0&&(O=!0);let A=Math.min(1,x+k*.5);if(A<=.02)continue;let j=A;r||(j*=1+.07*Math.sin(b*Math.PI*3-ee),v[a]&&k>.02&&(j*=1+.25*k*Math.sin(e*.012+a)),j=Math.min(1,j));let M=Math.max(g,y(c*(.28+.42*A))),N=y((c-M)/2),P=Math.round(j*Z);P!==D&&(D=P,i.fillStyle=p[D]??p[Z]??f),i.fillRect(l+N,u+N,M,M)}}return O},v=()=>{m(),h(performance.now()),_(performance.now())};c.current=v;let y=e=>{let t=s.current;if(!t)return;let r=l.current;if(!r.inside){let e=n.getBoundingClientRect();t.left=e.left,t.top=e.top}r.x=e.clientX-t.left,r.y=e.clientY-t.top,r.inside||(r.smoothX=r.x,r.smoothY=r.y),r.inside=!0,a.requestFrame()},b=()=>{l.current.inside=!1,a.requestFrame()},x=0;a.setFrameHandler(e=>{let t=x===0?1:Math.min(3,(e-x)/(1e3/60));x=e;let n=h(e);g(t);let r=_(e,t);return n?`active`:l.current.inside||r?`idle`:(x=0,`stop`)}),m();let S=new ResizeObserver(()=>{m(),r?(h(performance.now()),_(performance.now())):a.requestFrame()});return S.observe(n),r?v():(n.addEventListener(`pointermove`,y,{passive:!0}),n.addEventListener(`pointerleave`,b)),()=>{a.setFrameHandler(null),S.disconnect(),n.removeEventListener(`pointermove`,y),n.removeEventListener(`pointerleave`,b),u.inside=!1}},[e,a,r,i])}var ut=[1,.66,.33,0],dt=e=>`${(1-e*(1-Xe))*100}%`,ft=(e,t)=>(e+.5)/t*100;function pt({values:e,max:t,labels:n,formatValue:r}){let[i,a]=(0,b.useState)(null),o=(0,b.useRef)(null),s=F(),c=t=>{let n=o.current?.getBoundingClientRect();if(!n?.width)return;let r=(t-n.left)/n.width,i=Math.round(r*e.length-.5);a(Math.min(e.length-1,Math.max(0,i)))},l=i!==null,u=i??0,f=e[u]??0,p=s?void 0:`left 260ms ease-out, top 260ms ease-out`;return(0,I.jsxs)(`div`,{ref:o,className:`absolute inset-0 cursor-crosshair touch-none`,onPointerMove:e=>c(e.clientX),onPointerLeave:()=>a(null),children:[(0,I.jsx)(`span`,{className:d(`pointer-events-none absolute inset-y-0 w-px -translate-x-1/2 bg-[var(--brand-line)] transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,transition:p}}),(0,I.jsxs)(`div`,{className:d(`pointer-events-none absolute size-0 transition-opacity duration-150`,l?`opacity-100`:`opacity-0`),style:{left:`${ft(u,e.length)}%`,top:`${et(f,t)*100}%`,transition:p},children:[(0,I.jsx)(`span`,{className:`absolute size-[9px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--brand)] ring-2 ring-[var(--console-surface)]`}),(0,I.jsxs)(`span`,{className:`console-mono absolute bottom-3 flex -translate-x-1/2 items-baseline gap-1.5 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 whitespace-nowrap shadow-[var(--shadow-overlay)]`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-[var(--console-muted)]`,children:n[u]}),(0,I.jsx)(`span`,{className:`text-[12px] font-semibold text-[var(--console-text)]`,children:r(f)})]})]})]})}function mt({values:e,max:t,labels:n,height:r,formatValue:i,formatTick:a,className:o}){let s=(0,b.useRef)(null);return lt(s,{values:e,max:t,reducedMotion:F()}),(0,I.jsxs)(`div`,{className:d(`flex`,o),"aria-hidden":!0,children:[a?(0,I.jsx)(`div`,{className:`relative shrink-0`,style:{height:r,width:38},children:ut.map(e=>(0,I.jsx)(`span`,{className:`console-mono absolute right-2 -translate-y-1/2 text-[9.5px] whitespace-nowrap text-[var(--console-muted)]`,style:{top:dt(e)},children:a(t*e)},e))}):null,(0,I.jsxs)(`div`,{className:`chart-hatch relative min-w-0 flex-1`,style:{height:r},children:[ut.map(e=>(0,I.jsx)(`span`,{className:d(`pointer-events-none absolute inset-x-0`,e===0?`h-px bg-[var(--console-border-strong)]`:`border-t border-dashed border-[var(--console-border)]`),style:{top:dt(e)}},e)),(0,I.jsx)(`canvas`,{ref:s,className:`absolute inset-0 block`}),e.length>0?(0,I.jsx)(pt,{values:e,max:t,labels:n,formatValue:i}):null]})]})}var ht=168,gt=132,_t=6,vt={barRatio:.86,barMax:46,bandGap:2,minBand:3},Q=[{key:`input`,label:`Input`,color:`var(--token-input)`},{key:`output`,label:`Output`,color:`var(--token-output)`},{key:`cache_read`,label:`Cache read`,color:`var(--token-cache-read)`},{key:`cache_create`,label:`Cache write`,color:`var(--token-cache-write)`}],yt=Q.map(e=>e.color);function bt(e){return e>=1e3?`$${o(e)}`:`$${Math.round(e)}`}function $(e){return e.input+e.output+e.cache_read+e.cache_create}function xt(e){return`${f(e.date)}: ${o($(e))} tokens, ${a(e.cost)}, ${u(e.sessions)} sessions, ${u(e.messages)} messages, input ${o(e.input)}, output ${o(e.output)}, cache read ${o(e.cache_read)}, cache write ${o(e.cache_create)}`}function St({daily:e}){let t=(0,b.useMemo)(()=>e.map(e=>e.cost),[e]),n=(0,b.useMemo)(()=>e.map(e=>f(e.date)),[e]),r=t.reduce((e,t)=>e+t,0),i=t.reduce((e,t)=>Math.max(e,t),0);return i<=0?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`mt-[14px] flex items-baseline justify-between border-t border-dashed border-[var(--console-border)] pt-[11px]`,children:[(0,I.jsx)(`span`,{className:`console-mono text-[10.5px] text-[var(--console-text)]`,children:`Daily cost`}),(0,I.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[`Peak `,a(i),` · Avg `,a(r/e.length),` · Total `,a(r)]})]}),(0,I.jsx)(mt,{values:t,max:i,labels:n,height:gt,formatValue:a,formatTick:bt,className:`mt-[7px]`})]})}function Ct({bucket:e,index:t,count:n}){return(0,I.jsxs)(`div`,{className:d(`console-mono pointer-events-none absolute top-2 z-10 rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-2 text-[10.5px] whitespace-nowrap text-[var(--console-text)] shadow-[var(--shadow-overlay)]`,t>=n*.75?`-translate-x-full`:`-translate-x-1/2`),style:{left:`${(t+.5)/n*100}%`},children:[(0,I.jsx)(`div`,{children:f(e.date)}),(0,I.jsxs)(`div`,{children:[o($(e)),` tok ·`,` `,(0,I.jsx)(`span`,{className:`text-[var(--brand)]`,children:a(e.cost)})]}),(0,I.jsxs)(`div`,{children:[u(e.sessions),` sessions · `,u(e.messages),` messages`]}),(0,I.jsxs)(`div`,{className:`text-[var(--console-muted)]`,children:[`In `,o(e.input),` · Out `,o(e.output),` · Read`,` `,o(e.cache_read),` · Write `,o(e.cache_create)]})]})}function wt({daily:e}){let[t,n]=(0,b.useState)(null),r=(0,b.useMemo)(()=>e.map(e=>Q.map(t=>e[t.key])),[e]),i=(0,b.useMemo)(()=>e.map(xt),[e]),a=(0,b.useMemo)(()=>ee(e.reduce((e,t)=>Math.max(e,$(t)),0)),[e]),s=t===null?void 0:e[t.column];return(0,I.jsxs)(`div`,{className:`relative mt-[14px]`,children:[(0,I.jsx)(L,{values:r,axisMax:a,colors:yt,hovered:t,onHover:n,layout:vt,height:ht,formatTick:o,ariaLabel:`Daily usage chart`,itemLabels:i}),s&&t?(0,I.jsx)(`div`,{className:`absolute inset-x-0 top-0`,style:{left:38},children:(0,I.jsx)(Ct,{bucket:s,index:t.column,count:e.length})}):null]})}function Tt({daily:e}){let t=e[0],n=e[e.length-1],r=t&&n?` · ${f(t.date)} → ${f(n.date)}`:``,i=Math.max(1,Math.ceil(e.length/_t));return(0,I.jsxs)(y,{role:`region`,"aria-label":`Daily usage`,className:`p-4`,children:[(0,I.jsx)(g,{title:`Daily usage`,action:(0,I.jsx)(`div`,{className:`console-mono flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-[var(--console-muted)]`,children:Q.map(e=>(0,I.jsxs)(`span`,{"data-testid":`overview-legend-token`,className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`size-2 rounded-[2px]`,style:{background:e.color},"aria-hidden":!0}),e.label]},e.key))})}),(0,I.jsxs)(`p`,{className:`console-mono mt-1 text-[10.5px] text-[var(--console-muted)]`,children:[`Stacked bars = token mix · Area below = daily cost`,r]}),e.length===0?(0,I.jsx)(`p`,{className:`console-mono mt-[14px] text-[11px] text-[var(--console-muted)]`,children:`No usage data`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(wt,{daily:e}),(0,I.jsx)(St,{daily:e}),(0,I.jsx)(`div`,{style:{paddingLeft:38},children:(0,I.jsx)(`div`,{className:`console-mono mt-2 flex text-[10px] text-[var(--console-muted)]`,children:e.map((t,n)=>(0,I.jsx)(`span`,{className:`flex-1 text-center`,children:n%i===0||n===e.length-1?f(t.date):``},t.date))})})]}),(0,I.jsxs)(`table`,{className:`sr-only`,"aria-label":`Daily usage data`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:`Date`}),(0,I.jsx)(`th`,{children:`Sessions`}),(0,I.jsx)(`th`,{children:`Messages`}),(0,I.jsx)(`th`,{children:`Tokens`}),(0,I.jsx)(`th`,{children:`Cost`})]})}),(0,I.jsx)(`tbody`,{children:e.map(e=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:f(e.date)}),(0,I.jsx)(`td`,{children:u(e.sessions)}),(0,I.jsx)(`td`,{children:u(e.messages)}),(0,I.jsx)(`td`,{children:u($(e))}),(0,I.jsx)(`td`,{children:a(e.cost)})]},e.date))})]})]})}function Et({project:e,agent:t,onAgentChange:n,window:r,agentCatalog:i,rangePreset:a,onRangeChange:o,onSelectCustom:s}){let[c,l]=(0,b.useState)(void 0),u=n?t:c,{dashboard:d,error:f,retry:p}=x(r,{project:e,agent:u});return(0,I.jsxs)(`div`,{"data-testid":`dashboard`,className:`mx-auto max-w-6xl space-y-4`,children:[(0,I.jsx)(He,{agent:u,onAgentChange:n?void 0:l,agentCatalog:i,scopeCounts:d?.scopeCounts,window:r,rangePreset:a,onRangeChange:o,onSelectCustom:s}),f?(0,I.jsx)(_,{title:`Couldn't load the dashboard.`,message:f,onRetry:()=>void p()}):null,d?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qe,{totals:d.totals,rangeDays:d.window.days}),(0,I.jsx)(Tt,{daily:d.dailyActivity}),(0,I.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,I.jsx)(be,{perAgent:d.perAgent}),(0,I.jsx)(Be,{modelCost:d.modelCost,modelDistribution:d.modelDistribution,totals:d.totals})]})]}):f?null:(0,I.jsx)(Ye,{})]})}export{Et as OverviewScreen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{d as r,g as i,i as a,l as o,m as s,n as c,r as l,s as u,t as d,u as f}from"./utils-C7BqyxxV.js";import{r as p,t as m}from"./panel-ND0J63d3.js";import{S as h,l as g,p as _,r as v,t as y,u as b}from"./contract-xJyW5u7a.js";import{a as x,o as S,p as C}from"./session-indexes-BsgjUoc1.js";import{a as w,i as T,r as E}from"./index-DEjvzumm.js";import{OverviewScreen as D}from"./OverviewScreen-5hvQVp4H.js";var O=e(t(),1);function k(e){return e.time_updated??e.time_created}function A(e){return e.reference}function j(e,t){let n=_(t);if(e===n)return`Today`;if(e===y(n,-1))return`Yesterday`;let r=new Date(e);return f(r.getTime())}function M(e){let{session:t}=e,n=A(t);return{routeKey:g(n.agentName,n.sessionId),reference:n,time:k(t),title:E(t),messageCount:t.stats.message_count,cost:t.stats.total_cost??0}}function N(e,t){if(t.length===1){e.push(t[0]);return}let n=t.toSorted((e,t)=>k(e.session)-k(t.session));for(let t=n.length-1;t>=0;--t)e.push(n[t])}function P(e,t,n){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`page total must be a non-negative safe integer`);if(!Number.isSafeInteger(n)||n<=0)throw RangeError(`page limit must be a positive safe integer`);if(e===0)return{offset:0,end:0};let r=Number.isSafeInteger(t)&&t>0?t:0,i=r-r%n,a=Math.floor((e-1)/n)*n,o=Math.min(i,a);return{offset:o,end:o+Math.min(n,e-o)}}function F(e,t){let{session:n,inclusiveStats:r}=e,i=A(n);return{routeKey:g(i.agentName,i.sessionId),reference:i,time:k(n),title:E(n),agentKey:i.agentName,childCount:e.descendantCount,childRoots:e.children,messageCount:r.messageCount,tokens:r.totalTokens,cost:r.cost,isOrphan:t}}function I(e,t=0,n=40){let{offset:r,end:i}=P(e.childCount,t,n),a=[],o=[];N(o,e.childRoots);let s=0;for(;o.length>0&&s<i;){let e=o.pop();s>=r&&a.push(M(e)),s+=1,N(o,e.children)}return{rows:a,offset:r,pageNumber:Math.floor(r/n)+1,hasPrevious:r>0,hasNext:i<e.childCount}}function L(e,t=0,n=40){let{offset:r,end:i}=P(e.mainCount,t,n),a=i-r,o=[],s=0,c=0;for(let t of e.days){if(c===a)break;let e=Math.max(0,r-s);if(s+=t.nodes.length,e>=t.nodes.length)continue;let n=t.nodes.slice(e,e+a-c);if(n.length===0)continue;let i=n.map(e=>F(e,e.session.parent_reference!=null));o.push({dayKey:t.dayKey,dayStart:t.dayStart,label:t.label,mainCount:t.mainCount,subCount:t.subCount,rows:i}),c+=i.length}return{days:o,offset:r,pageNumber:Math.floor(r/n)+1,shown:c,hasPrevious:r>0,hasNext:i<e.mainCount}}function R(e,t){let n=v(e),r=t?.now??Date.now();return{days:b(n.entries).map(e=>({dayKey:e.dayKey,dayStart:e.dayStart,label:j(e.dayStart,r),mainCount:e.mainCount,subCount:e.subCount,nodes:e.nodes})),orphanCount:n.orphans.length,mainCount:n.entries.length,subCount:n.entries.reduce((e,t)=>e+t.descendantCount,0),totalTokens:n.entries.reduce((e,t)=>e+t.inclusiveStats.totalTokens,0)}}function z(e,t,n){return t===`hidden`||e.childCount===0?!1:t===`expanded`||n.has(e.routeKey)}var B=n(),V={sm:`px-2 py-[3px] text-[10.5px]`,md:`px-3 py-[5px] text-xs`};function H({options:e,value:t,onChange:n,size:r=`md`,ariaLabel:i}){let a=(0,O.useRef)([]),o=e.findIndex(e=>e.value===t),s=o<0?0:o,c=(t,r)=>{let i=(t+r+e.length)%e.length;n(e[i].value),a.current[i]?.focus()};return(0,B.jsx)(`div`,{role:`radiogroup`,"aria-label":i,className:`inline-flex rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[3px]`,children:e.map((e,t)=>{let i=t===o;return(0,B.jsx)(`button`,{ref:e=>{a.current[t]=e},type:`button`,role:`radio`,"aria-checked":i,tabIndex:t===s?0:-1,onClick:()=>n(e.value),onKeyDown:e=>{e.key===`ArrowRight`||e.key===`ArrowDown`?(e.preventDefault(),c(t,1)):(e.key===`ArrowLeft`||e.key===`ArrowUp`)&&(e.preventDefault(),c(t,-1))},className:d(`console-mono motion-hover rounded-sm border border-transparent whitespace-nowrap focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,V[r],i?`bg-[var(--brand)] text-[var(--brand-fg)]`:`text-[var(--console-muted)] hover:text-[var(--console-text)]`),children:e.label},e.value)})})}var U=[{value:`collapsed`,label:`Collapsed`},{value:`expanded`,label:`Expand all`},{value:`hidden`,label:`Hidden`}];function W({mode:e,onChange:t}){return(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`console-eyebrow`,children:`Sub-sessions`}),(0,B.jsx)(H,{options:U,value:e,onChange:t,size:`sm`,ariaLabel:`Sub-session display`})]})}function G({id:e,row:t,onOpen:n}){let[r,a]=(0,O.useState)(0),o=(0,O.useMemo)(()=>I(t,r),[r,t]);return(0,B.jsxs)(`div`,{id:e,className:`border-t border-dashed border-[var(--console-border-strong)] bg-[var(--console-surface-muted)] p-[10px_16px_12px_66px]`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`span`,{className:`console-eyebrow`,children:`Sub-sessions · derived from this session`}),t.childCount>40?(0,B.jsxs)(`span`,{className:`console-mono text-[10px] text-[var(--console-muted)]`,children:[`Page `,o.pageNumber,` · `,o.rows.length,` shown`]}):null]}),(0,B.jsx)(`div`,{className:`mt-2 flex flex-col gap-1.5 border-l border-dashed border-[var(--console-border-strong)] pl-[14px]`,children:o.rows.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>n(e.reference),className:`motion-hover flex items-center gap-[11px] rounded-md border border-[var(--console-border)] bg-[var(--console-surface)] p-[9px_12px] text-left hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,B.jsx)(`span`,{className:`console-mono w-[34px] shrink-0 text-[10px] text-[var(--console-muted)]`,children:l(e.time)}),e.kind==null?null:(0,B.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:e.kind}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12.5px] text-[var(--console-text)]`,children:e.title}),(0,B.jsxs)(`span`,{className:`console-mono shrink-0 text-[10px] text-[var(--console-muted)]`,children:[u(e.messageCount),` msgs · `,i(e.cost)]})]},e.routeKey))}),o.hasPrevious||o.hasNext?(0,B.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Previous sub-session page`,disabled:!o.hasPrevious,onClick:()=>a(o.offset-40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Previous`}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Next sub-session page`,disabled:!o.hasNext,onClick:()=>a(o.offset+40),className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2 py-1 text-[10px] text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Next`})]}):null]})}function K({row:e,mode:t,expanded:n,agentCatalog:r,onToggle:o,onOpen:s}){let d=(0,O.useId)(),f=w(r,e.agentKey),p=f?.displayName??e.agentKey,m=e.childCount>0;return(0,B.jsxs)(`article`,{className:`overflow-hidden rounded-lg border bg-[var(--console-surface)] shadow-[var(--shadow-raised)] ${n?`border-[var(--brand-line)]`:`border-[var(--console-border)]`}`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-[13px] p-[13px_16px]`,children:[(0,B.jsx)(`span`,{className:`console-mono w-[38px] shrink-0 text-[11px] text-[var(--console-muted)]`,children:l(e.time)}),e.isOrphan?(0,B.jsx)(`span`,{className:`console-mono shrink-0 rounded-sm border border-[var(--console-border-strong)] px-1.5 text-[9.5px] text-[var(--console-muted)]`,children:`Unmounted`}):null,(0,B.jsx)(`span`,{className:`inline-flex size-6 shrink-0 items-center justify-center rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)]`,children:f?.icon?(0,B.jsx)(c,{icon:f.icon,iconColored:f.iconColored,alt:p,className:`size-[13px] object-contain`}):null}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(e.reference),className:`min-w-0 flex-1 text-left focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,B.jsx)(`span`,{className:`block truncate text-[13.5px] font-medium text-[var(--console-text)]`,children:e.title}),(0,B.jsxs)(`span`,{className:`console-mono mt-[3px] block truncate text-[10.5px] text-[var(--console-muted)]`,children:[p,` · `,u(e.messageCount),` msgs · `,a(e.tokens),` tok`,m?` · ${e.childCount} sub-sessions`:``]})]}),m&&t!==`hidden`?(0,B.jsxs)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":d,onClick:()=>o(e.routeKey),className:`console-mono motion-hover inline-flex shrink-0 items-center gap-1.5 rounded-full border border-[var(--brand-line)] bg-[var(--brand-soft)] px-2.5 py-[3px] text-[10.5px] text-[var(--brand)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,B.jsx)(`span`,{className:`text-[11px]`,children:`⑂`}),e.childCount,` sub`,(0,B.jsx)(`span`,{className:`opacity-70`,children:n?`▾`:`▸`})]}):null,(0,B.jsxs)(`span`,{className:`console-mono w-[76px] shrink-0 text-right text-[11px] text-[var(--console-muted)]`,children:[i(e.cost),m?` incl. sub`:``]})]}),n?(0,B.jsx)(G,{id:d,row:e,onOpen:s}):null]})}function q({day:e,mode:t,openIds:n,agentCatalog:r,onToggle:i,onOpen:a}){return(0,B.jsxs)(`div`,{className:`flex gap-5`,children:[(0,B.jsxs)(`div`,{className:`w-[84px] shrink-0 pt-[14px] text-right`,children:[(0,B.jsx)(`div`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e.label}),(0,B.jsxs)(`div`,{className:`console-mono mt-0.5 text-[10px] text-[var(--console-muted)]`,children:[e.mainCount,` main · `,e.subCount,` sub`]})]}),(0,B.jsxs)(`div`,{className:`relative flex min-w-0 flex-1 flex-col gap-2.5 border-l border-[var(--console-border)] py-2.5 pr-0 pl-[22px]`,children:[(0,B.jsx)(`span`,{className:`absolute top-[18px] -left-[4px] size-[7px] rounded-full bg-[var(--brand)]`}),e.rows.map(e=>(0,B.jsx)(K,{row:e,mode:t,expanded:z(e,t,n),agentCatalog:r,onToggle:i,onOpen:a},e.routeKey))]})]})}function J({sessions:e,projectName:t,agentCatalog:n,onOpenSession:r}){let[i,o]=(0,O.useState)(`collapsed`),[s,c]=(0,O.useState)(()=>new Set),[l,u]=(0,O.useState)(0),d=(0,O.useMemo)(()=>R(e),[e]),f=(0,O.useMemo)(()=>L(d,l),[l,d]),p=(0,O.useCallback)(e=>{c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]);return(0,B.jsxs)(`section`,{"aria-label":`${t} timeline`,className:`flex flex-col gap-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`${d.mainCount} sessions · ${d.subCount} sub-sessions · ${a(d.totalTokens)} tokens`}),(0,B.jsx)(`div`,{className:`ml-auto`,children:(0,B.jsx)(W,{mode:i,onChange:o})})]}),d.mainCount>40?(0,B.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,B.jsxs)(`span`,{children:[`Page `,f.pageNumber,` · `,f.shown,` shown`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,"aria-label":`Previous timeline page`,disabled:!f.hasPrevious,onClick:()=>u(f.offset-40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Previous`}),(0,B.jsx)(`button`,{type:`button`,"aria-label":`Next timeline page`,disabled:!f.hasNext,onClick:()=>u(f.offset+40),className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Next`})]})]}):null,(0,B.jsx)(`div`,{className:`flex flex-col gap-3`,children:f.days.map(e=>(0,B.jsx)(q,{day:e,mode:i,openIds:s,agentCatalog:n,onToggle:p,onOpen:r},e.dayKey))}),d.orphanCount>0?(0,B.jsxs)(`p`,{className:`console-mono text-[10.5px] text-[var(--console-muted)]`,children:[d.orphanCount,` unmounted sub-sessions · parent file is gone`]}):null]})}function Y({label:e,value:t,hint:n}){return(0,B.jsxs)(m,{className:`p-[14px_16px]`,children:[(0,B.jsx)(`p`,{className:`console-eyebrow`,children:e}),(0,B.jsx)(`p`,{className:`console-mono mt-[9px] text-[27px] font-semibold tracking-[-0.02em] text-[var(--console-text)]`,children:t}),n?(0,B.jsx)(`p`,{className:`console-mono mt-[7px] text-[10.5px] text-[var(--console-muted)]`,children:n}):null]})}function X({agents:e,agentCatalog:t}){return e.length===0?null:(0,B.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:e.slice(0,4).map(e=>{let n=w(t,e.name);return(0,B.jsxs)(`span`,{className:`console-mono inline-flex items-center gap-1 rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:[n?.icon?(0,B.jsx)(c,{icon:n.icon,iconColored:n.iconColored,alt:n.displayName,className:`size-3 object-contain`}):null,n?.displayName??e.name,` · `,e.sessions]},e.name)})})}function Z({project:e,agentCatalog:t}){return(0,B.jsx)(`li`,{children:(0,B.jsxs)(S,{to:x({kind:e.identityKind,key:e.identityKey}),className:`block rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--brand-line)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:[(0,B.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h2`,{className:`line-clamp-1 text-[13px] font-medium text-[var(--console-text)]`,children:e.displayName}),(0,B.jsx)(`p`,{className:`console-mono mt-[5px] break-all text-[10.5px] text-[var(--console-muted)]`,children:e.identityKey})]}),(0,B.jsxs)(`div`,{className:`console-mono flex shrink-0 flex-wrap gap-2 text-[11px] text-[var(--console-text-secondary)]`,children:[(0,B.jsxs)(`span`,{children:[r(e.sessionCount),` sessions`]}),(0,B.jsxs)(`span`,{children:[a(e.tokens),` tokens`]}),(0,B.jsx)(`span`,{className:`text-[var(--brand)]`,children:o(e.cost)}),(0,B.jsx)(`span`,{className:`text-[var(--console-muted)]`,children:s(e.lastActivity)})]})]}),(0,B.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,B.jsx)(X,{agents:e.agentStats,agentCatalog:t}),(0,B.jsx)(`span`,{className:`console-eyebrow`,children:e.identityKind})]})]})})}function Q({initialPage:e,window:t,agentCatalog:n,loading:i,error:c,onRetry:l}){let u=T(t,e),d=u.page??e,f=d.projects.slice(0,250),h=u.error??c,g=u.error?()=>void u.retry():l;return d.summary.projects===0?h?(0,B.jsx)(`div`,{className:`mx-auto max-w-6xl`,children:(0,B.jsx)(p,{title:`Couldn't load projects.`,message:h,onRetry:g})}):i||u.loading?(0,B.jsx)(m,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:`Loading projects...`}):(0,B.jsx)(m,{className:`mx-auto max-w-6xl p-6 text-sm text-[var(--console-muted)]`,children:`No projects found`}):(0,B.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[h?(0,B.jsx)(p,{title:`Couldn't refresh projects.`,message:h,onRetry:g}):null,(0,B.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,B.jsx)(Y,{label:`Projects`,value:r(d.summary.projects)}),(0,B.jsx)(Y,{label:`Sessions`,value:r(d.summary.sessions)}),(0,B.jsx)(Y,{label:`Tokens`,value:a(d.summary.tokens)}),(0,B.jsx)(Y,{label:`Total Cost`,value:o(d.summary.cost),hint:d.summary.latestActivity?`Latest ${s(d.summary.latestActivity)}`:void 0})]}),(0,B.jsxs)(`div`,{className:`console-mono flex items-center justify-between gap-3 text-[11px] text-[var(--console-muted)]`,children:[(0,B.jsxs)(`span`,{children:[`Page `,u.pageNumber,` · `,r(f.length),` shown`]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,disabled:!u.canPrevious,onClick:u.previous,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Previous`}),(0,B.jsx)(`button`,{type:`button`,disabled:!u.canNext,onClick:u.next,className:`rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-2.5 py-1.5 text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface-muted)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-40`,children:`Next`})]})]}),(0,B.jsx)(`ul`,{className:`grid gap-3`,children:f.map(e=>(0,B.jsx)(Z,{project:e,agentCatalog:n},`${e.identityKind}:${e.identityKey}`))})]})}function $({agents:e,agentCatalog:t,activeAgent:n,onChange:r}){let i=e=>`console-mono inline-flex items-center gap-1 rounded-full border px-[13px] py-[5px] text-[11px] motion-hover focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none ${e?`border-[var(--brand)] bg-[var(--brand)] text-[var(--brand-fg)]`:`border-[var(--console-border)] bg-[var(--console-surface)] text-[var(--console-muted)] hover:border-[var(--brand-line)]`}`;return(0,B.jsx)(m,{className:`p-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`console-eyebrow`,children:`Agent`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>r(void 0),className:i(!n),children:`All Agents`}),e.map(e=>{let a=w(t,e.name),o=n===e.name;return(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(o?void 0:e.name),className:i(o),children:[a?.icon?(0,B.jsx)(c,{icon:a.icon,iconColored:a.iconColored,alt:a.displayName,className:`size-3 object-contain`}):null,a?.displayName??e.name,` · `,e.sessions]},e.name)})]})})}function ee({project:e}){return(0,B.jsxs)(m,{className:`p-4`,children:[(0,B.jsx)(`h2`,{className:`console-display text-[19px] font-semibold text-[var(--console-text)]`,children:e.displayName}),(0,B.jsxs)(`p`,{className:`console-mono mt-1 break-all text-[10.5px] text-[var(--console-muted)]`,children:[e.identityKind,`: `,e.identityKey]})]})}function te({project:e,loading:t,error:n,onRetry:r,agentCatalog:i,projectKey:a,sessions:o,activeAgent:s,onChangeAgent:c,timeWindow:l,rangePreset:u,onRangeChange:d,onSelectCustom:f}){let g=C();if(t)return(0,B.jsx)(m,{className:`mx-auto max-w-4xl p-6 text-sm text-[var(--console-muted)]`,children:`Loading project...`});if(n)return(0,B.jsx)(`div`,{className:`mx-auto max-w-4xl`,children:(0,B.jsx)(p,{title:`Couldn't load project.`,message:n,onRetry:r})});if(!e)return(0,B.jsxs)(m,{className:`mx-auto max-w-4xl p-6`,children:[(0,B.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:`Project Not Found`}),(0,B.jsx)(`p`,{className:`console-mono mt-2 break-all text-xs text-[var(--console-muted)]`,children:a}),(0,B.jsx)(S,{to:`/projects`,className:`console-mono mt-4 inline-flex rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-2 py-1 text-xs text-[var(--console-text)] motion-hover hover:bg-[var(--console-surface)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:outline-none`,children:`Back to Projects`})]});let _=s?o.filter(e=>e.reference.agentName===s):o;return(0,B.jsxs)(`div`,{className:`mx-auto max-w-6xl space-y-4`,children:[(0,B.jsx)(ee,{project:e}),(0,B.jsx)($,{agents:e.agentStats,agentCatalog:i,activeAgent:s,onChange:c}),(0,B.jsx)(D,{project:{kind:e.identityKind,key:e.identityKey},agent:s,onAgentChange:c,window:l,agentCatalog:i,rangePreset:u,onRangeChange:d,onSelectCustom:f},`${e.identityKind}:${e.identityKey}`),(0,B.jsx)(J,{sessions:_,projectName:e.displayName,agentCatalog:i,onOpenSession:e=>g(h(e))},`${e.identityKind}:${e.identityKey}:${s??`all`}`)]})}export{te as ProjectDashboardView,Q as ProjectsOverview};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-B-hcVAMW.js";import{S as t}from"./contract-xJyW5u7a.js";import{o as n}from"./session-indexes-BsgjUoc1.js";import{n as r,o as i,r as a}from"./index-DEjvzumm.js";var o=e(),s={recent:`Recent`,title:`Title`,user_message:`User message`,assistant_reply:`Assistant reply`,tool_output:`Tool output`,file_path:`File path`};function c(e,t){let n=[],r=0;for(let{start:i,end:a}of t)i<r||a<=i||a>e.length||(i>r&&n.push(e.slice(r,i)),n.push((0,o.jsx)(`mark`,{children:e.slice(i,a)},`${i}-${a}`)),r=a);return r<e.length&&n.push(e.slice(r)),n}function l({query:e,state:l,agentNameMap:u,agents:d,projects:f,filters:p,onChangeFilters:m,onOpenResult:h,onRetry:g,selectedIndex:_,registerResultRef:v}){let y=l.status===`loaded`?l.results:[],b=(0,o.jsx)(i,{agents:d,projects:f,filters:p,onChangeFilters:m});return l.status===`loading`?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsx)(`p`,{className:`sr-only`,"aria-live":`polite`,children:`Searching…`}),(0,o.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:4}).map((e,t)=>(0,o.jsxs)(`div`,{"data-testid":`search-result-skeleton`,className:`rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)]`,children:[(0,o.jsx)(`div`,{className:`skeleton-shimmer h-3 w-32 rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-3 h-4 w-2/3 rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-2 h-3 w-full rounded-sm`}),(0,o.jsx)(`div`,{className:`skeleton-shimmer mt-1 h-3 w-5/6 rounded-sm`})]},t))})]}):l.status===`failed`?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsxs)(`div`,{className:`rounded-lg border border-[var(--console-error-border)] bg-[var(--console-error-bg)] p-6`,"aria-live":`polite`,children:[(0,o.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-error)]`,children:`Search Failed`}),(0,o.jsxs)(`p`,{className:`console-mono mt-2 break-words text-xs text-[var(--console-error)]`,children:[l.error,`. Check the server connection, then try again.`]}),(0,o.jsx)(`button`,{type:`button`,onClick:g,className:`console-mono motion-hover motion-press mt-4 rounded-sm border border-[var(--console-error-border)] bg-[var(--console-surface)] px-3 py-1.5 text-xs font-semibold text-[var(--console-error)] hover:bg-[var(--console-error-bg)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none`,children:`Retry Search`})]})]}):y.length===0?(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,(0,o.jsxs)(`div`,{className:`rounded-lg border border-[var(--console-border)] bg-[var(--console-surface)] p-6 shadow-[var(--shadow-raised)]`,children:[(0,o.jsx)(`h2`,{className:`console-display text-[15px] font-semibold text-[var(--console-text)]`,children:e?`No matches`:`No recent sessions`}),e?(0,o.jsxs)(`p`,{className:`console-mono mt-2 text-xs text-[var(--console-muted)]`,children:[`Query: `,e]}):null]})]}):(0,o.jsxs)(`div`,{className:`grid gap-3`,children:[b,(0,o.jsx)(`div`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:`Navigate j k · Open Enter · Exit Esc`}),y.map((i,l)=>{let d=i.reference.agentName.toLowerCase(),f=u.get(d)??i.reference.agentName,p=`${i.reference.agentName}/${i.reference.sessionId}`,m=l===_,g=!!i.session.parent_reference&&!i.parent;return(0,o.jsxs)(n,{ref:e=>v(p,e),to:t(i.reference),state:{searchQuery:e},onClick:h,"data-selected":m?`true`:void 0,className:`rounded-lg border bg-[var(--console-surface)] p-4 shadow-[var(--shadow-raised)] motion-hover hover:border-[var(--console-border-strong)] focus-visible:ring-2 focus-visible:ring-[var(--brand)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--console-bg)] focus-visible:outline-none ${m?`border-[var(--brand)]`:`border-[var(--console-border)]`}`,children:[(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,o.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface-muted)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:f}),(0,o.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border)] bg-[var(--console-surface)] px-1.5 py-0.5 text-[10px] uppercase text-[var(--console-muted)]`,children:s[i.matchType]}),g?(0,o.jsx)(`span`,{className:`console-mono rounded-sm border border-[var(--console-border-strong)] px-1.5 py-0.5 text-[10px] text-[var(--console-muted)]`,children:`Unmounted`}):null,(0,o.jsx)(`span`,{className:`console-mono text-[11px] text-[var(--console-muted)]`,children:i.session.directory})]}),i.parent?(0,o.jsx)(`p`,{className:`console-mono mt-3 line-clamp-1 text-[11px] text-[var(--console-muted)]`,children:i.parent.title}):null,(0,o.jsxs)(`h2`,{className:`text-[13px] font-semibold text-[var(--console-text)] ${i.parent?`mt-1 flex items-center gap-1.5 pl-3`:`mt-3`}`,children:[i.parent?(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`console-mono text-[var(--brand)]`,children:`›`}):null,a(i.session)]}),(0,o.jsx)(r,{tags:i.session.smart_tags,className:`mt-2`}),(0,o.jsx)(`p`,{className:`mt-2 text-xs leading-6 text-[var(--console-text-secondary)]`,children:c(i.snippet||a(i.session),i.snippet?i.snippetHighlights:[])})]},p)})]})}export{l as SearchResultsPanel};
|