@roastcodes/ttdash 6.2.1 → 6.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/assets/AnimatedBarFill-DFAXO-3i.js +1 -0
  2. package/dist/assets/{AnomalyDetection-BdGl1xvC.js → AnomalyDetection-DKM--5-J.js} +1 -1
  3. package/dist/assets/{AutoImportModal-bokip1Pn.js → AutoImportModal-Cqefa6n_.js} +1 -1
  4. package/dist/assets/CacheROI-BLADEjtP.js +1 -0
  5. package/dist/assets/ChartCard-DxxB4rGm.js +2 -0
  6. package/dist/assets/ChartLegend-Vpk95i3r.js +1 -0
  7. package/dist/assets/CorrelationAnalysis-CI9eGa8R.js +1 -0
  8. package/dist/assets/CostByModelOverTime-BDvnsdLO.js +1 -0
  9. package/dist/assets/{CostByWeekday-X20qjGNA.js → CostByWeekday-BPU1qW5f.js} +1 -1
  10. package/dist/assets/CostForecast-fwd7SRIn.js +1 -0
  11. package/dist/assets/CumulativeCost-CwiklwFD.js +1 -0
  12. package/dist/assets/{CustomTooltip-CBVU1pyK.js → CustomTooltip-CfoUDPbT.js} +1 -1
  13. package/dist/assets/DistributionAnalysis-B8pjQMNj.js +1 -0
  14. package/dist/assets/{DrillDownModal-BXf7B9B8.js → DrillDownModal-kczVCwfa.js} +1 -1
  15. package/dist/assets/{HelpPanel-HNxQElT5.js → HelpPanel-D4zNwrI2.js} +1 -1
  16. package/dist/assets/{InfoButton-CTgLGzb9.js → InfoButton-BGjUQfHz.js} +1 -1
  17. package/dist/assets/InfoHeading-BxLyydv8.js +1 -0
  18. package/dist/assets/{MetricCard-Drluz0b9.js → MetricCard-r_uhdKDU.js} +1 -1
  19. package/dist/assets/{ModelEfficiency-CZ4ZzDtA.js → ModelEfficiency-Di3fDAn7.js} +1 -1
  20. package/dist/assets/{ModelMix-TDHxSk5H.js → ModelMix-BgCzWf9V.js} +1 -1
  21. package/dist/assets/{PeriodComparison-B9WuoaCr.js → PeriodComparison-BIoF7n2v.js} +1 -1
  22. package/dist/assets/{ProviderEfficiency-DpDIYr_l.js → ProviderEfficiency-BFUYfBkW.js} +1 -1
  23. package/dist/assets/ProviderLimitsSection-BxaczEFO.js +1 -0
  24. package/dist/assets/RecentDays-Bac6HOtv.js +1 -0
  25. package/dist/assets/RequestCacheHitRateByModel-DD2j4dXY.js +1 -0
  26. package/dist/assets/RequestQuality-CUy5BQzj.js +1 -0
  27. package/dist/assets/RequestsOverTime-Bv3riiRF.js +1 -0
  28. package/dist/assets/SettingsModal-4uENZ87D.js +1 -0
  29. package/dist/assets/TokenEfficiency-6dfn-4_1.js +1 -0
  30. package/dist/assets/TokenTypes-Dx67irJb.js +1 -0
  31. package/dist/assets/TokensOverTime-C1858Oi-.js +1 -0
  32. package/dist/assets/{app-settings-C3i52ycx.js → app-settings-BInClAwB.js} +1 -1
  33. package/dist/assets/button-CRvPoJg9.js +1 -0
  34. package/dist/assets/card-B4CVYJDH.js +1 -0
  35. package/dist/assets/chart-theme-BdE8bEiN.js +1 -0
  36. package/dist/assets/{constants-jyhBMReu.js → constants-BDzjWFuU.js} +1 -1
  37. package/dist/assets/{dialog-C0AeNKs8.js → dialog-Djogwk0C.js} +1 -1
  38. package/dist/assets/{formatted-value-rO0EpKbc.js → formatted-value-CpLoDrYF.js} +1 -1
  39. package/dist/assets/{formatters-yKppUXb3.js → formatters-C7EouP6y.js} +1 -1
  40. package/dist/assets/help-content-B2N8SHIE.js +1 -0
  41. package/dist/assets/i18n-BS3-GJaA.js +1 -0
  42. package/dist/assets/index-8kk0H-lQ.css +2 -0
  43. package/dist/assets/index-C59tb1_V.js +3 -0
  44. package/dist/assets/motion-vendor-BNVN-Ktr.js +9 -0
  45. package/dist/assets/{section-header-DbV45zH5.js → section-header-Dz0QIE6e.js} +1 -1
  46. package/dist/assets/{ui-vendor-BolBXLiD.js → ui-vendor-C_SJC6eX.js} +1 -1
  47. package/dist/assets/useTranslation-0ThAx3Gl.js +1 -0
  48. package/dist/index.html +25 -24
  49. package/package.json +1 -1
  50. package/server.js +7 -0
  51. package/src/locales/de/common.json +10 -0
  52. package/src/locales/en/common.json +10 -0
  53. package/dist/assets/CacheROI-IyVKLGZu.js +0 -1
  54. package/dist/assets/ChartCard-CBUnItl-.js +0 -2
  55. package/dist/assets/ChartLegend-B64cJdDI.js +0 -1
  56. package/dist/assets/CorrelationAnalysis-Dnd0YUCO.js +0 -1
  57. package/dist/assets/CostByModelOverTime-C10Hr2xR.js +0 -1
  58. package/dist/assets/CostForecast-C--EIZ4B.js +0 -1
  59. package/dist/assets/CumulativeCost-D9v6GDcr.js +0 -1
  60. package/dist/assets/DistributionAnalysis-Cdly0pAu.js +0 -1
  61. package/dist/assets/InfoHeading-oi90uCR7.js +0 -1
  62. package/dist/assets/ProviderLimitsSection-CSuisho_.js +0 -1
  63. package/dist/assets/RecentDays-Cz4Yd_-Q.js +0 -1
  64. package/dist/assets/RequestCacheHitRateByModel-5bkvg7Hx.js +0 -1
  65. package/dist/assets/RequestQuality-iUIOJrpr.js +0 -1
  66. package/dist/assets/RequestsOverTime-D10OssgN.js +0 -1
  67. package/dist/assets/SettingsModal-D9-T5heB.js +0 -1
  68. package/dist/assets/TokenEfficiency-CGeyr8Zq.js +0 -1
  69. package/dist/assets/TokenTypes-BiRBF9VP.js +0 -1
  70. package/dist/assets/TokensOverTime-DeT3D-aC.js +0 -1
  71. package/dist/assets/button-D--hHeVj.js +0 -1
  72. package/dist/assets/card-h-Z9EWBl.js +0 -1
  73. package/dist/assets/chart-theme-D5iCFDJg.js +0 -1
  74. package/dist/assets/help-content-Bt5KCpWS.js +0 -1
  75. package/dist/assets/i18n-C88wS2Uy.js +0 -1
  76. package/dist/assets/index-DjMakAzD.js +0 -3
  77. package/dist/assets/index-DuoM1Ukq.css +0 -2
  78. package/dist/assets/motion-vendor-vKc6gXHZ.js +0 -1
  79. package/dist/assets/useTranslation-BSl7t2D6.js +0 -1
  80. /package/dist/assets/{calculations-GOdNqKo6.js → calculations-BJw_4KdI.js} +0 -0
  81. /package/dist/assets/{provider-limits-5e1fUwPl.js → provider-limits-BgKrr7k7.js} +0 -0
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n,n as r}from"./motion-vendor-BNVN-Ktr.js";import{a as i,o as a}from"./useTranslation-0ThAx3Gl.js";import{l as o,s}from"./card-B4CVYJDH.js";var c=e(t()),l=n();function u({width:e,className:t,style:n,active:u,order:d=0,delayMs:f,durationMs:p}){let m=(0,c.useRef)(null),h=o(m,{kind:`meter`,amount:.2,order:d,...f===void 0?{}:{delayMs:f}}),g=i(),_=u??h.active,v=f??h.delayMs,y=p??s.meterDurationMs;return g?(0,l.jsx)(`div`,{ref:m,className:a(t),style:{...n,width:_?e:`0%`}}):(0,l.jsx)(r.div,{ref:m,className:a(t),...n?{style:n}:{},initial:!1,animate:{width:_?e:`0%`},transition:{duration:y/1e3,delay:_?v/1e3:0,ease:[.22,1,.36,1]}})}export{u as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{h as i,i as a,n as o}from"./formatters-yKppUXb3.js";import{i as s}from"./icons-vendor-CIvT_-Pb.js";import{a as c,i as l,n as u,t as d}from"./card-h-Z9EWBl.js";import{t as f}from"./help-content-Bt5KCpWS.js";import{t as p}from"./InfoHeading-oi90uCR7.js";import{t as m}from"./calculations-GOdNqKo6.js";var h=e(t()),g=n();function _({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:_}=r(),{anomalies:v,mean:y,stdDev:b}=(0,h.useMemo)(()=>{if(e.length<3)return{anomalies:[],mean:0,stdDev:0};let t=e.map(e=>e.totalCost),n=t.reduce((e,t)=>e+t,0)/t.length,r=Math.sqrt(t.reduce((e,t)=>e+(t-n)**2,0)/t.length);return{anomalies:m(e),mean:n,stdDev:r}},[e]);return v.length===0?(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsx)(c,{className:`text-sm font-medium text-muted-foreground`,children:_(`anomaly.title`,{period:i(n,!0)})})})}),(0,g.jsx)(u,{children:(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_(`anomaly.none`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:_(`anomaly.withinStdDev`)})]})})]}):(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsxs)(c,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-yellow-500`}),_(`anomaly.title`,{period:i(n,!0)}),` (`,v.length,`)`]})})}),(0,g.jsxs)(u,{children:[(0,g.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:_(`anomaly.description`,{period:i(n,!0),mean:o(y),stdDev:o(b)})}),(0,g.jsx)(`div`,{className:`space-y-2`,children:[...v].sort((e,t)=>t.totalCost-e.totalCost).map(e=>{let n=b>0?(e.totalCost-y)/b:0,r=n.toFixed(1),i=e.totalCost>y,s=Math.abs(n)>=3?`critical`:`warn`;return(0,g.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between rounded-lg p-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${s===`critical`?`bg-red-400/10 hover:bg-red-400/20 border border-red-400/20`:`bg-muted/30 hover:bg-muted/50`}`,disabled:!t,"aria-disabled":!t,onClick:()=>t?.(e.date),children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`h-2 w-2 rounded-full ${i?`bg-red-400`:`bg-green-400`} ${s===`critical`?`animate-pulse`:``}`}),(0,g.jsx)(`span`,{className:`text-sm`,children:a(e.date,`long`)}),s===`critical`&&(0,g.jsx)(`span`,{className:`rounded bg-red-400/10 px-1.5 py-0.5 text-[9px] font-semibold tracking-wider text-red-400 uppercase`,children:_(`anomaly.critical`)})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,g.jsx)(`span`,{className:`font-mono text-sm font-medium ${i?`text-red-400`:`text-green-400`}`,children:o(e.totalCost)}),(0,g.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-xs font-medium ${s===`critical`?`bg-red-400/15 text-red-300`:`text-muted-foreground`}`,children:[i?`+`:``,r,`σ`]})]})]},e.date)})})]})]})}export{_ as AnomalyDetection};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{t as r}from"./useTranslation-0ThAx3Gl.js";import{h as i,i as a,n as o}from"./formatters-C7EouP6y.js";import{i as s}from"./icons-vendor-CIvT_-Pb.js";import{a as c,i as l,n as u,t as d}from"./card-B4CVYJDH.js";import{t as f}from"./help-content-B2N8SHIE.js";import{t as p}from"./InfoHeading-BxLyydv8.js";import{t as m}from"./calculations-BJw_4KdI.js";var h=e(t()),g=n();function _({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:_}=r(),{anomalies:v,mean:y,stdDev:b}=(0,h.useMemo)(()=>{if(e.length<3)return{anomalies:[],mean:0,stdDev:0};let t=e.map(e=>e.totalCost),n=t.reduce((e,t)=>e+t,0)/t.length,r=Math.sqrt(t.reduce((e,t)=>e+(t-n)**2,0)/t.length);return{anomalies:m(e),mean:n,stdDev:r}},[e]);return v.length===0?(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsx)(c,{className:`text-sm font-medium text-muted-foreground`,children:_(`anomaly.title`,{period:i(n,!0)})})})}),(0,g.jsx)(u,{children:(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,g.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:_(`anomaly.none`)}),(0,g.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:_(`anomaly.withinStdDev`)})]})})]}):(0,g.jsxs)(d,{children:[(0,g.jsx)(l,{className:`pb-2`,children:(0,g.jsx)(p,{info:f.anomalyDetection,children:(0,g.jsxs)(c,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,g.jsx)(s,{className:`h-4 w-4 text-yellow-500`}),_(`anomaly.title`,{period:i(n,!0)}),` (`,v.length,`)`]})})}),(0,g.jsxs)(u,{children:[(0,g.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:_(`anomaly.description`,{period:i(n,!0),mean:o(y),stdDev:o(b)})}),(0,g.jsx)(`div`,{className:`space-y-2`,children:[...v].sort((e,t)=>t.totalCost-e.totalCost).map(e=>{let n=b>0?(e.totalCost-y)/b:0,r=n.toFixed(1),i=e.totalCost>y,s=Math.abs(n)>=3?`critical`:`warn`;return(0,g.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between rounded-lg p-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${s===`critical`?`bg-red-400/10 hover:bg-red-400/20 border border-red-400/20`:`bg-muted/30 hover:bg-muted/50`}`,disabled:!t,"aria-disabled":!t,onClick:()=>t?.(e.date),children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,g.jsx)(`div`,{className:`h-2 w-2 rounded-full ${i?`bg-red-400`:`bg-green-400`} ${s===`critical`?`animate-pulse`:``}`}),(0,g.jsx)(`span`,{className:`text-sm`,children:a(e.date,`long`)}),s===`critical`&&(0,g.jsx)(`span`,{className:`rounded bg-red-400/10 px-1.5 py-0.5 text-[9px] font-semibold tracking-wider text-red-400 uppercase`,children:_(`anomaly.critical`)})]}),(0,g.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,g.jsx)(`span`,{className:`font-mono text-sm font-medium ${i?`text-red-400`:`text-green-400`}`,children:o(e.totalCost)}),(0,g.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 font-mono text-xs font-medium ${s===`critical`?`bg-red-400/15 text-red-300`:`text-muted-foreground`}`,children:[i?`+`:``,r,`σ`]})]})]},e.date)})})]})]})}export{_ as AnomalyDetection};
@@ -1,3 +1,3 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{B as i,H as a,c as o,x as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-D--hHeVj.js";import{a as l,i as u,n as d,r as f,t as p}from"./dialog-C0AeNKs8.js";var m=e(t());function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e){try{let t=JSON.parse(e);return h(t)?t:null}catch{return null}}function _(e,t){switch(e.key){case`startingLocalImport`:return t(`autoImportModal.startingLocalImport`);case`loadingUsageData`:return t(`autoImportModal.loadingUsageData`,{command:String(e.vars?.command??``)});case`processingUsageData`:return t(`autoImportModal.processingUsageData`,{seconds:String(e.vars?.seconds??`0`)});case`serverConnectionLost`:return t(`autoImportModal.serverConnectionLost`);case`autoImportRunning`:return t(`autoImportModal.autoImportRunning`);case`noRunnerFound`:return t(`autoImportModal.noRunnerFound`);case`errorPrefix`:return t(`autoImportModal.errorPrefix`,{message:String(e.vars?.message??``)});default:return e.key}}function v(e,t=e=>e){let n=new AbortController,r=new TextDecoder,i=!1,a=!1,o=!1,s=()=>{i||(i=!0,e.onDone())},c=(n,r)=>{switch(n){case`check`:{let t=g(r);t&&e.onCheck(t);return}case`progress`:{let n=g(r);n&&e.onProgress({...n,message:_(n,t)});return}case`stderr`:{let t=g(r);t&&e.onStderr(t);return}case`success`:{let t=g(r);t&&e.onSuccess(t);return}case`error`:{o=!0;let n=g(r);n?e.onError({message:_(n,t)}):e.onError({message:t(`autoImportModal.serverConnectionLost`)});return}case`done`:a=!0,s()}},l=(e,t)=>{t.length!==0&&c(e||`message`,t.join(`
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{t as r}from"./useTranslation-0ThAx3Gl.js";import{B as i,H as a,c as o,x as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-CRvPoJg9.js";import{a as l,i as u,n as d,r as f,t as p}from"./dialog-Djogwk0C.js";var m=e(t());function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function g(e){try{let t=JSON.parse(e);return h(t)?t:null}catch{return null}}function _(e,t){switch(e.key){case`startingLocalImport`:return t(`autoImportModal.startingLocalImport`);case`loadingUsageData`:return t(`autoImportModal.loadingUsageData`,{command:String(e.vars?.command??``)});case`processingUsageData`:return t(`autoImportModal.processingUsageData`,{seconds:String(e.vars?.seconds??`0`)});case`serverConnectionLost`:return t(`autoImportModal.serverConnectionLost`);case`autoImportRunning`:return t(`autoImportModal.autoImportRunning`);case`noRunnerFound`:return t(`autoImportModal.noRunnerFound`);case`errorPrefix`:return t(`autoImportModal.errorPrefix`,{message:String(e.vars?.message??``)});default:return e.key}}function v(e,t=e=>e){let n=new AbortController,r=new TextDecoder,i=!1,a=!1,o=!1,s=()=>{i||(i=!0,e.onDone())},c=(n,r)=>{switch(n){case`check`:{let t=g(r);t&&e.onCheck(t);return}case`progress`:{let n=g(r);n&&e.onProgress({...n,message:_(n,t)});return}case`stderr`:{let t=g(r);t&&e.onStderr(t);return}case`success`:{let t=g(r);t&&e.onSuccess(t);return}case`error`:{o=!0;let n=g(r);n?e.onError({message:_(n,t)}):e.onError({message:t(`autoImportModal.serverConnectionLost`)});return}case`done`:a=!0,s()}},l=(e,t)=>{t.length!==0&&c(e||`message`,t.join(`
2
2
  `))},u=(e,t)=>{for(let n of e){if(!n){l(t.currentEvent,t.dataLines),t.currentEvent=``,t.dataLines=[];continue}if(n.startsWith(`event:`)){t.currentEvent=n.slice(6).trim();continue}n.startsWith(`data:`)&&t.dataLines.push(n.slice(5).trimStart())}};return(async()=>{let i=await fetch(`/api/auto-import/stream`,{method:`POST`,signal:n.signal});if(!i.ok){let n=t(`autoImportModal.serverConnectionLost`);try{let e=await i.json();h(e)&&typeof e.message==`string`&&e.message.trim()&&(n=e.message)}catch{}e.onError({message:n}),s();return}if(!i.body){e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}let c=i.body.getReader(),d=``,f={currentEvent:``,dataLines:[]};for(;;){let{value:n,done:i}=await c.read();if(i){d+=r.decode(),d&&u(d.split(/\r?\n/),f),l(f.currentEvent,f.dataLines),!a&&!o&&e.onError({message:t(`autoImportModal.serverConnectionLost`)}),s();return}d+=r.decode(n,{stream:!0});let p=d.split(/\r?\n/);d=p.pop()??``,u(p,f)}})().catch(r=>{if(n.signal.aborted){s();return}e.onError({message:r instanceof Error&&r.message?r.message:t(`autoImportModal.serverConnectionLost`)}),s()}),{close:()=>{n.abort(),s()}}}var y=n(),b={check:`text-primary`,progress:`text-muted-foreground`,stderr:`text-foreground`,success:`text-green-500`,error:`text-destructive`};function x({open:e,onOpenChange:t,onSuccess:n}){let{t:h}=r(),[g,_]=(0,m.useState)(`idle`),[x,S]=(0,m.useState)([]),[C,w]=(0,m.useState)(null),T=(0,m.useRef)(null),E=(0,m.useRef)(null),D=(0,m.useCallback)((e,t)=>{S(n=>[...n,{type:e,text:t}])},[]),O=(0,m.useCallback)((e,t)=>t?h(e,t):h(e),[h]);(0,m.useEffect)(()=>{if(!e)return;_(`checking`),S([]),w(null);let t=v({onCheck:e=>{e.status===`checking`?D(`check`,h(`autoImportModal.checkingTool`,{tool:e.tool})):e.status===`found`?(D(`check`,h(`autoImportModal.toolFound`,{tool:e.tool,method:e.method,version:e.version})),_(`running`)):e.status===`not_found`&&D(`check`,h(`autoImportModal.toolNotFound`,{tool:e.tool}))},onProgress:e=>{D(`progress`,e.message)},onStderr:e=>{D(`stderr`,e.line)},onSuccess:e=>{D(`success`,h(`autoImportModal.importedDays`,{days:e.days,cost:e.totalCost.toFixed(2)})),w(e),_(`success`),n()},onError:e=>{D(`error`,e.message),_(`error`)},onDone:()=>{E.current=null}},O);return E.current=t,()=>{t.close(),E.current=null}},[e,D,O,n,h]),(0,m.useEffect)(()=>{T.current&&(T.current.scrollTop=T.current.scrollHeight)},[x]);let k=g===`checking`||g===`running`;return(0,y.jsx)(p,{open:e,onOpenChange:e=>{k||t(e)},children:(0,y.jsxs)(d,{className:`max-w-lg`,onPointerDownOutside:e=>{k&&e.preventDefault()},children:[(0,y.jsxs)(u,{children:[(0,y.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,y.jsx)(o,{className:`h-5 w-5`}),h(`autoImportModal.title`)]}),(0,y.jsx)(f,{children:h(`autoImportModal.description`)})]}),(0,y.jsxs)(`div`,{ref:T,className:`max-h-[300px] min-h-[120px] overflow-y-auto rounded-lg border border-border bg-muted/30 p-3 font-mono text-xs`,children:[x.length===0&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(`autoImportModal.connecting`)}),x.map((e,t)=>(0,y.jsx)(`div`,{className:b[e.type],children:e.text.split(`
3
3
  `).map((e,t)=>(0,y.jsx)(`div`,{children:e},t))},t))]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[k&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(s,{className:`h-4 w-4 animate-spin text-primary`}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:h(g===`checking`?`autoImportModal.checkingPrerequisites`:`autoImportModal.importingData`)})]}),g===`success`&&C&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(a,{className:`h-4 w-4 text-green-500`}),(0,y.jsx)(`span`,{className:`text-green-500`,children:h(`autoImportModal.loadedDays`,{days:C.days,cost:C.totalCost.toFixed(2)})})]}),g===`error`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(i,{className:`h-4 w-4 text-destructive`}),(0,y.jsx)(`span`,{className:`text-destructive`,children:h(`autoImportModal.errorOccurred`)})]})]}),!k&&(0,y.jsx)(c,{variant:`outline`,size:`sm`,onClick:()=>t(!1),children:h(`autoImportModal.close`)})]})]})})}export{x as AutoImportModal};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{t as r}from"./useTranslation-0ThAx3Gl.js";import{g as i,u as a}from"./formatters-C7EouP6y.js";import{t as o}from"./icons-vendor-CIvT_-Pb.js";import{r as s}from"./constants-BDzjWFuU.js";import{c}from"./model-utils-BIvGAFGz.js";import{a as l,i as u,n as d,t as f}from"./card-B4CVYJDH.js";import{t as p}from"./formatted-value-CpLoDrYF.js";import{t as m}from"./help-content-B2N8SHIE.js";import{t as h}from"./InfoHeading-BxLyydv8.js";import{t as g}from"./AnimatedBarFill-DFAXO-3i.js";var _=e(t()),v=n();function y({data:e,viewMode:t=`daily`}){let{t:n}=r(),{actualCost:y,hypotheticalCost:b,savings:x,savingsPercent:S,dailyAvg:C,heuristicModels:w}=(0,_.useMemo)(()=>{let t=0,n=0,r=new Set;for(let i of e){t+=i.totalCost;for(let e of i.modelBreakdowns){let t=c(e.modelName),i=s[t];if(!i){r.add(t),n+=e.cost+e.cacheReadTokens/1e6*10;continue}let a=e.cacheReadTokens/1e6*i.input,o=e.cacheReadTokens/1e6*i.cacheRead;n+=e.cost-o+a}}let i=n-t,a=n>0?i/n*100:0,o=e.reduce((e,t)=>e+(t._aggregatedDays??1),0),l=o>0?t/o:0;return{actualCost:t,hypotheticalCost:n,savings:i,savingsPercent:a,dailyAvg:l,heuristicModels:Array.from(r).sort()}},[e]);if(e.length===0)return(0,v.jsxs)(f,{children:[(0,v.jsx)(u,{className:`pb-2`,children:(0,v.jsxs)(l,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,v.jsx)(o,{className:`h-4 w-4 text-muted-foreground/30`}),n(`cacheRoi.title`)]})}),(0,v.jsx)(d,{children:(0,v.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:n(`cacheRoi.noData`)})})]});let T=Math.sign(x),E=T>0,D=Math.max(0,Math.min(100,b>0?y/b*100:100)),O=Math.max(0,100-D),k=T<0?`text-rose-700 dark:text-rose-300`:`text-emerald-700 dark:text-emerald-300`,A=`bg-rose-500/60 dark:bg-rose-400/60`,j=`bg-emerald-500/65 dark:bg-emerald-400/60`;return(0,v.jsxs)(f,{children:[(0,v.jsx)(u,{className:`pb-2`,children:(0,v.jsx)(h,{info:m.cacheROI,children:(0,v.jsxs)(l,{className:`flex items-center gap-2 text-sm font-medium text-muted-foreground`,children:[(0,v.jsx)(o,{className:`h-4 w-4 text-yellow-500`}),n(`cacheRoi.title`)]})})}),(0,v.jsxs)(d,{className:`space-y-4`,children:[w.length>0&&(0,v.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/12 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:n(`cacheRoi.heuristicFallback`,{count:w.length,modelsLabel:w.length===1?n(`cacheRoi.model`):n(`cacheRoi.models`)})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 sm:grid-cols-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withoutCache`)}),(0,v.jsx)(`div`,{className:`text-lg font-bold text-rose-700 dark:text-rose-300`,children:(0,v.jsx)(p,{value:b,type:`currency`})})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.withCacheActual`)}),(0,v.jsx)(`div`,{className:`text-lg font-bold ${k}`,children:(0,v.jsx)(p,{value:y,type:`currency`})})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.savings`)}),(0,v.jsxs)(`div`,{className:`text-lg font-bold ${k}`,children:[(0,v.jsx)(p,{value:x,type:`currency`}),(0,v.jsxs)(`span`,{className:`ml-1 text-xs ${k}`,children:[`(`,a(S),`)`]})]})]}),(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:n(`cacheRoi.avgCostPerUnit`,{unit:i(t)})}),(0,v.jsx)(`div`,{className:`text-lg font-bold text-foreground`,children:(0,v.jsx)(p,{value:C,type:`currency`})})]})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,v.jsx)(`span`,{className:`w-24 text-muted-foreground`,children:n(`cacheRoi.withoutCache`)}),(0,v.jsx)(`div`,{className:`h-6 flex-1 overflow-hidden rounded-md bg-rose-500/12 dark:bg-rose-500/18`,children:(0,v.jsx)(g,{className:`h-full rounded-md ${A}`,width:`100%`,order:0})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,v.jsx)(`span`,{className:`w-24 text-muted-foreground`,children:n(`cacheRoi.withCache`)}),(0,v.jsxs)(`div`,{className:`relative h-6 flex-1 overflow-hidden rounded-md bg-muted/20`,children:[(0,v.jsx)(g,{className:`absolute inset-y-0 left-0 rounded-l-md ${E?j:A}`,width:`${D}%`,order:0}),E&&O>0?(0,v.jsx)(g,{className:`absolute inset-y-0 rounded-r-md bg-emerald-500/12 dark:bg-emerald-400/16 border-l border-emerald-500/35 dark:border-emerald-400/30 border-dashed`,style:{left:`${D}%`},width:`${O}%`,order:1}):(0,v.jsx)(`div`,{className:`absolute inset-y-0 right-0 left-0 bg-muted/10`})]})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`h-2 w-2 rounded-sm ${j}`}),` `,n(`cacheRoi.paid`)]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`h-2 w-2 rounded-sm bg-emerald-500/12 dark:bg-emerald-400/16 border border-emerald-500/35 dark:border-emerald-400/30 border-dashed`}),` `,n(`cacheRoi.saved`)]})]})]})]})]})}export{y as CacheROI};
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n,n as r,t as i}from"./motion-vendor-BNVN-Ktr.js";import{a,o,t as s}from"./useTranslation-0ThAx3Gl.js";import{n as c}from"./formatters-C7EouP6y.js";import{b as l}from"./icons-vendor-CIvT_-Pb.js";import{a as u,i as d,l as f,n as p,r as m,s as h,t as g,u as _}from"./card-B4CVYJDH.js";import{a as v,n as y,r as b,t as x}from"./dialog-Djogwk0C.js";import{t as S}from"./InfoButton-BGjUQfHz.js";import{t as C}from"./chart-theme-BdE8bEiN.js";var w=e(t());function T(e){let t=``;if(e==null)return`""`;if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)t=String(e);else try{t=JSON.stringify(e)??``}catch{t=``}return`"${t.replace(/"/g,`""`)}"`}function E(e){return e.map(e=>T(e)).join(`,`)}var D=n();function O(e){if(e.length===0)return``;let t=e[0];if(!t)return``;let n=Object.keys(t);return[E(n),...e.map(e=>E(n.map(t=>e[t])))].join(`
2
+ `)}var k=(0,w.createContext)({active:!1,delayMs:0,runKey:0});function A(){return(0,w.useContext)(k).active}function j(){return(0,w.useContext)(k)}function M(){return(0,w.useContext)(k).runKey}function N({children:e}){let t=a(),n=j();return(0,D.jsx)(D.Fragment,{children:e(t?!1:n.active)})}function P({children:e,variant:t=`line`}){let n=a(),i=A(),o=M(),s={width:`100%`,height:`100%`,overflow:t===`radial`?`visible`:`hidden`,transformOrigin:t===`bar`?`center bottom`:`center center`,paddingTop:t===`radial`?8:0,paddingBottom:t===`radial`?8:0,boxSizing:`border-box`};return n?(0,D.jsx)(`div`,{style:s,children:e}):(0,D.jsx)(r.div,{style:s,initial:!1,animate:i?{opacity:1,y:0}:{opacity:0,y:8},transition:{duration:C.revealDuration/1e3,delay:0,ease:h.sectionRevealEase},children:(0,D.jsx)(`div`,{children:e},n?`reduced-motion`:`chart-run-${o}`)})}function F({title:e,subtitle:t,summary:n,info:r,expandable:a=!0,children:C,className:T,chartData:E,valueKey:A,valueFormatter:j,expandedExtra:M}){let{t:N}=s(),P=_(),[F,I]=(0,w.useState)(!1),L=(0,w.useRef)(null),R=i(L,{once:!0,amount:.25}),z=f(L,{kind:`chart`,amount:.3}),B=(0,w.useMemo)(()=>F?{active:!0,delayMs:0,runKey:1}:P?{active:z.active,delayMs:z.delayMs,runKey:z.runKey}:{active:R,delayMs:h.chartStartDelayMs,runKey:+!!R},[z.active,z.delayMs,z.runKey,F,R,P]),V=(0,w.useMemo)(()=>{if(!E||!A)return null;let e=E.map(e=>e[A]).filter(e=>typeof e==`number`&&!isNaN(e));if(e.length===0)return null;let t=e.reduce((e,t)=>e+t,0);return{min:Math.min(...e),max:Math.max(...e),avg:t/e.length,total:t,count:e.length}},[E,A]),H=j??c,U=e=>typeof C==`function`?C(e):C,W=P?.sectionVisible??!0,G=(0,w.useCallback)(()=>{if(!E||E.length===0)return;let t=O(E);if(!t)return;let n=new Blob([t],{type:`text/csv`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e}.csv`,i.click(),URL.revokeObjectURL(r)},[E,e]),K=(0,D.jsxs)(d,{className:`pb-2`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,D.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,D.jsx)(u,{className:`text-sm font-medium text-muted-foreground`,children:e}),r&&(0,D.jsx)(S,{text:r})]}),(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:n&&(0,D.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:n})})]}),t&&(0,D.jsx)(m,{className:`mt-0.5`,children:t})]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(k.Provider,{value:B,children:(0,D.jsxs)(g,{ref:L,className:o(`group relative`,T),children:[K,(0,D.jsx)(p,{children:U(!1)}),a&&(0,D.jsx)(`button`,{type:`button`,onClick:()=>I(!0),tabIndex:W?void 0:-1,className:`absolute top-3 right-3 z-10 rounded-lg border border-border/50 bg-background/80 p-1.5 text-muted-foreground opacity-100 backdrop-blur-sm transition-opacity duration-200 hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none motion-reduce:transition-none md:opacity-0 md:group-focus-within:opacity-100 md:group-hover:opacity-100`,title:N(`common.expand`),"aria-label":N(`common.expandWithTitle`,{title:e}),children:(0,D.jsx)(l,{className:`h-3.5 w-3.5`})})]})}),a&&(0,D.jsx)(x,{open:F,onOpenChange:I,children:(0,D.jsxs)(y,{className:`h-[92vh] max-h-[92vh] w-[96vw] max-w-[96vw] overflow-auto p-0 sm:h-[90vh] sm:max-h-[90vh] sm:w-[95vw] sm:max-w-[95vw]`,children:[(0,D.jsx)(v,{className:`sr-only`,children:e}),(0,D.jsx)(b,{className:`sr-only`,children:N(`chartCard.expandedDescription`)}),(0,D.jsx)(k.Provider,{value:{active:F,delayMs:0,runKey:1},children:(0,D.jsxs)(`div`,{className:`relative flex h-full flex-col`,children:[(0,D.jsxs)(`div`,{className:`p-4 pb-2 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`h2`,{className:`text-lg font-semibold`,children:e}),t&&(0,D.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]}),E&&E.length>0&&(0,D.jsx)(`button`,{type:`button`,onClick:G,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-muted-foreground transition-all duration-200 hover:bg-accent hover:text-foreground`,children:N(`chartCard.exportCsv`)})]}),V&&(0,D.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3 sm:grid-cols-5`,children:[(0,D.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:N(`dashboard.stats.min`)}),(0,D.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:H(V.min)})]}),(0,D.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:N(`dashboard.stats.max`)}),(0,D.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:H(V.max)})]}),(0,D.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:N(`dashboard.stats.avg`)}),(0,D.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:H(V.avg)})]}),(0,D.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:N(`dashboard.stats.total`)}),(0,D.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:H(V.total)})]}),(0,D.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,D.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:N(`dashboard.stats.dataPoints`)}),(0,D.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:V.count})]})]})]}),(0,D.jsxs)(`div`,{className:`flex-1 overflow-auto p-4 pt-2 sm:p-6`,children:[U(!0),M]})]})})]})})]})}export{E as a,M as i,F as n,P as r,N as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-BNVN-Ktr.js";import{o as t}from"./useTranslation-0ThAx3Gl.js";var n=e();function r({payload:e,className:r,renderLabel:i}){return e?.length?(0,n.jsx)(`div`,{className:t(`mt-3 pb-1`,r),children:(0,n.jsx)(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2 pr-2`,children:e.map((e,t)=>{let r=typeof e.color==`string`?e.color:`currentColor`,a=String(e.value??``),o=i?i(e):a,s=e.id??e.dataKey??`${a}-${r}-${t}`;return(0,n.jsxs)(`div`,{className:`inline-flex min-w-0 items-center gap-2 text-xs`,children:[(0,n.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:r}}),(0,n.jsx)(`span`,{className:`min-w-0 break-words text-muted-foreground`,children:o})]},String(s))})})}):null}export{r as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,l as r,m as i,r as a,s as o,u as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-BNVN-Ktr.js";import{t as d}from"./useTranslation-0ThAx3Gl.js";import{d as f,i as p,l as m,n as h,u as g}from"./formatters-C7EouP6y.js";import{a as _,i as v,l as y,n as b,t as x}from"./card-B4CVYJDH.js";import{t as S}from"./help-content-B2N8SHIE.js";import{t as C}from"./InfoHeading-BxLyydv8.js";import{c as w,n as T,r as E}from"./chart-theme-BdE8bEiN.js";var D=e(l()),O=u();function k(e,t,n){return e(n===`requestCost`?t>=.6?`charts.correlation.strongRequestCost`:t>=.3?`charts.correlation.mediumRequestCost`:`charts.correlation.weakRequestCost`:t<=-.3?`charts.correlation.negativeCache`:t<.2?`charts.correlation.neutralCache`:`charts.correlation.positiveCache`)}function A(e,t){if(e.length!==t.length||e.length<2)return 0;let n=e.reduce((e,t)=>e+t,0)/e.length,r=t.reduce((e,t)=>e+t,0)/t.length,i=e.reduce((e,i,a)=>{let o=t[a];return o===void 0?e:e+(i-n)*(o-r)},0),a=e.reduce((e,t)=>e+(t-n)**2,0),o=t.reduce((e,t)=>e+(t-r)**2,0);return a===0||o===0?0:i/Math.sqrt(a*o)}function j({active:e,payload:t,mode:n}){let{t:r}=d();if(!e||!t?.length)return null;let i=t[0]?.payload;return i?(0,O.jsxs)(`div`,{className:`max-w-[260px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,O.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:p(i.label)}),(0,O.jsx)(`div`,{className:`space-y-1`,children:n===`requestCost`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:m(i.requests)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cost`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:h(i.y)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.tokensLabel`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:i.tokens===void 0?`–`:f(i.tokens)})]})]}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.cacheRate`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:i.cacheRate===void 0?`–`:g(i.cacheRate,1)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.costPerRequest`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:h(i.y)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-muted-foreground`,children:r(`charts.correlation.requestsLabel`)}),(0,O.jsx)(`span`,{className:`font-mono font-medium`,children:i.requests===void 0?`–`:m(i.requests)})]})]})})]}):null}function M({title:e,subtitle:l,mode:u,data:d,color:f,animationBegin:p=0,xAxisName:m,xTickFormatter:g,yAxisName:_,footer:v,showPoints:y,animatePoints:b}){let x=y?d:[];return(0,O.jsx)(`div`,{children:(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,O.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e}),(0,O.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:l})]}),(0,O.jsx)(t,{width:`100%`,height:260,children:(0,O.jsxs)(a,{margin:E,children:[(0,O.jsx)(i,{strokeDasharray:`3 3`,stroke:T.grid,opacity:.25}),(0,O.jsx)(r,{type:`number`,dataKey:`x`,stroke:T.axis,fontSize:10,tickLine:!1,name:m,...g?{tickFormatter:g}:{}}),(0,O.jsx)(n,{type:`number`,dataKey:`y`,stroke:T.axis,fontSize:10,tickLine:!1,axisLine:!1,name:_,tickFormatter:h}),(0,O.jsx)(o,{type:`number`,dataKey:`z`,range:[30,180]}),(0,O.jsx)(c,{content:(0,O.jsx)(j,{mode:u}),cursor:{strokeDasharray:`4 4`}}),(0,O.jsx)(s,{data:x,fill:f,stroke:f,fillOpacity:.72,...w(b,p)})]})}),(0,O.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:v})]})})}function N({data:e}){let{t}=d(),n=(0,D.useRef)(null),r=y(n,{kind:`chart`,amount:.28}),i=r.shouldReduceMotion||r.active,a=!r.shouldReduceMotion&&r.active,o=(0,D.useMemo)(()=>e.map(e=>({x:e.requestCount,y:e.totalCost,z:Math.max(5,Math.sqrt(e.totalTokens/1e3)),label:e.date,tokens:e.totalTokens,requests:e.requestCount})),[e]),s=(0,D.useMemo)(()=>e.filter(e=>e.requestCount>0&&e.totalTokens>0).map(e=>{let t=e.cacheReadTokens/e.totalTokens*100;return{x:t,y:e.totalCost/e.requestCount,z:Math.max(5,Math.sqrt(e.requestCount)),label:e.date,cacheRate:t,requests:e.requestCount}}),[e]),c=A(o.map(e=>e.x),o.map(e=>e.y)),l=A(s.map(e=>e.x),s.map(e=>e.y));return e.length<2?(0,O.jsxs)(x,{ref:n,children:[(0,O.jsx)(v,{children:(0,O.jsx)(C,{info:S.correlationAnalysis,children:(0,O.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,O.jsx)(b,{children:(0,O.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground`,children:t(`charts.correlation.requiresData`)})})]}):(0,O.jsxs)(x,{ref:n,children:[(0,O.jsx)(v,{children:(0,O.jsx)(C,{info:S.correlationAnalysis,children:(0,O.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:t(`charts.correlation.title`)})})}),(0,O.jsxs)(b,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,O.jsx)(M,{title:t(`charts.correlation.requestsVsCost`),subtitle:`r ${c.toFixed(2)} · ${t(`charts.correlation.points`,{count:o.length})}`,mode:`requestCost`,data:o,color:T.cost,showPoints:i,animatePoints:a,xAxisName:t(`charts.correlation.requestsAxis`),yAxisName:t(`charts.correlation.cost`),footer:k(t,c,`requestCost`)},`request-cost-${r.runKey}`),(0,O.jsx)(M,{title:t(`charts.correlation.cacheVsCostPerRequest`),subtitle:`r ${l.toFixed(2)} · ${t(`charts.correlation.points`,{count:s.length})}`,mode:`cacheEfficiency`,data:s,color:T.cumulative,showPoints:i,animatePoints:a,animationBegin:70,xAxisName:t(`charts.correlation.cacheRate`),xTickFormatter:e=>g(e,0),yAxisName:t(`charts.correlation.costPerRequestAxis`),footer:k(t,l,`cacheEfficiency`)},`cache-cost-${r.runKey}`)]})]})}export{N as CorrelationAnalysis};
@@ -0,0 +1 @@
1
+ import{b as e,c as t,l as n,m as r,o as i,p as a,v as o,y as s}from"./charts-vendor-CiBqdKXh.js";import{a as c}from"./motion-vendor-BNVN-Ktr.js";import{t as l}from"./useTranslation-0ThAx3Gl.js";import{a as u,n as d,t as f}from"./formatters-C7EouP6y.js";import{t as p}from"./model-utils-BIvGAFGz.js";import{t as m}from"./help-content-B2N8SHIE.js";import{n as h,o as g,r as _}from"./chart-theme-BdE8bEiN.js";import{n as v,r as y,t as b}from"./ChartCard-DxxB4rGm.js";import{t as x}from"./ChartLegend-Vpk95i3r.js";import{t as S}from"./CustomTooltip-CfoUDPbT.js";var C=c();function w({data:c,models:w}){let{t:T}=l(),E=w.map(e=>({model:e,total:c.reduce((t,n)=>t+(f(n[e])??0),0)})).sort((e,t)=>t.total-e.total)[0]??null,D=(0,C.jsx)(b,{children:l=>(0,C.jsxs)(`div`,{className:`mt-6`,children:[(0,C.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:T(`charts.costByModelOverTime.movingAverageHeading`)}),(0,C.jsx)(y,{variant:`line`,children:(0,C.jsx)(e,{width:`100%`,height:350,children:(0,C.jsxs)(i,{data:c,margin:_,children:[(0,C.jsx)(r,{strokeDasharray:`3 3`,stroke:h.grid,opacity:.3}),(0,C.jsx)(n,{dataKey:`date`,tickFormatter:u,stroke:h.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(t,{tickFormatter:e=>{let t=f(e);return t===null?``:d(t)},stroke:h.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(o,{content:(0,C.jsx)(S,{formatter:e=>d(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,C.jsx)(s,{content:(0,C.jsx)(x,{})}),w.map((e,t)=>(0,C.jsx)(a,{type:`monotone`,dataKey:`${e}_ma7`,stroke:p(e),name:`${e} ${T(`charts.costByModelOverTime.movingAverageSuffix`)}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,...g(l,{order:t%5,role:`secondary`})},`${e}_ma7`))]})})})]})});return(0,C.jsx)(v,{title:T(`charts.costByModelOverTime.title`),subtitle:E?T(`charts.costByModelOverTime.topDriver`,{model:E.model,total:d(E.total)}):T(`charts.costByModelOverTime.subtitle`),info:m.costByModelOverTime,className:`lg:col-span-2`,chartData:c,valueKey:`cost`,valueFormatter:d,expandedExtra:D,children:(0,C.jsx)(b,{children:l=>(0,C.jsx)(y,{variant:`line`,children:(0,C.jsx)(e,{width:`100%`,height:300,children:(0,C.jsxs)(i,{data:c,margin:_,children:[(0,C.jsx)(r,{strokeDasharray:`3 3`,stroke:h.grid,opacity:.3}),(0,C.jsx)(n,{dataKey:`date`,tickFormatter:u,stroke:h.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(t,{tickFormatter:e=>{let t=f(e);return t===null?``:d(t)},stroke:h.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(o,{content:(0,C.jsx)(S,{formatter:e=>d(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,C.jsx)(s,{content:(0,C.jsx)(x,{})}),w.map((e,t)=>(0,C.jsx)(a,{type:`monotone`,dataKey:e,stroke:p(e),name:e,dot:!1,strokeWidth:1.5,...g(l,{order:t%5})},e))]})})})})})}export{w as CostByModelOverTime};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,l as o,m as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-vKc6gXHZ.js";import{t as d}from"./useTranslation-BSl7t2D6.js";import{n as f,t as p}from"./formatters-yKppUXb3.js";import{t as m}from"./help-content-Bt5KCpWS.js";import{n as h,r as g,t as _}from"./ChartCard-CBUnItl-.js";import{t as v}from"./CustomTooltip-CBVU1pyK.js";import{n as y,r as b,t as x}from"./chart-theme-D5iCFDJg.js";var S=e(l()),C=u();function w({data:e}){let{t:l}=d(),[u,w]=(0,S.useState)(null),T=(0,S.useId)(),E=e=>`${T}-${e}`.replace(/:/g,``),D=Math.max(...e.map(e=>e.cost)),O=Math.min(...e.map(e=>e.cost)),k=e.findIndex(e=>e.cost===D),A=e.findIndex(e=>e.cost===O),j=e.filter(e=>e.day===`Sa`||e.day===`So`).reduce((e,t)=>e+t.cost,0),M=e.reduce((e,t)=>e+t.cost,0);return(0,C.jsx)(h,{title:l(`charts.costByWeekday.title`),subtitle:l(`charts.costByWeekday.subtitle`,{peak:e[k]?.day??`–`,low:e[A]?.day??`–`,share:`${(M>0?j/M*100:0).toFixed(0)}%`}),info:m.costByWeekday,chartData:e,valueKey:`cost`,valueFormatter:f,children:(0,C.jsx)(_,{children:d=>(0,C.jsx)(g,{variant:`bar`,children:(0,C.jsx)(r,{width:`100%`,height:300,children:(0,C.jsxs)(n,{data:e,margin:b,onMouseMove:e=>{e?.activeTooltipIndex!==void 0&&typeof e.activeTooltipIndex==`number`&&w(e.activeTooltipIndex)},onMouseLeave:()=>w(null),children:[(0,C.jsxs)(`defs`,{children:[(0,C.jsxs)(`linearGradient`,{id:E(`weekday`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:y.cost,stopOpacity:.9}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:y.cost,stopOpacity:.4})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayActive`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:y.cost,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:y.cost,stopOpacity:.6})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayPeak`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:.5})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayLow`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.8}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.3})]})]}),(0,C.jsx)(s,{strokeDasharray:`3 3`,stroke:y.grid,opacity:.3}),(0,C.jsx)(o,{dataKey:`day`,stroke:y.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(i,{tickFormatter:e=>{let t=p(e);return t===null?``:f(t)},stroke:y.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(c,{content:(0,C.jsx)(v,{formatter:e=>f(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,C.jsx)(a,{dataKey:`cost`,radius:[4,4,0,0],name:l(`charts.costByWeekday.averageCost`),isAnimationActive:d,animationBegin:x.stagger,animationDuration:x.duration,animationEasing:x.easing,children:e.map((e,n)=>{let r=`url(#${E(`weekday`)})`;return u===n?r=`url(#${E(`weekdayActive`)})`:n===k?r=`url(#${E(`weekdayPeak`)})`:n===A&&(r=`url(#${E(`weekdayLow`)})`),(0,C.jsx)(t,{fill:r},n)})})]})})})})})}export{w as CostByWeekday};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,l as o,m as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-BNVN-Ktr.js";import{t as d}from"./useTranslation-0ThAx3Gl.js";import{n as f,t as p}from"./formatters-C7EouP6y.js";import{t as m}from"./help-content-B2N8SHIE.js";import{a as h,n as g,r as _}from"./chart-theme-BdE8bEiN.js";import{n as v,r as y,t as b}from"./ChartCard-DxxB4rGm.js";import{t as x}from"./CustomTooltip-CfoUDPbT.js";var S=e(l()),C=u();function w({data:e}){let{t:l}=d(),[u,w]=(0,S.useState)(null),T=(0,S.useId)(),E=e=>`${T}-${e}`.replace(/:/g,``),D=Math.max(...e.map(e=>e.cost)),O=Math.min(...e.map(e=>e.cost)),k=e.findIndex(e=>e.cost===D),A=e.findIndex(e=>e.cost===O),j=e.filter(e=>e.day===`Sa`||e.day===`So`).reduce((e,t)=>e+t.cost,0),M=e.reduce((e,t)=>e+t.cost,0);return(0,C.jsx)(v,{title:l(`charts.costByWeekday.title`),subtitle:l(`charts.costByWeekday.subtitle`,{peak:e[k]?.day??`–`,low:e[A]?.day??`–`,share:`${(M>0?j/M*100:0).toFixed(0)}%`}),info:m.costByWeekday,chartData:e,valueKey:`cost`,valueFormatter:f,children:(0,C.jsx)(b,{children:d=>(0,C.jsx)(y,{variant:`bar`,children:(0,C.jsx)(r,{width:`100%`,height:300,children:(0,C.jsxs)(n,{data:e,margin:_,onMouseMove:e=>{e?.activeTooltipIndex!==void 0&&typeof e.activeTooltipIndex==`number`&&w(e.activeTooltipIndex)},onMouseLeave:()=>w(null),children:[(0,C.jsxs)(`defs`,{children:[(0,C.jsxs)(`linearGradient`,{id:E(`weekday`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:g.cost,stopOpacity:.9}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:g.cost,stopOpacity:.4})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayActive`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:g.cost,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:g.cost,stopOpacity:.6})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayPeak`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:1}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(35, 80%, 52%)`,stopOpacity:.5})]}),(0,C.jsxs)(`linearGradient`,{id:E(`weekdayLow`),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,C.jsx)(`stop`,{offset:`0%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.8}),(0,C.jsx)(`stop`,{offset:`100%`,stopColor:`hsl(160, 50%, 52%)`,stopOpacity:.3})]})]}),(0,C.jsx)(s,{strokeDasharray:`3 3`,stroke:g.grid,opacity:.3}),(0,C.jsx)(o,{dataKey:`day`,stroke:g.axis,fontSize:11,tickLine:!1}),(0,C.jsx)(i,{tickFormatter:e=>{let t=p(e);return t===null?``:f(t)},stroke:g.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,C.jsx)(c,{content:(0,C.jsx)(x,{formatter:e=>f(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,C.jsx)(a,{dataKey:`cost`,radius:[4,4,0,0],name:l(`charts.costByWeekday.averageCost`),...h(d),children:e.map((e,n)=>{let r=`url(#${E(`weekday`)})`;return u===n?r=`url(#${E(`weekdayActive`)})`:n===k?r=`url(#${E(`weekdayPeak`)})`:n===A&&(r=`url(#${E(`weekdayLow`)})`),(0,C.jsx)(t,{fill:r},n)})})]})})})})})}export{w as CostByWeekday};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,p as o,t as s,v as c,w as l,y as u}from"./charts-vendor-CiBqdKXh.js";import{a as d}from"./motion-vendor-BNVN-Ktr.js";import{t as f}from"./useTranslation-0ThAx3Gl.js";import{a as p,n as m,t as h}from"./formatters-C7EouP6y.js";import{a as g}from"./icons-vendor-CIvT_-Pb.js";import{t as _}from"./MetricCard-r_uhdKDU.js";import{t as v}from"./formatted-value-CpLoDrYF.js";import{t as y}from"./help-content-B2N8SHIE.js";import{i as b,n as x,o as S,r as C}from"./chart-theme-BdE8bEiN.js";import{n as w,r as T,t as E}from"./ChartCard-DxxB4rGm.js";import{t as D}from"./ChartLegend-Vpk95i3r.js";import{t as O}from"./CustomTooltip-CfoUDPbT.js";import{r as k}from"./calculations-BJw_4KdI.js";var A=e(l()),j=d();function M({data:e,viewMode:l=`daily`}){let{t:d}=f(),{chartData:M,forecastTotal:N,currentMonthTotal:P,dailyAvgTrend:F,projectedDailyBurn:I,remainingDays:L,confidence:R,confidenceColor:z}=(0,A.useMemo)(()=>{let t=k(e);if(!t)return{chartData:[],forecastTotal:0,currentMonthTotal:0,dailyAvgTrend:null,projectedDailyBurn:0,remainingDays:0,confidence:`low`,confidenceColor:`text-red-400 bg-red-400/10`};let{currentMonth:n,currentMonthTotal:r,remainingDays:i,projectedDailyBurn:a,volatility:o,lowerDaily:s,upperDaily:c,forecastTotal:l,dailyAvgTrend:u,confidence:d,elapsedCalendarSeries:f,daysInMonth:p}=t,m=d===`high`?`text-green-400 bg-green-400/10`:d===`medium`?`text-yellow-400 bg-yellow-400/10`:`text-red-400 bg-red-400/10`,h=[];for(let e of f)h.push({date:e.date,cost:e.cost});let g=f[f.length-1]?.cost??0;if(h.length>0){let e=h[h.length-1];e&&(e.forecast=g,e.lower=Math.max(0,g-o),e.upper=g+o,e.band=(e.upper??0)-(e.lower??0))}for(let e=f.length+1;e<=p;e++){let t=`${n}-${String(e).padStart(2,`0`)}`;h.push({date:t,forecast:a,lower:s,upper:c,band:c-s})}return{chartData:h,forecastTotal:l,currentMonthTotal:r,dailyAvgTrend:u,projectedDailyBurn:a,remainingDays:i,confidence:d,confidenceColor:m}},[e]);if(l!==`daily`){let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)).reduce((e,t)=>e+t.totalCost,0),n=e.length>0?t/e.length:0;return e.length===0?(0,j.jsx)(`div`,{className:`space-y-4`,children:(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border/50 bg-card/80 p-6 text-center`,children:[(0,j.jsx)(g,{className:`mb-3 h-8 w-8 text-muted-foreground/20`}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:d(`forecast.noData`)})]})}):(0,j.jsx)(`div`,{className:`space-y-4`,children:(0,j.jsx)(_,{label:d(l===`monthly`?`forecast.avgMonthlyCost`:`forecast.avgYearlyCost`),value:(0,j.jsx)(v,{value:n,type:`currency`}),subtitle:d(`forecast.totalOverPeriods`,{total:m(t),count:e.length,unit:d(l===`monthly`?`periods.months`:`periods.years`)}),icon:(0,j.jsx)(g,{className:`h-4 w-4`})})})}return M.length===0?(0,j.jsx)(`div`,{className:`space-y-4`,children:(0,j.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-border/50 bg-card/80 p-6 text-center`,children:[(0,j.jsx)(g,{className:`mb-3 h-8 w-8 text-muted-foreground/20`}),(0,j.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:d(`forecast.noForecast`)}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:d(`forecast.requiresTwoDays`)})]})}):(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(_,{label:(0,j.jsxs)(`span`,{className:`flex items-center gap-2`,children:[d(`forecast.monthEndForecast`),` `,(0,j.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] font-semibold tracking-wider uppercase ${z}`,children:d(`forecast.${R}`)})]}),value:(0,j.jsx)(v,{value:N,type:`currency`}),subtitle:`${d(`forecast.soFar`,{value:m(P)})} · ${d(`forecast.remainingDays`,{count:L})}${F?` · ${d(`forecast.projectedPerDay`,{value:m(I)})}`:``}`,icon:(0,j.jsx)(g,{className:`h-4 w-4`}),trend:F&&F.change!==0?{value:F.change,label:d(`forecast.vsLastWeek`)}:null}),(0,j.jsx)(w,{title:d(`forecast.chartTitle`),subtitle:d(`forecast.chartSubtitle`),summary:(0,j.jsx)(v,{value:N,type:`currency`}),info:y.forecast,chartData:M,valueKey:`cost`,valueFormatter:m,children:(0,j.jsx)(E,{children:e=>(0,j.jsx)(T,{variant:`line`,children:(0,j.jsx)(t,{width:`100%`,height:250,children:(0,j.jsxs)(s,{data:M,margin:C,children:[(0,j.jsx)(`defs`,{children:(0,j.jsxs)(`linearGradient`,{id:`forecast-cost-grad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,j.jsx)(`stop`,{offset:`0%`,stopColor:x.cost,stopOpacity:.3}),(0,j.jsx)(`stop`,{offset:`100%`,stopColor:x.cost,stopOpacity:0})]})}),(0,j.jsx)(a,{strokeDasharray:`3 3`,stroke:x.grid}),(0,j.jsx)(i,{dataKey:`date`,tickFormatter:p,stroke:x.axis,fontSize:11,tickLine:!1}),(0,j.jsx)(n,{tickFormatter:e=>{let t=h(e);return t===null?``:m(t)},stroke:x.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,j.jsx)(c,{content:(0,j.jsx)(O,{formatter:e=>m(e)})}),(0,j.jsx)(u,{content:(0,j.jsx)(D,{})}),(0,j.jsx)(r,{type:`monotone`,dataKey:`lower`,stackId:`forecast-band`,stroke:`none`,fill:`transparent`,name:d(`forecast.lowerBound`)}),(0,j.jsx)(r,{type:`monotone`,dataKey:`band`,stackId:`forecast-band`,stroke:`none`,fill:x.cumulative,fillOpacity:.12,name:d(`forecast.uncertaintyBand`),...b(e,{role:`stacked`})}),(0,j.jsx)(r,{type:`monotone`,dataKey:`cost`,stroke:x.cost,fill:`url(#forecast-cost-grad)`,name:d(`forecast.actualCost`),strokeWidth:2,dot:!1,connectNulls:!0,...b(e)}),(0,j.jsx)(o,{type:`monotone`,dataKey:`forecast`,stroke:x.cumulative,name:d(`forecast.projection`),dot:!1,strokeWidth:2,strokeDasharray:`6 3`,connectNulls:!0,...S(e,{role:`secondary`})})]})})})})})]})}export{M as CostForecast};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,p as o,t as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-BNVN-Ktr.js";import{t as d}from"./useTranslation-0ThAx3Gl.js";import{a as f,n as p,t as m}from"./formatters-C7EouP6y.js";import{t as h}from"./help-content-B2N8SHIE.js";import{i as g,n as _,o as v,r as y}from"./chart-theme-BdE8bEiN.js";import{n as b,r as x,t as S}from"./ChartCard-DxxB4rGm.js";import{t as C}from"./CustomTooltip-CfoUDPbT.js";import{r as w}from"./calculations-BJw_4KdI.js";var T=e(l()),E=u();function D({data:e,rawData:l}){let{t:u}=d(),D=(0,T.useId)().replace(/:/g,``),O=(0,T.useMemo)(()=>{if(e.length<3)return e;let t=e[e.length-1];if(!t?.date||!t.cumulative)return e;let n=w(l);if(!n)return e;let{currentMonth:r,daysInMonth:i,projectedDailyBurn:a}=n,o=n.elapsedDays;if(o>=i)return e;let s=t.cumulative+a*(i-o),c=`${r}-${String(i).padStart(2,`0`)}`;return[...e.map(e=>({...e,projected:void 0})),{...e[e.length-1],projected:t.cumulative},{date:c,cumulative:void 0,projected:s,cost:0,ma7:0}]},[e,l]),k=e[e.length-1]?.cumulative??0;return(0,E.jsx)(b,{title:u(`charts.cumulativeCost.title`),subtitle:u(`charts.cumulativeCost.total`,{value:p(k)}),info:h.cumulativeCost,chartData:e,valueKey:`cumulative`,valueFormatter:p,children:(0,E.jsx)(S,{children:e=>(0,E.jsx)(x,{variant:`line`,children:(0,E.jsx)(t,{width:`100%`,height:300,children:(0,E.jsxs)(s,{data:O,margin:y,children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`${D}-cumulGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:_.cumulative,stopOpacity:.4}),(0,E.jsx)(`stop`,{offset:`60%`,stopColor:_.cumulative,stopOpacity:.1}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:_.cumulative,stopOpacity:0})]})}),(0,E.jsx)(a,{strokeDasharray:`3 3`,stroke:_.grid,opacity:.3}),(0,E.jsx)(i,{dataKey:`date`,tickFormatter:f,stroke:_.axis,fontSize:11,tickLine:!1}),(0,E.jsx)(n,{tickFormatter:e=>{let t=m(e);return t===null?``:p(t)},stroke:_.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,E.jsx)(c,{content:(0,E.jsx)(C,{formatter:e=>p(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,E.jsx)(r,{type:`monotone`,dataKey:`cumulative`,stroke:_.cumulative,fill:`url(#${D}-cumulGrad)`,name:u(`charts.cumulativeCost.cumulative`),strokeWidth:2,activeDot:{r:5,strokeWidth:2,stroke:_.cumulative,fill:`hsl(var(--background))`},dot:!1,...g(e),connectNulls:!1}),(0,E.jsx)(o,{type:`monotone`,dataKey:`projected`,stroke:_.cumulative,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,name:u(`charts.cumulativeCost.projection`),connectNulls:!0,...v(e,{role:`secondary`})})]})})})})})}export{D as CumulativeCost};
@@ -1 +1 @@
1
- import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{t}from"./useTranslation-BSl7t2D6.js";var n=e();function r({active:e,payload:r,label:i,formatter:a,pinnedEntryNames:o=[],showComputedTotal:s=!0,hideZeroValues:c=!1}){let{t:l}=t();if(!e||!r?.length)return null;let u=e=>e.name.includes(`Ø`)||e.dataKey?.toString().includes(`MA7`)||e.dataKey?.toString().includes(`_ma7`),d=e=>o.includes(e.name),f=e=>!c||Math.abs(e.value??0)>1e-4,p=r.filter(e=>!u(e)&&!d(e)&&f(e)).sort((e,t)=>(t.value??0)-(e.value??0)),m=r.filter(e=>!u(e)&&d(e)&&f(e)),h=r.filter(e=>u(e)),g=p.reduce((e,t)=>e+(t.value??0),0),_=s&&p.length>=2,v=r[0]?.payload??{},y=p.length===1?p[0]:m.length===1?m[0]:null,b=y?v[`${y.dataKey}Prev`]:void 0,x=typeof b==`number`?b:null,S=y?h.find(e=>e.dataKey===`${y.dataKey}MA7`||e.dataKey===`${y.dataKey.toString().toLowerCase()}MA7`)??(h.length===1?h[0]:null):null,C=y&&x!==null?y.value-x:null,w=y&&S?y.value-S.value:null,T=l(`customTooltip.total`),E=l(`customTooltip.delta`);return(0,n.jsxs)(`div`,{className:`max-w-[280px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,n.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:i}),(0,n.jsxs)(`div`,{className:`space-y-1.5`,children:[p.map((e,t)=>{let r=_&&g>0?e.value/g*100:null;return(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value}),r!==null&&(0,n.jsxs)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:[r.toFixed(0),`%`]})]},t)}),_&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`font-medium text-muted-foreground`,children:[T,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(g,T):g}),(0,n.jsx)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:`100%`})]})]}),h.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),h.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2 opacity-70`,children:[(0,n.jsx)(`span`,{className:`h-0.5 w-2 shrink-0 border-t border-dashed`,style:{borderColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`ma-${t}`))]}),m.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),m.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`pinned-${t}`))]}),(C!==null||w!==null)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),C!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsPrevious`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[C>=0?`+`:``,a?a(C,E):C]})]}),w!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsAverage`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[w>=0?`+`:``,a?a(w,E):w]})]})]})]})]})}export{r as t};
1
+ import{a as e}from"./motion-vendor-BNVN-Ktr.js";import{t}from"./useTranslation-0ThAx3Gl.js";var n=e();function r({active:e,payload:r,label:i,formatter:a,pinnedEntryNames:o=[],showComputedTotal:s=!0,hideZeroValues:c=!1}){let{t:l}=t();if(!e||!r?.length)return null;let u=e=>e.name.includes(`Ø`)||e.dataKey?.toString().includes(`MA7`)||e.dataKey?.toString().includes(`_ma7`),d=e=>o.includes(e.name),f=e=>!c||Math.abs(e.value??0)>1e-4,p=r.filter(e=>!u(e)&&!d(e)&&f(e)).sort((e,t)=>(t.value??0)-(e.value??0)),m=r.filter(e=>!u(e)&&d(e)&&f(e)),h=r.filter(e=>u(e)),g=p.reduce((e,t)=>e+(t.value??0),0),_=s&&p.length>=2,v=r[0]?.payload??{},y=p.length===1?p[0]:m.length===1?m[0]:null,b=y?v[`${y.dataKey}Prev`]:void 0,x=typeof b==`number`?b:null,S=y?h.find(e=>e.dataKey===`${y.dataKey}MA7`||e.dataKey===`${y.dataKey.toString().toLowerCase()}MA7`)??(h.length===1?h[0]:null):null,C=y&&x!==null?y.value-x:null,w=y&&S?y.value-S.value:null,T=l(`customTooltip.total`),E=l(`customTooltip.delta`);return(0,n.jsxs)(`div`,{className:`max-w-[280px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,n.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:i}),(0,n.jsxs)(`div`,{className:`space-y-1.5`,children:[p.map((e,t)=>{let r=_&&g>0?e.value/g*100:null;return(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value}),r!==null&&(0,n.jsxs)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:[r.toFixed(0),`%`]})]},t)}),_&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`font-medium text-muted-foreground`,children:[T,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(g,T):g}),(0,n.jsx)(`span`,{className:`w-10 text-right font-mono text-muted-foreground/60`,children:`100%`})]})]}),h.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),h.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2 opacity-70`,children:[(0,n.jsx)(`span`,{className:`h-0.5 w-2 shrink-0 border-t border-dashed`,style:{borderColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`ma-${t}`))]}),m.length>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),m.map((e,t)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,n.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:a?a(e.value,e.name):e.value})]},`pinned-${t}`))]}),(C!==null||w!==null)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(`div`,{className:`my-1 border-t border-border/40`}),C!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsPrevious`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[C>=0?`+`:``,a?a(C,E):C]})]}),w!==null&&(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(`span`,{className:`h-2 w-2 shrink-0`}),(0,n.jsxs)(`span`,{className:`text-muted-foreground`,children:[l(`customTooltip.vsAverage`),`:`]}),(0,n.jsxs)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:[w>=0?`+`:``,a?a(w,E):w]})]})]})]})]})}export{r as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,a as n,b as r,c as i,d as a,l as o,m as s,v as c,w as l}from"./charts-vendor-CiBqdKXh.js";import{a as u}from"./motion-vendor-BNVN-Ktr.js";import{t as d}from"./useTranslation-0ThAx3Gl.js";import{d as f,h as p,l as m,n as h}from"./formatters-C7EouP6y.js";import{t as g}from"./help-content-B2N8SHIE.js";import{a as _,n as v,r as y}from"./chart-theme-BdE8bEiN.js";import{i as b,n as x,r as S,t as C}from"./ChartCard-DxxB4rGm.js";var w=e(l()),T=u();function E(e,t){if(e.length===0)return[];let n=Math.min(...e),r=Math.max(...e),i=Math.min(8,Math.max(4,Math.ceil(Math.sqrt(e.length)))),a=(r-n||1)/i,o=Array.from({length:i},(e,o)=>{let s=n+a*o,c=o===i-1?r:s+a;return{label:`${t(s)}–${t(c)}`,rangeStart:s,rangeEnd:c,count:0}});for(let t of e){let e=o[Math.min(i-1,Math.floor((t-n)/a))];e&&(e.count+=1)}return o}function D({active:e,payload:t}){let{t:n}=d();if(!e||!t?.length)return null;let r=t[0];return r?(0,T.jsxs)(`div`,{className:`max-w-[280px] rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,T.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:r.payload.label}),(0,T.jsxs)(`div`,{className:`space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.interval`)}),(0,T.jsx)(`span`,{className:`font-mono font-medium`,children:r.payload.label})]}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,T.jsx)(`span`,{className:`text-muted-foreground`,children:n(`charts.distribution.dataPoints`)}),(0,T.jsx)(`span`,{className:`font-mono font-medium`,children:m(r.value)})]})]})]}):null}function O({data:e,viewMode:t=`daily`}){let{t:n}=d(),r=(0,w.useId)().replace(/:/g,``),i=(0,w.useMemo)(()=>{if(e.length<2)return[];let r=e.map(e=>e.totalCost),i=e.map(e=>e.requestCount),a=e.map(e=>e.requestCount>0?e.totalTokens/e.requestCount:0);return[{title:n(`charts.distribution.costPerPeriod`,{period:p(t)}),data:E(r,h)},{title:n(`charts.distribution.requestsPerPeriod`,{period:p(t)}),data:E(i,m)},{title:n(`charts.distribution.tokensPerRequest`),data:E(a,f)}]},[e,t,n]);return e.length<2?(0,T.jsx)(x,{title:n(`charts.distribution.title`),info:g.distributionAnalysis,expandable:!1,children:(0,T.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground`,children:n(`charts.distribution.requiresData`)})}):(0,T.jsx)(x,{title:n(`charts.distribution.title`),info:g.distributionAnalysis,expandable:!1,children:(0,T.jsx)(k,{distributions:i,uid:r})})}function k({distributions:e,uid:l}){let{t:u}=d(),f=b();return(0,T.jsx)(`div`,{className:`space-y-5`,children:e.map((e,d)=>(0,T.jsxs)(`div`,{children:[(0,T.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,T.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e.title}),(0,T.jsxs)(`div`,{className:`text-[10px] text-muted-foreground`,children:[e.data.length,` `,u(`charts.distribution.buckets`)]})]}),(0,T.jsx)(C,{children:u=>(0,T.jsx)(S,{variant:`bar`,children:(0,T.jsx)(r,{width:`100%`,height:160,children:(0,T.jsxs)(n,{data:e.data,margin:y,children:[(0,T.jsx)(`defs`,{children:(0,T.jsxs)(`linearGradient`,{id:`${l}-distribution-${d}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,T.jsx)(`stop`,{offset:`0%`,stopColor:v.cost,stopOpacity:.9}),(0,T.jsx)(`stop`,{offset:`100%`,stopColor:v.cost,stopOpacity:.4})]})}),(0,T.jsx)(s,{strokeDasharray:`3 3`,stroke:v.grid,opacity:.25}),(0,T.jsx)(o,{dataKey:`label`,stroke:v.axis,fontSize:10,tickLine:!1,interval:0,angle:e.data.length>5?-16:0,textAnchor:e.data.length>5?`end`:`middle`,height:e.data.length>5?48:30}),(0,T.jsx)(i,{stroke:v.axis,fontSize:10,tickLine:!1,axisLine:!1,allowDecimals:!1}),(0,T.jsx)(c,{content:(0,T.jsx)(D,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,T.jsx)(a,{dataKey:`count`,radius:[6,6,0,0],fill:`url(#${l}-distribution-${d})`,..._(u,d),children:e.data.map((n,r)=>(0,T.jsx)(t,{fill:`hsla(215, 70%, 55%, ${(.45+(e.data.length>1?r/(e.data.length-1):0)*.35).toFixed(2)})`},`${e.title}-${r}`))})]})},`distribution-${f}-${d}`)})})]},e.title))})}export{O as DistributionAnalysis};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,b as n,g as r,i,v as ee,w as a}from"./charts-vendor-CiBqdKXh.js";import{a as o}from"./motion-vendor-vKc6gXHZ.js";import{a as s,t as te}from"./useTranslation-BSl7t2D6.js";import{d as c,i as ne,l,n as u,u as d}from"./formatters-yKppUXb3.js";import{U as re,W as ie}from"./icons-vendor-CIvT_-Pb.js";import{t as f}from"./button-D--hHeVj.js";import{c as ae,i as p,r as oe,t as m}from"./model-utils-BIvGAFGz.js";import{a as se,i as ce,n as le,r as ue,t as de}from"./dialog-C0AeNKs8.js";import{t as h}from"./formatted-value-rO0EpKbc.js";import{t as fe}from"./CustomTooltip-CBVU1pyK.js";var g=e(a()),_=o();function pe(e){return/^\d{4}$/.test(e)?`year`:/^\d{4}-\d{2}$/.test(e)?`month`:`day`}function v(e){return e.cacheReadTokens+e.cacheCreationTokens+e.inputTokens+e.outputTokens+e.thinkingTokens}function y(e,t){return t>0?e/(t/1e6):null}function b(e,t){return t>0?e/t:null}function x(e,t){if(t===null)return null;let n=e-t;return{absolute:n,percent:t===0?null:n/t*100}}function S(e,t,n=`–`){return e?e.absolute===0?`→ ${t(0)}`:`${e.absolute>0?`↑`:`↓`} ${t(Math.abs(e.absolute))}`:n}function C(e,t=`–`){return!e||e.percent===null?t:e.percent===0?`0.0%`:`${e.percent>0?`+`:``}${e.percent.toFixed(1)}%`}function me(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return e.isContentEditable||t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function he(e,t){return`${e}${t}`}function w({day:e,contextData:a=[],open:o,hasPrevious:w,hasNext:ge,currentIndex:_e,totalCount:ve,onPrevious:T,onNext:E,onClose:ye}){let{t:D}=te(),O=e?pe(e.date):`day`,k=(0,g.useMemo)(()=>[...a].sort((e,t)=>e.date.localeCompare(t.date)),[a]),A=(0,g.useMemo)(()=>e?k.findIndex(t=>t.date===e.date):-1,[e,k]),j=A>0?k[A-1]:null,M=A>0?k.slice(Math.max(0,A-7),A):[],N=w??A>0,P=ge??(A>=0&&A<k.length-1),be=_e??(A>=0?A+1:0),xe=ve??k.length,F=e?v(e):0,I=F>0,L=(0,g.useMemo)(()=>{if(!e)return[];let t=new Map;for(let n of e.modelBreakdowns){let e=ae(n.modelName),r=oe(n.modelName),i=t.get(e)??{provider:r,cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheCreate:0,thinking:0,requests:0};i.cost+=n.cost,i.tokens+=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens+n.thinkingTokens,i.input+=n.inputTokens,i.output+=n.outputTokens,i.cacheRead+=n.cacheReadTokens,i.cacheCreate+=n.cacheCreationTokens,i.thinking+=n.thinkingTokens,i.requests+=n.requestCount,t.set(e,i)}return Array.from(t.entries()).map(([t,n])=>({name:t,...n,costShare:e.totalCost>0?n.cost/e.totalCost*100:0,tokenShare:F>0?n.tokens/F*100:0,costPerMillion:y(n.cost,n.tokens),costPerRequest:b(n.cost,n.requests),tokensPerRequest:b(n.tokens,n.requests)})).sort((e,t)=>t.cost-e.cost)},[e,F]),R=(0,g.useMemo)(()=>{let t=new Map;for(let e of L){let n=t.get(e.provider)??{cost:0,tokens:0,requests:0,activeModels:new Set};n.cost+=e.cost,n.tokens+=e.tokens,n.requests+=e.requests,n.activeModels.add(e.name),t.set(e.provider,n)}return Array.from(t.entries()).map(([t,n])=>({provider:t,cost:n.cost,tokens:n.tokens,requests:n.requests,activeModels:n.activeModels.size,costShare:e&&e.totalCost>0?n.cost/e.totalCost*100:0})).sort((e,t)=>t.cost-e.cost)},[e,L]);if(!e)return null;let z=L.map(e=>({name:e.name,value:e.cost})),Se=I?e.cacheReadTokens/F*100:0,B=b(F,e.requestCount),V=b(e.totalCost,e.requestCount),H=y(e.totalCost,F),U=e.requestCount>0||e.modelBreakdowns.some(e=>e.requestCount>0)||a.some(e=>e.requestCount>0),Ce=[...a].sort((e,t)=>t.totalCost-e.totalCost).findIndex(t=>t.date===e.date)+1,we=U?[...a].sort((e,t)=>t.requestCount-e.requestCount).findIndex(t=>t.date===e.date)+1:0,W=M.length>0?M.reduce((e,t)=>e+t.totalCost,0)/M.length:null,G=M.length>0?M.reduce((e,t)=>e+t.requestCount,0)/M.length:null,K=M.length>0?M.reduce((e,t)=>e+v(t),0)/M.length:null,q=M.length>0?y(M.reduce((e,t)=>e+t.totalCost,0),M.reduce((e,t)=>e+v(t),0)):null,J=he(M.length>0?M.length:7,D(`drillDown.windowUnit.${O}`)),Te=j?v(j):null,Y=j?y(j.totalCost,v(j)):null,X=L[0]??null,Z=U?L.reduce((e,t)=>!e||t.requests>e.requests?t:e,null):null,Q=L.reduce((e,t)=>!e||t.tokens>e.tokens?t:e,null),$=L.reduce((e,t)=>t.costPerMillion===null?e:!e||e.costPerMillion===null||t.costPerMillion>e.costPerMillion?t:e,null),Ee=e.totalCost>0?L.slice(0,3).reduce((e,t)=>e+t.cost,0)/e.totalCost*100:0,De=[{label:D(`common.tokens`),value:(0,_.jsx)(h,{value:F,type:`tokens`})},{label:`$/1M`,value:H===null?`–`:(0,_.jsx)(h,{value:H,type:`currency`})},{label:D(`common.requests`),value:(0,_.jsx)(h,{value:e.requestCount,type:`number`})},{label:D(`common.models`),value:l(L.length)},{label:D(`drillDown.activeProviders`),value:l(R.length)},{label:D(`drillDown.tokensPerRequest`),value:B===null?`–`:(0,_.jsx)(h,{value:B,type:`tokens`})},{label:D(`drillDown.costPerRequest`),value:V===null?`–`:(0,_.jsx)(h,{value:V,type:`currency`})},{label:D(`drillDown.cacheRate`),value:(0,_.jsx)(h,{value:Se,type:`percent`})},{label:D(`common.thinking`),value:(0,_.jsx)(h,{value:e.thinkingTokens,type:`tokens`})},{label:D(`drillDown.costRank`),value:Ce>0?`#${Ce}`:`–`},{label:D(`drillDown.requestRank`),value:we>0?`#${we}`:`–`},{label:D(`drillDown.coverage`),value:(e._aggregatedDays??1)>1?D(`drillDown.coverageDays`,{count:e._aggregatedDays??1}):D(`drillDown.singlePeriod`,{period:D(`periods.${O}`)})}],Oe=[{label:D(`drillDown.costVsPrevious`),primary:S(x(e.totalCost,j?.totalCost??null),u),secondary:C(x(e.totalCost,j?.totalCost??null))},{label:D(`drillDown.tokensVsPrevious`),primary:S(x(F,Te),c),secondary:C(x(F,Te))},{label:D(`drillDown.requestsVsPrevious`),primary:S(x(e.requestCount,j?.requestCount??null),e=>l(Math.round(e))),secondary:C(x(e.requestCount,j?.requestCount??null))},{label:D(`drillDown.costPerMillionVsAverageWindow`,{window:J}),primary:S(H===null?null:x(H,q),u),secondary:q===null?`–`:u(q)},{label:D(`drillDown.costVsAverageWindow`,{window:J}),primary:S(x(e.totalCost,W),u),secondary:W===null?`–`:u(W)},{label:D(`drillDown.requestsVsAverageWindow`,{window:J}),primary:S(x(e.requestCount,G),e=>l(Math.round(e))),secondary:G===null?`–`:l(Math.round(G))},{label:D(`drillDown.tokensVsAverageWindow`,{window:J}),primary:S(x(F,K),c),secondary:K===null?`–`:c(K)},{label:D(`drillDown.costPerMillionVsPrevious`),primary:S(H===null?null:x(H,Y),u),secondary:Y===null?`–`:u(Y)}],ke=[{id:`cacheRead`,value:e.cacheReadTokens,color:`hsl(160, 50%, 42%)`,label:D(`drillDown.tokenSegments.cacheRead`)},{id:`cacheWrite`,value:e.cacheCreationTokens,color:`hsl(262, 60%, 55%)`,label:D(`drillDown.tokenSegments.cacheWrite`)},{id:`input`,value:e.inputTokens,color:`hsl(340, 55%, 52%)`,label:D(`common.input`)},{id:`output`,value:e.outputTokens,color:`hsl(35, 80%, 52%)`,label:D(`common.output`)},{id:`thinking`,value:e.thinkingTokens,color:`hsl(12, 78%, 56%)`,label:D(`common.thinking`)}],Ae=[{label:D(`drillDown.topCostModel`),title:X?.name??`–`,value:X?d(X.costShare):`–`},{label:D(`drillDown.topRequestModel`),title:Z?.name??`–`,value:Z&&Z.requests>0?D(`drillDown.requestCountShort`,{count:Z.requests}):`–`},{label:D(`drillDown.topTokenModel`),title:Q?.name??`–`,value:Q?d(Q.tokenShare):`–`},{label:D(`drillDown.priciestPerMillionModel`),title:$?.name??`–`,value:$?.costPerMillion!==null&&$?.costPerMillion!==void 0?(0,_.jsx)(h,{value:$.costPerMillion,type:`currency`}):`–`},{label:D(`drillDown.topCostShare`),title:X?d(X.costShare):`–`,value:X?.provider??`–`},{label:D(`drillDown.topThreeCostShare`),title:d(Ee),value:D(`drillDown.modelCount`,{count:Math.min(L.length,3)})}],je=D(O===`day`?`drillDown.previousDay`:`drillDown.previousPeriod`),Me=D(O===`day`?`drillDown.nextDay`:`drillDown.nextPeriod`);return(0,_.jsx)(de,{open:o,onOpenChange:e=>!e&&ye(),children:(0,_.jsxs)(le,{className:`max-h-[85vh] max-w-5xl overflow-y-auto`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||me(e.target)||(e.key===`ArrowLeft`&&N&&(e.preventDefault(),T?.()),e.key===`ArrowRight`&&P&&(e.preventDefault(),E?.()))},children:[(0,_.jsxs)(ce,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(se,{children:[ne(e.date,`long`),` — `,u(e.totalCost)]}),(0,_.jsx)(ue,{children:D(`drillDown.description`,{periodType:D(`periods.${O}`)})})]}),(0,_.jsxs)(`div`,{className:`flex flex-col items-stretch gap-2 sm:items-end`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:T,disabled:!N,"aria-label":je,children:[(0,_.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:je})]}),(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:E,disabled:!P,"aria-label":Me,children:[(0,_.jsx)(`span`,{children:Me}),(0,_.jsx)(re,{className:`h-4 w-4`,"aria-hidden":`true`})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground sm:justify-end`,children:[(0,_.jsx)(`span`,{children:D(`drillDown.position`,{current:be,total:xe})}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,_.jsx)(`span`,{children:D(`drillDown.keyboardHint`)})]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-1 text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.periodType`,{period:D(`periods.${O}`)})}),(e._aggregatedDays??1)>1&&(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.coverageDays`,{count:e._aggregatedDays??1})})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.overview`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:De.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-muted/30 p-3 text-center`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-mono text-sm font-medium`,children:e.value})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.benchmarks`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Oe.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-medium`,children:e.primary}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.secondary})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.modelBreakdown`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.modelCount`,{count:L.length})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-2`,children:Ae.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-medium`,children:e.title}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.value})]},e.label))}),z.length>0&&(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.costShareByModel`)}),(0,_.jsx)(n,{width:`100%`,height:220,children:(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{data:z,cx:`50%`,cy:`50%`,innerRadius:46,outerRadius:84,paddingAngle:2,dataKey:`value`,children:z.map(e=>(0,_.jsx)(t,{fill:m(e.name)},e.name))}),(0,_.jsx)(ee,{content:(0,_.jsx)(fe,{formatter:e=>u(e)})})]})})]})]}),(0,_.jsx)(`div`,{className:`space-y-3`,children:L.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,_.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,p(e.provider)),children:e.provider})]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.requestCountShort`,{count:e.requests})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokenShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.tokenShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerMillion===null?`–`:(0,_.jsx)(h,{value:e.costPerMillion,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerRequest===null?`–`:(0,_.jsx)(h,{value:e.costPerRequest,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokensPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.tokensPerRequest===null?`–`:(0,_.jsx)(h,{value:e.tokensPerRequest,type:`tokens`})})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-[11px] sm:grid-cols-5`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.input`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.input)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.output`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.output)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheRead`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheRead)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheWrite`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheCreate)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.thinking`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.thinking)})]})]})]},e.name))})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.providerSummary`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.providerCount`,{count:R.length})})]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:R.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,p(e.provider)),children:e.provider}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.activeModelsCount`,{count:e.activeModels})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]})]})]},e.provider))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.tokenDistribution`)}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`flex h-3 overflow-hidden rounded-full`,children:I&&ke.map(e=>{let t=(e.value/F*100).toFixed(1),n=`${e.label}: ${c(e.value)} (${t}%)`;return(0,_.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${e.value/F*100}%`,backgroundColor:e.color},title:n,"aria-label":n},e.id)})}),(0,_.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 text-xs sm:grid-cols-2 lg:grid-cols-5`,children:ke.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:e.color}}),e.label]}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.value)}),(0,_.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:I?d(e.value/F*100):`–`})]},e.id))})]})]})]})})}export{w as DrillDownModal};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,b as n,g as r,i,v as ee,w as a}from"./charts-vendor-CiBqdKXh.js";import{a as o}from"./motion-vendor-BNVN-Ktr.js";import{o as s,t as te}from"./useTranslation-0ThAx3Gl.js";import{d as c,i as ne,l,n as u,u as d}from"./formatters-C7EouP6y.js";import{U as re,W as ie}from"./icons-vendor-CIvT_-Pb.js";import{t as f}from"./button-CRvPoJg9.js";import{c as ae,i as p,r as oe,t as m}from"./model-utils-BIvGAFGz.js";import{a as se,i as ce,n as le,r as ue,t as de}from"./dialog-Djogwk0C.js";import{t as h}from"./formatted-value-CpLoDrYF.js";import{t as fe}from"./CustomTooltip-CfoUDPbT.js";var g=e(a()),_=o();function pe(e){return/^\d{4}$/.test(e)?`year`:/^\d{4}-\d{2}$/.test(e)?`month`:`day`}function v(e){return e.cacheReadTokens+e.cacheCreationTokens+e.inputTokens+e.outputTokens+e.thinkingTokens}function y(e,t){return t>0?e/(t/1e6):null}function b(e,t){return t>0?e/t:null}function x(e,t){if(t===null)return null;let n=e-t;return{absolute:n,percent:t===0?null:n/t*100}}function S(e,t,n=`–`){return e?e.absolute===0?`→ ${t(0)}`:`${e.absolute>0?`↑`:`↓`} ${t(Math.abs(e.absolute))}`:n}function C(e,t=`–`){return!e||e.percent===null?t:e.percent===0?`0.0%`:`${e.percent>0?`+`:``}${e.percent.toFixed(1)}%`}function me(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return e.isContentEditable||t===`INPUT`||t===`TEXTAREA`||t===`SELECT`}function he(e,t){return`${e}${t}`}function w({day:e,contextData:a=[],open:o,hasPrevious:w,hasNext:ge,currentIndex:_e,totalCount:ve,onPrevious:T,onNext:E,onClose:ye}){let{t:D}=te(),O=e?pe(e.date):`day`,k=(0,g.useMemo)(()=>[...a].sort((e,t)=>e.date.localeCompare(t.date)),[a]),A=(0,g.useMemo)(()=>e?k.findIndex(t=>t.date===e.date):-1,[e,k]),j=A>0?k[A-1]:null,M=A>0?k.slice(Math.max(0,A-7),A):[],N=w??A>0,P=ge??(A>=0&&A<k.length-1),be=_e??(A>=0?A+1:0),xe=ve??k.length,F=e?v(e):0,I=F>0,L=(0,g.useMemo)(()=>{if(!e)return[];let t=new Map;for(let n of e.modelBreakdowns){let e=ae(n.modelName),r=oe(n.modelName),i=t.get(e)??{provider:r,cost:0,tokens:0,input:0,output:0,cacheRead:0,cacheCreate:0,thinking:0,requests:0};i.cost+=n.cost,i.tokens+=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens+n.thinkingTokens,i.input+=n.inputTokens,i.output+=n.outputTokens,i.cacheRead+=n.cacheReadTokens,i.cacheCreate+=n.cacheCreationTokens,i.thinking+=n.thinkingTokens,i.requests+=n.requestCount,t.set(e,i)}return Array.from(t.entries()).map(([t,n])=>({name:t,...n,costShare:e.totalCost>0?n.cost/e.totalCost*100:0,tokenShare:F>0?n.tokens/F*100:0,costPerMillion:y(n.cost,n.tokens),costPerRequest:b(n.cost,n.requests),tokensPerRequest:b(n.tokens,n.requests)})).sort((e,t)=>t.cost-e.cost)},[e,F]),R=(0,g.useMemo)(()=>{let t=new Map;for(let e of L){let n=t.get(e.provider)??{cost:0,tokens:0,requests:0,activeModels:new Set};n.cost+=e.cost,n.tokens+=e.tokens,n.requests+=e.requests,n.activeModels.add(e.name),t.set(e.provider,n)}return Array.from(t.entries()).map(([t,n])=>({provider:t,cost:n.cost,tokens:n.tokens,requests:n.requests,activeModels:n.activeModels.size,costShare:e&&e.totalCost>0?n.cost/e.totalCost*100:0})).sort((e,t)=>t.cost-e.cost)},[e,L]);if(!e)return null;let z=L.map(e=>({name:e.name,value:e.cost})),Se=I?e.cacheReadTokens/F*100:0,B=b(F,e.requestCount),V=b(e.totalCost,e.requestCount),H=y(e.totalCost,F),U=e.requestCount>0||e.modelBreakdowns.some(e=>e.requestCount>0)||a.some(e=>e.requestCount>0),Ce=[...a].sort((e,t)=>t.totalCost-e.totalCost).findIndex(t=>t.date===e.date)+1,we=U?[...a].sort((e,t)=>t.requestCount-e.requestCount).findIndex(t=>t.date===e.date)+1:0,W=M.length>0?M.reduce((e,t)=>e+t.totalCost,0)/M.length:null,G=M.length>0?M.reduce((e,t)=>e+t.requestCount,0)/M.length:null,K=M.length>0?M.reduce((e,t)=>e+v(t),0)/M.length:null,q=M.length>0?y(M.reduce((e,t)=>e+t.totalCost,0),M.reduce((e,t)=>e+v(t),0)):null,J=he(M.length>0?M.length:7,D(`drillDown.windowUnit.${O}`)),Te=j?v(j):null,Y=j?y(j.totalCost,v(j)):null,X=L[0]??null,Z=U?L.reduce((e,t)=>!e||t.requests>e.requests?t:e,null):null,Q=L.reduce((e,t)=>!e||t.tokens>e.tokens?t:e,null),$=L.reduce((e,t)=>t.costPerMillion===null?e:!e||e.costPerMillion===null||t.costPerMillion>e.costPerMillion?t:e,null),Ee=e.totalCost>0?L.slice(0,3).reduce((e,t)=>e+t.cost,0)/e.totalCost*100:0,De=[{label:D(`common.tokens`),value:(0,_.jsx)(h,{value:F,type:`tokens`})},{label:`$/1M`,value:H===null?`–`:(0,_.jsx)(h,{value:H,type:`currency`})},{label:D(`common.requests`),value:(0,_.jsx)(h,{value:e.requestCount,type:`number`})},{label:D(`common.models`),value:l(L.length)},{label:D(`drillDown.activeProviders`),value:l(R.length)},{label:D(`drillDown.tokensPerRequest`),value:B===null?`–`:(0,_.jsx)(h,{value:B,type:`tokens`})},{label:D(`drillDown.costPerRequest`),value:V===null?`–`:(0,_.jsx)(h,{value:V,type:`currency`})},{label:D(`drillDown.cacheRate`),value:(0,_.jsx)(h,{value:Se,type:`percent`})},{label:D(`common.thinking`),value:(0,_.jsx)(h,{value:e.thinkingTokens,type:`tokens`})},{label:D(`drillDown.costRank`),value:Ce>0?`#${Ce}`:`–`},{label:D(`drillDown.requestRank`),value:we>0?`#${we}`:`–`},{label:D(`drillDown.coverage`),value:(e._aggregatedDays??1)>1?D(`drillDown.coverageDays`,{count:e._aggregatedDays??1}):D(`drillDown.singlePeriod`,{period:D(`periods.${O}`)})}],Oe=[{label:D(`drillDown.costVsPrevious`),primary:S(x(e.totalCost,j?.totalCost??null),u),secondary:C(x(e.totalCost,j?.totalCost??null))},{label:D(`drillDown.tokensVsPrevious`),primary:S(x(F,Te),c),secondary:C(x(F,Te))},{label:D(`drillDown.requestsVsPrevious`),primary:S(x(e.requestCount,j?.requestCount??null),e=>l(Math.round(e))),secondary:C(x(e.requestCount,j?.requestCount??null))},{label:D(`drillDown.costPerMillionVsAverageWindow`,{window:J}),primary:S(H===null?null:x(H,q),u),secondary:q===null?`–`:u(q)},{label:D(`drillDown.costVsAverageWindow`,{window:J}),primary:S(x(e.totalCost,W),u),secondary:W===null?`–`:u(W)},{label:D(`drillDown.requestsVsAverageWindow`,{window:J}),primary:S(x(e.requestCount,G),e=>l(Math.round(e))),secondary:G===null?`–`:l(Math.round(G))},{label:D(`drillDown.tokensVsAverageWindow`,{window:J}),primary:S(x(F,K),c),secondary:K===null?`–`:c(K)},{label:D(`drillDown.costPerMillionVsPrevious`),primary:S(H===null?null:x(H,Y),u),secondary:Y===null?`–`:u(Y)}],ke=[{id:`cacheRead`,value:e.cacheReadTokens,color:`hsl(160, 50%, 42%)`,label:D(`drillDown.tokenSegments.cacheRead`)},{id:`cacheWrite`,value:e.cacheCreationTokens,color:`hsl(262, 60%, 55%)`,label:D(`drillDown.tokenSegments.cacheWrite`)},{id:`input`,value:e.inputTokens,color:`hsl(340, 55%, 52%)`,label:D(`common.input`)},{id:`output`,value:e.outputTokens,color:`hsl(35, 80%, 52%)`,label:D(`common.output`)},{id:`thinking`,value:e.thinkingTokens,color:`hsl(12, 78%, 56%)`,label:D(`common.thinking`)}],Ae=[{label:D(`drillDown.topCostModel`),title:X?.name??`–`,value:X?d(X.costShare):`–`},{label:D(`drillDown.topRequestModel`),title:Z?.name??`–`,value:Z&&Z.requests>0?D(`drillDown.requestCountShort`,{count:Z.requests}):`–`},{label:D(`drillDown.topTokenModel`),title:Q?.name??`–`,value:Q?d(Q.tokenShare):`–`},{label:D(`drillDown.priciestPerMillionModel`),title:$?.name??`–`,value:$?.costPerMillion!==null&&$?.costPerMillion!==void 0?(0,_.jsx)(h,{value:$.costPerMillion,type:`currency`}):`–`},{label:D(`drillDown.topCostShare`),title:X?d(X.costShare):`–`,value:X?.provider??`–`},{label:D(`drillDown.topThreeCostShare`),title:d(Ee),value:D(`drillDown.modelCount`,{count:Math.min(L.length,3)})}],je=D(O===`day`?`drillDown.previousDay`:`drillDown.previousPeriod`),Me=D(O===`day`?`drillDown.nextDay`:`drillDown.nextPeriod`);return(0,_.jsx)(de,{open:o,onOpenChange:e=>!e&&ye(),children:(0,_.jsxs)(le,{className:`max-h-[85vh] max-w-5xl overflow-y-auto`,onKeyDown:e=>{e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||me(e.target)||(e.key===`ArrowLeft`&&N&&(e.preventDefault(),T?.()),e.key===`ArrowRight`&&P&&(e.preventDefault(),E?.()))},children:[(0,_.jsxs)(ce,{children:[(0,_.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(se,{children:[ne(e.date,`long`),` — `,u(e.totalCost)]}),(0,_.jsx)(ue,{children:D(`drillDown.description`,{periodType:D(`periods.${O}`)})})]}),(0,_.jsxs)(`div`,{className:`flex flex-col items-stretch gap-2 sm:items-end`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:T,disabled:!N,"aria-label":je,children:[(0,_.jsx)(ie,{className:`h-4 w-4`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:je})]}),(0,_.jsxs)(f,{type:`button`,variant:`outline`,size:`sm`,onClick:E,disabled:!P,"aria-label":Me,children:[(0,_.jsx)(`span`,{children:Me}),(0,_.jsx)(re,{className:`h-4 w-4`,"aria-hidden":`true`})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground sm:justify-end`,children:[(0,_.jsx)(`span`,{children:D(`drillDown.position`,{current:be,total:xe})}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,_.jsx)(`span`,{children:D(`drillDown.keyboardHint`)})]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-1 text-xs text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.periodType`,{period:D(`periods.${O}`)})}),(e._aggregatedDays??1)>1&&(0,_.jsx)(`span`,{className:`rounded-full border border-border/60 bg-muted/20 px-2 py-1`,children:D(`drillDown.coverageDays`,{count:e._aggregatedDays??1})})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.overview`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:De.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-muted/30 p-3 text-center`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-mono text-sm font-medium`,children:e.value})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.benchmarks`)}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Oe.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 font-medium`,children:e.primary}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.secondary})]},e.label))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.modelBreakdown`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.modelCount`,{count:L.length})})]}),(0,_.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-[280px_minmax(0,1fr)]`,children:[(0,_.jsxs)(`div`,{className:`space-y-3`,children:[(0,_.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-2`,children:Ae.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.label}),(0,_.jsx)(`div`,{className:`mt-1 truncate font-medium`,children:e.title}),(0,_.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.value})]},e.label))}),z.length>0&&(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.costShareByModel`)}),(0,_.jsx)(n,{width:`100%`,height:220,children:(0,_.jsxs)(i,{children:[(0,_.jsx)(r,{data:z,cx:`50%`,cy:`50%`,innerRadius:46,outerRadius:84,paddingAngle:2,dataKey:`value`,children:z.map(e=>(0,_.jsx)(t,{fill:m(e.name)},e.name))}),(0,_.jsx)(ee,{content:(0,_.jsx)(fe,{formatter:e=>u(e)})})]})})]})]}),(0,_.jsx)(`div`,{className:`space-y-3`,children:L.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,_.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,p(e.provider)),children:e.provider})]}),(0,_.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.requestCountShort`,{count:e.requests})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokenShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.tokenShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerMillion===null?`–`:(0,_.jsx)(h,{value:e.costPerMillion,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.costPerRequest===null?`–`:(0,_.jsx)(h,{value:e.costPerRequest,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.tokensPerRequest`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:e.tokensPerRequest===null?`–`:(0,_.jsx)(h,{value:e.tokensPerRequest,type:`tokens`})})]})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-[11px] sm:grid-cols-5`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.input`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.input)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.output`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.output)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheRead`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheRead)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.cacheWrite`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.cacheCreate)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-background/60 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.thinking`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.thinking)})]})]})]},e.name))})]})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.providerSummary`)}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.providerCount`,{count:R.length})})]}),(0,_.jsx)(`div`,{className:`grid grid-cols-1 gap-3 lg:grid-cols-2`,children:R.map(e=>(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,_.jsx)(`span`,{className:s(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,p(e.provider)),children:e.provider}),(0,_.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`drillDown.activeModelsCount`,{count:e.activeModels})})]}),(0,_.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs sm:grid-cols-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.cost`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.cost,type:`currency`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`drillDown.costShare`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:d(e.costShare)})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`tables.recentDays.tokens`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.tokens,type:`tokens`})})]}),(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsx)(`div`,{className:`text-muted-foreground`,children:D(`common.requests`)}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,_.jsx)(h,{value:e.requests,type:`number`})})]})]})]},e.provider))})]}),(0,_.jsxs)(`section`,{className:`space-y-3`,children:[(0,_.jsx)(`h3`,{className:`text-sm font-semibold`,children:D(`drillDown.tokenDistribution`)}),(0,_.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,_.jsx)(`div`,{className:`flex h-3 overflow-hidden rounded-full`,children:I&&ke.map(e=>{let t=(e.value/F*100).toFixed(1),n=`${e.label}: ${c(e.value)} (${t}%)`;return(0,_.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${e.value/F*100}%`,backgroundColor:e.color},title:n,"aria-label":n},e.id)})}),(0,_.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 text-xs sm:grid-cols-2 lg:grid-cols-5`,children:ke.map(e=>(0,_.jsxs)(`div`,{className:`rounded-lg bg-background/70 px-2.5 py-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,_.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{backgroundColor:e.color}}),e.label]}),(0,_.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.value)}),(0,_.jsx)(`div`,{className:`mt-1 text-[11px] text-muted-foreground`,children:I?d(e.value/F*100):`–`})]},e.id))})]})]})]})})}export{w as DrillDownModal};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{J as i,K as a,T as o}from"./icons-vendor-CIvT_-Pb.js";import{a as s,i as c,n as l,t as u}from"./constants-jyhBMReu.js";import{a as d,i as f,n as p,r as m,t as h}from"./dialog-C0AeNKs8.js";import{a as g,i as _,n as v,r as y,t as b}from"./help-content-Bt5KCpWS.js";var x=e(t()),S=n(),C=[`requestQuality`,`providerLimits`,`concentrationRisk`],w=[`providerEfficiency`,`modelEfficiency`,`recentDays`];function T({open:e,onOpenChange:t}){let{t:n}=r(),T=g(),E=(0,x.useMemo)(()=>Object.keys(b),[]),D=(0,x.useMemo)(()=>Object.keys(_),[]),O=(0,x.useMemo)(()=>({totalCost:n(`helpPanel.metricLabels.totalCost`),totalTokens:n(`helpPanel.metricLabels.totalTokens`),activeDays:n(`helpPanel.metricLabels.activeDays`),topModel:n(`helpPanel.metricLabels.topModel`),cacheHitRate:n(`helpPanel.metricLabels.cacheHitRate`),costPerMillion:n(`helpPanel.metricLabels.costPerMillion`),mostExpensiveDay:n(`helpPanel.metricLabels.mostExpensiveDay`),cheapestDay:n(`helpPanel.metricLabels.cheapestDay`),avgCostPerDay:n(`helpPanel.metricLabels.avgCostPerDay`),outputTokens:n(`helpPanel.metricLabels.outputTokens`)}),[n]),k=(0,x.useMemo)(()=>({costOverTime:n(`helpPanel.chartLabels.costOverTime`),costByModel:n(`helpPanel.chartLabels.costByModel`),costByModelOverTime:n(`helpPanel.chartLabels.costByModelOverTime`),cumulativeCost:n(`helpPanel.chartLabels.cumulativeCost`),costByWeekday:n(`helpPanel.chartLabels.costByWeekday`),tokensOverTime:n(`helpPanel.chartLabels.tokensOverTime`),requestsOverTime:n(`helpPanel.chartLabels.requestsOverTime`),requestCacheHitRate:n(`helpPanel.chartLabels.requestCacheHitRate`),tokenTypes:n(`helpPanel.chartLabels.tokenTypes`),tokenEfficiency:n(`helpPanel.chartLabels.tokenEfficiency`),modelMix:n(`helpPanel.chartLabels.modelMix`),distributionAnalysis:n(`helpPanel.chartLabels.distributionAnalysis`),correlationAnalysis:n(`helpPanel.chartLabels.correlationAnalysis`),heatmap:n(`helpPanel.chartLabels.heatmap`),requestHeatmap:n(`helpPanel.chartLabels.requestHeatmap`),tokenHeatmap:n(`helpPanel.chartLabels.tokenHeatmap`),forecast:n(`helpPanel.chartLabels.forecast`),cacheROI:n(`helpPanel.chartLabels.cacheROI`),providerLimitProgress:n(`helpPanel.chartLabels.providerLimitProgress`),providerSubscriptionMix:n(`helpPanel.chartLabels.providerSubscriptionMix`),providerLimitTimeline:n(`helpPanel.chartLabels.providerLimitTimeline`),periodComparison:n(`helpPanel.chartLabels.periodComparison`),anomalyDetection:n(`helpPanel.chartLabels.anomalyDetection`)}),[n]),A=(0,x.useMemo)(()=>({insights:n(`helpPanel.sectionLabels.insights`),metrics:n(`helpPanel.sectionLabels.metrics`),today:n(`helpPanel.sectionLabels.today`),currentMonth:n(`helpPanel.sectionLabels.currentMonth`),activity:n(`helpPanel.sectionLabels.activity`),forecastCache:n(`helpPanel.sectionLabels.forecastCache`),costAnalysis:n(`helpPanel.sectionLabels.costAnalysis`),tokenAnalysis:n(`helpPanel.sectionLabels.tokenAnalysis`),requestAnalysis:n(`helpPanel.sectionLabels.requestAnalysis`),advancedAnalysis:n(`helpPanel.sectionLabels.advancedAnalysis`),comparisons:n(`helpPanel.sectionLabels.comparisons`),tables:n(`helpPanel.sectionLabels.tables`),limits:n(`helpPanel.sectionLabels.limits`)}),[n]),j=(0,x.useMemo)(()=>({requestQuality:n(`helpPanel.featureLabels.requestQuality`),providerLimits:n(`helpPanel.featureLabels.providerLimits`),concentrationRisk:n(`helpPanel.featureLabels.concentrationRisk`),providerEfficiency:n(`helpPanel.featureLabels.providerEfficiency`),modelEfficiency:n(`helpPanel.featureLabels.modelEfficiency`),recentDays:n(`helpPanel.featureLabels.recentDays`)}),[n]);return(0,S.jsx)(h,{open:e,onOpenChange:t,children:(0,S.jsxs)(p,{className:`max-h-[80vh] max-w-lg overflow-y-auto`,children:[(0,S.jsxs)(f,{children:[(0,S.jsx)(d,{className:`text-lg font-semibold`,children:n(`header.help`)}),(0,S.jsx)(m,{children:n(`commandPalette.description`)})]}),(0,S.jsxs)(`section`,{className:`rounded-lg border border-border/60 bg-muted/40 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`helpPanel.projectLinks.title`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`helpPanel.projectLinks.description`,{version:s})})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,S.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.npm`)}),(0,S.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.github`)}),(0,S.jsx)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.issues`)})]})]}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`header.help`)})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:T.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-foreground`,children:e.description}),(0,S.jsx)(`kbd`,{className:`inline-flex items-center gap-0.5 rounded border border-border bg-background px-2 py-0.5 font-mono text-xs text-muted-foreground`,children:e.keys})]},e.keys))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`dashboard.metrics.title`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:Object.entries(y).map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:O[e]??e}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.chartsAndFeatures`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:E.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:k[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:b[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.dashboardSectionsTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:D.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:A[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.featuresTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:C.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.tablesTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:w.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]})]})})}export{T as HelpPanel};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{t as r}from"./useTranslation-0ThAx3Gl.js";import{J as i,K as a,T as o}from"./icons-vendor-CIvT_-Pb.js";import{a as s,i as c,n as l,t as u}from"./constants-BDzjWFuU.js";import{a as d,i as f,n as p,r as m,t as h}from"./dialog-Djogwk0C.js";import{a as g,i as _,n as v,r as y,t as b}from"./help-content-B2N8SHIE.js";var x=e(t()),S=n(),C=[`requestQuality`,`providerLimits`,`concentrationRisk`],w=[`providerEfficiency`,`modelEfficiency`,`recentDays`];function T({open:e,onOpenChange:t}){let{t:n}=r(),T=g(),E=(0,x.useMemo)(()=>Object.keys(b),[]),D=(0,x.useMemo)(()=>Object.keys(_),[]),O=(0,x.useMemo)(()=>({totalCost:n(`helpPanel.metricLabels.totalCost`),totalTokens:n(`helpPanel.metricLabels.totalTokens`),activeDays:n(`helpPanel.metricLabels.activeDays`),topModel:n(`helpPanel.metricLabels.topModel`),cacheHitRate:n(`helpPanel.metricLabels.cacheHitRate`),costPerMillion:n(`helpPanel.metricLabels.costPerMillion`),mostExpensiveDay:n(`helpPanel.metricLabels.mostExpensiveDay`),cheapestDay:n(`helpPanel.metricLabels.cheapestDay`),avgCostPerDay:n(`helpPanel.metricLabels.avgCostPerDay`),outputTokens:n(`helpPanel.metricLabels.outputTokens`)}),[n]),k=(0,x.useMemo)(()=>({costOverTime:n(`helpPanel.chartLabels.costOverTime`),costByModel:n(`helpPanel.chartLabels.costByModel`),costByModelOverTime:n(`helpPanel.chartLabels.costByModelOverTime`),cumulativeCost:n(`helpPanel.chartLabels.cumulativeCost`),costByWeekday:n(`helpPanel.chartLabels.costByWeekday`),tokensOverTime:n(`helpPanel.chartLabels.tokensOverTime`),requestsOverTime:n(`helpPanel.chartLabels.requestsOverTime`),requestCacheHitRate:n(`helpPanel.chartLabels.requestCacheHitRate`),tokenTypes:n(`helpPanel.chartLabels.tokenTypes`),tokenEfficiency:n(`helpPanel.chartLabels.tokenEfficiency`),modelMix:n(`helpPanel.chartLabels.modelMix`),distributionAnalysis:n(`helpPanel.chartLabels.distributionAnalysis`),correlationAnalysis:n(`helpPanel.chartLabels.correlationAnalysis`),heatmap:n(`helpPanel.chartLabels.heatmap`),requestHeatmap:n(`helpPanel.chartLabels.requestHeatmap`),tokenHeatmap:n(`helpPanel.chartLabels.tokenHeatmap`),forecast:n(`helpPanel.chartLabels.forecast`),cacheROI:n(`helpPanel.chartLabels.cacheROI`),providerLimitProgress:n(`helpPanel.chartLabels.providerLimitProgress`),providerSubscriptionMix:n(`helpPanel.chartLabels.providerSubscriptionMix`),providerLimitTimeline:n(`helpPanel.chartLabels.providerLimitTimeline`),periodComparison:n(`helpPanel.chartLabels.periodComparison`),anomalyDetection:n(`helpPanel.chartLabels.anomalyDetection`)}),[n]),A=(0,x.useMemo)(()=>({insights:n(`helpPanel.sectionLabels.insights`),metrics:n(`helpPanel.sectionLabels.metrics`),today:n(`helpPanel.sectionLabels.today`),currentMonth:n(`helpPanel.sectionLabels.currentMonth`),activity:n(`helpPanel.sectionLabels.activity`),forecastCache:n(`helpPanel.sectionLabels.forecastCache`),costAnalysis:n(`helpPanel.sectionLabels.costAnalysis`),tokenAnalysis:n(`helpPanel.sectionLabels.tokenAnalysis`),requestAnalysis:n(`helpPanel.sectionLabels.requestAnalysis`),advancedAnalysis:n(`helpPanel.sectionLabels.advancedAnalysis`),comparisons:n(`helpPanel.sectionLabels.comparisons`),tables:n(`helpPanel.sectionLabels.tables`),limits:n(`helpPanel.sectionLabels.limits`)}),[n]),j=(0,x.useMemo)(()=>({requestQuality:n(`helpPanel.featureLabels.requestQuality`),providerLimits:n(`helpPanel.featureLabels.providerLimits`),concentrationRisk:n(`helpPanel.featureLabels.concentrationRisk`),providerEfficiency:n(`helpPanel.featureLabels.providerEfficiency`),modelEfficiency:n(`helpPanel.featureLabels.modelEfficiency`),recentDays:n(`helpPanel.featureLabels.recentDays`)}),[n]);return(0,S.jsx)(h,{open:e,onOpenChange:t,children:(0,S.jsxs)(p,{className:`max-h-[80vh] max-w-lg overflow-y-auto`,children:[(0,S.jsxs)(f,{children:[(0,S.jsx)(d,{className:`text-lg font-semibold`,children:n(`header.help`)}),(0,S.jsx)(m,{children:n(`commandPalette.description`)})]}),(0,S.jsxs)(`section`,{className:`rounded-lg border border-border/60 bg-muted/40 px-4 py-3`,children:[(0,S.jsxs)(`div`,{className:`space-y-1`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:n(`helpPanel.projectLinks.title`)}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`helpPanel.projectLinks.description`,{version:s})})]}),(0,S.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,S.jsx)(`a`,{href:c,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.npm`)}),(0,S.jsx)(`a`,{href:l,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.github`)}),(0,S.jsx)(`a`,{href:u,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center rounded-md border border-border/60 bg-background px-3 py-1.5 text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,children:n(`helpPanel.projectLinks.issues`)})]})]}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`header.help`)})]}),(0,S.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:T.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`span`,{className:`text-sm text-foreground`,children:e.description}),(0,S.jsx)(`kbd`,{className:`inline-flex items-center gap-0.5 rounded border border-border bg-background px-2 py-0.5 font-mono text-xs text-muted-foreground`,children:e.keys})]},e.keys))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`dashboard.metrics.title`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:Object.entries(y).map(([e,t])=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:O[e]??e}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.chartsAndFeatures`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:E.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:k[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:b[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.dashboardSectionsTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:D.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:A[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:_[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.featuresTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:C.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]}),(0,S.jsx)(`hr`,{className:`border-border`}),(0,S.jsxs)(`section`,{children:[(0,S.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,S.jsx)(i,{className:`h-4 w-4 text-primary`}),(0,S.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`helpPanel.tablesTitle`)})]}),(0,S.jsx)(`div`,{className:`space-y-2`,children:w.map(e=>(0,S.jsxs)(`div`,{className:`rounded-md bg-muted/50 px-3 py-2`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:j[e]}),(0,S.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:v[e]})]},e))})]})]})})}export{T as HelpPanel};
@@ -1 +1 @@
1
- import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{a as t,t as n}from"./useTranslation-BSl7t2D6.js";import{v as r,x as i,y as a}from"./formatters-yKppUXb3.js";import{E as o}from"./icons-vendor-CIvT_-Pb.js";var s=e();function c({text:e,className:c}){let{t:l}=n();return(0,s.jsxs)(r,{children:[(0,s.jsx)(i,{asChild:!0,children:(0,s.jsx)(`button`,{type:`button`,"aria-label":l(`common.showInfo`),"data-info-button":`true`,className:t(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,c),children:(0,s.jsx)(o,{className:`h-3.5 w-3.5`})})}),(0,s.jsx)(a,{side:`top`,className:`max-w-xs text-xs`,children:e})]})}export{c as t};
1
+ import{a as e}from"./motion-vendor-BNVN-Ktr.js";import{o as t,t as n}from"./useTranslation-0ThAx3Gl.js";import{v as r,x as i,y as a}from"./formatters-C7EouP6y.js";import{E as o}from"./icons-vendor-CIvT_-Pb.js";var s=e();function c({text:e,className:c}){let{t:l}=n();return(0,s.jsxs)(r,{children:[(0,s.jsx)(i,{asChild:!0,children:(0,s.jsx)(`button`,{type:`button`,"aria-label":l(`common.showInfo`),"data-info-button":`true`,className:t(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/50 transition-colors hover:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,c),children:(0,s.jsx)(o,{className:`h-3.5 w-3.5`})})}),(0,s.jsx)(a,{side:`top`,className:`max-w-xs text-xs`,children:e})]})}export{c as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./motion-vendor-BNVN-Ktr.js";import{o as t}from"./useTranslation-0ThAx3Gl.js";import{t as n}from"./InfoButton-BGjUQfHz.js";var r=e();function i({children:e,info:i,className:a}){return(0,r.jsxs)(`div`,{className:t(`flex min-w-0 items-center gap-2`,a),children:[e,i&&(0,r.jsx)(n,{text:i,className:`shrink-0`})]})}export{i as t};
@@ -1 +1 @@
1
- import{a as e}from"./motion-vendor-vKc6gXHZ.js";import{a as t}from"./useTranslation-BSl7t2D6.js";import{t as n}from"./card-h-Z9EWBl.js";import{t as r}from"./InfoButton-CTgLGzb9.js";var i=e();function a({label:e,value:a,subtitle:o,icon:s,trend:c,info:l,className:u}){let d=c&&c.value>0?`bg-rose-500/14 text-rose-700 dark:bg-rose-500/12 dark:text-rose-300`:`bg-emerald-500/14 text-emerald-700 dark:bg-emerald-500/12 dark:text-emerald-300`;return(0,i.jsxs)(n,{className:t(`flex min-h-[122px] flex-col gap-1 p-4 transition-transform duration-200 hover:-translate-y-0.5 hover:shadow-lg motion-reduce:transform-none motion-reduce:transition-none`,u),children:[(0,i.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,i.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1 text-xs leading-tight font-medium text-balance text-muted-foreground`,children:[e,l&&(0,i.jsx)(r,{text:l})]}),s&&(0,i.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:s})]}),(0,i.jsx)(`div`,{className:`text-2xl leading-none font-bold tracking-tight`,children:a}),(0,i.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-2`,children:[o&&(0,i.jsx)(`span`,{className:`text-xs text-pretty text-muted-foreground`,children:o}),c&&c.value!==0&&(0,i.jsxs)(`span`,{className:t(`inline-flex items-center gap-0.5 rounded-md px-1.5 py-0.5 text-[10px] font-semibold`,d),children:[c.value>0?`↑`:`↓`,Math.abs(c.value).toFixed(1),`%`,c.label&&` ${c.label}`]})]})]})}export{a as t};
1
+ import{a as e}from"./motion-vendor-BNVN-Ktr.js";import{o as t}from"./useTranslation-0ThAx3Gl.js";import{t as n}from"./card-B4CVYJDH.js";import{t as r}from"./InfoButton-BGjUQfHz.js";var i=e();function a({label:e,value:a,subtitle:o,icon:s,trend:c,info:l,className:u}){let d=c&&c.value>0?`bg-rose-500/14 text-rose-700 dark:bg-rose-500/12 dark:text-rose-300`:`bg-emerald-500/14 text-emerald-700 dark:bg-emerald-500/12 dark:text-emerald-300`;return(0,i.jsxs)(n,{className:t(`flex min-h-[122px] flex-col gap-1 p-4 transition-transform duration-200 hover:-translate-y-0.5 hover:shadow-lg motion-reduce:transform-none motion-reduce:transition-none`,u),children:[(0,i.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,i.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1 text-xs leading-tight font-medium text-balance text-muted-foreground`,children:[e,l&&(0,i.jsx)(r,{text:l})]}),s&&(0,i.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:s})]}),(0,i.jsx)(`div`,{className:`text-2xl leading-none font-bold tracking-tight`,children:a}),(0,i.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-2`,children:[o&&(0,i.jsx)(`span`,{className:`text-xs text-pretty text-muted-foreground`,children:o}),c&&c.value!==0&&(0,i.jsxs)(`span`,{className:t(`inline-flex items-center gap-0.5 rounded-md px-1.5 py-0.5 text-[10px] font-semibold`,d),children:[c.value>0?`↑`:`↓`,Math.abs(c.value).toFixed(1),`%`,c.label&&` ${c.label}`]})]})]})}export{a as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-yKppUXb3.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d,n as f,r as p,t as m}from"./model-utils-BIvGAFGz.js";import{a as h,i as g,n as _,t as v}from"./card-h-Z9EWBl.js";import{t as y}from"./formatted-value-rO0EpKbc.js";import{n as b}from"./help-content-Bt5KCpWS.js";import{t as x}from"./InfoHeading-oi90uCR7.js";var S=e(t()),C=n();function w({modelCosts:e,totalCost:t,viewMode:n=`daily`}){let{t:w}=i(),[T,E]=(0,S.useState)(`cost`),[D,O]=(0,S.useState)(!1),k=(0,S.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,cost:n.cost,tokens:n.tokens,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,costPerRequest:n.requests>0?n.cost/n.requests:0,tokensPerRequest:n.requests>0?n.tokens/n.requests:0,share:t>0?n.cost/t*100:0,requestShare:0,cacheShare:n.tokens>0?(n.cacheRead??0)/n.tokens*100:0,thinkingShare:n.tokens>0?(n.thinking??0)/n.tokens*100:0,days:n.days,requests:n.requests,costPerDay:n.days>0?n.cost/n.days:0})),[e,t]),A=(0,S.useMemo)(()=>k.reduce((e,t)=>e+t.requests,0),[k]),j=(0,S.useMemo)(()=>k.map(e=>({...e,requestShare:A>0?e.requests/A*100:0})),[k,A]),M=(0,S.useMemo)(()=>[...j].sort((e,t)=>{let n=e[T]-t[T];return D?n:-n}),[j,D,T]),N=M[0]??null,P=(0,S.useMemo)(()=>[...k].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[k]),F=e=>{e===T?O(!D):(E(e),O(!1))},I=e=>T===e?D?`ascending`:`descending`:`none`,L=({label:e,field:t})=>(0,C.jsx)(`th`,{"aria-sort":I(t),className:r(`px-3 py-2 text-right text-xs font-medium`,T===t?`text-foreground`:`text-muted-foreground`),children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>F(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,C.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,T===t&&`text-primary`)})]})});return(0,C.jsxs)(v,{children:[(0,C.jsx)(g,{children:(0,C.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,C.jsx)(x,{info:b.modelEfficiency,children:(0,C.jsx)(h,{className:`text-sm font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.title`)})}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.count`,{count:k.length})})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModel`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?w(`tables.modelEfficiency.share`,{value:l(N.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.mostEfficient`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:P?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:P?w(`tables.modelEfficiency.share`,{value:l(P.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.totalRequests`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k.length>0?w(`tables.modelEfficiency.perModel`,{value:(A/k.length).toFixed(0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModelTokens`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?a(N.tokens):`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?`${N.days} ${s(n,!0)}`:`–`})]})]})]})}),(0,C.jsxs)(_,{children:[(0,C.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:M.map(e=>(0,C.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`truncate font-medium`,children:e.name})]}),(0,C.jsx)(`div`,{className:`mt-1 inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium text-muted-foreground`,children:p(e.name)})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.share`,{value:l(e.share,1)})})]})]}),(0,C.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokens`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerMillion`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`common.requests`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.requests)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokensPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokensPerRequest)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:`Cache %`}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,C.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,C.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,C.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.model`)}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cost`),field:`cost`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokens`),field:`tokens`}),(0,C.jsx)(L,{label:`$/1M`,field:`costPerMillion`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.shareShort`),field:`share`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.req`),field:`requests`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.reqShare`),field:`requestShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.costPerReq`),field:`costPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokensPerReq`),field:`tokensPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cacheShare`),field:`cacheShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.thinkingShare`),field:`thinkingShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.avgPerUnit`,{unit:o(n)}),field:`costPerDay`}),(0,C.jsx)(L,{label:s(n,!0),field:`days`})]})}),(0,C.jsx)(`tbody`,{children:M.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,C.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,C.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,C.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,d(p(e.name))),children:p(e.name)})]})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.tokens,type:`tokens`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})}),(0,C.jsxs)(`td`,{className:`relative px-3 py-2.5 text-right font-mono tabular-nums`,children:[(0,C.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm transition-all duration-500`,style:{width:`${e.share}%`,backgroundColor:f(e.name,.16)}}),(0,C.jsx)(`span`,{className:`relative`,children:l(e.share)})]}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.requestShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokensPerRequest)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.thinkingShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerDay,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:e.days})]},e.name))})]})})]})]})}export{w as ModelEfficiency};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{o as r,t as i}from"./useTranslation-0ThAx3Gl.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-C7EouP6y.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d,n as f,r as p,t as m}from"./model-utils-BIvGAFGz.js";import{a as h,i as g,n as _,t as v}from"./card-B4CVYJDH.js";import{t as y}from"./formatted-value-CpLoDrYF.js";import{n as b}from"./help-content-B2N8SHIE.js";import{t as x}from"./InfoHeading-BxLyydv8.js";var S=e(t()),C=n();function w({modelCosts:e,totalCost:t,viewMode:n=`daily`}){let{t:w}=i(),[T,E]=(0,S.useState)(`cost`),[D,O]=(0,S.useState)(!1),k=(0,S.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,cost:n.cost,tokens:n.tokens,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,costPerRequest:n.requests>0?n.cost/n.requests:0,tokensPerRequest:n.requests>0?n.tokens/n.requests:0,share:t>0?n.cost/t*100:0,requestShare:0,cacheShare:n.tokens>0?(n.cacheRead??0)/n.tokens*100:0,thinkingShare:n.tokens>0?(n.thinking??0)/n.tokens*100:0,days:n.days,requests:n.requests,costPerDay:n.days>0?n.cost/n.days:0})),[e,t]),A=(0,S.useMemo)(()=>k.reduce((e,t)=>e+t.requests,0),[k]),j=(0,S.useMemo)(()=>k.map(e=>({...e,requestShare:A>0?e.requests/A*100:0})),[k,A]),M=(0,S.useMemo)(()=>[...j].sort((e,t)=>{let n=e[T]-t[T];return D?n:-n}),[j,D,T]),N=M[0]??null,P=(0,S.useMemo)(()=>[...k].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[k]),F=e=>{e===T?O(!D):(E(e),O(!1))},I=e=>T===e?D?`ascending`:`descending`:`none`,L=({label:e,field:t})=>(0,C.jsx)(`th`,{"aria-sort":I(t),className:r(`px-3 py-2 text-right text-xs font-medium`,T===t?`text-foreground`:`text-muted-foreground`),children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>F(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,C.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,T===t&&`text-primary`)})]})});return(0,C.jsxs)(v,{children:[(0,C.jsx)(g,{children:(0,C.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,C.jsx)(x,{info:b.modelEfficiency,children:(0,C.jsx)(h,{className:`text-sm font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.title`)})}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.count`,{count:k.length})})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModel`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?w(`tables.modelEfficiency.share`,{value:l(N.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.mostEfficient`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:P?.name??`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:P?w(`tables.modelEfficiency.share`,{value:l(P.share,0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.totalRequests`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k.length>0?w(`tables.modelEfficiency.perModel`,{value:(A/k.length).toFixed(0)}):`–`})]}),(0,C.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,C.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:w(`tables.modelEfficiency.topModelTokens`)}),(0,C.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:N?a(N.tokens):`–`}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:N?`${N.days} ${s(n,!0)}`:`–`})]})]})]})}),(0,C.jsxs)(_,{children:[(0,C.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:M.map(e=>(0,C.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`truncate font-medium`,children:e.name})]}),(0,C.jsx)(`div`,{className:`mt-1 inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium text-muted-foreground`,children:p(e.name)})]}),(0,C.jsxs)(`div`,{className:`text-right`,children:[(0,C.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:w(`tables.modelEfficiency.share`,{value:l(e.share,1)})})]})]}),(0,C.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokens`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerMillion`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`common.requests`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:c(e.requests)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.costPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:w(`tables.modelEfficiency.tokensPerReq`)}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokensPerRequest)})]}),(0,C.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,C.jsx)(`div`,{className:`text-muted-foreground`,children:`Cache %`}),(0,C.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,C.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,C.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,C.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:w(`tables.modelEfficiency.model`)}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cost`),field:`cost`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokens`),field:`tokens`}),(0,C.jsx)(L,{label:`$/1M`,field:`costPerMillion`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.shareShort`),field:`share`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.req`),field:`requests`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.reqShare`),field:`requestShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.costPerReq`),field:`costPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.tokensPerReq`),field:`tokensPerRequest`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.cacheShare`),field:`cacheShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.thinkingShare`),field:`thinkingShare`}),(0,C.jsx)(L,{label:w(`tables.modelEfficiency.avgPerUnit`,{unit:o(n)}),field:`costPerDay`}),(0,C.jsx)(L,{label:s(n,!0),field:`days`})]})}),(0,C.jsx)(`tbody`,{children:M.map(e=>(0,C.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,C.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,C.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:m(e.name)}}),(0,C.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,C.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] leading-none font-medium`,d(p(e.name))),children:p(e.name)})]})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.cost,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.tokens,type:`tokens`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerMillion,type:`currency`})}),(0,C.jsxs)(`td`,{className:`relative px-3 py-2.5 text-right font-mono tabular-nums`,children:[(0,C.jsx)(`div`,{className:`absolute inset-y-1 left-0 rounded-sm transition-all duration-500`,style:{width:`${e.share}%`,backgroundColor:f(e.name,.16)}}),(0,C.jsx)(`span`,{className:`relative`,children:l(e.share)})]}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.requestShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerRequest,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokensPerRequest)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.thinkingShare,1)}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,C.jsx)(y,{value:e.costPerDay,type:`currency`})}),(0,C.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:e.days})]},e.name))})]})})]})]})}export{w as ModelEfficiency};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,n as o,v as s,w as c}from"./charts-vendor-CiBqdKXh.js";import{a as l}from"./motion-vendor-vKc6gXHZ.js";import{t as u}from"./useTranslation-BSl7t2D6.js";import{a as d,t as f,u as p}from"./formatters-yKppUXb3.js";import{c as m,t as h}from"./model-utils-BIvGAFGz.js";import{t as g}from"./help-content-Bt5KCpWS.js";import{n as _,r as v,t as y}from"./ChartCard-CBUnItl-.js";import{n as b,r as x,t as S}from"./chart-theme-D5iCFDJg.js";var C=e(c()),w=l();function T({active:e,payload:t,label:n}){if(!e||!t?.length)return null;let r=[...t].sort((e,t)=>t.value-e.value);return(0,w.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,w.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:n}),(0,w.jsx)(`div`,{className:`space-y-1`,children:r.map((e,t)=>(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,w.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:p(e.value)})]},t))})]})}function E({data:e}){let{t:c}=u(),{chartData:l,models:E}=(0,C.useMemo)(()=>{let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=new Set;for(let e of t)for(let t of e.modelBreakdowns)n.add(m(t.modelName));let r=Array.from(n).sort();return{chartData:t.map(e=>{let t=e.totalCost,n={date:e.date},i={};for(let t of e.modelBreakdowns){let e=m(t.modelName);i[e]=(i[e]??0)+t.cost}for(let e of r)n[e]=t>0?(i[e]??0)/t*100:0;return n}),models:r}},[e]);return l.length<3||E.length<2?null:(0,w.jsx)(_,{title:c(`charts.modelMix.title`),subtitle:c(`charts.modelMix.subtitle`),info:g.modelMix,children:(0,w.jsx)(y,{children:e=>(0,w.jsx)(v,{variant:`line`,children:(0,w.jsx)(t,{width:`100%`,height:250,children:(0,w.jsxs)(o,{data:l,margin:x,stackOffset:`none`,children:[(0,w.jsx)(`defs`,{children:E.map(e=>{let t=h(e),n=`mix-grad-${e.replace(/[\s.]/g,`-`)}`;return(0,w.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,w.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.85}),(0,w.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:.45})]},n)})}),(0,w.jsx)(a,{strokeDasharray:`3 3`,stroke:b.grid,opacity:.3}),(0,w.jsx)(i,{dataKey:`date`,tickFormatter:d,stroke:b.axis,fontSize:11,tickLine:!1}),(0,w.jsx)(n,{tickFormatter:e=>{let t=f(e);return t===null?``:p(Math.round(t),0)},stroke:b.axis,fontSize:11,tickLine:!1,axisLine:!1,domain:[0,100],ticks:[0,25,50,75,100]}),(0,w.jsx)(s,{content:(0,w.jsx)(T,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),E.map((t,n)=>(0,w.jsx)(r,{type:`monotone`,dataKey:t,stackId:`1`,stroke:h(t),strokeWidth:.5,strokeOpacity:.6,fill:`url(#${`mix-grad-${t.replace(/[\s.]/g,`-`)}`})`,name:t,isAnimationActive:e,animationBegin:S.stagger*(n%5),animationDuration:S.duration,animationEasing:S.easing},t))]})})})})})}export{E as ModelMix};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,l as i,m as a,n as o,v as s,w as c}from"./charts-vendor-CiBqdKXh.js";import{a as l}from"./motion-vendor-BNVN-Ktr.js";import{t as u}from"./useTranslation-0ThAx3Gl.js";import{a as d,t as f,u as p}from"./formatters-C7EouP6y.js";import{c as m,t as h}from"./model-utils-BIvGAFGz.js";import{t as g}from"./help-content-B2N8SHIE.js";import{i as _,n as v,r as y}from"./chart-theme-BdE8bEiN.js";import{n as b,r as x,t as S}from"./ChartCard-DxxB4rGm.js";var C=e(c()),w=l();function T({active:e,payload:t,label:n}){if(!e||!t?.length)return null;let r=[...t].sort((e,t)=>t.value-e.value);return(0,w.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-popover/90 p-3 text-xs shadow-lg backdrop-blur-xl`,children:[(0,w.jsx)(`p`,{className:`mb-1.5 font-medium text-muted-foreground`,children:n}),(0,w.jsx)(`div`,{className:`space-y-1`,children:r.map((e,t)=>(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full`,style:{backgroundColor:e.color}}),(0,w.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.name,`:`]}),(0,w.jsx)(`span`,{className:`ml-auto font-mono font-medium text-foreground`,children:p(e.value)})]},t))})]})}function E({data:e}){let{t:c}=u(),{chartData:l,models:E}=(0,C.useMemo)(()=>{let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=new Set;for(let e of t)for(let t of e.modelBreakdowns)n.add(m(t.modelName));let r=Array.from(n).sort();return{chartData:t.map(e=>{let t=e.totalCost,n={date:e.date},i={};for(let t of e.modelBreakdowns){let e=m(t.modelName);i[e]=(i[e]??0)+t.cost}for(let e of r)n[e]=t>0?(i[e]??0)/t*100:0;return n}),models:r}},[e]);return l.length<3||E.length<2?null:(0,w.jsx)(b,{title:c(`charts.modelMix.title`),subtitle:c(`charts.modelMix.subtitle`),info:g.modelMix,children:(0,w.jsx)(S,{children:e=>(0,w.jsx)(x,{variant:`line`,children:(0,w.jsx)(t,{width:`100%`,height:250,children:(0,w.jsxs)(o,{data:l,margin:y,stackOffset:`none`,children:[(0,w.jsx)(`defs`,{children:E.map(e=>{let t=h(e),n=`mix-grad-${e.replace(/[\s.]/g,`-`)}`;return(0,w.jsxs)(`linearGradient`,{id:n,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,w.jsx)(`stop`,{offset:`0%`,stopColor:t,stopOpacity:.85}),(0,w.jsx)(`stop`,{offset:`100%`,stopColor:t,stopOpacity:.45})]},n)})}),(0,w.jsx)(a,{strokeDasharray:`3 3`,stroke:v.grid,opacity:.3}),(0,w.jsx)(i,{dataKey:`date`,tickFormatter:d,stroke:v.axis,fontSize:11,tickLine:!1}),(0,w.jsx)(n,{tickFormatter:e=>{let t=f(e);return t===null?``:p(Math.round(t),0)},stroke:v.axis,fontSize:11,tickLine:!1,axisLine:!1,domain:[0,100],ticks:[0,25,50,75,100]}),(0,w.jsx)(s,{content:(0,w.jsx)(T,{}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),E.map((t,n)=>(0,w.jsx)(r,{type:`monotone`,dataKey:t,stackId:`1`,stroke:h(t),strokeWidth:.5,strokeOpacity:.6,fill:`url(#${`mix-grad-${t.replace(/[\s.]/g,`-`)}`})`,name:t,..._(e,{order:n%5,role:`stacked`})},t))]})})})})})}export{E as ModelMix};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{t as r}from"./useTranslation-BSl7t2D6.js";import{d as i,n as a,u as o}from"./formatters-yKppUXb3.js";import{nt as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-D--hHeVj.js";import{a as l,i as u,n as d,t as f}from"./card-h-Z9EWBl.js";import{t as p}from"./help-content-Bt5KCpWS.js";import{t as m}from"./InfoHeading-oi90uCR7.js";import{i as h}from"./calculations-GOdNqKo6.js";var g=e(t()),_=n();function v(e,t,n=!1){if(t===0&&e===0)return{value:0,color:`text-muted-foreground`,arrow:``,hasData:!1};if(t===0)return{value:0,color:`text-muted-foreground`,arrow:`↑`,hasData:!1};let r=(e-t)/t*100;return{value:Math.abs(r),color:r===0?`text-muted-foreground`:r>0===n?`text-green-400`:`text-red-400`,arrow:r>0?`↑`:r<0?`↓`:``,hasData:!0}}function y({data:e}){let{t}=r(),[n,y]=(0,g.useState)(`week`),{periodA:b,periodB:x,labelA:S,labelB:C}=(0,g.useMemo)(()=>{let r=[...e].sort((e,t)=>e.date.localeCompare(t.date));if(r.length===0)return{periodA:[],periodB:[],labelA:``,labelB:``};let i=r[r.length-1];if(!i)return{periodA:[],periodB:[],labelA:``,labelB:``};let a=i.date,o=new Date(a+`T00:00:00`),s=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(n===`week`){let e=o.getDay(),n=e===0?6:e-1,i=new Date(o);i.setDate(i.getDate()-n);let c=new Date(i);c.setDate(c.getDate()-7);let l=new Date(i);l.setDate(l.getDate()-1);let u=s(i),d=s(c);return{periodA:r.filter(e=>e.date>=u&&e.date<=a),periodB:r.filter(e=>e.date>=d&&e.date<u),labelA:t(`comparison.thisWeek`),labelB:t(`comparison.lastWeek`)}}let c=a.slice(0,7),l=new Date(o);l.setDate(1),l.setMonth(l.getMonth()-1);let u=s(l).slice(0,7);return{periodA:r.filter(e=>e.date.startsWith(c)),periodB:r.filter(e=>e.date.startsWith(u)),labelA:t(`comparison.thisMonth`),labelB:t(`comparison.lastMonth`)}},[e,n,t]),w=(0,g.useMemo)(()=>h(b),[b]),T=(0,g.useMemo)(()=>h(x),[x]);if(e.length<7)return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})})}),(0,_.jsx)(d,{children:(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`comparison.notEnoughData`)}),(0,_.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:t(`comparison.requiresDays`,{count:e.length})})]})})]});let E=x.length>0,D=e=>E?e:`–`,O=[{label:t(`comparison.cost`),a:a(w.totalCost),b:D(a(T.totalCost)),delta:v(w.totalCost,T.totalCost)},{label:t(`comparison.tokens`),a:i(w.totalTokens),b:D(i(T.totalTokens)),delta:v(w.totalTokens,T.totalTokens)},{label:`$/1M`,a:`$${w.costPerMillion.toFixed(2)}`,b:D(`$${T.costPerMillion.toFixed(2)}`),delta:v(w.costPerMillion,T.costPerMillion)},{label:t(`comparison.avgPerDay`),a:a(w.avgDailyCost),b:D(a(T.avgDailyCost)),delta:v(w.avgDailyCost,T.avgDailyCost)},{label:t(`comparison.cacheRate`),a:o(w.cacheHitRate),b:D(o(T.cacheHitRate)),delta:v(w.cacheHitRate,T.cacheHitRate,!0)},{label:t(`comparison.days`),a:String(w.activeDays),b:D(String(T.activeDays)),delta:v(w.activeDays,T.activeDays)}];return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})}),(0,_.jsxs)(`div`,{className:`flex gap-1`,children:[(0,_.jsx)(c,{variant:n===`week`?`default`:`outline`,size:`sm`,onClick:()=>y(`week`),className:`h-7 text-xs`,children:t(`comparison.week`)}),(0,_.jsx)(c,{variant:n===`month`?`default`:`outline`,size:`sm`,onClick:()=>y(`month`),className:`h-7 text-xs`,children:t(`comparison.month`)})]})]})}),(0,_.jsx)(d,{children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,_.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:t(`comparison.metric`)}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:C}),(0,_.jsx)(`th`,{className:`w-8 px-2 py-2 text-center text-xs text-muted-foreground`}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:S}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground`,children:t(`comparison.delta`)})]})}),(0,_.jsx)(`tbody`,{children:O.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-border/50`,children:[(0,_.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.label}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono`,children:e.b}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,_.jsx)(s,{className:`inline h-3 w-3 text-muted-foreground`})}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono font-medium`,children:e.a}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right`,children:e.delta.hasData?(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-mono text-xs font-medium ${e.delta.color} ${e.delta.color===`text-red-400`?`bg-red-400/10`:e.delta.color===`text-green-400`?`bg-green-400/10`:``}`,children:[e.delta.arrow,o(e.delta.value)]}):`–`})]},e.label))})]})})})]})}export{y as PeriodComparison};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{t as r}from"./useTranslation-0ThAx3Gl.js";import{d as i,n as a,u as o}from"./formatters-C7EouP6y.js";import{nt as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-CRvPoJg9.js";import{a as l,i as u,n as d,t as f}from"./card-B4CVYJDH.js";import{t as p}from"./help-content-B2N8SHIE.js";import{t as m}from"./InfoHeading-BxLyydv8.js";import{i as h}from"./calculations-BJw_4KdI.js";var g=e(t()),_=n();function v(e,t,n=!1){if(t===0&&e===0)return{value:0,color:`text-muted-foreground`,arrow:``,hasData:!1};if(t===0)return{value:0,color:`text-muted-foreground`,arrow:`↑`,hasData:!1};let r=(e-t)/t*100;return{value:Math.abs(r),color:r===0?`text-muted-foreground`:r>0===n?`text-green-400`:`text-red-400`,arrow:r>0?`↑`:r<0?`↓`:``,hasData:!0}}function y({data:e}){let{t}=r(),[n,y]=(0,g.useState)(`week`),{periodA:b,periodB:x,labelA:S,labelB:C}=(0,g.useMemo)(()=>{let r=[...e].sort((e,t)=>e.date.localeCompare(t.date));if(r.length===0)return{periodA:[],periodB:[],labelA:``,labelB:``};let i=r[r.length-1];if(!i)return{periodA:[],periodB:[],labelA:``,labelB:``};let a=i.date,o=new Date(a+`T00:00:00`),s=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;if(n===`week`){let e=o.getDay(),n=e===0?6:e-1,i=new Date(o);i.setDate(i.getDate()-n);let c=new Date(i);c.setDate(c.getDate()-7);let l=new Date(i);l.setDate(l.getDate()-1);let u=s(i),d=s(c);return{periodA:r.filter(e=>e.date>=u&&e.date<=a),periodB:r.filter(e=>e.date>=d&&e.date<u),labelA:t(`comparison.thisWeek`),labelB:t(`comparison.lastWeek`)}}let c=a.slice(0,7),l=new Date(o);l.setDate(1),l.setMonth(l.getMonth()-1);let u=s(l).slice(0,7);return{periodA:r.filter(e=>e.date.startsWith(c)),periodB:r.filter(e=>e.date.startsWith(u)),labelA:t(`comparison.thisMonth`),labelB:t(`comparison.lastMonth`)}},[e,n,t]),w=(0,g.useMemo)(()=>h(b),[b]),T=(0,g.useMemo)(()=>h(x),[x]);if(e.length<7)return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})})}),(0,_.jsx)(d,{children:(0,_.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`comparison.notEnoughData`)}),(0,_.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:t(`comparison.requiresDays`,{count:e.length})})]})})]});let E=x.length>0,D=e=>E?e:`–`,O=[{label:t(`comparison.cost`),a:a(w.totalCost),b:D(a(T.totalCost)),delta:v(w.totalCost,T.totalCost)},{label:t(`comparison.tokens`),a:i(w.totalTokens),b:D(i(T.totalTokens)),delta:v(w.totalTokens,T.totalTokens)},{label:`$/1M`,a:`$${w.costPerMillion.toFixed(2)}`,b:D(`$${T.costPerMillion.toFixed(2)}`),delta:v(w.costPerMillion,T.costPerMillion)},{label:t(`comparison.avgPerDay`),a:a(w.avgDailyCost),b:D(a(T.avgDailyCost)),delta:v(w.avgDailyCost,T.avgDailyCost)},{label:t(`comparison.cacheRate`),a:o(w.cacheHitRate),b:D(o(T.cacheHitRate)),delta:v(w.cacheHitRate,T.cacheHitRate,!0)},{label:t(`comparison.days`),a:String(w.activeDays),b:D(String(T.activeDays)),delta:v(w.activeDays,T.activeDays)}];return(0,_.jsxs)(f,{children:[(0,_.jsx)(u,{className:`pb-2`,children:(0,_.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,_.jsx)(m,{info:p.periodComparison,children:(0,_.jsx)(l,{className:`text-sm font-medium text-muted-foreground`,children:t(`comparison.title`)})}),(0,_.jsxs)(`div`,{className:`flex gap-1`,children:[(0,_.jsx)(c,{variant:n===`week`?`default`:`outline`,size:`sm`,onClick:()=>y(`week`),className:`h-7 text-xs`,children:t(`comparison.week`)}),(0,_.jsx)(c,{variant:n===`month`?`default`:`outline`,size:`sm`,onClick:()=>y(`month`),className:`h-7 text-xs`,children:t(`comparison.month`)})]})]})}),(0,_.jsx)(d,{children:(0,_.jsx)(`div`,{className:`overflow-x-auto`,children:(0,_.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,_.jsx)(`thead`,{children:(0,_.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,_.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:t(`comparison.metric`)}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:C}),(0,_.jsx)(`th`,{className:`w-8 px-2 py-2 text-center text-xs text-muted-foreground`}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-primary`,children:S}),(0,_.jsx)(`th`,{className:`px-2 py-2 text-right text-xs font-medium text-muted-foreground`,children:t(`comparison.delta`)})]})}),(0,_.jsx)(`tbody`,{children:O.map(e=>(0,_.jsxs)(`tr`,{className:`border-b border-border/50`,children:[(0,_.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.label}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono`,children:e.b}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-center`,children:(0,_.jsx)(s,{className:`inline h-3 w-3 text-muted-foreground`})}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right font-mono font-medium`,children:e.a}),(0,_.jsx)(`td`,{className:`px-2 py-2 text-right`,children:e.delta.hasData?(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-mono text-xs font-medium ${e.delta.color} ${e.delta.color===`text-red-400`?`bg-red-400/10`:e.delta.color===`text-green-400`?`bg-green-400/10`:``}`,children:[e.delta.arrow,o(e.delta.value)]}):`–`})]},e.label))})]})})})]})}export{y as PeriodComparison};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-vKc6gXHZ.js";import{a as r,t as i}from"./useTranslation-BSl7t2D6.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-yKppUXb3.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d}from"./model-utils-BIvGAFGz.js";import{a as f,i as p,n as m,t as h}from"./card-h-Z9EWBl.js";import{t as g}from"./formatted-value-rO0EpKbc.js";import{n as _}from"./help-content-Bt5KCpWS.js";import{t as v}from"./InfoHeading-oi90uCR7.js";var y=e(t()),b=n();function x({providerMetrics:e,totalCost:t,viewMode:n=`daily`}){let{t:x}=i(),[S,C]=(0,y.useState)(`cost`),[w,T]=(0,y.useState)(!1),E=(0,y.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,...n,share:t>0?n.cost/t*100:0,costPerRequest:n.requests>0?n.cost/n.requests:0,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,cacheShare:n.tokens>0?n.cacheRead/n.tokens*100:0})),[e,t]),D=(0,y.useMemo)(()=>[...E].sort((e,t)=>{let n=e[S]-t[S];return w?n:-n}),[E,w,S]),O=D[0]??null,k=(0,y.useMemo)(()=>[...E].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[E]),A=(0,y.useMemo)(()=>E.reduce((e,t)=>e+t.requests,0),[E]),j=e=>{S===e?T(!w):(C(e),T(!1))},M=e=>S===e?w?`ascending`:`descending`:`none`,N=({label:e,field:t})=>(0,b.jsx)(`th`,{"aria-sort":M(t),className:r(`px-3 py-2 text-right text-xs font-medium`,S===t?`text-foreground`:`text-muted-foreground`),children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>j(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,b.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,S===t&&`text-primary`)})]})});return(0,b.jsxs)(h,{children:[(0,b.jsxs)(p,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(v,{info:_.providerEfficiency,children:(0,b.jsx)(f,{className:`text-sm font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.title`)})}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.count`,{count:E.length})})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.leadProvider`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?x(`tables.providerEfficiency.share`,{value:l(O.share,0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.mostEfficient`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:k?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k?`${k.costPerMillion.toFixed(2)} $/1M`:`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.totalRequests`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:E.length>0?x(`tables.providerEfficiency.perProvider`,{value:(A/E.length).toFixed(0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.avgPerUnit`,{unit:o(n)})}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?(0,b.jsx)(g,{value:O.cost/Math.max(O.days,1),type:`currency`}):`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?`${O.days} ${s(n,!0)}`:`–`})]})]})]}),(0,b.jsxs)(m,{children:[(0,b.jsx)(`div`,{className:`mb-4 grid gap-2 md:hidden`,children:D.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name}),(0,b.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.share`,{value:l(e.share,1)})})]}),(0,b.jsxs)(`div`,{className:`text-right`,children:[(0,b.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[c(e.requests),` `,x(`tables.providerEfficiency.req`)]})]})]}),(0,b.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.tokens`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerReq`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerMillion`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.cacheShare`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,b.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,b.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.provider`)}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cost`),field:`cost`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.shareShort`),field:`share`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.req`),field:`requests`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.tokens`),field:`tokens`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerReq`),field:`costPerRequest`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerMillion`),field:`costPerMillion`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cacheShare`),field:`cacheShare`})]})}),(0,b.jsx)(`tbody`,{children:D.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,b.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.share,1)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokens)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)})]},e.name))})]})})]})]})}export{x as ProviderEfficiency};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{a as n}from"./motion-vendor-BNVN-Ktr.js";import{o as r,t as i}from"./useTranslation-0ThAx3Gl.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-C7EouP6y.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{i as d}from"./model-utils-BIvGAFGz.js";import{a as f,i as p,n as m,t as h}from"./card-B4CVYJDH.js";import{t as g}from"./formatted-value-CpLoDrYF.js";import{n as _}from"./help-content-B2N8SHIE.js";import{t as v}from"./InfoHeading-BxLyydv8.js";var y=e(t()),b=n();function x({providerMetrics:e,totalCost:t,viewMode:n=`daily`}){let{t:x}=i(),[S,C]=(0,y.useState)(`cost`),[w,T]=(0,y.useState)(!1),E=(0,y.useMemo)(()=>Array.from(e.entries()).map(([e,n])=>({name:e,...n,share:t>0?n.cost/t*100:0,costPerRequest:n.requests>0?n.cost/n.requests:0,costPerMillion:n.tokens>0?n.cost/(n.tokens/1e6):0,cacheShare:n.tokens>0?n.cacheRead/n.tokens*100:0})),[e,t]),D=(0,y.useMemo)(()=>[...E].sort((e,t)=>{let n=e[S]-t[S];return w?n:-n}),[E,w,S]),O=D[0]??null,k=(0,y.useMemo)(()=>[...E].filter(e=>e.tokens>0).sort((e,t)=>e.costPerMillion-t.costPerMillion)[0]??null,[E]),A=(0,y.useMemo)(()=>E.reduce((e,t)=>e+t.requests,0),[E]),j=e=>{S===e?T(!w):(C(e),T(!1))},M=e=>S===e?w?`ascending`:`descending`:`none`,N=({label:e,field:t})=>(0,b.jsx)(`th`,{"aria-sort":M(t),className:r(`px-3 py-2 text-right text-xs font-medium`,S===t?`text-foreground`:`text-muted-foreground`),children:(0,b.jsxs)(`button`,{type:`button`,onClick:()=>j(t),className:`inline-flex items-center gap-1 rounded-sm transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[e,(0,b.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,S===t&&`text-primary`)})]})});return(0,b.jsxs)(h,{children:[(0,b.jsxs)(p,{children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,b.jsx)(v,{info:_.providerEfficiency,children:(0,b.jsx)(f,{className:`text-sm font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.title`)})}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.count`,{count:E.length})})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 lg:grid-cols-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.leadProvider`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?x(`tables.providerEfficiency.share`,{value:l(O.share,0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.mostEfficient`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:k?.name??`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:k?`${k.costPerMillion.toFixed(2)} $/1M`:`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.totalRequests`)}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:c(A)}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:E.length>0?x(`tables.providerEfficiency.perProvider`,{value:(A/E.length).toFixed(0)}):`–`})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,b.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:x(`tables.providerEfficiency.avgPerUnit`,{unit:o(n)})}),(0,b.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:O?(0,b.jsx)(g,{value:O.cost/Math.max(O.days,1),type:`currency`}):`–`}),(0,b.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O?`${O.days} ${s(n,!0)}`:`–`})]})]})]}),(0,b.jsxs)(m,{children:[(0,b.jsx)(`div`,{className:`mb-4 grid gap-2 md:hidden`,children:D.map(e=>(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/10 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name}),(0,b.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:x(`tables.providerEfficiency.share`,{value:l(e.share,1)})})]}),(0,b.jsxs)(`div`,{className:`text-right`,children:[(0,b.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[c(e.requests),` `,x(`tables.providerEfficiency.req`)]})]})]}),(0,b.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.tokens`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:a(e.tokens)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerReq`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.costPerMillion`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})})]}),(0,b.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,b.jsx)(`div`,{className:`text-muted-foreground`,children:x(`tables.providerEfficiency.cacheShare`)}),(0,b.jsx)(`div`,{className:`mt-1 font-mono`,children:l(e.cacheShare,1)})]})]})]},e.name))}),(0,b.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,b.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,b.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:x(`tables.providerEfficiency.provider`)}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cost`),field:`cost`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.shareShort`),field:`share`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.req`),field:`requests`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.tokens`),field:`tokens`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerReq`),field:`costPerRequest`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.costPerMillion`),field:`costPerMillion`}),(0,b.jsx)(N,{label:x(`tables.providerEfficiency.cacheShare`),field:`cacheShare`})]})}),(0,b.jsx)(`tbody`,{children:D.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors even:bg-muted/5 hover:bg-muted/10`,children:[(0,b.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,b.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2 py-1 text-xs leading-none font-medium`,d(e.name)),children:e.name})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.cost,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.share,1)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:c(e.requests)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:a(e.tokens)}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerRequest,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:(0,b.jsx)(g,{value:e.costPerMillion,type:`currency`})}),(0,b.jsx)(`td`,{className:`px-3 py-2.5 text-right font-mono tabular-nums`,children:l(e.cacheShare,1)})]},e.name))})]})})]})]})}export{x as ProviderEfficiency};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{b as t,c as n,f as r,h as i,l as a,m as o,p as s,t as c,v as l,w as u,y as d}from"./charts-vendor-CiBqdKXh.js";import{a as f}from"./motion-vendor-BNVN-Ktr.js";import{t as p}from"./useTranslation-0ThAx3Gl.js";import{c as m,n as h,r as g,t as _}from"./formatters-C7EouP6y.js";import{i as v}from"./i18n-BS3-GJaA.js";import{L as y,a as b,i as x,m as S}from"./icons-vendor-CIvT_-Pb.js";import{a as C}from"./model-utils-BIvGAFGz.js";import{c as w,n as T,t as E}from"./card-B4CVYJDH.js";import{i as D,t as O}from"./help-content-B2N8SHIE.js";import{t as k}from"./section-header-Dz0QIE6e.js";import{i as A,n as j,o as M,r as N}from"./chart-theme-BdE8bEiN.js";import{n as P,r as F,t as I}from"./ChartCard-DxxB4rGm.js";import{t as L}from"./ChartLegend-Vpk95i3r.js";import{t as R}from"./AnimatedBarFill-DFAXO-3i.js";import{n as z,r as B}from"./provider-limits-BgKrr7k7.js";var V=e(u()),H=f();function U(e){return e.riskStatus===`limit`?v.t(`limits.statuses.limitExceeded`):e.riskStatus===`warning`?v.t(`limits.statuses.budgetTight`):e.riskStatus===`ok`?v.t(`limits.statuses.budgetStable`):v.t(`limits.statuses.noLimit`)}function W(e){return e.hasSubscription?e.subscriptionStatus===`gain`?v.t(`limits.statuses.subscriptionPaysOff`):v.t(`limits.statuses.belowSubscription`):v.t(`limits.statuses.noSubscription`)}function G(e,t){return e.monthlyLimit>0?v.t(`limits.badge.limit`,{value:e.utilization?.toFixed(0)??`0`}):e.hasSubscription?v.t(`limits.badge.subscription`,{value:Math.min(t,999).toFixed(0)}):v.t(`limits.badge.open`)}function K(e){let t=Number(Array.isArray(e)?e[0]??0:e??0);return Number.isFinite(t)?t:0}function q({data:e,providers:u,limits:f,selectedMonth:v}){let{t:q}=p(),{rows:J,focusMonth:Y,timelineData:X,atLimitCount:Z,nearLimitCount:Q,subscriptionTotal:$,subscriptionGainTotal:ee}=(0,V.useMemo)(()=>{let{months:t,monthMap:n,providerTotals:r}=z(e),i=B(e),a=v??i,o=u.map(e=>{let t=f[e],i=a?n.get(a)?.get(e)??0:0,o=r.get(e)??0,s=t?.monthlyLimit??0,c=!!t?.hasSubscription,l=c?t?.subscriptionPrice??0:0,u=s>0?Math.max(i-s,0):0,d=s>0?Math.max(s-i,0):null,p=s>0?i/s*100:null,m=c?i-l:null,h=m===null?0:Math.max(m,0),g=m===null?0:Math.max(-m,0),_=`none`;return s>0&&i>=s?_=`limit`:s>0&&i>=s*.8?_=`warning`:s>0&&(_=`ok`),{provider:e,cost:i,totalCost:o,monthlyLimit:s,subscriptionPrice:l,hasSubscription:c,remaining:d,overrun:u,utilization:p,subscriptionDelta:m,subscriptionGain:h,subscriptionGap:g,riskStatus:_,subscriptionStatus:c?h>0?`gain`:`gap`:`none`}}).sort((e,t)=>e.riskStatus===`limit`&&t.riskStatus!==`limit`?-1:e.riskStatus!==`limit`&&t.riskStatus===`limit`?1:e.subscriptionStatus===`gain`&&t.subscriptionStatus!==`gain`?-1:e.subscriptionStatus!==`gain`&&t.subscriptionStatus===`gain`?1:t.cost-e.cost);return{rows:o,focusMonth:a,timelineData:t.map(e=>{let t=n.get(e)??new Map,r=u.reduce((e,n)=>e+(t.get(n)??0),0),i=u.reduce((e,t)=>{let n=f[t]?.monthlyLimit??0;return e+(n>0?n:0)},0),a=u.reduce((e,t)=>{let n=f[t];return e+(n?.hasSubscription?n.subscriptionPrice:0)},0),o=u.reduce((e,n)=>{let r=f[n]?.monthlyLimit??0,i=t.get(n)??0;return e+(r>0?Math.max(i-r,0):0)},0),s=u.reduce((e,n)=>{let r=f[n],i=t.get(n)??0,a=r?.hasSubscription?r.subscriptionPrice:0;return e+Math.max(i-a,0)},0),c=u.reduce((e,n)=>{let r=f[n],i=t.get(n)??0,a=r?.hasSubscription?r.subscriptionPrice:0;return e+(r?.hasSubscription?Math.max(a-i,0):0)},0);return{month:e,totalCost:r,totalLimit:i>0?i:null,totalSubscriptions:a>0?a:null,totalOverrun:o,totalSubscriptionGain:s,totalSubscriptionGap:c}}),atLimitCount:o.filter(e=>e.riskStatus===`limit`).length,nearLimitCount:o.filter(e=>e.riskStatus===`warning`).length,subscriptionTotal:o.reduce((e,t)=>e+t.subscriptionPrice,0),subscriptionGainTotal:o.reduce((e,t)=>e+t.subscriptionGain,0)}},[e,f,u,v]);return u.length===0?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(k,{title:q(`limits.sectionTitle`),badge:q(`limits.providersBadge`,{count:u.length}),description:q(`limits.sectionDescription`),info:D.limits}),Z>0&&(0,H.jsx)(w,{className:`mb-4 rounded-2xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-100`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,H.jsx)(x,{className:`h-4 w-4`}),q(`limits.warningBanner`,{count:Z})]})}),(0,H.jsx)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-4`,children:[{label:q(`limits.cards.atLimit`),value:String(Z),hint:Y?m(Y):q(`limits.cards.noMonth`),icon:(0,H.jsx)(x,{className:`h-4 w-4`})},{label:q(`limits.cards.nearLimit`),value:String(Q),hint:q(`limits.cards.nearLimitHint`),icon:(0,H.jsx)(S,{className:`h-4 w-4`})},{label:q(`limits.cards.subscriptionVolume`),value:h($),hint:q(`limits.cards.subscriptionVolumeHint`),icon:(0,H.jsx)(y,{className:`h-4 w-4`})},{label:q(`limits.cards.subscriptionValue`),value:h(ee),hint:q(`limits.cards.subscriptionValueHint`),icon:(0,H.jsx)(b,{className:`h-4 w-4`})}].map((e,t)=>(0,H.jsx)(w,{order:t,children:(0,H.jsx)(E,{className:`h-full`,children:(0,H.jsx)(T,{className:`p-4`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e.label}),(0,H.jsx)(`div`,{className:`mt-1 text-2xl font-semibold tabular-nums`,children:e.value}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hint})]}),(0,H.jsx)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 p-2 text-muted-foreground`,children:e.icon})]})})})},e.label))}),(0,H.jsx)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:J.map((e,t)=>{let n=C(e.provider),r=e.monthlyLimit>0?Math.min(e.cost/e.monthlyLimit*100,100):0,i=e.hasSubscription&&e.subscriptionPrice>0?e.cost/e.subscriptionPrice*100:0,a=Math.min(i,100);return(0,H.jsx)(w,{delayMs:80+t*35,children:(0,H.jsx)(E,{className:e.riskStatus===`limit`?`border-red-500/40 bg-red-500/[0.06]`:e.subscriptionStatus===`gain`?`border-emerald-500/30 bg-emerald-500/[0.05]`:void 0,children:(0,H.jsxs)(T,{className:`p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:U(e)}),(0,H.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground/80`,children:W(e)})]}),(0,H.jsx)(`div`,{className:`rounded-full border px-2.5 py-1 text-[11px] font-medium`,style:n,children:G(e,i)})]}),(0,H.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:q(`limits.tracks.usageFocusMonth`)}),(0,H.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:h(e.cost)})]}),(0,H.jsxs)(`div`,{className:`text-right`,children:[(0,H.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:q(`limits.tracks.limitSubscription`)}),(0,H.jsxs)(`div`,{className:`mt-1 text-sm font-medium tabular-nums`,children:[e.monthlyLimit>0?h(e.monthlyLimit):q(`limits.statuses.noLimit`),` `,`/ `,e.hasSubscription?h(e.subscriptionPrice):`–`]})]})]}),(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:q(`limits.tracks.budgetRisk`)}),(0,H.jsx)(`span`,{children:e.monthlyLimit>0?e.overrun>0?`+${h(e.overrun)}`:h(e.remaining??0):q(`limits.statuses.noLimit`)})]}),(0,H.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.monthlyLimit>0?(0,H.jsx)(R,{className:e.riskStatus===`limit`?`h-full bg-red-400`:e.riskStatus===`warning`?`h-full bg-amber-400`:`h-full`,width:`${r}%`,order:t*2,...e.riskStatus===`limit`||e.riskStatus===`warning`?{}:{style:{backgroundColor:n.color}}}):(0,H.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:q(`limits.tracks.subscriptionEffect`)}),(0,H.jsx)(`span`,{className:e.subscriptionStatus===`gain`?`text-emerald-300`:e.subscriptionStatus===`gap`?`text-amber-200`:``,children:e.hasSubscription?e.subscriptionStatus===`gain`?`+${h(e.subscriptionGain)}`:h(e.subscriptionGap):q(`limits.statuses.noSubscription`)})]}),(0,H.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-muted/30`,children:e.hasSubscription?(0,H.jsx)(R,{className:e.subscriptionStatus===`gain`?`h-full bg-emerald-400`:`h-full bg-amber-300`,width:`${a}%`,order:t*2+1}):(0,H.jsx)(`div`,{className:`h-full w-full bg-muted/20`})})]})]})]})})},e.provider)})}),(0,H.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[(0,H.jsx)(P,{title:q(`limits.tracks.budgetTitle`),subtitle:q(Y?`limits.tracks.budgetSubtitle`:`limits.tracks.budgetNoMonth`),info:O.providerLimitProgress,chartData:J,valueKey:`cost`,valueFormatter:h,children:(0,H.jsx)(`div`,{className:`space-y-3`,children:J.map((e,t)=>{let n=(e.monthlyLimit>0?Math.max(e.monthlyLimit,e.cost,1):Math.max(e.cost,1))*1.15,r=`${e.cost/n*100}%`,i=e.monthlyLimit>0?`${e.monthlyLimit/n*100}%`:`0%`,a=e.monthlyLimit>0?`${Math.min(e.cost,e.monthlyLimit)/n*100}%`:r,o=e.monthlyLimit>0&&e.overrun>0?`${e.overrun/n*100}%`:`0%`;return(0,H.jsxs)(w,{delayMs:90+t*40,className:`rounded-xl border border-border/50 bg-muted/10 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.monthlyLimit<=0?q(`limits.statuses.noLimit`):e.overrun>0?q(`limits.tracks.alreadyAboveLimit`,{value:h(e.overrun)}):q(`limits.tracks.stillToLimit`,{value:h(e.remaining??0)})})]}),(0,H.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,H.jsxs)(`div`,{className:`text-muted-foreground`,children:[q(`limits.tracks.usage`),` `,h(e.cost)]}),(0,H.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[q(`limits.tracks.limit`),` `,e.monthlyLimit>0?h(e.monthlyLimit):`–`]})]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsxs)(`div`,{className:`relative h-14`,children:[(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.monthlyLimit>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`absolute top-5 left-0 h-4 rounded-l-full bg-sky-400/12`,style:{width:i}}),(0,H.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-red-400/12`,style:{left:i,width:`calc(100% - ${i})`}}),(0,H.jsx)(R,{className:e.riskStatus===`warning`?`absolute top-5 left-0 h-4 rounded-full bg-amber-400`:`absolute top-5 left-0 h-4 rounded-full bg-sky-400`,width:a,order:t*2}),e.overrun>0&&(0,H.jsx)(R,{className:`absolute top-5 h-4 rounded-r-full bg-red-400`,style:{left:i},width:o,order:t*2+1}),(0,H.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,H.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 rounded-full border border-border/70 bg-background px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,style:{left:i},children:q(`limits.tracks.limit`)})]}):(0,H.jsx)(R,{className:`absolute top-5 left-0 h-4 rounded-full bg-muted-foreground/40`,width:r,order:t*2}),(0,H.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,H.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:h(n)})]})}),(0,H.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.currentlyUsed`)}),(0,H.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:h(e.cost)})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.remainingToLimit`)}),(0,H.jsx)(`div`,{className:e.monthlyLimit>0&&e.overrun===0?`mt-1 font-medium text-sky-300`:`mt-1 font-medium text-muted-foreground`,children:e.monthlyLimit>0?e.overrun===0?h(e.remaining??0):`$0.00`:`–`})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.alreadyOverLimit`)}),(0,H.jsx)(`div`,{className:e.overrun>0?`mt-1 font-medium text-red-300`:`mt-1 font-medium text-muted-foreground`,children:e.monthlyLimit>0?e.overrun>0?h(e.overrun):`$0.00`:`–`})]})]})]},e.provider)})})}),(0,H.jsx)(P,{title:q(`limits.tracks.subscriptionTitle`),subtitle:q(Y?`limits.tracks.subscriptionSubtitle`:`limits.tracks.subscriptionNoMonth`),info:O.providerSubscriptionMix,chartData:J,valueKey:`cost`,valueFormatter:h,children:(0,H.jsx)(`div`,{className:`space-y-3`,children:J.map((e,t)=>{let n=(e.hasSubscription?Math.max(e.subscriptionPrice,e.cost,1):Math.max(e.cost,1))*1.15,r=`${e.cost/n*100}%`,i=e.hasSubscription?`${e.subscriptionPrice/n*100}%`:`0%`,a=e.hasSubscription?`${Math.min(e.cost,e.subscriptionPrice)/n*100}%`:r,o=e.hasSubscription&&e.subscriptionGain>0?`${e.subscriptionGain/n*100}%`:`0%`;return(0,H.jsxs)(w,{delayMs:90+t*40,className:`rounded-xl border border-border/50 bg-muted/10 p-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-semibold`,children:e.provider}),(0,H.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:e.hasSubscription?e.subscriptionStatus===`gain`?q(`limits.tracks.alreadyAboveBreakEvenText`,{value:h(e.subscriptionGain)}):q(`limits.tracks.stillToBreakEven`,{value:h(e.subscriptionGap)}):q(`limits.tracks.noSubscriptionSet`)})]}),(0,H.jsxs)(`div`,{className:`text-right text-xs`,children:[(0,H.jsxs)(`div`,{className:`text-muted-foreground`,children:[q(`limits.tracks.usage`),` `,h(e.cost)]}),(0,H.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[q(`limits.tracks.subscription`),` `,e.hasSubscription?h(e.subscriptionPrice):`–`]})]})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsxs)(`div`,{className:`relative h-14`,children:[(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-5 h-4 rounded-full bg-muted/25`}),e.hasSubscription?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`absolute top-5 left-0 h-4 rounded-l-full bg-amber-300/18`,style:{width:i}}),(0,H.jsx)(`div`,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400/14`,style:{left:i,width:`calc(100% - ${i})`}}),(0,H.jsx)(R,{className:`absolute top-5 left-0 h-4 rounded-full bg-amber-300`,width:a,order:t*2}),e.subscriptionGain>0&&(0,H.jsx)(R,{className:`absolute top-5 h-4 rounded-r-full bg-emerald-400`,style:{left:i},width:o,order:t*2+1}),(0,H.jsx)(`div`,{className:`absolute top-2 h-10 w-px bg-border`,style:{left:i}}),(0,H.jsx)(`div`,{className:`absolute top-0 -translate-x-1/2 rounded-full border border-border/70 bg-background px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,style:{left:i},children:q(`limits.tracks.breakEven`)})]}):(0,H.jsx)(R,{className:`absolute top-5 left-0 h-4 rounded-full bg-muted-foreground/40`,width:r,order:t*2}),(0,H.jsx)(`div`,{className:`absolute top-11 left-0 text-[10px] text-muted-foreground`,children:`$0`}),(0,H.jsx)(`div`,{className:`absolute top-11 right-0 text-[10px] text-muted-foreground`,children:h(n)})]})}),(0,H.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 text-xs md:grid-cols-3`,children:[(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.currentlyUsed`)}),(0,H.jsx)(`div`,{className:`mt-1 font-medium text-foreground`,children:h(e.cost)})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.remainingToBreakEven`)}),(0,H.jsx)(`div`,{className:e.hasSubscription&&e.subscriptionGap>0?`mt-1 font-medium text-amber-200`:`mt-1 font-medium text-muted-foreground`,children:e.hasSubscription?e.subscriptionGap>0?h(e.subscriptionGap):`$0.00`:`–`})]}),(0,H.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-background/40 px-3 py-2`,children:[(0,H.jsx)(`div`,{className:`text-muted-foreground`,children:q(`limits.tracks.alreadyAboveBreakEven`)}),(0,H.jsx)(`div`,{className:e.subscriptionGain>0?`mt-1 font-medium text-emerald-300`:`mt-1 font-medium text-muted-foreground`,children:e.hasSubscription?e.subscriptionGain>0?h(e.subscriptionGain):`$0.00`:`–`})]})]})]},e.provider)})})})]}),(0,H.jsx)(`div`,{className:`mt-4`,children:(0,H.jsx)(P,{title:q(`limits.tracks.portfolioTitle`),subtitle:q(`limits.tracks.portfolioSubtitle`),info:O.providerLimitTimeline,chartData:X,valueKey:`totalCost`,valueFormatter:h,children:(0,H.jsx)(I,{children:e=>(0,H.jsx)(F,{variant:`line`,children:(0,H.jsx)(t,{width:`100%`,height:320,children:(0,H.jsxs)(c,{data:X,margin:N,children:[(0,H.jsxs)(`defs`,{children:[(0,H.jsxs)(`linearGradient`,{id:`limits-risk-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,H.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(248 113 113)`,stopOpacity:.28}),(0,H.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(248 113 113)`,stopOpacity:0})]}),(0,H.jsxs)(`linearGradient`,{id:`limits-gain-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,H.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(74 222 128)`,stopOpacity:.28}),(0,H.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(74 222 128)`,stopOpacity:0})]})]}),(0,H.jsx)(o,{strokeDasharray:`3 3`,stroke:j.grid,opacity:.25}),(0,H.jsx)(a,{dataKey:`month`,tickFormatter:m,stroke:j.axis,fontSize:11,tickLine:!1}),(0,H.jsx)(n,{tickFormatter:e=>{let t=_(e);return t===null?``:h(Math.abs(t))},stroke:j.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,H.jsx)(l,{formatter:(e,t)=>[g(Math.abs(K(e))),t??``],labelFormatter:e=>m(String(e)),contentStyle:{borderRadius:12,borderColor:`hsl(var(--border))`,background:`color-mix(in srgb, hsl(var(--popover)) 90%, transparent)`}}),(0,H.jsx)(d,{content:(0,H.jsx)(L,{})}),(0,H.jsx)(i,{y:0,stroke:`hsl(var(--border))`,strokeDasharray:`4 4`}),(0,H.jsx)(r,{type:`monotone`,dataKey:`totalSubscriptionGain`,name:q(`limits.cards.subscriptionValue`),stroke:`rgb(74 222 128)`,fill:`url(#limits-gain-area)`,strokeWidth:2,...A(e)}),(0,H.jsx)(r,{type:`monotone`,dataKey:`totalOverrun`,name:q(`limits.tracks.alreadyOverLimit`),stroke:`rgb(248 113 113)`,fill:`url(#limits-risk-area)`,strokeWidth:2,...A(e,{order:1,role:`stacked`})}),(0,H.jsx)(s,{type:`monotone`,dataKey:`totalCost`,name:`${q(`limits.tracks.usage`)} ${q(`common.costs`).toLowerCase()}`,stroke:j.cost,strokeWidth:2,dot:!1,...M(e,{role:`secondary`})}),(0,H.jsx)(s,{type:`monotone`,dataKey:`totalLimit`,name:q(`limits.tracks.limits`),stroke:`rgb(251 146 60)`,strokeDasharray:`6 3`,strokeWidth:2,dot:!1,connectNulls:!0,...M(e,{order:1,role:`secondary`})}),(0,H.jsx)(s,{type:`monotone`,dataKey:`totalSubscriptions`,name:q(`limits.tracks.subscriptions`),stroke:`rgb(125 211 252)`,strokeDasharray:`3 3`,strokeWidth:2,dot:!1,connectNulls:!0,...M(e,{order:2,role:`secondary`})})]})})})})})})]})}export{q as ProviderLimitsSection};