specrails-desktop 2.64.0 → 2.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-D23wXKgy.js → ActivityFeedPage-Dtp7EyHc.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DQzS4XcK.js → AgentBrowserCapture-CLqlEFw8.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-CFTiSl8T.js → AgentModeAnalyticsPane-B8_hM3Tw.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-DAaSzIPA.js → AgentModeCodePane-CNF8ZNjE.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-C29YpixV.js → AgentModeJobsPane-CJpJbO9m.js} +1 -1
- package/client/dist/assets/AgentsPage-BC8XSR79.js +120 -0
- package/client/dist/assets/{AnalyticsPage-81fI80nA.js → AnalyticsPage-Cdv4jLtW.js} +1 -1
- package/client/dist/assets/{CodePage-Ct4XEPdx.js → CodePage-DI1kegAr.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-Bt37XOLF.js → DesktopAnalyticsPage-Bdp8E8U6.js} +1 -1
- package/client/dist/assets/{DocsDialog-_IEr8umI.js → DocsDialog-Bm4RS7FX.js} +1 -1
- package/client/dist/assets/{DocsPage-DX9WOqt2.js → DocsPage-DihYcU8r.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-DDI6TdsS.js → InteractiveJobComposer-BO6ASN-2.js} +1 -1
- package/client/dist/assets/{JobDetailModal-CkD0PBaZ.js → JobDetailModal-CuPYq7tP.js} +1 -1
- package/client/dist/assets/{JobDetailPage-B8Rd4U5J.js → JobDetailPage-BusMjJi9.js} +1 -1
- package/client/dist/assets/{JobsPage-ChOiSbJn.js → JobsPage-C0QbsF2d.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-6Xwt2G6G.js → LoopBuilderPage-B7TlU4iS.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-CyDapSvB.js → LoopPreviewModal-BRWtXOD2.js} +1 -1
- package/client/dist/assets/{LoopWindowSurface-gRdx4nmg.js → LoopWindowSurface-DE0v2K1p.js} +1 -1
- package/client/dist/assets/{LoopsPage-BPGVFsH-.js → LoopsPage-C4q1DmCE.js} +1 -1
- package/client/dist/assets/{PluginsPage-DQRRdCUi.js → PluginsPage-Z1JHSMdR.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-Ce8DSG6H.js → ProjectSettingsDialog-BUNj0tvN.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-WVoio8GJ.js → ReviewPacketPage-hwfPNjyy.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-CTBZUXAN.js → TemplatePreviewModal-V7FpMWuw.js} +1 -1
- package/client/dist/assets/{index-IdGpV21X.js → index-Ce4yZtKf.js} +6 -6
- package/client/dist/index.html +1 -1
- package/docs/internals/core-runtime-updates.md +3 -3
- package/local-runner/dist/specrails-local-runner.js +487 -148
- package/mcp-bridge/dist/specrails-mcp.js +330 -42
- package/package.json +6 -3
- package/client/dist/assets/AgentsPage-B-sSTP1I.js +0 -118
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{f as r}from"./chunk-OB3PAWPO-B1EMk45A.js";import{m as i,r as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{t as o}from"./Trans-BbFxRFtR.js";import{n as s,t as c}from"./createLucideIcon-DtODIU64.js";import{a as l,n as u,r as d}from"./useDesktop-BjLT0_EE.js";import{n as f,s as p}from"./provider-capabilities-lePfeT_Y.js";import{n as m,r as h,t as g}from"./spending-CQnrWiR3.js";import{t as _}from"./clsx-CjueKrWZ.js";import{t as v}from"./formatDistanceToNow-NjPHBLfB.js";import{Dt as y,en as b}from"./index-IdGpV21X.js";import{t as x}from"./ExportDropdown-Bb1lHx3r.js";import{$ as S,A as C,B as ee,C as te,Ct as w,D as T,E,F as D,H as O,I as k,J as A,K as ne,L as j,M,N,P,R as F,S as re,St as I,T as ie,U as L,V as R,W as z,X as ae,Y as B,Z as V,_ as oe,_t as se,a as H,at as ce,bt as le,c as ue,ct as de,dt as U,et as fe,f as pe,ft as me,g as he,h as ge,ht as _e,i as ve,it as ye,j as be,k as xe,l as Se,lt as Ce,m as we,mt as W,n as Te,o as Ee,ot as De,p as Oe,pt as ke,r as Ae,rt as je,s as Me,t as Ne,tt as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,yt as G,z as Be}from"./BarChart-BDMqVFJy.js";var Ve={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};Ve.node;var He=c(Ve),K=e(t(),1),q=n();function Ue(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function We(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Ke=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`chat-sidebar`,`spec-launcher`,`proposal`,`agent-studio`,`setup`,`smash`,`file-summary`,`loop`];function qe({data:e,loading:t,period:n}){let{t:r}=s(`analytics`),[i,a]=(0,K.useState)(0),o=(0,K.useRef)(0),c=(0,K.useRef)(null),l=(0,K.useRef)(0);if((0,K.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd,n=++l.current;if(c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),o.current===0&&t>0){let e=performance.now(),r=i=>{if(n!==l.current)return;let o=Math.min(1,(i-e)/600),s=1-(1-o)**3;a(0+(t-0)*s),o<1?c.current=requestAnimationFrame(r):c.current=null};c.current=requestAnimationFrame(r)}else a(t);return o.current=t,()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[e]),t&&!e)return(0,q.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let u=e.summary.totalCostUsd,d=e.summary.totalRuns,f=e.summary.totalTokens,p=e.summary.totalEstimatedCostUsd??0,_=typeof e.summary.pricedRuns==`number`||typeof e.summary.unpricedRuns==`number`,v=e.summary.unpricedRuns??0,y=e.summary.pricedRuns??(_?Math.max(0,d-v):d),b=_&&d>0&&y===0&&v>0,x=y>0&&v>0,S=typeof e.summary.usageReportedRuns==`number`||typeof e.summary.usageUnavailableRuns==`number`,C=e.summary.usageUnavailableRuns??0,ee=e.summary.usageReportedRuns??(S?Math.max(0,d-C):d),te=S&&d>0&&ee===0&&C>0,w=ee>0&&C>0,T=v>0?null:e.summary.deltaPct,E=e.trackingStartedAt,D=p>0,O=e.bySurface.map(e=>e.surface).filter(e=>!Ke.includes(e)),k=[...Ke,...O].map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}}),A=n?r(`windowLabels.${n}`):null;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{children:r(`hero.spending`)}),A&&(0,q.jsxs)(`span`,{"data-testid":`hero-window-label`,className:`normal-case tracking-normal text-muted-foreground/70 font-normal`,children:[`· `,A]})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,"data-testid":b?`hero-cost-unavailable`:void 0,title:b?r(`hero.costUnavailableTooltip`):void 0,children:b?`—`:We(i)}),T!==null&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${T>=0?`text-accent-warning`:`text-accent-success`}`,children:[T>=0?(0,q.jsx)(h,{className:`w-3 h-3`}):(0,q.jsx)(He,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(T).toFixed(0)})]})]}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:r(`hero.invocations`,{count:d})}),te?(0,q.jsx)(`span`,{"data-testid":`hero-usage-unavailable`,className:`text-muted-foreground/80 italic`,title:r(`hero.usageUnavailableTooltip`),children:r(`hero.usageUnavailable`)}):w&&f!=null?(0,q.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.usagePartiallyUnavailableTooltip`),children:r(`hero.usagePartiallyUnavailable`,{tokens:Ge(f),count:C})}):f!=null&&f>0?(0,q.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:Ge(f)})}):null,b&&(0,q.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.costUnavailableTooltip`),children:r(`hero.costUnavailable`)}),x&&(0,q.jsx)(`span`,{"data-testid":`hero-cost-partial`,className:`text-muted-foreground/80 italic`,title:r(`hero.costPartiallyUnavailableTooltip`),children:r(`hero.costPartiallyUnavailable`,{count:v})}),D&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:Ue(p)}),children:r(`hero.includesEstimated`,{amount:Ue(p)})})]})]}),d===0&&E&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:E.slice(0,10)})})]}),d===0?(0,q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:E?r(`hero.trackingStarted`,{date:E.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):b?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-4 text-xs text-muted-foreground/80`,children:r(`hero.costUnavailableTooltip`)}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:k.map(e=>{let t=u>0?e.costUsd/u*100:0;return t===0?null:(0,q.jsx)(`div`,{className:`h-full ${g[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:m[e.surface],value:Ue(e.costUsd)})},e.surface)})}),(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:k.filter(e=>e.costUsd>0).map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full ${g[e.surface].dot}`}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:m[e.surface]}),(0,q.jsx)(`span`,{className:`text-foreground font-medium`,children:Ue(e.costUsd)}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Je={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`},Ye={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`,kimi:`bg-purple-400`};function Xe(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Ze(e){return Je[e]??e}function Qe(e){return Ye[e]??`bg-accent-secondary`}function $e({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let r=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0),i=e.byProvider.some(e=>typeof e.unpricedCount==`number`?e.unpricedCount>0:e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:n(`providerCard.title`)}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,q.jsx)(o,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,q.jsx)(`span`,{className:`font-medium`})}})})]})}),r===0&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:n(i?`providerCard.costUnavailableTooltip`:`providerCard.noCost`)}),r>0&&(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,i=r>0?t/r*100:0;if(i===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${Xe(t)}`;return(0,q.jsx)(`div`,{className:`h-full ${Qe(e.provider)}`,style:{width:`${i}%`},title:n(`providerCard.segmentTitle`,{label:Ze(e.provider),value:a,count:e.count})},e.provider)})})}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 ${r>0?``:`mt-3`}`,children:e.byProvider.map(e=>(0,q.jsx)(et,{entry:e},e.provider))})]})}function et({entry:e}){let{t}=s(`analytics`),n=e.costUsd+e.estimatedCostUsd,r=e.costUsd===0&&e.estimatedCostUsd>0,i=e.unpricedCount??(e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0?e.count:0),a=e.pricedCount??Math.max(0,e.count-i),o=e.count>0&&i>0&&a===0,c=a>0&&i>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Qe(e.provider)}`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:Ze(e.provider)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),o?(0,q.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,q.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,title:c?t(`providerCard.costPartiallyUnavailableTooltip`):void 0,children:[r?`~`:``,Xe(n),c&&(0,q.jsx)(`span`,{className:`ml-1 font-normal text-muted-foreground/80 italic`,children:t(`providerCard.costPartiallyUnavailable`,{count:i})})]})]})}var tt=Math.cos,nt=Math.sin,J=Math.sqrt,Y=Math.PI;Y/2;var rt=2*Y,it={draw(e,t){let n=J(t/Y);e.moveTo(n,0),e.arc(0,0,n,0,rt)}},at={draw(e,t){let n=J(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},ot=J(1/3),st=ot*2,ct={draw(e,t){let n=J(t/st),r=n*ot;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},lt={draw(e,t){let n=J(t),r=-n/2;e.rect(r,r,n,n)}},ut=.8908130915292852,dt=nt(Y/10)/nt(7*Y/10),ft=nt(rt/10)*dt,pt=-tt(rt/10)*dt,mt={draw(e,t){let n=J(t*ut),r=ft*n,i=pt*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=rt*t/5,o=tt(a),s=nt(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},ht=J(3),gt={draw(e,t){let n=-J(t/(ht*3));e.moveTo(0,n*2),e.lineTo(-ht*n,-n),e.lineTo(ht*n,-n),e.closePath()}},X=-.5,Z=J(3)/2,_t=1/J(12),vt=(_t/2+1)*3,yt={draw(e,t){let n=J(t/vt),r=n/2,i=n*_t,a=r,o=n*_t+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo(X*r-Z*i,Z*r+X*i),e.lineTo(X*a-Z*o,Z*a+X*o),e.lineTo(X*s-Z*c,Z*s+X*c),e.lineTo(X*r+Z*i,X*i-Z*r),e.lineTo(X*a+Z*o,X*o-Z*a),e.lineTo(X*s+Z*c,X*c-Z*s),e.closePath()}};function bt(e,t){let n=null,r=Fe(i);e=typeof e==`function`?e:U(e||it),t=typeof t==`function`?t:U(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:U(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:U(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}var xt=[`type`,`size`,`sizeType`];function St(){return St=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},St.apply(null,arguments)}function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ct(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ot(e,t){if(e==null)return{};var n,r,i=kt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function kt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var At={symbolCircle:it,symbolCross:at,symbolDiamond:ct,symbolSquare:lt,symbolStar:mt,symbolTriangle:gt,symbolWye:yt},jt=Math.PI/180,Mt=e=>At[`symbol${se(e)}`]||it,Nt=(e,t,n)=>{if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*jt;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Pt=(e,t)=>{At[`symbol${se(e)}`]=t},Ft=e=>{var t=e.type,n=t===void 0?`circle`:t,r=e.size,i=r===void 0?64:r,a=e.sizeType,o=a===void 0?`area`:a,s=wt(wt({},Ot(e,xt)),{},{type:n,size:i,sizeType:o}),c=`circle`;typeof n==`string`&&(c=n);var l=()=>{var e=Mt(c),t=bt().type(e).size(Nt(i,o,c))();if(t!==null)return t},u=s.className,d=s.cx,f=s.cy,p=le(s);return _e(d)&&_e(f)&&_e(i)?K.createElement(`path`,St({},p,{className:_(`recharts-symbols`,u),transform:`translate(${d}, ${f})`,d:l()})):null};Ft.registerSymbol=Pt;var It=[`option`];function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(null,arguments)}function Rt(e,t){if(e==null)return{};var n,r,i=zt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Bt(e){return K.createElement(Ft,e)}function Vt(e){var t=e.option,n=Rt(e,It);return typeof t==`string`?K.createElement(E,{option:K.createElement(Ft,Lt({type:t},n)),DefaultShape:Bt,shapeProps:n}):K.createElement(E,{option:t,DefaultShape:Bt,shapeProps:n})}var Ht=je([(e,t,n,r,i,a,o)=>O(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>F(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>F(e,`yAxis`,n,o),(e,t,n,r)=>ee(e,`zAxis`,r,!1),je([Be,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var c=e.chartData,l=e.dataStartIndex,u=e.dataEndIndex;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return sn({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ut=[`id`],Wt=[`onMouseEnter`,`onClick`,`onMouseLeave`],Gt=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Kt(e,t){if(e==null)return{};var n,r,i=qt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(null,arguments)}function Jt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Jt(Object(n),!0).forEach(function(t){Yt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yt(e,t,n){return(t=Xt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){var t=Zt(e,`string`);return typeof t==`symbol`?t:t+``}function Zt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Qt=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:fe(n,t),payload:e}]},$t=K.memo(e=>{var t=e.dataKey,n=e.points,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.formatter,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:fe(o,t),hide:s,type:l,color:a,unit:``,formatter:c,graphicalItemId:u}};return K.createElement(re,{tooltipEntrySettings:d})});function en(e){var t=e.points,n=e.props,r=n.line,i=n.lineType,a=n.lineJointType;if(!r)return null;var o=I(n),s=w(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var u=me(t),d=u.xmin,f=u.xmax,p=u.a,m=u.b,h=e=>p*e+m;c=[{x:d,y:h(d)},{x:f,y:h(f)}]}var g=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=K.isValidElement(r)?K.cloneElement(r,g):typeof r==`function`?r(g):K.createElement(L,Q({},g,{type:a})),K.createElement(G,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function tn(e){var t=e.showLabels,n=e.points,r=e.children,i=A(),a=(0,K.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return K.createElement(xe,{value:t?a:void 0},r)}function nn(e){var t=e.entry,n=e.index,r=e.shape,i=e.activeShape,a=e.baseProps,o=e.id,s=e.restOfAllOtherProps,c=e.animationElapsedTime,l=e.isAnimating,u=e.isEntrance,d=e.onMouseEnterFromContext,f=e.onMouseLeaveFromContext,p=e.onClickFromContext,m=i!=null&&i!==!1,h=ce((0,K.useMemo)(()=>{var e=String(n);return t=>m&&D(t)===e},[m,n]))??!1,g=h&&i!=null&&i!==!1?i:r,_=$($($({},a),t),{},{isActive:h,index:n,animationElapsedTime:c,isAnimating:l,isEntrance:u,[V]:String(o)});return K.createElement(P,{zIndex:h?R.activeDot:void 0},K.createElement(G,Q({className:`recharts-scatter-symbol`},de(s,t,n),{onMouseEnter:d(t,n),onMouseLeave:f(t,n),onClick:p(t,n)}),K.createElement(Vt,Q({option:g},_))))}function rn(e){var t=e.points,n=e.allOtherScatterProps,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=n.shape,s=n.activeShape,c=n.dataKey,l=n.id,u=Kt(n,Ut),d=n.onMouseEnter,f=n.onClick,p=n.onMouseLeave,m=Kt(n,Wt),h=Le(d,c,l),g=ie(p),_=te(f,c,l);if(!Ce(t))return null;var v=I(u);return K.createElement(K.Fragment,null,K.createElement(en,{points:t,props:u}),t.map((e,t)=>K.createElement(nn,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,entry:e,index:t,shape:o,activeShape:s,baseProps:v,id:l,restOfAllOtherProps:m,animationElapsedTime:r,isAnimating:i,isEntrance:a,onMouseEnterFromContext:h,onMouseLeaveFromContext:g,onClickFromContext:_})))}var an=(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`removed`?[]:e.status===`matched`?[$($({},e.next),{},{cx:e.next.cx==null?void 0:ke(e.prev.cx,e.next.cx,t),cy:e.next.cy==null?void 0:ke(e.prev.cy,e.next.cy,t),size:ke(e.prev.size,e.next.size,t)})]:[$($({},e.next),{},{size:ke(0,e.next.size,t)})]);function on(e){var t=e.previousPointsRef,n=e.props,r=n.points,i=n.isAnimationActive,a=n.animationBegin,o=n.animationDuration,s=n.animationEasing,c=n.animationInterpolateFn,l=Ie(),u=l.isAnimating,d=l.handleAnimationStart,f=l.handleAnimationEnd,p=ne();return p==null?null:K.createElement(tn,{showLabels:!u,points:r},K.createElement(oe,{animationInput:n,animationIdPrefix:`recharts-scatter-`,items:r,previousItemsRef:t,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:d,onAnimationEnd:f,animationInterpolateFn:c,animationMatchBy:n.animationMatchBy,layout:p},(e,t,r)=>K.createElement(G,null,K.createElement(rn,{points:e,allOtherScatterProps:n,showLabels:!u,animationElapsedTime:t,isAnimating:u||t<1,isEntrance:r}))),n.children,K.createElement(C,{label:n.label}))}function sn(e){var t=e.displayedData,n=e.xAxis,r=e.yAxis,i=e.zAxis,a=e.scatterSettings,o=e.xAxisTicks,s=e.yAxisTicks,c=e.cells,l=W(n.dataKey)?a.dataKey:n.dataKey,u=W(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:k.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=Pe(e,l),g=Pe(e,u),_=!W(d)&&Pe(e,d)||`-`,v=[{name:W(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:W(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=S({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=S({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,C=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-C,y:b==null?void 0:b-C,width:2*C,height:2*C,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var cn=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:Pe(e,t)});function ln(e){var t=e.hide,n=e.points,r=e.className,i=e.needClip,a=e.xAxisId,o=e.yAxisId,s=e.id,c=(0,K.useRef)(null);if(t)return null;var l=_(`recharts-scatter`,r),u=s;return K.createElement(P,{zIndex:e.zIndex},K.createElement(G,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&K.createElement(`defs`,null,K.createElement(Ee,{clipPathId:u,xAxisId:a,yAxisId:o})),K.createElement(ue,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:cn,errorBarOffset:0},K.createElement(G,{key:`recharts-scatter-symbols`},K.createElement(on,{props:e,previousPointsRef:c})))))}var un={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,animationMatchBy:ze,animationInterpolateFn:an,zIndex:R.scatter};function dn(e){var t=De(e,un),n=t.animationBegin,r=t.animationDuration,i=t.animationEasing,a=t.hide,o=t.isAnimationActive,s=t.legendType,c=t.lineJointType,l=t.lineType,u=t.shape,d=t.xAxisId,f=t.yAxisId,p=t.zAxisId,m=Kt(t,Gt),h=Me(d,f).needClip,g=(0,K.useMemo)(()=>T(e.children,be),[e.children]),_=ae(),v=ce(t=>Ht(t,d,f,p,e.id,g,_));return h==null||v==null?null:K.createElement(K.Fragment,null,K.createElement($t,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,formatter:e.formatter,tooltipType:e.tooltipType,id:e.id}),K.createElement(ln,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function fn(e){var t=De(e,un),n=ae();return K.createElement(he,{id:t.id,type:`scatter`},e=>K.createElement(K.Fragment,null,K.createElement(Re,{legendPayload:Qt(t)}),K.createElement(ge,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),K.createElement(dn,Q({},t,{id:e}))))}var pn=K.memo(fn,z);pn.displayName=`Scatter`;function mn(e){var t=ye(),n=(0,K.useRef)(null);return(0,K.useLayoutEffect)(()=>{n.current===null?t(pe(e)):n.current!==e&&t(we({prev:n.current,next:e})),n.current=e},[e,t]),(0,K.useLayoutEffect)(()=>()=>{n.current&&=(t(Oe(n.current)),null)},[t]),null}var hn={zAxisId:0,range:k.range,scale:k.scale,type:k.type};function gn(e){var t=De(e,hn);return K.createElement(mn,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:k.allowDuplicatedCategory,allowDataOverflow:k.allowDataOverflow,reversed:k.reversed,includeHidden:k.includeHidden})}gn.displayName=`ZAxis`;var _n=[`item`],vn=(0,K.forwardRef)((e,t)=>K.createElement(Te,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_n,tooltipPayloadSearcher:N,categoricalChartProps:e,ref:t}));function yn({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r={jobs:n(`surfaces.job`),explore:n(`surfaces.exploreSpec`),quick:n(`surfaces.quickSpec`),refine:n(`surfaces.aiEdit`),fileSummaries:n(`surfaces.fileSummary`),smash:n(`surfaces.smash`),loop:n(`surfaces.loop`)},i=e.dailyTimeline.map(e=>({date:e.date.slice(5),[r.jobs]:e.jobsCostUsd,[r.explore]:e.exploreCostUsd,[r.quick]:e.quickCostUsd,[r.refine]:e.aiEditCostUsd,[r.fileSummaries]:e.fileSummaryCostUsd??0,[r.smash]:e.smashCostUsd??0,[r.loop]:e.loopCostUsd??0})),a=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0),o=e.dailyTimeline.reduce((e,t)=>e+(t.unpricedCount??0),0),c=a&&o>0,l=!a&&o>0;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`timeline.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:l?n(`timeline.costPartiallyUnavailable`,{count:o}):n(`timeline.subtitle`)})]}),c?(0,q.jsx)(`div`,{"data-testid":`timeline-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.costUnavailable`)}):a?(0,q.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.empty`)}):(0,q.jsx)(`div`,{className:`h-[220px]`,children:(0,q.jsx)(B,{width:`100%`,height:`100%`,children:(0,q.jsxs)(Ne,{data:i,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,q.jsx)(Se,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,q.jsx)(ve,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,q.jsx)(Ae,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,q.jsx)(M,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,q.jsx)(H,{dataKey:r.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,q.jsx)(H,{dataKey:r.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,q.jsx)(H,{dataKey:r.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,q.jsx)(H,{dataKey:r.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,q.jsx)(H,{dataKey:r.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,q.jsx)(H,{dataKey:r.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,q.jsx)(H,{dataKey:r.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function bn(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xn(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function Sn({values:e}){let t=Math.max(1e-4,...e);return(0,q.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,q.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Cn({mode:e,label:t,accentClass:n}){let{t:r}=s(`analytics`),i=e.mode===`explore`&&e.totalRuns<5,a=(e.estimatedCostUsd??0)>0,c=e.avgCostPerSpec==null&&(e.unpricedCount??0)>0;return(0,q.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,q.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),i?(0,q.jsxs)(`div`,{className:`py-3`,children:[(0,q.jsx)(`p`,{className:`text-sm text-foreground`,children:r(`quickVsExplore.sparseCta`)}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":a?`true`:void 0,title:c?r(`quickVsExplore.costUnavailableTooltip`):a?r(`quickVsExplore.estimatedTooltip`):void 0,children:[a&&e.avgCostPerSpec!=null?`~`:``,bn(e.avgCostPerSpec)]}),(0,q.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:r(c?`quickVsExplore.costUnavailable`:`quickVsExplore.perSpec`)}),(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(Sn,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,q.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(o,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,q.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,q.jsx)(`div`,{children:r(`quickVsExplore.avgDuration`,{duration:xn(e.avgDurationMs)})}),(0,q.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wn({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r=e.byMode.find(e=>e.mode===`quick`),i=e.byMode.find(e=>e.mode===`explore`);if(!r||!i)return null;let a=r.avgCostPerSpec&&i.avgCostPerSpec&&r.avgCostPerSpec>0?i.avgCostPerSpec/r.avgCostPerSpec:null,o=a!==null&&r.totalRuns>=1&&i.totalRuns>=5,c=(r.estimatedCostUsd??0)>0||(i.estimatedCostUsd??0)>0;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,q.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`quickVsExplore.title`)})}),(0,q.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,q.jsx)(Cn,{mode:r,label:n(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,q.jsx)(Cn,{mode:i,label:n(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),o&&(0,q.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,q.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,q.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,n(`quickVsExplore.ratio`,{ratio:a.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,q.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(`quickVsExplore.estimatedFootnote`)})})]})}function Tn(e){return e<.005&&e>0?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function En(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dn({data:e,loading:t}){let{t:n}=s(`analytics`),r=e?.agentMissions;if(t||!r||r.summary.turns===0)return null;let{summary:a,topConversations:o}=r,c=a.estimatedCostUsd>0,l=a.prevTotalCostUsd>0?(a.totalCostUsd-a.prevTotalCostUsd)/a.prevTotalCostUsd*100:null;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card p-4`,"data-testid":`agent-missions-card`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(b,{className:`h-4 w-4 text-accent-highlight`}),(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:n(`agentMissions.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`agentMissions.subtitle`)})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsxs)(`span`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":c?`true`:void 0,title:c?n(`agentMissions.estimatedNote`):void 0,children:[c?`~`:``,Tn(a.totalCostUsd)]}),l!==null&&(0,q.jsxs)(`span`,{className:l>0?`text-xs text-accent-warning`:`text-xs text-accent-success`,children:[l>0?`+`:``,l.toFixed(0),`% `,n(`agentMissions.vsPrev`)]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`agentMissions.turnsAndTokens`,{turns:a.turns,tokens:En(a.tokensIn+a.tokensOut)})}),o.length>0&&(0,q.jsx)(`ul`,{className:`mt-3 space-y-1 border-t border-border/40 pt-2`,children:o.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/85`,children:e.title?.trim()||n(`agentMissions.untitled`)}),(0,q.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:[e.turns,` · `,e.lastAt?v(new Date(e.lastAt),{addSuffix:!0,locale:i()}):`—`]}),(0,q.jsxs)(`span`,{className:`shrink-0 tabular-nums font-medium`,children:[e.estimatedCostUsd>0?`~`:``,Tn(e.costUsd)]})]},e.conversationId??`unknown`))})]})}function On({data:e,loading:t,onSelectModel:n,activeModel:r}){let{t:i}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.summary.totalCostUsd,o=e.byModel.slice(0,5),c=o.reduce((e,t)=>e+t.costUsd,0),l=Math.max(0,a-c),u=l>=.005;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`models.title`)}),o.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`models.empty`)}):(0,q.jsxs)(`ul`,{className:`space-y-1.5`,children:[o.map(e=>{let t=a>0?e.costUsd/a*100:0,o=r===e.model,s=(e.estimatedCostUsd??0)>0,c=e.unpricedCount??0,l=Math.max(0,e.count-c),u=e.count>0&&c>0&&l===0,d=l>0&&c>0;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${o?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":u?`model-cost-unavailable`:void 0,title:u?i(`models.costUnavailableTooltip`):d?i(`models.costPartiallyUnavailableTooltip`):s?i(`models.estimatedTooltip`):void 0,children:u?i(`models.costUnavailableWithRuns`,{count:e.count}):(0,q.jsxs)(q.Fragment,{children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count,d&&(0,q.jsx)(`span`,{className:`ml-1 italic`,children:i(`models.costPartiallyUnavailable`,{count:c})})]})})]}),(0,q.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,q.jsx)(`div`,{className:`h-full ${o?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)}),u&&(0,q.jsx)(`li`,{"data-testid":`model-others`,children:(0,q.jsxs)(`div`,{className:`w-full rounded-md px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:i(`models.others`)}),(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,l.toFixed(2)]})]}),(0,q.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,q.jsx)(`div`,{className:`h-full bg-foreground/25`,style:{width:`${a>0?l/a*100:0}%`}})})]})})]})]})}var kn={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`,"chat-sidebar":`var(--accent-info, #5fa8d3)`,"spec-launcher":`var(--accent-secondary, #f7768e)`,proposal:`var(--accent-highlight, #c084fc)`,"agent-studio":`var(--accent-success, #50fa7b)`,setup:`var(--accent-primary, #7aa2f7)`},An=Object.keys(m);function jn({data:e,loading:t,onSelectPoint:n}){let{t:r}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=An,a=i.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),o=e.scatter.length===0,c=e.summary.unpricedRuns??0,l=o&&c>0,u=!o&&c>0,d=e.scatterTruncated===!0,f=e.scatterTotal??e.scatter.length;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`scatter.title`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:i.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:kn[e]}}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:m[e]})]},e))})]}),d&&!o&&(0,q.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:r(`scatter.truncated`,{shown:e.scatter.length,total:f})}),u&&(0,q.jsx)(`div`,{"data-testid":`scatter-cost-partial-notice`,className:`mb-2 text-[10px] text-muted-foreground/80 italic`,children:r(`scatter.costPartiallyUnavailable`,{count:c})}),l?(0,q.jsx)(`div`,{"data-testid":`scatter-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.costUnavailable`)}):o?(0,q.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.empty`)}):(0,q.jsx)(`div`,{className:`h-[260px]`,children:(0,q.jsx)(B,{width:`100%`,height:`100%`,children:(0,q.jsxs)(vn,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,q.jsx)(Se,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,q.jsx)(ve,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:r(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,q.jsx)(Ae,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,q.jsx)(gn,{range:[40,80]}),(0,q.jsx)(M,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,r(`scatter.costLabel`)]:[String(e),n===`turns`?r(`scatter.turnsLabel`):n]}}),a.map(e=>(0,q.jsx)(pn,{data:e.points,fill:kn[e.surface],onClick:e=>{let t=e;t?.raw&&n(t.raw)}},e.surface))]})})})]})}function Mn({data:e,loading:t,onSelectTicket:n}){let{t:r}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.topTickets;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:r(`topTickets.title`)}),i.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`topTickets.empty`)}):(0,q.jsx)(`ul`,{className:`divide-y divide-border/30`,children:i.map((e,t)=>{let i=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>r(`topTickets.breakdownItem`,{n:t.count,label:m[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?r(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:r(`topTickets.deletedTicket`,{id:e.ticketId}),s=!e.ticketTitle&&!a?`opacity-50`:``,c=e.unpricedCount??0,l=e.totalRuns>0&&c===e.totalRuns,u=c>0&&!l;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${s}`,disabled:a,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,q.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:i||`—`})]}),(0,q.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium`,title:l?r(`topTickets.costUnavailableTooltip`):u?r(`topTickets.costPartiallyUnavailableTooltip`):void 0,children:l?r(`topTickets.costUnavailable`):`$${e.totalCostUsd.toFixed(2)}`}),u&&(0,q.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic`,children:r(`topTickets.costPartiallyUnavailable`,{count:c})}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var Nn={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`};function Pn(e){return Nn[e]??e}function Fn(e){return!!e&&!(e in Nn)}function In(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Ln(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Rn(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function zn(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function Bn(e,t){if(e.model)return e.model;if(!Rn(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Vn({rows:e,loading:t,truncated:n,totalAvailable:r,tableFilters:i,onTableFiltersChange:a}){let{t:o}=s(`analytics`),[c,l]=(0,K.useState)(null),u=zn(e),d=new Set(e.map(e=>e.provider??`claude`)).size>1,f=n||r>e.length;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:o(`table.title`)}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,q.jsxs)(`select`,{value:i.status??``,onChange:e=>a({...i,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":o(`table.statusFilterAria`),children:[(0,q.jsx)(`option`,{value:``,children:o(`table.allStatus`)}),(0,q.jsx)(`option`,{value:`success`,children:o(`table.success`)}),(0,q.jsx)(`option`,{value:`failed`,children:o(`table.failed`)}),(0,q.jsx)(`option`,{value:`aborted`,children:o(`table.aborted`)})]}),(0,q.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:o(`table.minCostPlaceholder`),value:i.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);a({...i,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":o(`table.minCostFilterAria`)})]})]}),t?(0,q.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:o(`table.empty`)}):(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,q.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,q.jsxs)(`tr`,{className:`text-left`,children:[(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colSurface`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colTicket`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colCost`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colTurns`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colTokens`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colModel`)}),d&&(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colProvider`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colStatus`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colStarted`)})]})}),(0,q.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=g[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Rn(e),a=i?o(`table.contractLayer`):m[t],s=Bn(e,u);return(0,q.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,q.jsx)(`td`,{className:`px-2 py-2`,children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,q.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,q.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:o(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,q.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,q.jsx)(`span`,{className:`text-muted-foreground/90`,children:o(`table.contractLayerRefinement`)}):e.ticket_title??(0,q.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:o(`table.deleted`)})]})}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,q.jsxs)(`span`,{title:o(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,In(e.total_cost_usd)]}):e.total_cost_usd==null&&Fn(e.provider)?(0,q.jsx)(`span`,{title:o(`table.costUnknownLocalTooltip`),"data-testid":`cost-unknown-local`,className:`text-muted-foreground/70`,children:`—`}):In(e.total_cost_usd)}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right`,children:Ln(e.num_turns)}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?Ln(r):`—`}),(0,q.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[s??`—`,s&&!e.model?(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:o(`table.inferred`)}):null]}),d&&(0,q.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:Pn(e.provider??`claude`)}),(0,q.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,q.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,q.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,q.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:o(`table.statusValue.${e.status}`)})]}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),f&&e.length>0&&(0,q.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:o(`table.truncated`,{shown:e.length,total:r.toLocaleString()})})]})}var Hn=[`legacy_loop_traversal`,`queue_manager_slash`,`merge_back`],Un=e=>Number.isSafeInteger(e)&&e>=0;function Wn(e){let t=e;if(!t||!Un(t.total)||!t.byKind||Hn.some(e=>!Un(t.byKind[e]))||t.lastAt!==null&&(typeof t.lastAt!=`string`||!Number.isFinite(Date.parse(t.lastAt))))throw Error(`Invalid telemetry`);return t}function Gn({projectId:e}){let{t}=s(`analytics`),n=(0,K.useRef)(new Map),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)({projectId:e,loading:!0,error:!1});(0,K.useEffect)(()=>{let t=!0,r=new AbortController;return o({projectId:e,loading:!0,error:!1}),(async()=>{try{let i=await fetch(`${l()}/analytics/legacy-launches`,{signal:r.signal});if(!i.ok)throw Error(`Telemetry unavailable`);let a=Wn(await i.json());if(!t)return;n.current.set(e,a),o({projectId:e,loading:!1,error:!1})}catch{t&&o({projectId:e,loading:!1,error:!0})}})(),()=>{t=!1,r.abort()}},[e,r]);let c=n.current.get(e),u=a.projectId!==e||a.loading,d=a.projectId===e&&a.error;return(0,q.jsxs)(`section`,{className:`rounded-xl border border-border/40 bg-card/40 p-4 space-y-3`,"aria-label":t(`legacyUsage.title`),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-medium`,children:t(`legacyUsage.title`)}),(0,q.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>i(e=>e+1),className:`text-xs underline disabled:opacity-50`,children:t(`legacyUsage.refresh`)})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`legacyUsage.scope`)}),d&&(0,q.jsx)(`p`,{role:`status`,className:`text-xs text-destructive`,children:t(`legacyUsage.unavailable`)}),!c&&u&&(0,q.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`legacyUsage.loading`)}),c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm`,children:t(`legacyUsage.total`,{count:c.total})}),(0,q.jsx)(`dl`,{className:`grid gap-2 text-xs sm:grid-cols-3`,children:Hn.map(e=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:t(`legacyUsage.kinds.${e}`)}),(0,q.jsx)(`dd`,{className:`font-mono tabular-nums`,children:c.byKind[e]})]},e))}),c.lastAt&&(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`legacyUsage.last`),` `,(0,q.jsx)(`time`,{dateTime:c.lastAt,children:new Date(c.lastAt).toLocaleString()})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`legacyUsage.evidence`)})]})}var Kn=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],qn=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`},{value:`loop`,labelKey:`surfaces.loop`}];function Jn(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function Yn(){let{t:e}=s(`analytics`),{activeProjectId:t,projects:n}=d(),[i,o]=r(),c=n.find(e=>e.id===t),m=c?u(c):[`claude`],h=m.length>1,g=i.get(`period`)??`30d`,_=(i.get(`surface`)??``).split(`,`).filter(Boolean),v=(i.get(`provider`)??``).split(`,`).filter(Boolean),b=i.get(`ticketId`),S=(i.get(`model`)??``).split(`,`).filter(Boolean),C=(i.get(`modelProvider`)??``).split(`,`).filter(Boolean),ee=S.length>0&&S.length===C.length?S.map((e,t)=>({provider:C[t],model:e})):void 0,te=(0,K.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[w,T]=(0,K.useState)({period:g,surface:_.length>0?_:void 0,provider:v.length>0?v:void 0,ticketId:b?Number(b):void 0,model:S.length>0?S:void 0,modelKeys:ee,tzOffsetMinutes:te}),[E,D]=(0,K.useState)(null),[O,k]=(0,K.useState)(!0),[A,ne]=(0,K.useState)(null),[j,M]=(0,K.useState)({}),[N,P]=(0,K.useState)(null),[F,re]=(0,K.useState)(`recency`),I=(0,K.useRef)(new Map),ie=(0,K.useRef)(0);(0,K.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,w.period),w.surface&&w.surface.length>0&&e.set(`surface`,w.surface.join(`,`)),w.provider&&w.provider.length>0&&e.set(`provider`,w.provider.join(`,`)),w.ticketId&&e.set(`ticketId`,String(w.ticketId)),w.model&&w.model.length>0&&(e.set(`model`,w.model.join(`,`)),w.modelKeys&&w.modelKeys.length===w.model.length&&e.set(`modelProvider`,w.modelKeys.map(e=>e.provider).join(`,`))),o(e,{replace:!0})},[w.period,w.surface,w.provider,w.ticketId,w.model,w.modelKeys,o]);let L=(0,K.useCallback)(async()=>{if(!t)return;let e=++ie.current;ne(null);let n=`${t}:${Jn(w)}`,r=I.current.get(n);r?(D(r),k(!1)):k(!0);try{let t=await fetch(`${l()}/spending?${Jn(w)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==ie.current)return;let r=await t.json();I.current.set(n,r),D(r),k(!1)}catch(t){if(e!==ie.current)return;ne(t.message),k(!1)}},[t,w]),R=(0,K.useRef)(0),z=(0,K.useCallback)(async()=>{if(!t)return;let e=++R.current,n={...w};j.model&&(n.model=[j.model],n.modelKeys=void 0),j.status&&(n.status=j.status),typeof j.minCostUsd==`number`&&(n.minCostUsd=j.minCostUsd),n.sortBy=F;try{let t=await fetch(`${l()}/invocations?${Jn(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==R.current)return;P(r)}catch{if(e!==R.current)return;P(null)}},[t,w,j,F]),ae=(0,K.useRef)(t);(0,K.useEffect)(()=>{ae.current!==t&&(ae.current=t,D(null),P(null),k(!0))},[t]),(0,K.useEffect)(()=>{L()},[L]),(0,K.useEffect)(()=>{z()},[z]);let B=(0,K.useRef)(null),V=a();(0,K.useEffect)(()=>{let e=`analytics-spending`;return V.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{I.current.clear(),L(),z()},500))}),()=>{V.unregisterHandler(e),B.current&&clearTimeout(B.current)}},[V,t,L,z]);function oe(e){if(e===`all`){T(e=>({...e,surface:void 0}));return}T(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}let se=(0,K.useCallback)((e,t)=>{T(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(E?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[E]);function H(){T(e=>({...e,model:void 0,modelKeys:void 0}))}function ce(e){if(e===`all`){T(e=>({...e,provider:void 0}));return}T(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let le=w.surface,ue=!le||le.length===0,de=w.provider,U=!de||de.length===0,fe=(0,K.useMemo)(()=>{let e={period:w.period};return w.surface&&w.surface.length>0&&(e.surface=w.surface.join(`,`)),w.provider&&w.provider.length>0&&(e.provider=w.provider.join(`,`)),w.ticketId&&(e.ticketId=String(w.ticketId)),e},[w]),pe=E?E.summary.totalRuns===0:!1;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,q.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),w.ticketId&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>T(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:w.ticketId})}),w.model&&w.model.length>0&&(0,q.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:H,title:e(`page.clearModelFilter`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:[e(`page.modelChip`,{model:w.model[0]}),(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Kn.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>T(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${w.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,q.jsx)(x,{baseUrl:`${l()}/analytics/export`,params:fe,disabled:pe}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{I.current.clear(),L(),z()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,q.jsx)(y,{className:`w-3 h-3`})})]})]}),(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:qn.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>oe(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ue:le?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),h&&(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${U?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),m.map(t=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>ce(t),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${de?.includes(t)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:[p(t),f(t)&&(0,q.jsx)(`span`,{className:`ml-1 rounded-full bg-accent-secondary/15 px-1.5 text-[9px] uppercase tracking-wide text-accent-secondary`,children:e(`page.localEngine`)})]},t))]})]}),A&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,q.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:A})}),(0,q.jsxs)(`button`,{onClick:()=>L(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,q.jsx)(y,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,q.jsx)(qe,{data:E,loading:O,period:w.period}),t&&(0,q.jsx)(Gn,{projectId:t}),(0,q.jsx)($e,{data:E,loading:O}),(0,q.jsx)(yn,{data:E,loading:O}),(0,q.jsx)(Dn,{data:E,loading:O}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,q.jsx)(wn,{data:E,loading:O}),(0,q.jsx)(On,{data:E,loading:O,onSelectModel:se,activeModel:w.model?.[0]})]}),(0,q.jsx)(jn,{data:E,loading:O,onSelectPoint:e=>{M(e=>({...e})),T(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,q.jsx)(Mn,{data:E,loading:O,onSelectTicket:e=>T(t=>({...t,ticketId:e??void 0}))}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,q.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":F===t,onClick:()=>re(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${F===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,q.jsx)(Vn,{rows:N?.rows??[],loading:O&&!N,truncated:(N?.truncated??!1)||(N?.totalAvailable??0)>(N?.rows.length??0),totalAvailable:N?.totalAvailable??0,tableFilters:j,onTableFiltersChange:M})]})]})}export{Yn as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{f as r}from"./chunk-OB3PAWPO-B1EMk45A.js";import{m as i,r as a}from"./useSharedWebSocket-Bj4LMp7b.js";import{t as o}from"./Trans-BbFxRFtR.js";import{n as s,t as c}from"./createLucideIcon-DtODIU64.js";import{a as l,n as u,r as d}from"./useDesktop-BjLT0_EE.js";import{n as f,s as p}from"./provider-capabilities-lePfeT_Y.js";import{n as m,r as h,t as g}from"./spending-CQnrWiR3.js";import{t as _}from"./clsx-CjueKrWZ.js";import{t as v}from"./formatDistanceToNow-NjPHBLfB.js";import{Dt as y,en as b}from"./index-Ce4yZtKf.js";import{t as x}from"./ExportDropdown-Bb1lHx3r.js";import{$ as S,A as C,B as ee,C as te,Ct as w,D as T,E,F as D,H as O,I as k,J as A,K as ne,L as j,M,N,P,R as F,S as re,St as I,T as ie,U as L,V as R,W as z,X as ae,Y as B,Z as V,_ as oe,_t as se,a as H,at as ce,bt as le,c as ue,ct as de,dt as U,et as fe,f as pe,ft as me,g as he,h as ge,ht as _e,i as ve,it as ye,j as be,k as xe,l as Se,lt as Ce,m as we,mt as W,n as Te,o as Ee,ot as De,p as Oe,pt as ke,r as Ae,rt as je,s as Me,t as Ne,tt as Pe,ut as Fe,v as Ie,w as Le,x as Re,y as ze,yt as G,z as Be}from"./BarChart-BDMqVFJy.js";var Ve={name:`arrow-down-right`,size:24,node:[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]};Ve.node;var He=c(Ve),K=e(t(),1),q=n();function Ue(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function We(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Ke=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`chat-sidebar`,`spec-launcher`,`proposal`,`agent-studio`,`setup`,`smash`,`file-summary`,`loop`];function qe({data:e,loading:t,period:n}){let{t:r}=s(`analytics`),[i,a]=(0,K.useState)(0),o=(0,K.useRef)(0),c=(0,K.useRef)(null),l=(0,K.useRef)(0);if((0,K.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd,n=++l.current;if(c.current!==null&&(cancelAnimationFrame(c.current),c.current=null),o.current===0&&t>0){let e=performance.now(),r=i=>{if(n!==l.current)return;let o=Math.min(1,(i-e)/600),s=1-(1-o)**3;a(0+(t-0)*s),o<1?c.current=requestAnimationFrame(r):c.current=null};c.current=requestAnimationFrame(r)}else a(t);return o.current=t,()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)}},[e]),t&&!e)return(0,q.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let u=e.summary.totalCostUsd,d=e.summary.totalRuns,f=e.summary.totalTokens,p=e.summary.totalEstimatedCostUsd??0,_=typeof e.summary.pricedRuns==`number`||typeof e.summary.unpricedRuns==`number`,v=e.summary.unpricedRuns??0,y=e.summary.pricedRuns??(_?Math.max(0,d-v):d),b=_&&d>0&&y===0&&v>0,x=y>0&&v>0,S=typeof e.summary.usageReportedRuns==`number`||typeof e.summary.usageUnavailableRuns==`number`,C=e.summary.usageUnavailableRuns??0,ee=e.summary.usageReportedRuns??(S?Math.max(0,d-C):d),te=S&&d>0&&ee===0&&C>0,w=ee>0&&C>0,T=v>0?null:e.summary.deltaPct,E=e.trackingStartedAt,D=p>0,O=e.bySurface.map(e=>e.surface).filter(e=>!Ke.includes(e)),k=[...Ke,...O].map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}}),A=n?r(`windowLabels.${n}`):null;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5`,children:[(0,q.jsx)(`span`,{children:r(`hero.spending`)}),A&&(0,q.jsxs)(`span`,{"data-testid":`hero-window-label`,className:`normal-case tracking-normal text-muted-foreground/70 font-normal`,children:[`· `,A]})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,"data-testid":b?`hero-cost-unavailable`:void 0,title:b?r(`hero.costUnavailableTooltip`):void 0,children:b?`—`:We(i)}),T!==null&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${T>=0?`text-accent-warning`:`text-accent-success`}`,children:[T>=0?(0,q.jsx)(h,{className:`w-3 h-3`}):(0,q.jsx)(He,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(T).toFixed(0)})]})]}),(0,q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,q.jsx)(`span`,{children:r(`hero.invocations`,{count:d})}),te?(0,q.jsx)(`span`,{"data-testid":`hero-usage-unavailable`,className:`text-muted-foreground/80 italic`,title:r(`hero.usageUnavailableTooltip`),children:r(`hero.usageUnavailable`)}):w&&f!=null?(0,q.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.usagePartiallyUnavailableTooltip`),children:r(`hero.usagePartiallyUnavailable`,{tokens:Ge(f),count:C})}):f!=null&&f>0?(0,q.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:Ge(f)})}):null,b&&(0,q.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.costUnavailableTooltip`),children:r(`hero.costUnavailable`)}),x&&(0,q.jsx)(`span`,{"data-testid":`hero-cost-partial`,className:`text-muted-foreground/80 italic`,title:r(`hero.costPartiallyUnavailableTooltip`),children:r(`hero.costPartiallyUnavailable`,{count:v})}),D&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:Ue(p)}),children:r(`hero.includesEstimated`,{amount:Ue(p)})})]})]}),d===0&&E&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:E.slice(0,10)})})]}),d===0?(0,q.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:E?r(`hero.trackingStarted`,{date:E.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):b?(0,q.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-4 text-xs text-muted-foreground/80`,children:r(`hero.costUnavailableTooltip`)}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:k.map(e=>{let t=u>0?e.costUsd/u*100:0;return t===0?null:(0,q.jsx)(`div`,{className:`h-full ${g[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:m[e.surface],value:Ue(e.costUsd)})},e.surface)})}),(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:k.filter(e=>e.costUsd>0).map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full ${g[e.surface].dot}`}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:m[e.surface]}),(0,q.jsx)(`span`,{className:`text-foreground font-medium`,children:Ue(e.costUsd)}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Je={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`},Ye={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`,kimi:`bg-purple-400`};function Xe(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Ze(e){return Je[e]??e}function Qe(e){return Ye[e]??`bg-accent-secondary`}function $e({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let r=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0),i=e.byProvider.some(e=>typeof e.unpricedCount==`number`?e.unpricedCount>0:e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0);return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:n(`providerCard.title`)}),(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,q.jsx)(o,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,q.jsx)(`span`,{className:`font-medium`})}})})]})}),r===0&&(0,q.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:n(i?`providerCard.costUnavailableTooltip`:`providerCard.noCost`)}),r>0&&(0,q.jsx)(q.Fragment,{children:(0,q.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,i=r>0?t/r*100:0;if(i===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${Xe(t)}`;return(0,q.jsx)(`div`,{className:`h-full ${Qe(e.provider)}`,style:{width:`${i}%`},title:n(`providerCard.segmentTitle`,{label:Ze(e.provider),value:a,count:e.count})},e.provider)})})}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 ${r>0?``:`mt-3`}`,children:e.byProvider.map(e=>(0,q.jsx)(et,{entry:e},e.provider))})]})}function et({entry:e}){let{t}=s(`analytics`),n=e.costUsd+e.estimatedCostUsd,r=e.costUsd===0&&e.estimatedCostUsd>0,i=e.unpricedCount??(e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0?e.count:0),a=e.pricedCount??Math.max(0,e.count-i),o=e.count>0&&i>0&&a===0,c=a>0&&i>0;return(0,q.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,q.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Qe(e.provider)}`}),(0,q.jsx)(`span`,{className:`text-xs font-medium`,children:Ze(e.provider)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),o?(0,q.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,q.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,title:c?t(`providerCard.costPartiallyUnavailableTooltip`):void 0,children:[r?`~`:``,Xe(n),c&&(0,q.jsx)(`span`,{className:`ml-1 font-normal text-muted-foreground/80 italic`,children:t(`providerCard.costPartiallyUnavailable`,{count:i})})]})]})}var tt=Math.cos,nt=Math.sin,J=Math.sqrt,Y=Math.PI;Y/2;var rt=2*Y,it={draw(e,t){let n=J(t/Y);e.moveTo(n,0),e.arc(0,0,n,0,rt)}},at={draw(e,t){let n=J(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},ot=J(1/3),st=ot*2,ct={draw(e,t){let n=J(t/st),r=n*ot;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},lt={draw(e,t){let n=J(t),r=-n/2;e.rect(r,r,n,n)}},ut=.8908130915292852,dt=nt(Y/10)/nt(7*Y/10),ft=nt(rt/10)*dt,pt=-tt(rt/10)*dt,mt={draw(e,t){let n=J(t*ut),r=ft*n,i=pt*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=rt*t/5,o=tt(a),s=nt(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},ht=J(3),gt={draw(e,t){let n=-J(t/(ht*3));e.moveTo(0,n*2),e.lineTo(-ht*n,-n),e.lineTo(ht*n,-n),e.closePath()}},X=-.5,Z=J(3)/2,_t=1/J(12),vt=(_t/2+1)*3,yt={draw(e,t){let n=J(t/vt),r=n/2,i=n*_t,a=r,o=n*_t+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo(X*r-Z*i,Z*r+X*i),e.lineTo(X*a-Z*o,Z*a+X*o),e.lineTo(X*s-Z*c,Z*s+X*c),e.lineTo(X*r+Z*i,X*i-Z*r),e.lineTo(X*a+Z*o,X*o-Z*a),e.lineTo(X*s+Z*c,X*c-Z*s),e.closePath()}};function bt(e,t){let n=null,r=Fe(i);e=typeof e==`function`?e:U(e||it),t=typeof t==`function`?t:U(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:U(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:U(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}var xt=[`type`,`size`,`sizeType`];function St(){return St=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},St.apply(null,arguments)}function Ct(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function wt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ct(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ct(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ot(e,t){if(e==null)return{};var n,r,i=kt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function kt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var At={symbolCircle:it,symbolCross:at,symbolDiamond:ct,symbolSquare:lt,symbolStar:mt,symbolTriangle:gt,symbolWye:yt},jt=Math.PI/180,Mt=e=>At[`symbol${se(e)}`]||it,Nt=(e,t,n)=>{if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*jt;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},Pt=(e,t)=>{At[`symbol${se(e)}`]=t},Ft=e=>{var t=e.type,n=t===void 0?`circle`:t,r=e.size,i=r===void 0?64:r,a=e.sizeType,o=a===void 0?`area`:a,s=wt(wt({},Ot(e,xt)),{},{type:n,size:i,sizeType:o}),c=`circle`;typeof n==`string`&&(c=n);var l=()=>{var e=Mt(c),t=bt().type(e).size(Nt(i,o,c))();if(t!==null)return t},u=s.className,d=s.cx,f=s.cy,p=le(s);return _e(d)&&_e(f)&&_e(i)?K.createElement(`path`,St({},p,{className:_(`recharts-symbols`,u),transform:`translate(${d}, ${f})`,d:l()})):null};Ft.registerSymbol=Pt;var It=[`option`];function Lt(){return Lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lt.apply(null,arguments)}function Rt(e,t){if(e==null)return{};var n,r,i=zt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function zt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Bt(e){return K.createElement(Ft,e)}function Vt(e){var t=e.option,n=Rt(e,It);return typeof t==`string`?K.createElement(E,{option:K.createElement(Ft,Lt({type:t},n)),DefaultShape:Bt,shapeProps:n}):K.createElement(E,{option:t,DefaultShape:Bt,shapeProps:n})}var Ht=je([(e,t,n,r,i,a,o)=>O(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>F(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>F(e,`yAxis`,n,o),(e,t,n,r)=>ee(e,`zAxis`,r,!1),je([Be,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var c=e.chartData,l=e.dataStartIndex,u=e.dataEndIndex;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return sn({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ut=[`id`],Wt=[`onMouseEnter`,`onClick`,`onMouseLeave`],Gt=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Kt(e,t){if(e==null)return{};var n,r,i=qt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function qt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(null,arguments)}function Jt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Jt(Object(n),!0).forEach(function(t){Yt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Yt(e,t,n){return(t=Xt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xt(e){var t=Zt(e,`string`);return typeof t==`symbol`?t:t+``}function Zt(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Qt=e=>{var t=e.dataKey,n=e.name,r=e.fill,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:fe(n,t),payload:e}]},$t=K.memo(e=>{var t=e.dataKey,n=e.points,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.formatter,l=e.tooltipType,u=e.id,d={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:fe(o,t),hide:s,type:l,color:a,unit:``,formatter:c,graphicalItemId:u}};return K.createElement(re,{tooltipEntrySettings:d})});function en(e){var t=e.points,n=e.props,r=n.line,i=n.lineType,a=n.lineJointType;if(!r)return null;var o=I(n),s=w(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var u=me(t),d=u.xmin,f=u.xmax,p=u.a,m=u.b,h=e=>p*e+m;c=[{x:d,y:h(d)},{x:f,y:h(f)}]}var g=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=K.isValidElement(r)?K.cloneElement(r,g):typeof r==`function`?r(g):K.createElement(L,Q({},g,{type:a})),K.createElement(G,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function tn(e){var t=e.showLabels,n=e.points,r=e.children,i=A(),a=(0,K.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return K.createElement(xe,{value:t?a:void 0},r)}function nn(e){var t=e.entry,n=e.index,r=e.shape,i=e.activeShape,a=e.baseProps,o=e.id,s=e.restOfAllOtherProps,c=e.animationElapsedTime,l=e.isAnimating,u=e.isEntrance,d=e.onMouseEnterFromContext,f=e.onMouseLeaveFromContext,p=e.onClickFromContext,m=i!=null&&i!==!1,h=ce((0,K.useMemo)(()=>{var e=String(n);return t=>m&&D(t)===e},[m,n]))??!1,g=h&&i!=null&&i!==!1?i:r,_=$($($({},a),t),{},{isActive:h,index:n,animationElapsedTime:c,isAnimating:l,isEntrance:u,[V]:String(o)});return K.createElement(P,{zIndex:h?R.activeDot:void 0},K.createElement(G,Q({className:`recharts-scatter-symbol`},de(s,t,n),{onMouseEnter:d(t,n),onMouseLeave:f(t,n),onClick:p(t,n)}),K.createElement(Vt,Q({option:g},_))))}function rn(e){var t=e.points,n=e.allOtherScatterProps,r=e.animationElapsedTime,i=e.isAnimating,a=e.isEntrance,o=n.shape,s=n.activeShape,c=n.dataKey,l=n.id,u=Kt(n,Ut),d=n.onMouseEnter,f=n.onClick,p=n.onMouseLeave,m=Kt(n,Wt),h=Le(d,c,l),g=ie(p),_=te(f,c,l);if(!Ce(t))return null;var v=I(u);return K.createElement(K.Fragment,null,K.createElement(en,{points:t,props:u}),t.map((e,t)=>K.createElement(nn,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,entry:e,index:t,shape:o,activeShape:s,baseProps:v,id:l,restOfAllOtherProps:m,animationElapsedTime:r,isAnimating:i,isEntrance:a,onMouseEnterFromContext:h,onMouseLeaveFromContext:g,onClickFromContext:_})))}var an=(e,t)=>e==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`removed`?[]:e.status===`matched`?[$($({},e.next),{},{cx:e.next.cx==null?void 0:ke(e.prev.cx,e.next.cx,t),cy:e.next.cy==null?void 0:ke(e.prev.cy,e.next.cy,t),size:ke(e.prev.size,e.next.size,t)})]:[$($({},e.next),{},{size:ke(0,e.next.size,t)})]);function on(e){var t=e.previousPointsRef,n=e.props,r=n.points,i=n.isAnimationActive,a=n.animationBegin,o=n.animationDuration,s=n.animationEasing,c=n.animationInterpolateFn,l=Ie(),u=l.isAnimating,d=l.handleAnimationStart,f=l.handleAnimationEnd,p=ne();return p==null?null:K.createElement(tn,{showLabels:!u,points:r},K.createElement(oe,{animationInput:n,animationIdPrefix:`recharts-scatter-`,items:r,previousItemsRef:t,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s,onAnimationStart:d,onAnimationEnd:f,animationInterpolateFn:c,animationMatchBy:n.animationMatchBy,layout:p},(e,t,r)=>K.createElement(G,null,K.createElement(rn,{points:e,allOtherScatterProps:n,showLabels:!u,animationElapsedTime:t,isAnimating:u||t<1,isEntrance:r}))),n.children,K.createElement(C,{label:n.label}))}function sn(e){var t=e.displayedData,n=e.xAxis,r=e.yAxis,i=e.zAxis,a=e.scatterSettings,o=e.xAxisTicks,s=e.yAxisTicks,c=e.cells,l=W(n.dataKey)?a.dataKey:n.dataKey,u=W(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:k.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=Pe(e,l),g=Pe(e,u),_=!W(d)&&Pe(e,d)||`-`,v=[{name:W(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:W(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=S({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=S({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,C=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-C,y:b==null?void 0:b-C,width:2*C,height:2*C,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var cn=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:Pe(e,t)});function ln(e){var t=e.hide,n=e.points,r=e.className,i=e.needClip,a=e.xAxisId,o=e.yAxisId,s=e.id,c=(0,K.useRef)(null);if(t)return null;var l=_(`recharts-scatter`,r),u=s;return K.createElement(P,{zIndex:e.zIndex},K.createElement(G,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&K.createElement(`defs`,null,K.createElement(Ee,{clipPathId:u,xAxisId:a,yAxisId:o})),K.createElement(ue,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:cn,errorBarOffset:0},K.createElement(G,{key:`recharts-scatter-symbols`},K.createElement(on,{props:e,previousPointsRef:c})))))}var un={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,animationMatchBy:ze,animationInterpolateFn:an,zIndex:R.scatter};function dn(e){var t=De(e,un),n=t.animationBegin,r=t.animationDuration,i=t.animationEasing,a=t.hide,o=t.isAnimationActive,s=t.legendType,c=t.lineJointType,l=t.lineType,u=t.shape,d=t.xAxisId,f=t.yAxisId,p=t.zAxisId,m=Kt(t,Gt),h=Me(d,f).needClip,g=(0,K.useMemo)(()=>T(e.children,be),[e.children]),_=ae(),v=ce(t=>Ht(t,d,f,p,e.id,g,_));return h==null||v==null?null:K.createElement(K.Fragment,null,K.createElement($t,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,formatter:e.formatter,tooltipType:e.tooltipType,id:e.id}),K.createElement(ln,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function fn(e){var t=De(e,un),n=ae();return K.createElement(he,{id:t.id,type:`scatter`},e=>K.createElement(K.Fragment,null,K.createElement(Re,{legendPayload:Qt(t)}),K.createElement(ge,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),K.createElement(dn,Q({},t,{id:e}))))}var pn=K.memo(fn,z);pn.displayName=`Scatter`;function mn(e){var t=ye(),n=(0,K.useRef)(null);return(0,K.useLayoutEffect)(()=>{n.current===null?t(pe(e)):n.current!==e&&t(we({prev:n.current,next:e})),n.current=e},[e,t]),(0,K.useLayoutEffect)(()=>()=>{n.current&&=(t(Oe(n.current)),null)},[t]),null}var hn={zAxisId:0,range:k.range,scale:k.scale,type:k.type};function gn(e){var t=De(e,hn);return K.createElement(mn,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:k.allowDuplicatedCategory,allowDataOverflow:k.allowDataOverflow,reversed:k.reversed,includeHidden:k.includeHidden})}gn.displayName=`ZAxis`;var _n=[`item`],vn=(0,K.forwardRef)((e,t)=>K.createElement(Te,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_n,tooltipPayloadSearcher:N,categoricalChartProps:e,ref:t}));function yn({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r={jobs:n(`surfaces.job`),explore:n(`surfaces.exploreSpec`),quick:n(`surfaces.quickSpec`),refine:n(`surfaces.aiEdit`),fileSummaries:n(`surfaces.fileSummary`),smash:n(`surfaces.smash`),loop:n(`surfaces.loop`)},i=e.dailyTimeline.map(e=>({date:e.date.slice(5),[r.jobs]:e.jobsCostUsd,[r.explore]:e.exploreCostUsd,[r.quick]:e.quickCostUsd,[r.refine]:e.aiEditCostUsd,[r.fileSummaries]:e.fileSummaryCostUsd??0,[r.smash]:e.smashCostUsd??0,[r.loop]:e.loopCostUsd??0})),a=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0),o=e.dailyTimeline.reduce((e,t)=>e+(t.unpricedCount??0),0),c=a&&o>0,l=!a&&o>0;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`timeline.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:l?n(`timeline.costPartiallyUnavailable`,{count:o}):n(`timeline.subtitle`)})]}),c?(0,q.jsx)(`div`,{"data-testid":`timeline-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.costUnavailable`)}):a?(0,q.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.empty`)}):(0,q.jsx)(`div`,{className:`h-[220px]`,children:(0,q.jsx)(B,{width:`100%`,height:`100%`,children:(0,q.jsxs)(Ne,{data:i,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,q.jsx)(Se,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,q.jsx)(ve,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,q.jsx)(Ae,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,q.jsx)(M,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,q.jsx)(H,{dataKey:r.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,q.jsx)(H,{dataKey:r.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,q.jsx)(H,{dataKey:r.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,q.jsx)(H,{dataKey:r.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,q.jsx)(H,{dataKey:r.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,q.jsx)(H,{dataKey:r.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,q.jsx)(H,{dataKey:r.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function bn(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xn(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function Sn({values:e}){let t=Math.max(1e-4,...e);return(0,q.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,q.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Cn({mode:e,label:t,accentClass:n}){let{t:r}=s(`analytics`),i=e.mode===`explore`&&e.totalRuns<5,a=(e.estimatedCostUsd??0)>0,c=e.avgCostPerSpec==null&&(e.unpricedCount??0)>0;return(0,q.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,q.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),i?(0,q.jsxs)(`div`,{className:`py-3`,children:[(0,q.jsx)(`p`,{className:`text-sm text-foreground`,children:r(`quickVsExplore.sparseCta`)}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":a?`true`:void 0,title:c?r(`quickVsExplore.costUnavailableTooltip`):a?r(`quickVsExplore.estimatedTooltip`):void 0,children:[a&&e.avgCostPerSpec!=null?`~`:``,bn(e.avgCostPerSpec)]}),(0,q.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:r(c?`quickVsExplore.costUnavailable`:`quickVsExplore.perSpec`)}),(0,q.jsx)(`div`,{className:`mt-3`,children:(0,q.jsx)(Sn,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,q.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,q.jsx)(`div`,{children:(0,q.jsx)(o,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,q.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,q.jsx)(`div`,{children:r(`quickVsExplore.avgDuration`,{duration:xn(e.avgDurationMs)})}),(0,q.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wn({data:e,loading:t}){let{t:n}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r=e.byMode.find(e=>e.mode===`quick`),i=e.byMode.find(e=>e.mode===`explore`);if(!r||!i)return null;let a=r.avgCostPerSpec&&i.avgCostPerSpec&&r.avgCostPerSpec>0?i.avgCostPerSpec/r.avgCostPerSpec:null,o=a!==null&&r.totalRuns>=1&&i.totalRuns>=5,c=(r.estimatedCostUsd??0)>0||(i.estimatedCostUsd??0)>0;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,q.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`quickVsExplore.title`)})}),(0,q.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,q.jsx)(Cn,{mode:r,label:n(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,q.jsx)(Cn,{mode:i,label:n(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),o&&(0,q.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,q.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,q.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,n(`quickVsExplore.ratio`,{ratio:a.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,q.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(`quickVsExplore.estimatedFootnote`)})})]})}function Tn(e){return e<.005&&e>0?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function En(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dn({data:e,loading:t}){let{t:n}=s(`analytics`),r=e?.agentMissions;if(t||!r||r.summary.turns===0)return null;let{summary:a,topConversations:o}=r,c=a.estimatedCostUsd>0,l=a.prevTotalCostUsd>0?(a.totalCostUsd-a.prevTotalCostUsd)/a.prevTotalCostUsd*100:null;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card p-4`,"data-testid":`agent-missions-card`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(b,{className:`h-4 w-4 text-accent-highlight`}),(0,q.jsx)(`h3`,{className:`text-sm font-medium`,children:n(`agentMissions.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`agentMissions.subtitle`)})]}),(0,q.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,q.jsxs)(`span`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":c?`true`:void 0,title:c?n(`agentMissions.estimatedNote`):void 0,children:[c?`~`:``,Tn(a.totalCostUsd)]}),l!==null&&(0,q.jsxs)(`span`,{className:l>0?`text-xs text-accent-warning`:`text-xs text-accent-success`,children:[l>0?`+`:``,l.toFixed(0),`% `,n(`agentMissions.vsPrev`)]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`agentMissions.turnsAndTokens`,{turns:a.turns,tokens:En(a.tokensIn+a.tokensOut)})}),o.length>0&&(0,q.jsx)(`ul`,{className:`mt-3 space-y-1 border-t border-border/40 pt-2`,children:o.map(e=>(0,q.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/85`,children:e.title?.trim()||n(`agentMissions.untitled`)}),(0,q.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:[e.turns,` · `,e.lastAt?v(new Date(e.lastAt),{addSuffix:!0,locale:i()}):`—`]}),(0,q.jsxs)(`span`,{className:`shrink-0 tabular-nums font-medium`,children:[e.estimatedCostUsd>0?`~`:``,Tn(e.costUsd)]})]},e.conversationId??`unknown`))})]})}function On({data:e,loading:t,onSelectModel:n,activeModel:r}){let{t:i}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.summary.totalCostUsd,o=e.byModel.slice(0,5),c=o.reduce((e,t)=>e+t.costUsd,0),l=Math.max(0,a-c),u=l>=.005;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`models.title`)}),o.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`models.empty`)}):(0,q.jsxs)(`ul`,{className:`space-y-1.5`,children:[o.map(e=>{let t=a>0?e.costUsd/a*100:0,o=r===e.model,s=(e.estimatedCostUsd??0)>0,c=e.unpricedCount??0,l=Math.max(0,e.count-c),u=e.count>0&&c>0&&l===0,d=l>0&&c>0;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${o?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":u?`model-cost-unavailable`:void 0,title:u?i(`models.costUnavailableTooltip`):d?i(`models.costPartiallyUnavailableTooltip`):s?i(`models.estimatedTooltip`):void 0,children:u?i(`models.costUnavailableWithRuns`,{count:e.count}):(0,q.jsxs)(q.Fragment,{children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count,d&&(0,q.jsx)(`span`,{className:`ml-1 italic`,children:i(`models.costPartiallyUnavailable`,{count:c})})]})})]}),(0,q.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,q.jsx)(`div`,{className:`h-full ${o?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)}),u&&(0,q.jsx)(`li`,{"data-testid":`model-others`,children:(0,q.jsxs)(`div`,{className:`w-full rounded-md px-2 py-1.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,q.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:i(`models.others`)}),(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,l.toFixed(2)]})]}),(0,q.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,q.jsx)(`div`,{className:`h-full bg-foreground/25`,style:{width:`${a>0?l/a*100:0}%`}})})]})})]})]})}var kn={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`,"chat-sidebar":`var(--accent-info, #5fa8d3)`,"spec-launcher":`var(--accent-secondary, #f7768e)`,proposal:`var(--accent-highlight, #c084fc)`,"agent-studio":`var(--accent-success, #50fa7b)`,setup:`var(--accent-primary, #7aa2f7)`},An=Object.keys(m);function jn({data:e,loading:t,onSelectPoint:n}){let{t:r}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=An,a=i.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),o=e.scatter.length===0,c=e.summary.unpricedRuns??0,l=o&&c>0,u=!o&&c>0,d=e.scatterTruncated===!0,f=e.scatterTotal??e.scatter.length;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`scatter.title`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:i.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:kn[e]}}),(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:m[e]})]},e))})]}),d&&!o&&(0,q.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:r(`scatter.truncated`,{shown:e.scatter.length,total:f})}),u&&(0,q.jsx)(`div`,{"data-testid":`scatter-cost-partial-notice`,className:`mb-2 text-[10px] text-muted-foreground/80 italic`,children:r(`scatter.costPartiallyUnavailable`,{count:c})}),l?(0,q.jsx)(`div`,{"data-testid":`scatter-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.costUnavailable`)}):o?(0,q.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.empty`)}):(0,q.jsx)(`div`,{className:`h-[260px]`,children:(0,q.jsx)(B,{width:`100%`,height:`100%`,children:(0,q.jsxs)(vn,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,q.jsx)(Se,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,q.jsx)(ve,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:r(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,q.jsx)(Ae,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,q.jsx)(gn,{range:[40,80]}),(0,q.jsx)(M,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,r(`scatter.costLabel`)]:[String(e),n===`turns`?r(`scatter.turnsLabel`):n]}}),a.map(e=>(0,q.jsx)(pn,{data:e.points,fill:kn[e.surface],onClick:e=>{let t=e;t?.raw&&n(t.raw)}},e.surface))]})})})]})}function Mn({data:e,loading:t,onSelectTicket:n}){let{t:r}=s(`analytics`);if(t&&!e)return(0,q.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.topTickets;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:r(`topTickets.title`)}),i.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`topTickets.empty`)}):(0,q.jsx)(`ul`,{className:`divide-y divide-border/30`,children:i.map((e,t)=>{let i=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>r(`topTickets.breakdownItem`,{n:t.count,label:m[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?r(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:r(`topTickets.deletedTicket`,{id:e.ticketId}),s=!e.ticketTitle&&!a?`opacity-50`:``,c=e.unpricedCount??0,l=e.totalRuns>0&&c===e.totalRuns,u=c>0&&!l;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${s}`,disabled:a,children:[(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,q.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:i||`—`})]}),(0,q.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium`,title:l?r(`topTickets.costUnavailableTooltip`):u?r(`topTickets.costPartiallyUnavailableTooltip`):void 0,children:l?r(`topTickets.costUnavailable`):`$${e.totalCostUsd.toFixed(2)}`}),u&&(0,q.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic`,children:r(`topTickets.costPartiallyUnavailable`,{count:c})}),(0,q.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var Nn={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`};function Pn(e){return Nn[e]??e}function Fn(e){return!!e&&!(e in Nn)}function In(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Ln(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Rn(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function zn(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function Bn(e,t){if(e.model)return e.model;if(!Rn(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Vn({rows:e,loading:t,truncated:n,totalAvailable:r,tableFilters:i,onTableFiltersChange:a}){let{t:o}=s(`analytics`),[c,l]=(0,K.useState)(null),u=zn(e),d=new Set(e.map(e=>e.provider??`claude`)).size>1,f=n||r>e.length;return(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,q.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:o(`table.title`)}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,q.jsxs)(`select`,{value:i.status??``,onChange:e=>a({...i,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":o(`table.statusFilterAria`),children:[(0,q.jsx)(`option`,{value:``,children:o(`table.allStatus`)}),(0,q.jsx)(`option`,{value:`success`,children:o(`table.success`)}),(0,q.jsx)(`option`,{value:`failed`,children:o(`table.failed`)}),(0,q.jsx)(`option`,{value:`aborted`,children:o(`table.aborted`)})]}),(0,q.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:o(`table.minCostPlaceholder`),value:i.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);a({...i,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":o(`table.minCostFilterAria`)})]})]}),t?(0,q.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,q.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:o(`table.empty`)}):(0,q.jsx)(`div`,{className:`overflow-x-auto`,children:(0,q.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,q.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,q.jsxs)(`tr`,{className:`text-left`,children:[(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colSurface`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colTicket`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colCost`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colTurns`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:o(`table.colTokens`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colModel`)}),d&&(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colProvider`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colStatus`)}),(0,q.jsx)(`th`,{className:`font-medium px-2 py-2`,children:o(`table.colStarted`)})]})}),(0,q.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=g[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Rn(e),a=i?o(`table.contractLayer`):m[t],s=Bn(e,u);return(0,q.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,q.jsx)(`td`,{className:`px-2 py-2`,children:(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,q.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,q.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:o(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,q.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,q.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,q.jsx)(`span`,{className:`text-muted-foreground/90`,children:o(`table.contractLayerRefinement`)}):e.ticket_title??(0,q.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:o(`table.deleted`)})]})}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,q.jsxs)(`span`,{title:o(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,In(e.total_cost_usd)]}):e.total_cost_usd==null&&Fn(e.provider)?(0,q.jsx)(`span`,{title:o(`table.costUnknownLocalTooltip`),"data-testid":`cost-unknown-local`,className:`text-muted-foreground/70`,children:`—`}):In(e.total_cost_usd)}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right`,children:Ln(e.num_turns)}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?Ln(r):`—`}),(0,q.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[s??`—`,s&&!e.model?(0,q.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:o(`table.inferred`)}):null]}),d&&(0,q.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:Pn(e.provider??`claude`)}),(0,q.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,q.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,q.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,q.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:o(`table.statusValue.${e.status}`)})]}),(0,q.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),f&&e.length>0&&(0,q.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:o(`table.truncated`,{shown:e.length,total:r.toLocaleString()})})]})}var Hn=[`legacy_loop_traversal`,`queue_manager_slash`,`merge_back`],Un=e=>Number.isSafeInteger(e)&&e>=0;function Wn(e){let t=e;if(!t||!Un(t.total)||!t.byKind||Hn.some(e=>!Un(t.byKind[e]))||t.lastAt!==null&&(typeof t.lastAt!=`string`||!Number.isFinite(Date.parse(t.lastAt))))throw Error(`Invalid telemetry`);return t}function Gn({projectId:e}){let{t}=s(`analytics`),n=(0,K.useRef)(new Map),[r,i]=(0,K.useState)(0),[a,o]=(0,K.useState)({projectId:e,loading:!0,error:!1});(0,K.useEffect)(()=>{let t=!0,r=new AbortController;return o({projectId:e,loading:!0,error:!1}),(async()=>{try{let i=await fetch(`${l()}/analytics/legacy-launches`,{signal:r.signal});if(!i.ok)throw Error(`Telemetry unavailable`);let a=Wn(await i.json());if(!t)return;n.current.set(e,a),o({projectId:e,loading:!1,error:!1})}catch{t&&o({projectId:e,loading:!1,error:!0})}})(),()=>{t=!1,r.abort()}},[e,r]);let c=n.current.get(e),u=a.projectId!==e||a.loading,d=a.projectId===e&&a.error;return(0,q.jsxs)(`section`,{className:`rounded-xl border border-border/40 bg-card/40 p-4 space-y-3`,"aria-label":t(`legacyUsage.title`),children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-medium`,children:t(`legacyUsage.title`)}),(0,q.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>i(e=>e+1),className:`text-xs underline disabled:opacity-50`,children:t(`legacyUsage.refresh`)})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`legacyUsage.scope`)}),d&&(0,q.jsx)(`p`,{role:`status`,className:`text-xs text-destructive`,children:t(`legacyUsage.unavailable`)}),!c&&u&&(0,q.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:t(`legacyUsage.loading`)}),c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`text-sm`,children:t(`legacyUsage.total`,{count:c.total})}),(0,q.jsx)(`dl`,{className:`grid gap-2 text-xs sm:grid-cols-3`,children:Hn.map(e=>(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-muted-foreground`,children:t(`legacyUsage.kinds.${e}`)}),(0,q.jsx)(`dd`,{className:`font-mono tabular-nums`,children:c.byKind[e]})]},e))}),c.lastAt&&(0,q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t(`legacyUsage.last`),` `,(0,q.jsx)(`time`,{dateTime:c.lastAt,children:new Date(c.lastAt).toLocaleString()})]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`legacyUsage.evidence`)})]})}var Kn=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],qn=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`},{value:`loop`,labelKey:`surfaces.loop`}];function Jn(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function Yn(){let{t:e}=s(`analytics`),{activeProjectId:t,projects:n}=d(),[i,o]=r(),c=n.find(e=>e.id===t),m=c?u(c):[`claude`],h=m.length>1,g=i.get(`period`)??`30d`,_=(i.get(`surface`)??``).split(`,`).filter(Boolean),v=(i.get(`provider`)??``).split(`,`).filter(Boolean),b=i.get(`ticketId`),S=(i.get(`model`)??``).split(`,`).filter(Boolean),C=(i.get(`modelProvider`)??``).split(`,`).filter(Boolean),ee=S.length>0&&S.length===C.length?S.map((e,t)=>({provider:C[t],model:e})):void 0,te=(0,K.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[w,T]=(0,K.useState)({period:g,surface:_.length>0?_:void 0,provider:v.length>0?v:void 0,ticketId:b?Number(b):void 0,model:S.length>0?S:void 0,modelKeys:ee,tzOffsetMinutes:te}),[E,D]=(0,K.useState)(null),[O,k]=(0,K.useState)(!0),[A,ne]=(0,K.useState)(null),[j,M]=(0,K.useState)({}),[N,P]=(0,K.useState)(null),[F,re]=(0,K.useState)(`recency`),I=(0,K.useRef)(new Map),ie=(0,K.useRef)(0);(0,K.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,w.period),w.surface&&w.surface.length>0&&e.set(`surface`,w.surface.join(`,`)),w.provider&&w.provider.length>0&&e.set(`provider`,w.provider.join(`,`)),w.ticketId&&e.set(`ticketId`,String(w.ticketId)),w.model&&w.model.length>0&&(e.set(`model`,w.model.join(`,`)),w.modelKeys&&w.modelKeys.length===w.model.length&&e.set(`modelProvider`,w.modelKeys.map(e=>e.provider).join(`,`))),o(e,{replace:!0})},[w.period,w.surface,w.provider,w.ticketId,w.model,w.modelKeys,o]);let L=(0,K.useCallback)(async()=>{if(!t)return;let e=++ie.current;ne(null);let n=`${t}:${Jn(w)}`,r=I.current.get(n);r?(D(r),k(!1)):k(!0);try{let t=await fetch(`${l()}/spending?${Jn(w)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==ie.current)return;let r=await t.json();I.current.set(n,r),D(r),k(!1)}catch(t){if(e!==ie.current)return;ne(t.message),k(!1)}},[t,w]),R=(0,K.useRef)(0),z=(0,K.useCallback)(async()=>{if(!t)return;let e=++R.current,n={...w};j.model&&(n.model=[j.model],n.modelKeys=void 0),j.status&&(n.status=j.status),typeof j.minCostUsd==`number`&&(n.minCostUsd=j.minCostUsd),n.sortBy=F;try{let t=await fetch(`${l()}/invocations?${Jn(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==R.current)return;P(r)}catch{if(e!==R.current)return;P(null)}},[t,w,j,F]),ae=(0,K.useRef)(t);(0,K.useEffect)(()=>{ae.current!==t&&(ae.current=t,D(null),P(null),k(!0))},[t]),(0,K.useEffect)(()=>{L()},[L]),(0,K.useEffect)(()=>{z()},[z]);let B=(0,K.useRef)(null),V=a();(0,K.useEffect)(()=>{let e=`analytics-spending`;return V.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(B.current&&clearTimeout(B.current),B.current=setTimeout(()=>{I.current.clear(),L(),z()},500))}),()=>{V.unregisterHandler(e),B.current&&clearTimeout(B.current)}},[V,t,L,z]);function oe(e){if(e===`all`){T(e=>({...e,surface:void 0}));return}T(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}let se=(0,K.useCallback)((e,t)=>{T(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(E?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[E]);function H(){T(e=>({...e,model:void 0,modelKeys:void 0}))}function ce(e){if(e===`all`){T(e=>({...e,provider:void 0}));return}T(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let le=w.surface,ue=!le||le.length===0,de=w.provider,U=!de||de.length===0,fe=(0,K.useMemo)(()=>{let e={period:w.period};return w.surface&&w.surface.length>0&&(e.surface=w.surface.join(`,`)),w.provider&&w.provider.length>0&&(e.provider=w.provider.join(`,`)),w.ticketId&&(e.ticketId=String(w.ticketId)),e},[w]),pe=E?E.summary.totalRuns===0:!1;return(0,q.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,q.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),w.ticketId&&(0,q.jsx)(`button`,{type:`button`,onClick:()=>T(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:w.ticketId})}),w.model&&w.model.length>0&&(0,q.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:H,title:e(`page.clearModelFilter`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:[e(`page.modelChip`,{model:w.model[0]}),(0,q.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Kn.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>T(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${w.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,q.jsx)(x,{baseUrl:`${l()}/analytics/export`,params:fe,disabled:pe}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>{I.current.clear(),L(),z()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,q.jsx)(y,{className:`w-3 h-3`})})]})]}),(0,q.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:qn.map(t=>(0,q.jsx)(`button`,{type:`button`,onClick:()=>oe(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ue:le?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),h&&(0,q.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>ce(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${U?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),m.map(t=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>ce(t),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${de?.includes(t)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:[p(t),f(t)&&(0,q.jsx)(`span`,{className:`ml-1 rounded-full bg-accent-secondary/15 px-1.5 text-[9px] uppercase tracking-wide text-accent-secondary`,children:e(`page.localEngine`)})]},t))]})]}),A&&(0,q.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,q.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:A})}),(0,q.jsxs)(`button`,{onClick:()=>L(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,q.jsx)(y,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,q.jsx)(qe,{data:E,loading:O,period:w.period}),t&&(0,q.jsx)(Gn,{projectId:t}),(0,q.jsx)($e,{data:E,loading:O}),(0,q.jsx)(yn,{data:E,loading:O}),(0,q.jsx)(Dn,{data:E,loading:O}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,q.jsx)(wn,{data:E,loading:O}),(0,q.jsx)(On,{data:E,loading:O,onSelectModel:se,activeModel:w.model?.[0]})]}),(0,q.jsx)(jn,{data:E,loading:O,onSelectPoint:e=>{M(e=>({...e})),T(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,q.jsx)(Mn,{data:E,loading:O,onSelectTicket:e=>T(t=>({...t,ticketId:e??void 0}))}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,q.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":F===t,onClick:()=>re(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${F===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,q.jsx)(Vn,{rows:N?.rows??[],loading:O&&!N,truncated:(N?.truncated??!1)||(N?.totalAvailable??0)>(N?.rows.length??0),totalAvailable:N?.totalAvailable??0,tableFilters:j,onTableFiltersChange:M})]})]})}export{Yn as default};
|