@roastcodes/ttdash 6.2.0 → 6.2.2

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 (70) hide show
  1. package/dist/assets/AnimatedBarFill-Da354-1y.js +1 -0
  2. package/dist/assets/AnomalyDetection-D06kgR_V.js +1 -0
  3. package/dist/assets/{AutoImportModal-C8gA0_mL.js → AutoImportModal-CuzbrUVc.js} +3 -3
  4. package/dist/assets/CacheROI-fJ1paHaT.js +1 -0
  5. package/dist/assets/ChartCard-CS4Kbe6r.js +2 -0
  6. package/dist/assets/ChartLegend-Vzg_GmF-.js +1 -0
  7. package/dist/assets/CorrelationAnalysis-DX-ZQKVJ.js +1 -0
  8. package/dist/assets/CostByModelOverTime-BRo1PCRo.js +1 -0
  9. package/dist/assets/CostByWeekday-BJwEWkmF.js +1 -0
  10. package/dist/assets/CostForecast-BxICbpzM.js +1 -0
  11. package/dist/assets/CumulativeCost-BdlOTRDX.js +1 -0
  12. package/dist/assets/CustomTooltip-CEd8U-a3.js +1 -0
  13. package/dist/assets/DistributionAnalysis-Cw8bRtt9.js +1 -0
  14. package/dist/assets/DrillDownModal-BT2rFk_U.js +1 -0
  15. package/dist/assets/HelpPanel-Ct4CbfBg.js +1 -0
  16. package/dist/assets/InfoButton-CyA48Vlx.js +1 -0
  17. package/dist/assets/InfoHeading-CFbl45C9.js +1 -0
  18. package/dist/assets/MetricCard-CLFpH1l1.js +1 -0
  19. package/dist/assets/ModelEfficiency-CO7sQQnT.js +1 -0
  20. package/dist/assets/ModelMix-C4P2SpQZ.js +1 -0
  21. package/dist/assets/PeriodComparison-BogfA2IN.js +1 -0
  22. package/dist/assets/ProviderEfficiency-CY4HJ7Fy.js +1 -0
  23. package/dist/assets/ProviderLimitsSection-BcCrH2XG.js +1 -0
  24. package/dist/assets/RecentDays-K0Uzk7UU.js +1 -0
  25. package/dist/assets/RequestCacheHitRateByModel-8ip50S7V.js +1 -0
  26. package/dist/assets/RequestQuality-ByYXyzn8.js +1 -0
  27. package/dist/assets/RequestsOverTime-B4yB-x_5.js +1 -0
  28. package/dist/assets/SettingsModal-Badl8kHp.js +1 -0
  29. package/dist/assets/TokenEfficiency-Bhdj4v75.js +1 -0
  30. package/dist/assets/TokenTypes-CaVA8FXP.js +1 -0
  31. package/dist/assets/TokensOverTime-BA7W_OfG.js +1 -0
  32. package/dist/assets/app-settings-EFIYxqQU.js +1 -0
  33. package/dist/assets/button-olcuyddH.js +1 -0
  34. package/dist/assets/calculations-BJw_4KdI.js +1 -0
  35. package/dist/assets/card-CskYMXga.js +1 -0
  36. package/dist/assets/chart-theme-BdE8bEiN.js +1 -0
  37. package/dist/assets/constants-DOCA3QtR.js +1 -0
  38. package/dist/assets/dialog-D4LfH66U.js +1 -0
  39. package/dist/assets/formatted-value-DuGw8WPX.js +1 -0
  40. package/dist/assets/formatters-BzLLk0br.js +1 -0
  41. package/dist/assets/help-content-Cuf5l3_6.js +1 -0
  42. package/dist/assets/i18n-D1WJ4-W9.js +1 -0
  43. package/dist/assets/index-8kk0H-lQ.css +2 -0
  44. package/dist/assets/index-D6_2fCBR.js +3 -0
  45. package/dist/assets/model-utils-BIvGAFGz.js +1 -0
  46. package/dist/assets/motion-vendor-BNFhNARW.js +9 -0
  47. package/dist/assets/provider-limits-BgKrr7k7.js +1 -0
  48. package/dist/assets/section-header-KpKzq-Qa.js +1 -0
  49. package/dist/assets/ui-vendor-DOI7LsxH.js +45 -0
  50. package/dist/assets/useTranslation-JH30oWEP.js +1 -0
  51. package/dist/index.html +27 -8
  52. package/package.json +15 -5
  53. package/server/report/index.js +13 -11
  54. package/server.js +281 -56
  55. package/shared/dashboard-domain.d.ts +12 -0
  56. package/shared/dashboard-domain.js +79 -0
  57. package/shared/dashboard-types.d.ts +4 -0
  58. package/shared/model-colors.d.ts +7 -0
  59. package/shared/model-colors.js +27 -0
  60. package/src/locales/de/common.json +51 -5
  61. package/src/locales/en/common.json +51 -4
  62. package/dist/assets/CustomTooltip-CdIOw3Ep.js +0 -1
  63. package/dist/assets/DrillDownModal-d6hcut-I.js +0 -1
  64. package/dist/assets/button-B26tLVFw.js +0 -1
  65. package/dist/assets/dialog-CA-ZSHjK.js +0 -1
  66. package/dist/assets/index-BkGSNAne.css +0 -2
  67. package/dist/assets/index-CMtAn7c8.js +0 -4
  68. package/dist/assets/motion-vendor-BXI2L__C.js +0 -1
  69. package/dist/assets/ui-vendor-BGjRFQGY.js +0 -45
  70. /package/dist/assets/{icons-vendor-z59La6A4.js → icons-vendor-CIvT_-Pb.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{o as n,r}from"./motion-vendor-BNFhNARW.js";import{a as i,i as a}from"./useTranslation-JH30oWEP.js";import{l as o,s}from"./card-CskYMXga.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=a(),_=u??h.active,v=f??h.delayMs,y=p??s.meterDurationMs;return g?(0,l.jsx)(`div`,{ref:m,className:i(t),style:{...n,width:_?e:`0%`}}):(0,l.jsx)(r.div,{ref:m,className:i(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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{t as r}from"./useTranslation-JH30oWEP.js";import{h as i,i as a,n as o}from"./formatters-BzLLk0br.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-CskYMXga.js";import{t as f}from"./help-content-Cuf5l3_6.js";import{t as p}from"./InfoHeading-CFbl45C9.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{r as n}from"./motion-vendor-BXI2L__C.js";import{a as r,i,n as a,o,r as s,t as c}from"./dialog-CA-ZSHjK.js";import{B as l,H as u,c as d,x as f}from"./icons-vendor-z59La6A4.js";import{t as p}from"./button-B26tLVFw.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
- `))},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}=o(),[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)(c,{open:e,onOpenChange:e=>{k||t(e)},children:(0,y.jsxs)(a,{className:`max-w-lg`,onPointerDownOutside:e=>{k&&e.preventDefault()},children:[(0,y.jsxs)(i,{children:[(0,y.jsxs)(r,{className:`flex items-center gap-2`,children:[(0,y.jsx)(d,{className:`h-5 w-5`}),h(`autoImportModal.title`)]}),(0,y.jsx)(s,{children:h(`autoImportModal.description`)})]}),(0,y.jsxs)(`div`,{ref:T,className:`bg-muted/30 rounded-lg p-3 font-mono text-xs max-h-[300px] min-h-[120px] overflow-y-auto border border-border`,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
- `).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)(f,{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)(u,{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)(l,{className:`h-4 w-4 text-destructive`}),(0,y.jsx)(`span`,{className:`text-destructive`,children:h(`autoImportModal.errorOccurred`)})]})]}),!k&&(0,y.jsx)(p,{variant:`outline`,size:`sm`,onClick:()=>t(!1),children:h(`autoImportModal.close`)})]})]})})}export{x as AutoImportModal};
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{t as r}from"./useTranslation-JH30oWEP.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-olcuyddH.js";import{a as l,i as u,n as d,r as f,t as p}from"./dialog-D4LfH66U.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
+ `))},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
+ `).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{o as n}from"./motion-vendor-BNFhNARW.js";import{t as r}from"./useTranslation-JH30oWEP.js";import{g as i,u as a}from"./formatters-BzLLk0br.js";import{t as o}from"./icons-vendor-CIvT_-Pb.js";import{r as s}from"./constants-DOCA3QtR.js";import{c}from"./model-utils-BIvGAFGz.js";import{a as l,i as u,n as d,t as f}from"./card-CskYMXga.js";import{t as p}from"./formatted-value-DuGw8WPX.js";import{t as m}from"./help-content-Cuf5l3_6.js";import{t as h}from"./InfoHeading-CFbl45C9.js";import{t as g}from"./AnimatedBarFill-Da354-1y.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{o as n,r,t as i}from"./motion-vendor-BNFhNARW.js";import{a,i as o,t as s}from"./useTranslation-JH30oWEP.js";import{n as c}from"./formatters-BzLLk0br.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-CskYMXga.js";import{a as v,n as y,r as b,t as x}from"./dialog-D4LfH66U.js";import{t as S}from"./InfoButton-CyA48Vlx.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=o(),n=j();return(0,D.jsx)(D.Fragment,{children:e(t?!1:n.active)})}function P({children:e,variant:t=`line`}){let n=o(),i=A(),a=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-${a}`)})}function F({title:e,subtitle:t,summary:n,info:r,expandable:o=!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:a(`group relative`,T),children:[K,(0,D.jsx)(p,{children:U(!1)}),o&&(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`})})]})}),o&&(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{o as e}from"./motion-vendor-BNFhNARW.js";import{a as t}from"./useTranslation-JH30oWEP.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{o as u}from"./motion-vendor-BNFhNARW.js";import{t as d}from"./useTranslation-JH30oWEP.js";import{d as f,i as p,l as m,n as h,u as g}from"./formatters-BzLLk0br.js";import{a as _,i as v,l as y,n as b,t as x}from"./card-CskYMXga.js";import{t as S}from"./help-content-Cuf5l3_6.js";import{t as C}from"./InfoHeading-CFbl45C9.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{o as c}from"./motion-vendor-BNFhNARW.js";import{t as l}from"./useTranslation-JH30oWEP.js";import{a as u,n as d,t as f}from"./formatters-BzLLk0br.js";import{t as p}from"./model-utils-BIvGAFGz.js";import{t as m}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.js";import{t as x}from"./ChartLegend-Vzg_GmF-.js";import{t as S}from"./CustomTooltip-CEd8U-a3.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};
@@ -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{o as u}from"./motion-vendor-BNFhNARW.js";import{t as d}from"./useTranslation-JH30oWEP.js";import{n as f,t as p}from"./formatters-BzLLk0br.js";import{t as m}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.js";import{t as x}from"./CustomTooltip-CEd8U-a3.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{o as d}from"./motion-vendor-BNFhNARW.js";import{t as f}from"./useTranslation-JH30oWEP.js";import{a as p,n as m,t as h}from"./formatters-BzLLk0br.js";import{a as g}from"./icons-vendor-CIvT_-Pb.js";import{t as _}from"./MetricCard-CLFpH1l1.js";import{t as v}from"./formatted-value-DuGw8WPX.js";import{t as y}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.js";import{t as D}from"./ChartLegend-Vzg_GmF-.js";import{t as O}from"./CustomTooltip-CEd8U-a3.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{o as u}from"./motion-vendor-BNFhNARW.js";import{t as d}from"./useTranslation-JH30oWEP.js";import{a as f,n as p,t as m}from"./formatters-BzLLk0br.js";import{t as h}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.js";import{t as C}from"./CustomTooltip-CEd8U-a3.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};
@@ -0,0 +1 @@
1
+ import{o as e}from"./motion-vendor-BNFhNARW.js";import{t}from"./useTranslation-JH30oWEP.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{o as u}from"./motion-vendor-BNFhNARW.js";import{t as d}from"./useTranslation-JH30oWEP.js";import{d as f,h as p,l as m,n as h}from"./formatters-BzLLk0br.js";import{t as g}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.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};
@@ -0,0 +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{o}from"./motion-vendor-BNFhNARW.js";import{a as s,t as te}from"./useTranslation-JH30oWEP.js";import{d as c,i as ne,l,n as u,u as d}from"./formatters-BzLLk0br.js";import{U as re,W as ie}from"./icons-vendor-CIvT_-Pb.js";import{t as f}from"./button-olcuyddH.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-D4LfH66U.js";import{t as h}from"./formatted-value-DuGw8WPX.js";import{t as fe}from"./CustomTooltip-CEd8U-a3.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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{t as r}from"./useTranslation-JH30oWEP.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-DOCA3QtR.js";import{a as d,i as f,n as p,r as m,t as h}from"./dialog-D4LfH66U.js";import{a as g,i as _,n as v,r as y,t as b}from"./help-content-Cuf5l3_6.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};
@@ -0,0 +1 @@
1
+ import{o as e}from"./motion-vendor-BNFhNARW.js";import{a as t,t as n}from"./useTranslation-JH30oWEP.js";import{v as r,x as i,y as a}from"./formatters-BzLLk0br.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{o as e}from"./motion-vendor-BNFhNARW.js";import{a as t}from"./useTranslation-JH30oWEP.js";import{t as n}from"./InfoButton-CyA48Vlx.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};
@@ -0,0 +1 @@
1
+ import{o as e}from"./motion-vendor-BNFhNARW.js";import{a as t}from"./useTranslation-JH30oWEP.js";import{t as n}from"./card-CskYMXga.js";import{t as r}from"./InfoButton-CyA48Vlx.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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{a as r,t as i}from"./useTranslation-JH30oWEP.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-BzLLk0br.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-CskYMXga.js";import{t as y}from"./formatted-value-DuGw8WPX.js";import{n as b}from"./help-content-Cuf5l3_6.js";import{t as x}from"./InfoHeading-CFbl45C9.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};
@@ -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,n as o,v as s,w as c}from"./charts-vendor-CiBqdKXh.js";import{o as l}from"./motion-vendor-BNFhNARW.js";import{t as u}from"./useTranslation-JH30oWEP.js";import{a as d,t as f,u as p}from"./formatters-BzLLk0br.js";import{c as m,t as h}from"./model-utils-BIvGAFGz.js";import{t as g}from"./help-content-Cuf5l3_6.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-CS4Kbe6r.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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{t as r}from"./useTranslation-JH30oWEP.js";import{d as i,n as a,u as o}from"./formatters-BzLLk0br.js";import{nt as s}from"./icons-vendor-CIvT_-Pb.js";import{t as c}from"./button-olcuyddH.js";import{a as l,i as u,n as d,t as f}from"./card-CskYMXga.js";import{t as p}from"./help-content-Cuf5l3_6.js";import{t as m}from"./InfoHeading-CFbl45C9.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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{a as r,t as i}from"./useTranslation-JH30oWEP.js";import{d as a,g as o,h as s,l as c,u as l}from"./formatters-BzLLk0br.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-CskYMXga.js";import{t as g}from"./formatted-value-DuGw8WPX.js";import{n as _}from"./help-content-Cuf5l3_6.js";import{t as v}from"./InfoHeading-CFbl45C9.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{o as f}from"./motion-vendor-BNFhNARW.js";import{t as p}from"./useTranslation-JH30oWEP.js";import{c as m,n as h,r as g,t as _}from"./formatters-BzLLk0br.js";import{i as v}from"./i18n-D1WJ4-W9.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-CskYMXga.js";import{i as D,t as O}from"./help-content-Cuf5l3_6.js";import{t as k}from"./section-header-KpKzq-Qa.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-CS4Kbe6r.js";import{t as L}from"./ChartLegend-Vzg_GmF-.js";import{t as R}from"./AnimatedBarFill-Da354-1y.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};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{a as r,t as i}from"./useTranslation-JH30oWEP.js";import{h as a,i as o,l as s,n as c,u as l}from"./formatters-BzLLk0br.js";import{tt as u}from"./icons-vendor-CIvT_-Pb.js";import{t as d}from"./button-olcuyddH.js";import{c as f,i as p,n as m,r as h,t as g}from"./model-utils-BIvGAFGz.js";import{a as _,i as v,n as y,t as b}from"./card-CskYMXga.js";import{t as x}from"./formatted-value-DuGw8WPX.js";import{n as S}from"./help-content-Cuf5l3_6.js";import{t as C}from"./InfoHeading-CFbl45C9.js";import{t as w}from"./AnimatedBarFill-Da354-1y.js";var T=e(t()),E=n(),D=30,O=120;function k(e){return Math.min(D+O,e)}function A(e,t,n){let r=k(e);if(t(r),r>=e)return null;let i=()=>{t(t=>{if(t>=e)return t;let r=Math.min(t+O,e);return r<e&&n(i),r})};return n(i)}function j(e){return e.modelBreakdowns.map(e=>({name:f(e.modelName),provider:h(e.modelName)})).filter((e,t,n)=>n.findIndex(t=>t.name===e.name&&t.provider===e.provider)===t)}function M(e){let t=new Map,n=0,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(!a)continue;if(i>7){let t=e[i-8];t&&(n-=t.totalCost,r-=t.requestCount)}if(i>0){let t=e[i-1];t&&(n+=t.totalCost,r+=t.requestCount)}let o=i>0?e[i-1]:null,s=Math.min(i,7),c=o&&o.totalCost>0?(a.totalCost-o.totalCost)/o.totalCost*100:null;t.set(a.date,{...c===null?{}:{prevCostDelta:c},...s>0?{avgCost7:n/s}:{},...s>0?{avgRequests7:r/s}:{}})}return t}function N(e,t){if(e)return{contentVisibility:`auto`,containIntrinsicSize:t}}function P({data:e,onClickDay:t,viewMode:n=`daily`}){let{t:f}=i(),[h,O]=(0,T.useState)(!1),[k,P]=(0,T.useState)(`date`),[F,I]=(0,T.useState)(!1),[L,R]=(0,T.useState)(D),[,z]=(0,T.useTransition)(),B=(0,T.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{switch(k){case`date`:return F?e.date.localeCompare(t.date):t.date.localeCompare(e.date);case`cost`:return F?e.totalCost-t.totalCost:t.totalCost-e.totalCost;case`tokens`:return F?e.totalTokens-t.totalTokens:t.totalTokens-e.totalTokens;case`costPerM`:{let n=e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,r=t.totalTokens>0?t.totalCost/(t.totalTokens/1e6):0;return F?n-r:r-n}}}),t},[e,k,F]);(0,T.useEffect)(()=>{if(!h){R(D);return}if(typeof window>`u`){R(B.length);return}let e=A(B.length,R,window.requestAnimationFrame);return()=>{e!==null&&window.cancelAnimationFrame(e)}},[h,B.length]);let V=(0,T.useMemo)(()=>h?B.slice(0,L):B.slice(0,D),[h,B,L]),H=(0,T.useMemo)(()=>[...e].sort((e,t)=>e.date.localeCompare(t.date)),[e]),U=(0,T.useMemo)(()=>M(H),[H]),W=(0,T.useMemo)(()=>Math.max(...e.map(e=>e.totalCost),0),[e]),G=(0,T.useMemo)(()=>{if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e)t+=o.totalCost,n+=o.totalTokens,r+=o.requestCount,i+=o.cacheReadTokens,(!a||o.totalCost>a.totalCost)&&(a=o);let o=n>0?i/n*100:0;return{totalCost:t,totalTokens:n,totalRequests:r,cacheShare:o,top:a}},[e]),K=(0,T.useMemo)(()=>V.map(e=>({day:e,benchmark:U.get(e.date),costPerM:e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,uniqueModels:j(e)})),[U,V]),q=e=>{z(()=>{e===k?I(!F):(P(e),I(!1))})},J=e=>k===e?F?`ascending`:`descending`:`none`,Y=(0,T.useCallback)((e,n)=>{t&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),t(n)))},[t]);return(0,E.jsxs)(b,{children:[(0,E.jsxs)(v,{className:`flex flex-row items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,E.jsx)(C,{info:S.recentDays,children:(0,E.jsx)(_,{className:`text-sm font-medium text-muted-foreground`,children:f(n===`monthly`?`tables.recentDays.monthsDetail`:n===`yearly`?`tables.recentDays.yearsDetail`:`tables.recentDays.daysDetail`)})}),(0,E.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:f(`tables.recentDays.showing`,{shown:V.length,total:B.length,unit:a(n,!0)})})]}),B.length>D&&(0,E.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>z(()=>{O(e=>!e)}),children:f(h?`tables.recentDays.showLess`:`tables.recentDays.showAll`)})]}),(0,E.jsxs)(y,{children:[G&&(0,E.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 lg:grid-cols-5`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,E.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.totalCost`)}),(0,E.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,E.jsx)(x,{value:G.totalCost,type:`currency`})})]}),(0,E.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,E.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.totalTokens`)}),(0,E.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,E.jsx)(x,{value:G.totalTokens,type:`tokens`})})]}),(0,E.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,E.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.requests`)}),(0,E.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:(0,E.jsx)(x,{value:G.totalRequests,type:`number`})})]}),(0,E.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,E.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.cacheReadShare`)}),(0,E.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:l(G.cacheShare,1)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/15 px-3 py-2`,children:[(0,E.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:f(`tables.recentDays.peak`)}),(0,E.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:G.top?o(G.top.date):`–`}),(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:G.top?c(G.top.totalCost):`–`})]})]}),h&&L<B.length&&(0,E.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground`,children:f(`tables.recentDays.showing`,{shown:L,total:B.length,unit:a(n,!0)})}),(0,E.jsx)(`div`,{className:`grid gap-2 md:hidden`,children:K.map(({day:e,benchmark:i,costPerM:a,uniqueModels:l})=>(0,E.jsxs)(`button`,{onClick:()=>t?.(e.date),className:`rounded-xl border border-border/50 bg-muted/10 p-3 text-left`,style:N(h,`220px`),children:[(0,E.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`font-medium`,children:o(e.date,`long`)}),(0,E.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:[s(e.requestCount),` `,f(`common.requests`)]})]}),(0,E.jsxs)(`div`,{className:`text-right`,children:[(0,E.jsx)(`div`,{className:`font-mono font-semibold`,children:(0,E.jsx)(x,{value:e.totalCost,type:`currency`,interactive:!1})}),(0,E.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:(0,E.jsx)(x,{value:e.totalTokens,type:`tokens`,interactive:!1})}),n===`daily`&&i?.prevCostDelta!==void 0&&(0,E.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.previousDay`),` `,i.prevCostDelta>=0?`↑`:`↓`,Math.abs(i.prevCostDelta).toFixed(0),`%`]})]})]}),(0,E.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 gap-2 text-xs`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,E.jsx)(`div`,{className:`text-muted-foreground`,children:f(`common.input`)}),(0,E.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,E.jsx)(x,{value:e.inputTokens,type:`tokens`,interactive:!1})})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,E.jsx)(`div`,{className:`text-muted-foreground`,children:f(`common.output`)}),(0,E.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,E.jsx)(x,{value:e.outputTokens,type:`tokens`,interactive:!1})})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-muted/20 px-2.5 py-2`,children:[(0,E.jsx)(`div`,{className:`text-muted-foreground`,children:`$/1M`}),(0,E.jsx)(`div`,{className:`mt-1 font-mono`,children:(0,E.jsx)(x,{value:a,type:`currency`,interactive:!1})})]})]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[l.slice(0,4).map(({name:e,provider:t})=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight font-medium`,style:{backgroundColor:m(e,.16),color:g(e)},children:[(0,E.jsx)(`span`,{children:e}),(0,E.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,p(t)),children:t})]},`${e}-${t}`)),l.length>4&&(0,E.jsx)(`span`,{className:`inline-flex items-center rounded-full border border-border/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:f(`tables.modelEfficiency.more`,{count:l.length-4})})]}),n===`daily`&&i?.avgCost7!==void 0&&(0,E.jsxs)(`div`,{className:`mt-3 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.avg7d`),` `,c(i.avgCost7),` ·`,` `,f(`tables.recentDays.reqAvg`),` `,i.avgRequests7?.toFixed(0)??`–`]})]},e.date))}),(0,E.jsx)(`div`,{className:`hidden overflow-x-auto md:block`,children:(0,E.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,E.jsx)(`thead`,{className:`sticky top-0 z-10 bg-card`,children:(0,E.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,E.jsx)(`th`,{"aria-sort":J(`date`),className:r(`px-2 py-2 text-left text-xs font-medium`,k===`date`?`text-foreground`:`text-muted-foreground`),children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>q(`date`),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:[f(`tables.recentDays.date`),` `,(0,E.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,k===`date`&&`text-primary`)})]})}),(0,E.jsx)(`th`,{"aria-sort":J(`cost`),className:r(`px-2 py-2 text-right text-xs font-medium`,k===`cost`?`text-foreground`:`text-muted-foreground`),children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>q(`cost`),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:[f(`tables.recentDays.cost`),` `,(0,E.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,k===`cost`&&`text-primary`)})]})}),(0,E.jsx)(`th`,{"aria-sort":J(`tokens`),className:r(`px-2 py-2 text-right text-xs font-medium`,k===`tokens`?`text-foreground`:`text-muted-foreground`),children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>q(`tokens`),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:[f(`tables.recentDays.tokens`),` `,(0,E.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,k===`tokens`&&`text-primary`)})]})}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground md:table-cell`,children:f(`common.input`)}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground md:table-cell`,children:f(`common.output`)}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground lg:table-cell`,children:f(`common.cacheWrite`)}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground lg:table-cell`,children:f(`common.cacheRead`)}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground xl:table-cell`,children:f(`common.thinking`)}),(0,E.jsx)(`th`,{className:`hidden px-2 py-2 text-right text-xs font-medium text-muted-foreground xl:table-cell`,children:f(`common.requestsShort`)}),(0,E.jsx)(`th`,{"aria-sort":J(`costPerM`),className:r(`px-2 py-2 text-right text-xs font-medium`,k===`costPerM`?`text-foreground`:`text-muted-foreground`),children:(0,E.jsxs)(`button`,{type:`button`,onClick:()=>q(`costPerM`),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:[`$/1M`,` `,(0,E.jsx)(u,{"aria-hidden":`true`,className:r(`h-3 w-3`,k===`costPerM`&&`text-primary`)})]})}),(0,E.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:f(`tables.recentDays.models`)})]})}),(0,E.jsx)(`tbody`,{children:K.map(({day:e,benchmark:i,costPerM:a,uniqueModels:s})=>(0,E.jsxs)(`tr`,{className:`cursor-pointer border-b border-l-[3px] border-border/50 transition-colors hover:bg-muted/10 focus-visible:bg-muted/10 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-inset active:bg-muted/20`,style:{borderLeftColor:`hsla(215, 70%, 55%, ${.2+(W>0?e.totalCost/W:0)*.8})`,...N(h,`52px`)},onClick:()=>t?.(e.date),onKeyDown:t=>Y(t,e.date),role:t?`button`:void 0,tabIndex:t?0:void 0,children:[(0,E.jsx)(`td`,{className:`px-2 py-2.5 whitespace-nowrap`,children:o(e.date,`long`)}),(0,E.jsxs)(`td`,{className:`relative px-2 py-2.5 text-right font-mono tabular-nums`,children:[(0,E.jsx)(w,{className:`absolute inset-y-1 left-0 rounded-sm bg-primary/8`,width:`${W>0?e.totalCost/W*100:0}%`,delayMs:140,durationMs:520}),(0,E.jsx)(`span`,{className:`relative`,children:(0,E.jsx)(x,{value:e.totalCost,type:`currency`})})]}),(0,E.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,E.jsx)(x,{value:e.totalTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums md:table-cell`,children:(0,E.jsx)(x,{value:e.inputTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums md:table-cell`,children:(0,E.jsx)(x,{value:e.outputTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums lg:table-cell`,children:(0,E.jsx)(x,{value:e.cacheCreationTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums lg:table-cell`,children:(0,E.jsx)(x,{value:e.cacheReadTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums xl:table-cell`,children:(0,E.jsx)(x,{value:e.thinkingTokens,type:`tokens`})}),(0,E.jsx)(`td`,{className:`hidden px-2 py-2.5 text-right font-mono tabular-nums xl:table-cell`,children:(0,E.jsx)(x,{value:e.requestCount,type:`number`})}),(0,E.jsx)(`td`,{className:`px-2 py-2.5 text-right font-mono tabular-nums`,children:(0,E.jsx)(x,{value:a,type:`currency`})}),(0,E.jsxs)(`td`,{className:`px-2 py-2.5`,children:[(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(({name:e,provider:t})=>(0,E.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight font-medium`,style:{backgroundColor:m(e,.16),color:g(e)},children:[(0,E.jsx)(`span`,{children:e}),(0,E.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-1 py-0.5 text-[9px] leading-none`,p(t)),children:t})]},`${e}-${t}`))}),n===`daily`&&i?.avgCost7!==void 0&&(0,E.jsxs)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:[f(`tables.recentDays.previousDay`),` `,i.prevCostDelta===void 0?`–`:`${i.prevCostDelta>=0?`↑`:`↓`}${Math.abs(i.prevCostDelta).toFixed(0)}%`,` `,`· `,f(`tables.recentDays.avg7d`),` `,c(i.avgCost7)]})]})]},e.date))})]})})]})]})}export{P as RecentDays};
@@ -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,f as o,l as s,m as c,p as l,t as u,v as d,w as f,y as p}from"./charts-vendor-CiBqdKXh.js";import{o as m}from"./motion-vendor-BNFhNARW.js";import{t as h}from"./useTranslation-JH30oWEP.js";import{a as g,g as _,u as v}from"./formatters-BzLLk0br.js";import{c as y,t as b}from"./model-utils-BIvGAFGz.js";import{t as x}from"./help-content-Cuf5l3_6.js";import{a as S,i as C,n as w,o as T,r as E}from"./chart-theme-BdE8bEiN.js";import{n as D,r as O,t as k}from"./ChartCard-CS4Kbe6r.js";import{t as A}from"./ChartLegend-Vzg_GmF-.js";import{t as j}from"./CustomTooltip-CEd8U-a3.js";import{n as M,o as N}from"./calculations-BJw_4KdI.js";var P=e(f()),F=m();function I(e){return v(e,1)}function L(e,t,n,r,i){let a=e+t+n+r+i;return a>0?r/a*100:0}function R({timelineData:e,summaryData:f,viewMode:m}){let{t:v}=h(),R=(0,P.useId)().replace(/:/g,``),z=v(`charts.requestCacheHitRate.total`),B=`trailing7Rate`,V=v(m===`daily`?`charts.requestCacheHitRate.trailing7Rate`:`charts.requestCacheHitRate.trendRate`),H=(0,P.useMemo)(()=>M(f).map(e=>({...e,model:e.model===`Total`?z:e.model})),[f,z]),U=(0,P.useMemo)(()=>{if(H.length===0)return null;let e=H[0];return e?{total:e,topModel:H.slice(1).sort((e,t)=>t.totalRate-e.totalRate)[0]??null,dominantModel:H.slice(1).sort((e,t)=>t.totalBaseTokens-e.totalBaseTokens)[0]??null,models:Math.max(H.length-1,0)}:null},[H]),W=(0,P.useMemo)(()=>{if(e.length===0)return[];let t=H.slice(1).map(e=>e.model),n=[...e].sort((e,t)=>e.date.localeCompare(t.date)),r=n.map(e=>L(e.inputTokens,e.outputTokens,e.cacheCreationTokens,e.cacheReadTokens,e.thinkingTokens)),i=N(r,Math.min(7,n.length)),a={};for(let e of t)a[e]=[];for(let e of n){let n=new Map;for(let r of e.modelBreakdowns){let e=y(r.modelName);if(!t.includes(e))continue;let i=n.get(e)??{input:0,output:0,cacheCreate:0,cacheRead:0,thinking:0};i.input+=r.inputTokens,i.output+=r.outputTokens,i.cacheCreate+=r.cacheCreationTokens,i.cacheRead+=r.cacheReadTokens,i.thinking+=r.thinkingTokens,n.set(e,i)}for(let e of t){let t=n.get(e),r=a[e];r&&r.push(t?L(t.input,t.output,t.cacheCreate,t.cacheRead,t.thinking):0)}}return n.map((e,n)=>{let o={date:e.date,totalRate:r[n],totalRate_ma7:i[n]};for(let e of t)o[e]=a[e]?.[n]??0;return o})},[e,H]);if(!U||W.length===0)return null;let G=Math.max(220,Math.min(310,H.length*28+48)),K=Math.max(280,Math.min(420,H.length*34+56)),q=m===`daily`?280:250,J=m===`daily`?360:320,Y=Object.keys(W[0]??{}).filter(e=>e!==`date`&&e!==`totalRate`&&e!==`totalRate_ma7`),X=(0,F.jsx)(`div`,{className:`mt-6 grid grid-cols-1 gap-4 xl:grid-cols-3`,children:H.slice(0,6).map(e=>(0,F.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,F.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.model}),(0,F.jsxs)(`div`,{className:`mt-2 flex items-end gap-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.totalRate`)}),(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:I(e.totalRate)})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:V}),(0,F.jsx)(`div`,{className:`text-lg font-semibold tabular-nums`,children:I(e[B])})]})]})]},e.model))});return(0,F.jsx)(D,{title:v(`charts.requestCacheHitRate.title`),subtitle:v(`charts.requestCacheHitRate.subtitle`,{total:I(U.total.totalRate),trailing:I(U.total[B])}),info:x.requestCacheHitRate,chartData:H,valueKey:`totalRate`,valueFormatter:I,expandedExtra:X,children:e=>{let f=e?8:6;return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-center md:grid-cols-4`,children:[(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.totalRate`)}),(0,F.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:I(U.total.totalRate)})]}),(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:V}),(0,F.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:I(U.total[B])})]}),(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.topModel`)}),(0,F.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:U.topModel?.model??`–`})]}),(0,F.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,F.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.models`)}),(0,F.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:U.models})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-4 ${e?`grid-cols-1 xl:grid-cols-[2fr_1fr]`:`grid-cols-1 lg:grid-cols-[2fr_1fr]`}`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.timelineHeading`,{unit:_(m)})}),(0,F.jsx)(k,{children:t=>(0,F.jsx)(O,{variant:`line`,children:(0,F.jsx)(r,{width:`100%`,height:e?J:q,children:(0,F.jsxs)(u,{data:W,margin:E,children:[(0,F.jsx)(`defs`,{children:(0,F.jsxs)(`linearGradient`,{id:`${R}-total-rate`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,F.jsx)(`stop`,{offset:`0%`,stopColor:w.cost,stopOpacity:.24}),(0,F.jsx)(`stop`,{offset:`100%`,stopColor:w.cost,stopOpacity:0})]})}),(0,F.jsx)(c,{strokeDasharray:`3 3`,stroke:w.grid,opacity:.3}),(0,F.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:w.axis,fontSize:11,tickLine:!1}),(0,F.jsx)(i,{type:`number`,domain:[0,100],tickFormatter:I,stroke:w.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,F.jsx)(d,{content:(0,F.jsx)(j,{formatter:e=>I(e),pinnedEntryNames:[v(`charts.requestCacheHitRate.totalRate`)],showComputedTotal:!1,hideZeroValues:!0}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,F.jsx)(p,{content:(0,F.jsx)(A,{})}),(0,F.jsx)(o,{type:`monotone`,dataKey:`totalRate`,stroke:w.cost,fill:`url(#${R}-total-rate)`,name:v(`charts.requestCacheHitRate.totalRate`),strokeWidth:2,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:w.cost,fill:`hsl(var(--background))`},...C(t)}),(0,F.jsx)(l,{type:`monotone`,dataKey:`totalRate_ma7`,stroke:w.ma7,name:V,dot:!1,strokeWidth:2,strokeDasharray:`5 5`,connectNulls:!0,...T(t,{role:`secondary`})}),Y.map((e,n)=>(0,F.jsx)(l,{type:`monotone`,dataKey:e,stroke:b(e),name:e,dot:!1,strokeWidth:1.8,connectNulls:!0,...T(t,{order:n+2,role:`secondary`})},e))]})})})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestCacheHitRate.modelBreakdownHeading`)}),(0,F.jsx)(k,{children:o=>(0,F.jsx)(O,{variant:`line`,children:(0,F.jsx)(r,{width:`100%`,height:e?K:G,children:(0,F.jsxs)(n,{data:H,layout:`vertical`,margin:{...E,left:e?30:20,right:8},barCategoryGap:e?14:10,barSize:f,maxBarSize:f,children:[(0,F.jsx)(c,{strokeDasharray:`3 3`,stroke:w.grid,opacity:.22,horizontal:!1}),(0,F.jsx)(s,{type:`number`,domain:[0,100],tickFormatter:I,stroke:w.axis,fontSize:10,tickLine:!1,axisLine:!1}),(0,F.jsx)(i,{type:`category`,dataKey:`model`,stroke:w.axis,fontSize:10,tickLine:!1,axisLine:!1,width:e?126:108}),(0,F.jsx)(d,{content:(0,F.jsx)(j,{formatter:e=>I(e),pinnedEntryNames:[v(`charts.requestCacheHitRate.totalRate`),V],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,F.jsx)(p,{content:(0,F.jsx)(A,{})}),(0,F.jsx)(a,{dataKey:`totalRate`,name:v(`charts.requestCacheHitRate.totalRate`),radius:[0,4,4,0],fill:w.cacheRead,...S(o),children:H.map(e=>(0,F.jsx)(t,{fill:e.model===z?w.cost:w.cacheRead,fillOpacity:e.model===z?.95:.82},`${e.model}-total`))}),(0,F.jsx)(a,{dataKey:B,name:V,radius:[0,4,4,0],fill:w.ma7,...S(o,1),children:H.map(e=>(0,F.jsx)(t,{fill:e.model===z?w.cumulative:w.ma7,fillOpacity:e.model===z?.95:.8},`${e.model}-recent`))})]})})})})]})]})]})}})}export{R as RequestCacheHitRateByModel};
@@ -0,0 +1 @@
1
+ import{o as e}from"./motion-vendor-BNFhNARW.js";import{t}from"./useTranslation-JH30oWEP.js";import{d as n,l as r,n as i,u as a}from"./formatters-BzLLk0br.js";import{a as o,i as s,n as c,t as l}from"./card-CskYMXga.js";import{n as u}from"./help-content-Cuf5l3_6.js";import{t as d}from"./InfoHeading-CFbl45C9.js";import{t as f}from"./AnimatedBarFill-Da354-1y.js";var p=e();function m({metrics:e,viewMode:m}){let{t:h}=t(),g=e.totalRequests>0?e.totalCacheRead/e.totalRequests:0,_=e.totalRequests>0?e.totalThinking/e.totalRequests:0,v=e.totalOutput>0?e.totalInput/e.totalOutput:0,y=e.activeDays>0?e.totalRequests/e.activeDays:0,b=[{label:h(`requestQuality.tokensPerRequest`),value:e.hasRequestData?n(e.avgTokensPerRequest):h(`common.notAvailable`),accent:`var(--chart-2)`,hint:h(`requestQuality.tokensHint`),progress:Math.min(e.avgTokensPerRequest/2e5,1)},{label:h(`requestQuality.costPerRequest`),value:e.hasRequestData?i(e.avgCostPerRequest):h(`common.notAvailable`),accent:`var(--chart-4)`,hint:h(`requestQuality.costHint`),progress:Math.min(e.avgCostPerRequest/.25,1)},{label:h(`requestQuality.cachePerRequest`),value:e.hasRequestData?n(g):h(`common.notAvailable`),accent:`var(--chart-1)`,hint:h(`requestQuality.cacheHint`),progress:Math.min(g/2e5,1)},{label:h(`requestQuality.thinkingPerRequest`),value:e.hasRequestData?n(_):h(`common.notAvailable`),accent:`var(--chart-5)`,hint:h(`requestQuality.thinkingHint`),progress:Math.min(_/1e4,1)}];return(0,p.jsxs)(l,{className:`overflow-visible`,children:[(0,p.jsx)(s,{children:(0,p.jsx)(d,{info:u.requestQuality,children:(0,p.jsx)(o,{className:`text-sm font-medium text-muted-foreground`,children:h(`requestQuality.title`)})})}),(0,p.jsxs)(c,{className:`space-y-4`,children:[(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-3 xl:grid-cols-4`,children:b.map((t,n)=>(0,p.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-3`,children:[(0,p.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:t.label}),(0,p.jsx)(`div`,{className:`mt-1 text-lg font-semibold tabular-nums`,children:t.value}),(0,p.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:t.hint}),(0,p.jsx)(`div`,{className:`mt-3 h-1.5 overflow-hidden rounded-full bg-muted/40`,children:(0,p.jsx)(f,{className:`h-full rounded-full`,order:n,style:{backgroundColor:`hsl(${t.accent})`},width:e.hasRequestData&&t.progress>0?`${Math.max(t.progress*100,6)}%`:`0%`})})]},t.label))}),(0,p.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-4`,children:[(0,p.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-primary/[0.12] via-transparent to-transparent p-4`,children:[(0,p.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:h(`requestQuality.requestDensity`)}),(0,p.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:r(Math.round(y))}),(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:h(`requestQuality.averagePerActiveUnit`,{unit:h(m===`yearly`?`periods.year`:m===`monthly`?`periods.month`:`periods.day`)})})]}),(0,p.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-3/[0.12] via-transparent to-transparent p-4`,children:[(0,p.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:h(`requestQuality.cacheHitRate`)}),(0,p.jsx)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:a(e.cacheHitRate,1)}),(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:h(`requestQuality.cacheHitHint`)})]}),(0,p.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-4/[0.12] via-transparent to-transparent p-4`,children:[(0,p.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:h(`requestQuality.inputOutput`)}),(0,p.jsxs)(`div`,{className:`mt-1 text-xl font-semibold tabular-nums`,children:[v.toFixed(2),`:1`]}),(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:h(`requestQuality.inputOutputHint`)})]}),(0,p.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-chart-5/[0.12] via-transparent to-transparent p-4`,children:[(0,p.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:h(`requestQuality.topRequestModel`)}),(0,p.jsx)(`div`,{className:`mt-1 truncate text-lg font-semibold`,children:e.topRequestModel?.name??`–`}),(0,p.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.topRequestModel?`${r(e.topRequestModel.requests)} ${h(`common.requests`)}`:h(`requestQuality.noRequestLeader`)})]})]})]})]})}export{m as RequestQuality};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{_ as t,b as n,c as r,f as i,g as a,i as o,l as s,m as c,p as l,t as u,v as d,w as f,y as p}from"./charts-vendor-CiBqdKXh.js";import{o as m}from"./motion-vendor-BNFhNARW.js";import{t as h}from"./useTranslation-JH30oWEP.js";import{a as g,g as _}from"./formatters-BzLLk0br.js";import{r as v}from"./i18n-D1WJ4-W9.js";import{t as y}from"./model-utils-BIvGAFGz.js";import{t as b}from"./formatted-value-DuGw8WPX.js";import{t as x}from"./help-content-Cuf5l3_6.js";import{i as S,n as C,o as w,r as T,s as E}from"./chart-theme-BdE8bEiN.js";import{n as D,r as O,t as k}from"./ChartCard-CS4Kbe6r.js";import{t as A}from"./ChartLegend-Vzg_GmF-.js";import{t as j}from"./CustomTooltip-CEd8U-a3.js";var M=e(f()),N=m();function P(e){return new Intl.NumberFormat(v(),{notation:e>=1e4?`compact`:`standard`,maximumFractionDigits:+(e>=1e4)}).format(e)}function F({viewBox:e,total:t}){let{t:n}=h();if(!e)return null;let{cx:r,cy:i}=e;return(0,N.jsxs)(`g`,{children:[(0,N.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.requestsOverTime.total`)}),(0,N.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function I({data:e,viewMode:f=`daily`,onClickDay:m}){let{t:v}=h(),I=(0,M.useId)().replace(/:/g,``),L=v(`charts.requestsOverTime.averagePerUnit`,{unit:_(f)}),R=v(f===`daily`?`charts.requestsOverTime.movingAverage`:`charts.requestsOverTime.trend`),z=v(f===`daily`?`charts.requestsOverTime.movingAverageHeading`:`charts.requestsOverTime.trendHeading`),B=(0,M.useMemo)(()=>{if(e.length===0)return null;let t=new Map;for(let n of e)for(let[e,r]of Object.entries(n))e===`date`||e===`totalRequests`||e===`totalRequestsMA7`||e===`totalRequestsPrev`||e.endsWith(`_ma7`)||e.endsWith(`Prev`)||typeof r==`number`&&t.set(e,(t.get(e)??0)+r);let n=Array.from(t.entries()).sort((e,t)=>t[1]-e[1]),r=e.reduce((e,t)=>e+t.totalRequests,0),i=[...e].sort((e,t)=>t.totalRequests-e.totalRequests)[0];return i?{totalRequests:r,peak:i,topModels:n}:null},[e]),V=(0,M.useMemo)(()=>(B?.topModels??[]).slice(0,5).map(([e])=>e),[B]),H=(0,M.useMemo)(()=>(B?.topModels??[]).map(([e,t])=>({name:e,value:t})),[B]),U=e=>{let t=e;t?.activePayload?.[0]?.payload?.date&&m&&m(t.activePayload[0].payload.date)},W=(0,N.jsx)(k,{children:t=>(0,N.jsxs)(`div`,{className:`mt-6 space-y-5`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:z}),(0,N.jsx)(O,{variant:`line`,children:(0,N.jsx)(n,{width:`100%`,height:360,children:(0,N.jsxs)(u,{data:e,margin:T,children:[(0,N.jsx)(c,{strokeDasharray:`3 3`,stroke:C.grid,opacity:.3}),(0,N.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:C.axis,fontSize:11,tickLine:!1}),(0,N.jsx)(r,{tickFormatter:P,stroke:C.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,N.jsx)(d,{content:(0,N.jsx)(j,{formatter:e=>P(e)}),cursor:{stroke:`hsl(var(--muted))`,strokeWidth:1}}),(0,N.jsx)(p,{content:(0,N.jsx)(A,{})}),(0,N.jsx)(l,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:C.ma7,name:v(`charts.requestsOverTime.totalMovingAverage`,{label:R}),dot:!1,strokeWidth:2.5,strokeDasharray:`6 4`,connectNulls:!0,...w(t,{role:`secondary`})}),(B?.topModels??[]).map(([e],n)=>(0,N.jsx)(l,{type:`monotone`,dataKey:`${e}_ma7`,stroke:y(e),name:`${e} ${R}`,dot:!1,strokeWidth:2,strokeDasharray:`5 4`,connectNulls:!0,...w(t,{order:n%6,role:`secondary`})},`${e}_ma7`))]})})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`div`,{className:`mb-2 text-[10px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.requestsByModelTotal`)}),(0,N.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:(B?.topModels??[]).map(([e,t])=>{let n=B&&B.totalRequests>0?t/B.totalRequests*100:0;return(0,N.jsxs)(`div`,{className:`rounded-lg border border-border/50 bg-muted/10 p-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:y(e)}}),(0,N.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e})]}),(0,N.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.toFixed(1),`%`]})]}),(0,N.jsx)(`div`,{className:`mt-2 text-lg font-semibold tabular-nums`,children:P(t)}),(0,N.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:v(`charts.requestsOverTime.requestsInRange`)})]},e)})})]})]})});return(0,N.jsx)(D,{title:v(`charts.requestsOverTime.title`),subtitle:B?v(`charts.requestsOverTime.summary`,{total:P(B.totalRequests),peak:P(B.peak.totalRequests),date:g(B.peak.date)}):v(`charts.requestsOverTime.subtitle`),info:x.requestsOverTime,summary:B?(0,N.jsx)(b,{value:B.totalRequests,type:`number`}):void 0,chartData:e,valueKey:`totalRequests`,valueFormatter:P,expandedExtra:W,children:f=>{let m=f?420:320,h=f?440:340,_=f?70:54,b=f?112:82,x=f?`48%`:`46%`;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`div`,{className:`mb-3 grid grid-cols-2 gap-2 text-center md:grid-cols-4`,children:[(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.total`)}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:B?P(B.totalRequests):`0`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:L}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:B&&e.length>0?P(B.totalRequests/e.length):`0`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.topModel`)}),(0,N.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:B?.topModels[0]?.[0]??`–`})]}),(0,N.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2`,children:[(0,N.jsx)(`div`,{className:`text-[9px] tracking-wider text-muted-foreground uppercase`,children:v(`charts.requestsOverTime.topShare`)}),(0,N.jsx)(`div`,{className:`text-sm font-semibold tabular-nums`,children:B&&B.totalRequests>0&&B.topModels[0]?`${(B.topModels[0][1]/B.totalRequests*100).toFixed(1)}%`:`–`})]})]}),(0,N.jsxs)(`div`,{className:`grid gap-4 ${f?`grid-cols-1 xl:grid-cols-3`:`grid-cols-1 lg:grid-cols-3`}`,children:[(0,N.jsx)(`div`,{className:f?`xl:col-span-2`:`lg:col-span-2`,children:(0,N.jsx)(k,{children:t=>(0,N.jsx)(O,{variant:`line`,children:(0,N.jsx)(n,{width:`100%`,height:m,children:(0,N.jsxs)(u,{data:e,margin:T,onClick:U,children:[(0,N.jsx)(`defs`,{children:(0,N.jsxs)(`linearGradient`,{id:`${I}-requests`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,N.jsx)(`stop`,{offset:`0%`,stopColor:C.cumulative,stopOpacity:.28}),(0,N.jsx)(`stop`,{offset:`100%`,stopColor:C.cumulative,stopOpacity:0})]})}),(0,N.jsx)(c,{strokeDasharray:`3 3`,stroke:C.grid,opacity:.3}),(0,N.jsx)(s,{dataKey:`date`,tickFormatter:g,stroke:C.axis,fontSize:11,tickLine:!1}),(0,N.jsx)(r,{tickFormatter:P,stroke:C.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,N.jsx)(d,{content:(0,N.jsx)(j,{formatter:e=>P(e),pinnedEntryNames:[v(`charts.requestsOverTime.totalRequestsSeries`)],showComputedTotal:!1}),cursor:{fill:`hsl(var(--muted))`,opacity:.12}}),(0,N.jsx)(p,{content:(0,N.jsx)(A,{})}),(0,N.jsx)(i,{type:`monotone`,dataKey:`totalRequests`,stroke:C.cumulative,fill:`url(#${I}-requests)`,name:v(`charts.requestsOverTime.totalRequestsSeries`),strokeWidth:1.8,dot:!1,activeDot:{r:5,strokeWidth:2,stroke:C.cumulative,fill:`hsl(var(--background))`},...S(t)}),(0,N.jsx)(l,{type:`monotone`,dataKey:`totalRequestsMA7`,stroke:C.ma7,name:R,dot:!1,strokeWidth:2.2,strokeDasharray:`5 5`,connectNulls:!0,...w(t,{role:`secondary`})}),V.map((e,n)=>(0,N.jsx)(l,{type:`monotone`,dataKey:e,stroke:y(e),name:e,dot:!1,strokeWidth:1.6,...w(t,{order:n%5+1})},e))]})})})})}),(0,N.jsx)(`div`,{className:`min-w-0 pt-1`,children:(0,N.jsx)(k,{children:e=>(0,N.jsx)(O,{variant:`radial`,children:(0,N.jsx)(n,{width:`100%`,height:h,children:(0,N.jsxs)(o,{children:[(0,N.jsxs)(a,{data:H,cx:`50%`,cy:x,innerRadius:_,outerRadius:b,paddingAngle:2,dataKey:`value`,nameKey:`name`,...E(e),children:[H.map(e=>(0,N.jsx)(t,{fill:y(e.name)},e.name)),(0,N.jsx)(F,{total:B?P(B.totalRequests):`0`})]}),(0,N.jsx)(d,{content:(0,N.jsx)(j,{formatter:e=>P(e)})}),(0,N.jsx)(p,{content:(0,N.jsx)(A,{className:f?`pt-[18px]`:`pt-2`,renderLabel:e=>{let t=String(e.value??``),n=H.find(e=>e.name===t);return`${t} (${n?P(n.value):``})`}})})]})})})})})]})]})}})}export{I as RequestsOverTime};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{w as t}from"./charts-vendor-CiBqdKXh.js";import{o as n}from"./motion-vendor-BNFhNARW.js";import{a as r,t as i}from"./useTranslation-JH30oWEP.js";import{s as a}from"./formatters-BzLLk0br.js";import{t as o}from"./i18n-D1WJ4-W9.js";import{I as s,N as ee,O as te,P as c,S as ne,et as re,h as ie,k as ae,r as l,rt as oe,w as se}from"./icons-vendor-CIvT_-Pb.js";import{t as u}from"./button-olcuyddH.js";import{i as d}from"./model-utils-BIvGAFGz.js";import{a as ce,i as le,n as ue,r as de,t as fe}from"./dialog-D4LfH66U.js";import{a as pe,c as f,i as me,l as p,o as he,s as m,t as ge}from"./app-settings-EFIYxqQU.js";import{n as _e}from"./help-content-Cuf5l3_6.js";import{t as ve}from"./InfoHeading-CFbl45C9.js";import{a as h,t as g}from"./provider-limits-BgKrr7k7.js";var _=e(t()),v=n();function y(e){let t=e.replace(`,`,`.`).trim();if(!t)return 0;let n=Number.parseFloat(t);return Number.isFinite(n)?Math.max(0,Number(n.toFixed(2))):0}function b(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function x(e){return[...new Set(e.map(e=>e.trim()).filter(Boolean))].sort((e,t)=>e.localeCompare(t))}function ye(e,t){let n={};for(let r of e)n[r]=t[r]??{...g};return n}function S(e,t,n){let r=e.indexOf(t),i=r+n;if(r<0||i<0||i>=e.length)return e;let a=[...e],[o]=a.splice(r,1);return o?(a.splice(i,0,o),a):e}function be(e,t,n){if(t===n)return e;let r=e.indexOf(t),i=e.indexOf(n);if(r<0||i<0)return e;let a=[...e],[o]=a.splice(r,1);if(!o)return e;let s=r<i?i-1:i;return a.splice(s,0,o),a}function C({open:e,onOpenChange:t,language:n,limitProviders:C,filterProviders:w,models:T,limits:E,defaultFilters:D,sectionVisibility:O,sectionOrder:k,lastLoadedAt:A,lastLoadSource:j,cliAutoLoadActive:xe=!1,hasData:Se,onSaveSettings:Ce,onExportSettings:we,onImportSettings:Te,onExportData:Ee,onImportData:De,settingsBusy:M=!1,dataBusy:N=!1}){let{t:P}=i(),[F,I]=(0,_.useState)(n),[L,R]=(0,_.useState)(()=>h(C,E)),[z,B]=(0,_.useState)(D),[V,H]=(0,_.useState)(O),[U,W]=(0,_.useState)(k),[G,K]=(0,_.useState)(null),[q,J]=(0,_.useState)(null),Y=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(I(n),R(h(C,E)),B(D),H(O),W(k),K(null),J(null))},[e,n,C,E,D,O,k]);let X=(0,_.useMemo)(()=>x([...w,...z.providers]),[w,z.providers]),Z=(0,_.useMemo)(()=>x([...T,...z.models]),[T,z.models]),Q=(e,t)=>{R(n=>({...n,[e]:{...n[e]??g,...t}}))},Oe=async()=>{await Ce({language:F,providerLimits:ye(C,L),defaultFilters:{...z,providers:x(z.providers),models:x(z.models)},sectionVisibility:V,sectionOrder:U}),t(!1)},ke=()=>{I(ge.language),R(h(C,{})),B(m),H(p()),W(f()),K(null),J(null)},Ae=()=>{B(m)},je=()=>{H(p()),W(f())},Me=()=>{R(h(C,{}))},Ne=P(j?`settings.modal.sources.${j}`:`settings.modal.sources.unknown`),$=(0,_.useMemo)(()=>U.map(e=>pe[e]).filter(e=>e!==void 0),[U]);return(0,v.jsx)(fe,{open:e,onOpenChange:t,children:(0,v.jsxs)(ue,{className:`max-h-[88vh] max-w-5xl overflow-x-visible overflow-y-auto`,onOpenAutoFocus:e=>{e.preventDefault(),Y.current?.focus()},children:[(0,v.jsxs)(le,{className:`overflow-visible`,children:[(0,v.jsx)(ve,{info:_e.providerLimits,children:(0,v.jsx)(ce,{ref:Y,tabIndex:-1,className:`focus:outline-none`,children:P(`settings.modal.title`)})}),(0,v.jsx)(de,{children:P(`settings.modal.description`)})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-muted/20 px-4 py-3`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.dataStatus`)}),(0,v.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-3`,children:[(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.lastLoaded`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:A?a(A):P(`common.notAvailable`)})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.loadedVia`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:Ne})]}),(0,v.jsxs)(`div`,{className:`space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-[11px] tracking-[0.12em] text-muted-foreground uppercase`,children:P(`settings.modal.cliAutoLoad`)}),(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(xe?`common.enabled`:`common.disabled`)})]})]})]}),(0,v.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(se,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.languageTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.languageDescription`)})]})]}),(0,v.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:o.map(e=>(0,v.jsx)(u,{type:`button`,"data-testid":`settings-language-${e}`,"aria-pressed":F===e,variant:F===e?`default`:`outline`,onClick:()=>I(e),children:P(`app.languages.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(ae,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.defaultFiltersTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.defaultFiltersDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-default-filters`,onClick:Ae,disabled:M,children:P(`common.reset`)})]}),(0,v.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.defaultViewMode`)}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:he.map(e=>(0,v.jsx)(u,{type:`button`,"aria-pressed":z.viewMode===e,variant:z.viewMode===e?`default`:`outline`,onClick:()=>B(t=>({...t,viewMode:e})),children:P(`settings.modal.viewModes.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.defaultDateRange`)}),(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:me.map(e=>(0,v.jsx)(u,{type:`button`,"aria-pressed":z.datePreset===e,variant:z.datePreset===e?`default`:`outline`,onClick:()=>B(t=>({...t,datePreset:e})),children:P(`settings.modal.datePresets.${e}`)},e))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.filterProviders`)}),X.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:P(`settings.modal.noProviders`)}):(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:X.map(e=>{let t=z.providers.includes(e);return(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>B(t=>({...t,providers:b(t.providers,e)})),className:r(`inline-flex items-center rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,t?`border-primary/30 bg-primary text-primary-foreground`:d(e)),children:e},e)})})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`settings.modal.filterModels`)}),Z.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-3 py-4 text-sm text-muted-foreground`,children:P(`settings.modal.noModels`)}):(0,v.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Z.map(e=>{let t=z.models.includes(e);return(0,v.jsx)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>B(t=>({...t,models:b(t.models,e)})),className:r(`inline-flex items-center rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,t?`border-primary/30 bg-primary text-primary-foreground`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent hover:text-foreground`),children:e},e)})})]})]})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(ee,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.sectionVisibilityTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.sectionVisibilityDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-section-visibility`,onClick:je,disabled:M,children:P(`common.reset`)})]}),(0,v.jsx)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:P(`settings.modal.sectionOrderHint`)}),(0,v.jsx)(`div`,{className:`mt-4 space-y-2`,children:$.map((e,t)=>{let n=V[e.id];return(0,v.jsxs)(`div`,{"data-section-id":e.id,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.id),K(e.id),J(e.id)},onDragOver:t=>{t.preventDefault(),q!==e.id&&J(e.id)},onDragLeave:()=>{q===e.id&&J(null)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(`text/plain`)||G;n&&(W(t=>be(t,n,e.id)),K(null),J(null))},onDragEnd:()=>{K(null),J(null)},className:r(`flex items-center gap-2 rounded-xl border px-3 py-2 text-sm transition-colors`,q===e.id?`border-primary/40 bg-primary/10`:`border-border/70 bg-muted/10`,G===e.id&&`opacity-70`),children:[(0,v.jsx)(`span`,{className:`inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md border border-border/60 bg-background/40 text-muted-foreground`,children:(0,v.jsx)(te,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,v.jsx)(`div`,{className:`truncate font-medium text-foreground`,children:P(e.labelKey)}),(0,v.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:P(`settings.modal.positionLabel`,{position:t+1,total:$.length})})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-up-${e.id}`,onClick:()=>W(t=>S(t,e.id,-1)),disabled:t===0,"aria-label":P(`settings.modal.moveSectionUp`,{section:P(e.labelKey)}),children:(0,v.jsx)(re,{className:`h-4 w-4`})}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`icon`,className:`h-8 w-8`,"data-testid":`move-section-down-${e.id}`,onClick:()=>W(t=>S(t,e.id,1)),disabled:t===$.length-1,"aria-label":P(`settings.modal.moveSectionDown`,{section:P(e.labelKey)}),children:(0,v.jsx)(oe,{className:`h-4 w-4`})}),(0,v.jsx)(`button`,{type:`button`,"data-testid":`toggle-section-visibility-${e.id}`,"aria-pressed":n,onClick:()=>H(t=>({...t,[e.id]:!t[e.id]})),className:r(`inline-flex min-w-[88px] items-center justify-center rounded-full border px-3 py-1.5 text-xs font-medium tracking-[0.12em] uppercase transition-colors`,n?`border-emerald-500/30 bg-emerald-500/10 text-foreground`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent hover:text-foreground`),children:P(n?`common.visible`:`common.hidden`)})]})]},e.id)})})]})]}),(0,v.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(ie,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.settingsBackupTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.settingsBackupDescription`)})]})]}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,v.jsxs)(u,{variant:`outline`,onClick:we,disabled:M,className:`gap-2`,children:[(0,v.jsx)(c,{className:`h-4 w-4`}),P(`settings.modal.exportSettings`)]}),(0,v.jsxs)(u,{variant:`outline`,onClick:Te,disabled:M,className:`gap-2`,children:[(0,v.jsx)(l,{className:`h-4 w-4`}),P(`settings.modal.importSettings`)]})]})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(s,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.dataBackupTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.dataBackupDescription`)})]})]}),(0,v.jsx)(`p`,{className:`mt-3 rounded-xl border border-amber-500/20 bg-amber-500/8 px-3 py-2 text-xs leading-relaxed text-amber-200/90`,children:P(`settings.modal.dataImportPolicy`)}),(0,v.jsx)(`p`,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:P(`settings.modal.dataImportReplaceHint`)}),(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,v.jsxs)(u,{variant:`outline`,onClick:Ee,disabled:!Se||N,className:`gap-2`,children:[(0,v.jsx)(c,{className:`h-4 w-4`}),P(`settings.modal.exportData`)]}),(0,v.jsxs)(u,{variant:`outline`,onClick:De,disabled:N,className:`gap-2`,children:[(0,v.jsx)(l,{className:`h-4 w-4`}),P(`settings.modal.importData`)]})]})]})]}),(0,v.jsxs)(`div`,{className:`rounded-2xl border border-border/50 bg-card/60 p-4 backdrop-blur-xl`,children:[(0,v.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,v.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,v.jsx)(`span`,{className:`mt-0.5 inline-flex h-9 w-9 items-center justify-center rounded-xl border border-border/60 bg-muted/20 text-muted-foreground`,children:(0,v.jsx)(ne,{className:`h-4 w-4`})}),(0,v.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:P(`settings.modal.providerLimitsTitle`)}),(0,v.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:P(`settings.modal.providerLimitsDescription`)})]})]}),(0,v.jsx)(u,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`reset-provider-limits`,onClick:Me,disabled:M,children:P(`common.reset`)})]}),(0,v.jsx)(`div`,{className:`mt-4`,children:C.length===0?(0,v.jsx)(`div`,{className:`rounded-xl border border-dashed border-border/60 bg-muted/10 px-4 py-8 text-center text-sm text-muted-foreground`,children:P(`settings.modal.noProviders`)}):(0,v.jsx)(`div`,{className:`space-y-3`,children:C.map(e=>{let t=L[e]??g;return(0,v.jsx)(`div`,{"data-provider-id":e,className:`rounded-2xl border border-border/50 bg-background/40 p-4`,children:(0,v.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,v.jsx)(`div`,{className:`min-w-0`,children:(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:r(`inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium`,d(e)),children:e}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>Q(e,{hasSubscription:!t.hasSubscription}),className:r(`inline-flex items-center rounded-full border px-2.5 py-1 text-xs font-medium transition-colors`,t.hasSubscription?`border-emerald-500/30 bg-emerald-500/10 text-emerald-300`:`border-border bg-muted/20 text-muted-foreground hover:bg-accent`),children:t.hasSubscription?P(`common.enabled`):P(`limits.statuses.noSubscription`)})]})}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:w-[420px]`,children:[(0,v.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,v.jsx)(`span`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`limits.modal.subscriptionPerMonth`)}),(0,v.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.subscriptionPrice,disabled:!t.hasSubscription,onChange:t=>Q(e,{subscriptionPrice:y(t.target.value)}),className:`h-10 w-full rounded-md border border-border bg-background px-3 text-sm disabled:cursor-not-allowed disabled:opacity-50`})]}),(0,v.jsxs)(`label`,{className:`space-y-1.5`,children:[(0,v.jsx)(`span`,{className:`text-[11px] font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:P(`limits.modal.monthlyLimit`)}),(0,v.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,value:t.monthlyLimit,onChange:t=>Q(e,{monthlyLimit:y(t.target.value)}),className:`h-10 w-full rounded-md border border-border bg-background px-3 text-sm`})]})]})]})},e)})})})]}),(0,v.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-t border-border/50 pt-4`,children:[(0,v.jsx)(u,{variant:`ghost`,onClick:ke,disabled:M,"data-testid":`reset-all-settings-drafts`,children:P(`common.reset`)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(u,{variant:`ghost`,onClick:()=>t(!1),disabled:M,children:P(`settings.modal.close`)}),(0,v.jsx)(u,{onClick:()=>void Oe(),disabled:M,children:P(`settings.modal.save`)})]})]})]})})}export{C as SettingsModal};
@@ -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}from"./charts-vendor-CiBqdKXh.js";import{o as d}from"./motion-vendor-BNFhNARW.js";import{t as f}from"./useTranslation-JH30oWEP.js";import{a as p,n as m,t as h}from"./formatters-BzLLk0br.js";import{t as g}from"./help-content-Cuf5l3_6.js";import{i as _,n as v,o as y,r as b}from"./chart-theme-BdE8bEiN.js";import{n as x,r as S,t as C}from"./ChartCard-CS4Kbe6r.js";import{t as w}from"./CustomTooltip-CEd8U-a3.js";import{o as T}from"./calculations-BJw_4KdI.js";var E=e(u()),D=d();function O({data:e}){let{t:u}=f(),d=(0,E.useId)().replace(/:/g,``),{chartData:O,avg:k}=(0,E.useMemo)(()=>{let t=[...e].sort((e,t)=>e.date.localeCompare(t.date)),n=t.map(e=>e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0),r=T(n),i=n.length>0?n.reduce((e,t)=>e+t,0)/n.length:0;return{chartData:t.map((e,t)=>({date:e.date,efficiency:n[t],effMA7:r[t]})),avg:i}},[e]);return O.length<3?null:(0,D.jsx)(x,{title:u(`charts.tokenEfficiency.title`),subtitle:u(`charts.tokenEfficiency.subtitle`,{value:m(k)}),info:g.tokenEfficiency,chartData:O,valueKey:`efficiency`,valueFormatter:m,children:(0,D.jsx)(C,{children:e=>(0,D.jsx)(S,{variant:`line`,children:(0,D.jsx)(t,{width:`100%`,height:250,children:(0,D.jsxs)(c,{data:O,margin:b,children:[(0,D.jsx)(`defs`,{children:(0,D.jsxs)(`linearGradient`,{id:`${d}-effGrad`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,D.jsx)(`stop`,{offset:`0%`,stopColor:v.input,stopOpacity:.2}),(0,D.jsx)(`stop`,{offset:`100%`,stopColor:v.input,stopOpacity:0})]})}),(0,D.jsx)(o,{strokeDasharray:`3 3`,stroke:v.grid,opacity:.3}),(0,D.jsx)(a,{dataKey:`date`,tickFormatter:p,stroke:v.axis,fontSize:11,tickLine:!1}),(0,D.jsx)(n,{tickFormatter:e=>{let t=h(e);return t===null?``:m(t)},stroke:v.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,D.jsx)(l,{content:(0,D.jsx)(w,{formatter:e=>m(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,D.jsx)(i,{y:k,stroke:v.axis,strokeDasharray:`3 3`,strokeOpacity:.5}),(0,D.jsx)(r,{type:`monotone`,dataKey:`efficiency`,stroke:v.input,fill:`url(#${d}-effGrad)`,strokeWidth:1.5,name:u(`charts.tokenEfficiency.series`),dot:!1,..._(e)}),(0,D.jsx)(s,{type:`monotone`,dataKey:`effMA7`,stroke:v.ma7,strokeWidth:2,strokeDasharray:`5 5`,dot:!1,connectNulls:!0,name:u(`charts.tokenEfficiency.movingAverage`),...y(e,{role:`secondary`})})]})})})})})}export{O as TokenEfficiency};
@@ -0,0 +1 @@
1
+ import{_ as e,b as t,g as n,i as r,v as i,y as a}from"./charts-vendor-CiBqdKXh.js";import{o}from"./motion-vendor-BNFhNARW.js";import{t as s}from"./useTranslation-JH30oWEP.js";import{d as c}from"./formatters-BzLLk0br.js";import{t as l}from"./help-content-Cuf5l3_6.js";import{n as u,s as d}from"./chart-theme-BdE8bEiN.js";import{n as f,r as p,t as m}from"./ChartCard-CS4Kbe6r.js";import{t as h}from"./ChartLegend-Vzg_GmF-.js";import{t as g}from"./CustomTooltip-CEd8U-a3.js";var _=o(),v={Input:u.input,Output:u.output,"Cache Write":u.cacheWrite,"Cache Read":u.cacheRead,Thinking:u.cost};function y({viewBox:e,total:t}){let{t:n}=s();if(!e)return null;let{cx:r,cy:i}=e;return(0,_.jsxs)(`g`,{children:[(0,_.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.tokenTypes.total`)}),(0,_.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function b({data:o}){let{t:b}=s(),x=o.reduce((e,t)=>e+t.value,0);return(0,_.jsx)(f,{title:b(`charts.tokenTypes.title`),subtitle:b(`charts.tokenTypes.subtitle`),info:l.tokenTypes,chartData:o,valueKey:`value`,valueFormatter:c,children:s=>{let l=s?560:320,f=s?`66%`:`57%`,b=s?84:58,S=s?134:92;return(0,_.jsx)(m,{children:m=>(0,_.jsx)(p,{variant:`radial`,children:(0,_.jsx)(t,{width:`100%`,height:l,children:(0,_.jsxs)(r,{children:[(0,_.jsxs)(n,{data:o,cx:`50%`,cy:f,innerRadius:b,outerRadius:S,paddingAngle:2,dataKey:`value`,nameKey:`name`,...d(m),children:[o.map(t=>(0,_.jsx)(e,{fill:v[t.name]??u.cost},t.name)),(0,_.jsx)(y,{total:c(x)})]}),(0,_.jsx)(i,{content:(0,_.jsx)(g,{formatter:e=>c(e)})}),(0,_.jsx)(a,{content:(0,_.jsx)(h,{className:s?`pt-[22px]`:`pt-2`,renderLabel:e=>{let t=String(e.value??``),n=o.find(e=>e.name===t);return`${t} (${n?c(n.value):``})`}})})]})})})})}})}export{b as TokenTypes};