@roastcodes/ttdash 6.2.1 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AnimatedBarFill-DFAXO-3i.js +1 -0
- package/dist/assets/{AnomalyDetection-BdGl1xvC.js → AnomalyDetection-DKM--5-J.js} +1 -1
- package/dist/assets/{AutoImportModal-bokip1Pn.js → AutoImportModal-Cqefa6n_.js} +1 -1
- package/dist/assets/CacheROI-BLADEjtP.js +1 -0
- package/dist/assets/ChartCard-DxxB4rGm.js +2 -0
- package/dist/assets/ChartLegend-Vpk95i3r.js +1 -0
- package/dist/assets/CorrelationAnalysis-CI9eGa8R.js +1 -0
- package/dist/assets/CostByModelOverTime-BDvnsdLO.js +1 -0
- package/dist/assets/{CostByWeekday-X20qjGNA.js → CostByWeekday-BPU1qW5f.js} +1 -1
- package/dist/assets/CostForecast-fwd7SRIn.js +1 -0
- package/dist/assets/CumulativeCost-CwiklwFD.js +1 -0
- package/dist/assets/{CustomTooltip-CBVU1pyK.js → CustomTooltip-CfoUDPbT.js} +1 -1
- package/dist/assets/DistributionAnalysis-B8pjQMNj.js +1 -0
- package/dist/assets/{DrillDownModal-BXf7B9B8.js → DrillDownModal-kczVCwfa.js} +1 -1
- package/dist/assets/{HelpPanel-HNxQElT5.js → HelpPanel-D4zNwrI2.js} +1 -1
- package/dist/assets/{InfoButton-CTgLGzb9.js → InfoButton-BGjUQfHz.js} +1 -1
- package/dist/assets/InfoHeading-BxLyydv8.js +1 -0
- package/dist/assets/{MetricCard-Drluz0b9.js → MetricCard-r_uhdKDU.js} +1 -1
- package/dist/assets/{ModelEfficiency-CZ4ZzDtA.js → ModelEfficiency-Di3fDAn7.js} +1 -1
- package/dist/assets/{ModelMix-TDHxSk5H.js → ModelMix-BgCzWf9V.js} +1 -1
- package/dist/assets/{PeriodComparison-B9WuoaCr.js → PeriodComparison-BIoF7n2v.js} +1 -1
- package/dist/assets/{ProviderEfficiency-DpDIYr_l.js → ProviderEfficiency-BFUYfBkW.js} +1 -1
- package/dist/assets/ProviderLimitsSection-BxaczEFO.js +1 -0
- package/dist/assets/RecentDays-Bac6HOtv.js +1 -0
- package/dist/assets/RequestCacheHitRateByModel-DD2j4dXY.js +1 -0
- package/dist/assets/RequestQuality-CUy5BQzj.js +1 -0
- package/dist/assets/RequestsOverTime-Bv3riiRF.js +1 -0
- package/dist/assets/SettingsModal-4uENZ87D.js +1 -0
- package/dist/assets/TokenEfficiency-6dfn-4_1.js +1 -0
- package/dist/assets/TokenTypes-Dx67irJb.js +1 -0
- package/dist/assets/TokensOverTime-C1858Oi-.js +1 -0
- package/dist/assets/{app-settings-C3i52ycx.js → app-settings-BInClAwB.js} +1 -1
- package/dist/assets/button-CRvPoJg9.js +1 -0
- package/dist/assets/card-B4CVYJDH.js +1 -0
- package/dist/assets/chart-theme-BdE8bEiN.js +1 -0
- package/dist/assets/{constants-jyhBMReu.js → constants-BDzjWFuU.js} +1 -1
- package/dist/assets/{dialog-C0AeNKs8.js → dialog-Djogwk0C.js} +1 -1
- package/dist/assets/{formatted-value-rO0EpKbc.js → formatted-value-CpLoDrYF.js} +1 -1
- package/dist/assets/{formatters-yKppUXb3.js → formatters-C7EouP6y.js} +1 -1
- package/dist/assets/help-content-B2N8SHIE.js +1 -0
- package/dist/assets/i18n-BS3-GJaA.js +1 -0
- package/dist/assets/index-8kk0H-lQ.css +2 -0
- package/dist/assets/index-C59tb1_V.js +3 -0
- package/dist/assets/motion-vendor-BNVN-Ktr.js +9 -0
- package/dist/assets/{section-header-DbV45zH5.js → section-header-Dz0QIE6e.js} +1 -1
- package/dist/assets/{ui-vendor-BolBXLiD.js → ui-vendor-C_SJC6eX.js} +1 -1
- package/dist/assets/useTranslation-0ThAx3Gl.js +1 -0
- package/dist/index.html +25 -24
- package/package.json +1 -1
- package/server.js +7 -0
- package/src/locales/de/common.json +10 -0
- package/src/locales/en/common.json +10 -0
- package/dist/assets/CacheROI-IyVKLGZu.js +0 -1
- package/dist/assets/ChartCard-CBUnItl-.js +0 -2
- package/dist/assets/ChartLegend-B64cJdDI.js +0 -1
- package/dist/assets/CorrelationAnalysis-Dnd0YUCO.js +0 -1
- package/dist/assets/CostByModelOverTime-C10Hr2xR.js +0 -1
- package/dist/assets/CostForecast-C--EIZ4B.js +0 -1
- package/dist/assets/CumulativeCost-D9v6GDcr.js +0 -1
- package/dist/assets/DistributionAnalysis-Cdly0pAu.js +0 -1
- package/dist/assets/InfoHeading-oi90uCR7.js +0 -1
- package/dist/assets/ProviderLimitsSection-CSuisho_.js +0 -1
- package/dist/assets/RecentDays-Cz4Yd_-Q.js +0 -1
- package/dist/assets/RequestCacheHitRateByModel-5bkvg7Hx.js +0 -1
- package/dist/assets/RequestQuality-iUIOJrpr.js +0 -1
- package/dist/assets/RequestsOverTime-D10OssgN.js +0 -1
- package/dist/assets/SettingsModal-D9-T5heB.js +0 -1
- package/dist/assets/TokenEfficiency-CGeyr8Zq.js +0 -1
- package/dist/assets/TokenTypes-BiRBF9VP.js +0 -1
- package/dist/assets/TokensOverTime-DeT3D-aC.js +0 -1
- package/dist/assets/button-D--hHeVj.js +0 -1
- package/dist/assets/card-h-Z9EWBl.js +0 -1
- package/dist/assets/chart-theme-D5iCFDJg.js +0 -1
- package/dist/assets/help-content-Bt5KCpWS.js +0 -1
- package/dist/assets/i18n-C88wS2Uy.js +0 -1
- package/dist/assets/index-DjMakAzD.js +0 -3
- package/dist/assets/index-DuoM1Ukq.css +0 -2
- package/dist/assets/motion-vendor-vKc6gXHZ.js +0 -1
- package/dist/assets/useTranslation-BSl7t2D6.js +0 -1
- /package/dist/assets/{calculations-GOdNqKo6.js → calculations-BJw_4KdI.js} +0 -0
- /package/dist/assets/{provider-limits-5e1fUwPl.js → provider-limits-BgKrr7k7.js} +0 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CostForecast-fwd7SRIn.js","assets/rolldown-runtime-COnpUsM8.js","assets/charts-vendor-CiBqdKXh.js","assets/motion-vendor-BNVN-Ktr.js","assets/icons-vendor-CIvT_-Pb.js","assets/useTranslation-0ThAx3Gl.js","assets/MetricCard-r_uhdKDU.js","assets/card-B4CVYJDH.js","assets/InfoButton-BGjUQfHz.js","assets/formatters-C7EouP6y.js","assets/ui-vendor-C_SJC6eX.js","assets/react-vendor-0R1rd57Z.js","assets/i18n-BS3-GJaA.js","assets/ChartCard-DxxB4rGm.js","assets/chart-theme-BdE8bEiN.js","assets/dialog-Djogwk0C.js","assets/ChartLegend-Vpk95i3r.js","assets/CustomTooltip-CfoUDPbT.js","assets/formatted-value-CpLoDrYF.js","assets/calculations-BJw_4KdI.js","assets/model-utils-BIvGAFGz.js","assets/help-content-B2N8SHIE.js","assets/CostByModelOverTime-BDvnsdLO.js","assets/CumulativeCost-CwiklwFD.js","assets/CostByWeekday-BPU1qW5f.js","assets/TokenEfficiency-6dfn-4_1.js","assets/ModelMix-BgCzWf9V.js","assets/TokensOverTime-C1858Oi-.js","assets/TokenTypes-Dx67irJb.js","assets/RequestsOverTime-Bv3riiRF.js","assets/RequestCacheHitRateByModel-DD2j4dXY.js","assets/CacheROI-BLADEjtP.js","assets/AnimatedBarFill-DFAXO-3i.js","assets/InfoHeading-BxLyydv8.js","assets/constants-BDzjWFuU.js","assets/ProviderLimitsSection-BxaczEFO.js","assets/section-header-Dz0QIE6e.js","assets/provider-limits-BgKrr7k7.js","assets/RequestQuality-CUy5BQzj.js","assets/DistributionAnalysis-B8pjQMNj.js","assets/CorrelationAnalysis-CI9eGa8R.js","assets/PeriodComparison-BIoF7n2v.js","assets/button-CRvPoJg9.js","assets/AnomalyDetection-DKM--5-J.js","assets/ModelEfficiency-Di3fDAn7.js","assets/ProviderEfficiency-BFUYfBkW.js","assets/RecentDays-Bac6HOtv.js","assets/DrillDownModal-kczVCwfa.js","assets/AutoImportModal-Cqefa6n_.js","assets/SettingsModal-4uENZ87D.js","assets/app-settings-BInClAwB.js","assets/HelpPanel-D4zNwrI2.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{C as t,_ as n,b as r,c as i,f as a,g as o,i as s,l as c,m as l,p as u,t as d,v as f,w as p,y as m}from"./charts-vendor-CiBqdKXh.js";import{u as h}from"./react-vendor-0R1rd57Z.js";import{a as g,n as _}from"./motion-vendor-BNVN-Ktr.js";import{_ as v,d as y,f as b,g as x,h as S,m as C,p as w,t as T,u as E,v as D}from"./ui-vendor-C_SJC6eX.js";import{a as O,i as k,o as A,r as j,t as M}from"./useTranslation-0ThAx3Gl.js";import{_ as N,a as P,b as ee,c as te,d as F,g as I,i as L,l as R,m as ne,n as z,o as re,p as B,s as ie,t as ae,u as V}from"./formatters-C7EouP6y.js";import{a as oe,i as se,r as ce}from"./i18n-BS3-GJaA.js";import{$ as le,A as ue,C as de,D as fe,F as pe,G as me,I as he,J as ge,K as _e,M as ve,P as ye,Q as be,R as xe,U as Se,V as Ce,W as we,X as Te,Y as Ee,Z as De,_ as Oe,a as ke,b as Ae,d as je,et as Me,f as Ne,g as Pe,i as Fe,it as H,j as Ie,k as Le,l as Re,n as ze,o as Be,p as Ve,q as He,r as Ue,rt as We,s as Ge,t as Ke,u as qe,v as Je,w as Ye,x as Xe,y as Ze,z as Qe}from"./icons-vendor-CIvT_-Pb.js";import{t as U}from"./button-CRvPoJg9.js";import{a as $e,i as et}from"./constants-BDzjWFuU.js";import{a as tt,c as W,i as nt,l as rt,n as it,o as at,s as ot,t as st}from"./model-utils-BIvGAFGz.js";import{a as ct,c as G,i as lt,l as ut,n as dt,o as ft,s as pt,t as mt}from"./card-B4CVYJDH.js";import{a as ht,n as gt,r as _t,t as vt}from"./dialog-Djogwk0C.js";import{a as yt,n as bt,r as xt,s as St,t as Ct}from"./app-settings-BInClAwB.js";import{t as K}from"./MetricCard-r_uhdKDU.js";import{t as q}from"./formatted-value-CpLoDrYF.js";import{i as wt,n as Tt,r as Et,t as Dt}from"./help-content-B2N8SHIE.js";import{t as Ot}from"./InfoHeading-BxLyydv8.js";import{t as kt}from"./section-header-Dz0QIE6e.js";import{i as At,n as jt,o as Mt,r as Nt,s as Pt}from"./chart-theme-BdE8bEiN.js";import{a as Ft,n as It,r as Lt,t as Rt}from"./ChartCard-DxxB4rGm.js";import{t as zt}from"./ChartLegend-Vpk95i3r.js";import{t as Bt}from"./CustomTooltip-CfoUDPbT.js";import{t as Vt}from"./AnimatedBarFill-DFAXO-3i.js";import{a as Ht}from"./provider-limits-BgKrr7k7.js";import{a as Ut,i as Wt,o as Gt,s as Kt}from"./calculations-BJw_4KdI.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var qt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Jt=new class extends qt{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},Yt={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Xt=new class{#e=Yt;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Zt(e){setTimeout(e,0)}var Qt=typeof window>`u`||`Deno`in globalThis;function J(){}function $t(e,t){return typeof e==`function`?e(t):e}function en(e){return typeof e==`number`&&e>=0&&e!==1/0}function tn(e,t){return Math.max(e+(t||0)-Date.now(),0)}function nn(e,t){return typeof e==`function`?e(t):e}function rn(e,t){return typeof e==`function`?e(t):e}function an(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==sn(o,t.options))return!1}else if(!ln(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function on(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(cn(t.options.mutationKey)!==cn(a))return!1}else if(!ln(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function sn(e,t){return(t?.queryKeyHashFn||cn)(e)}function cn(e){return JSON.stringify(e,(e,t)=>mn(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ln(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ln(e[n],t[n])):!1}var un=Object.prototype.hasOwnProperty;function dn(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=pn(e)&&pn(t);if(!r&&!(mn(e)&&mn(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:un.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=dn(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function fn(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function pn(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function mn(e){if(!hn(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!hn(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function hn(e){return Object.prototype.toString.call(e)===`[object Object]`}function gn(e){return new Promise(t=>{Xt.setTimeout(t,e)})}function _n(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:dn(e,t)}function vn(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function yn(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var bn=Symbol();function xn(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===bn?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Sn(e,t){return typeof e==`function`?e(...t):!!e}function Cn(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var wn=(()=>{let e=()=>Qt;return{isServer(){return e()},setIsServer(t){e=t}}})();function Tn(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var En=Zt;function Dn(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=En,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var Y=Dn(),On=new class extends qt{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function kn(e){return Math.min(1e3*2**e,3e4)}function An(e){return(e??`online`)===`online`?On.isOnline():!0}var jn=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Mn(e){let t=!1,n=0,r,i=Tn(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new jn(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>Jt.isFocused()&&(e.networkMode===`always`||On.isOnline())&&e.canRun(),u=()=>An(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(wn.isServer()?0:3),o=e.retryDelay??kn,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),gn(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var Nn=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),en(this.gcTime)&&(this.#e=Xt.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(wn.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(Xt.clearTimeout(this.#e),this.#e=void 0)}},Pn=class extends Nn{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=Ln(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=Ln(this.options);e.data!==void 0&&(this.setState(In(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=_n(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(J).catch(J):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>rn(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===bn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>nn(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!tn(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=xn(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Mn({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof jn&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof jn){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Fn(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...In(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),Y.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Fn(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:An(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function In(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function Ln(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var Rn=class extends qt{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=Tn(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Bn(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Vn(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Vn(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof rn(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!fn(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&Hn(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||rn(this.options.enabled,this.#t)!==rn(t.enabled,this.#t)||nn(this.options.staleTime,this.#t)!==nn(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||rn(this.options.enabled,this.#t)!==rn(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Wn(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&(this.trackProp(`data`),!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`))),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(J)),t}#g(){this.#b();let e=nn(this.options.staleTime,this.#t);if(wn.isServer()||this.#r.isStale||!en(e))return;let t=tn(this.#r.dataUpdatedAt,e)+1;this.#d=Xt.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!(wn.isServer()||rn(this.options.enabled,this.#t)===!1||!en(this.#p)||this.#p===0)&&(this.#f=Xt.setInterval(()=>{(this.options.refetchIntervalInBackground||Jt.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d!==void 0&&(Xt.clearTimeout(this.#d),this.#d=void 0)}#x(){this.#f!==void 0&&(Xt.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&Bn(e,t),o=i&&Hn(e,n,t,r);(a||o)&&(l={...l,...Fn(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=_n(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h)if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=_n(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:Un(e,t),refetch:this.refetch,promise:this.#o,isEnabled:rn(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=x.data!==void 0,r=x.status===`error`&&!t,i=e=>{r?e.reject(x.error):t&&e.resolve(x.data)},a=()=>{i(this.#o=x.promise=Tn())},o=this.#o;switch(o.status){case`pending`:e.queryHash===n.queryHash&&i(o);break;case`fulfilled`:(r||x.data!==o.value)&&a();break;case`rejected`:(!r||x.error!==o.reason)&&a();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!fn(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){Y.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function zn(e,t){return rn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status===`error`&&t.retryOnMount===!1)}function Bn(e,t){return zn(e,t)||e.state.data!==void 0&&Vn(e,t,t.refetchOnMount)}function Vn(e,t,n){if(rn(t.enabled,e)!==!1&&nn(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&Un(e,t)}return!1}function Hn(e,t,n,r){return(e!==t||rn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&Un(e,n)}function Un(e,t){return rn(t.enabled,e)!==!1&&e.isStaleByTime(nn(t.staleTime,e))}function Wn(e,t){return!fn(e.getCurrentResult(),t)}function Gn(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Cn(e,()=>t.signal,()=>n=!0)},u=xn(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?yn:vn;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?qn:Kn,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Kn(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function Kn(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qn(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Jn=class extends Nn{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Yn(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Mn({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),Y.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Yn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xn=class extends qt{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Jn({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Zn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Zn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Y.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>on(t,e))}findAll(e={}){return this.getAll().filter(t=>on(e,t))}notify(e){Y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Y.batch(()=>Promise.all(e.map(e=>e.continue().catch(J))))}};function Zn(e){return e.options.scope?.id}var Qn=class extends qt{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),fn(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&cn(t.mutationKey)!==cn(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Yn();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Y.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}},$n=class extends qt{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??sn(r,t),a=this.get(i);return a||(a=new Pn({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Y.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>an(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>an(e,t)):t}notify(e){Y.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Y.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Y.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},er=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new $n,this.#t=e.mutationCache||new Xn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Jt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=On.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(nn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=$t(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Y.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Y.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Y.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Y.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(J).catch(J)}invalidateQueries(e,t={}){return Y.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Y.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(J)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(J)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(nn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(J).catch(J)}fetchInfiniteQuery(e){return e.behavior=Gn(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(J).catch(J)}ensureInfiniteQueryData(e){return e.behavior=Gn(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return On.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(cn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ln(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(cn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ln(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=sn(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===bn&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},X=e(p(),1),Z=g(),tr=X.createContext(void 0),nr=e=>{let t=X.useContext(tr);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},rr=({client:e,children:t})=>(X.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Z.jsx)(tr.Provider,{value:e,children:t})),ir=X.createContext(!1),ar=()=>X.useContext(ir);ir.Provider;function or(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var sr=X.createContext(or()),cr=()=>X.useContext(sr),lr=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Sn(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ur=e=>{X.useEffect(()=>{e.clearReset()},[e])},dr=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Sn(n,[e.error,r])),fr=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},pr=(e,t)=>e.isLoading&&e.isFetching&&!t,mr=(e,t)=>e?.suspense&&t.isPending,hr=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gr(e,t,n){let r=ar(),i=cr(),a=nr(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o);let s=a.getQueryCache().get(o.queryHash);o._optimisticResults=r?`isRestoring`:`optimistic`,fr(o),lr(o,i,s),ur(i);let c=!a.getQueryCache().get(o.queryHash),[l]=X.useState(()=>new t(a,o)),u=l.getOptimisticResult(o),d=!r&&e.subscribed!==!1;if(X.useSyncExternalStore(X.useCallback(e=>{let t=d?l.subscribe(Y.batchCalls(e)):J;return l.updateResult(),t},[l,d]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),X.useEffect(()=>{l.setOptions(o)},[o,l]),mr(o,u))throw hr(o,l,i);if(dr({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!wn.isServer()&&pr(u,r)&&(c?hr(o,l,i):s?.promise)?.catch(J).finally(()=>{l.updateResult()}),o.notifyOnChangeProps?u:l.trackResult(u)}function _r(e,t){return gr(e,Rn,t)}function vr(e,t){let n=nr(t),[r]=X.useState(()=>new Qn(n,e));X.useEffect(()=>{r.setOptions(e)},[r,e]);let i=X.useSyncExternalStore(X.useCallback(e=>r.subscribe(Y.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=X.useCallback((e,t)=>{r.mutate(e,t).catch(J)},[r]);if(i.error&&Sn(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}var yr=h(),br=(0,X.createContext)(null);function xr({children:e}){let{t}=M(),n=O(),[r,i]=(0,X.useState)([]),a=(0,X.useCallback)((e,t=`info`)=>{let n=Math.random().toString(36).slice(2);i(r=>[...r,{id:n,message:e,type:t}]),setTimeout(()=>{i(e=>e.filter(e=>e.id!==n))},4e3)},[]),o=(0,X.useCallback)(e=>{i(t=>t.filter(t=>t.id!==e))},[]);return(0,Z.jsxs)(br.Provider,{value:{toasts:r,addToast:a,removeToast:o},children:[e,(0,Z.jsx)(`div`,{className:`fixed right-4 bottom-4 z-50 flex flex-col gap-2`,"aria-live":`polite`,"aria-relevant":`additions text`,children:r.map(e=>(0,Z.jsx)(`div`,{role:e.type===`error`?`alert`:`status`,"aria-atomic":`true`,className:`rounded-lg border border-border px-4 py-3 text-sm shadow-lg backdrop-blur-sm ${k(n,`animate-in slide-in-from-bottom-2 fade-in-0`)} ${e.type===`error`?`bg-destructive/90 text-destructive-foreground`:e.type===`success`?`bg-primary/90 text-primary-foreground`:`bg-card/95 text-card-foreground`}`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Z.jsx)(`div`,{className:`min-w-0 flex-1`,children:e.message}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-sm opacity-80 transition-opacity hover:opacity-100 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,"aria-label":t(`common.close`),children:(0,Z.jsx)(ze,{className:`h-3.5 w-3.5`})})]})},e.id))})]})}function Sr(){let e=(0,X.useContext)(br);if(!e)throw Error(`useToast must be used within ToastProvider`);return e}function Cr({source:e}){let{t}=M();return e.type===`auto-import`?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-green-500/20 bg-green-500/10 px-2 py-0.5 text-[10px] font-medium text-green-400`,title:e.title??t(`emptyState.autoImport`),children:[(0,Z.jsx)(Ke,{className:`h-2.5 w-2.5`}),t(`emptyState.autoImport`),e.time&&(0,Z.jsxs)(`span`,{className:`text-green-400/60`,children:[`· `,e.time]})]}):e.type===`file`?(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1 rounded-md border border-blue-500/20 bg-blue-500/10 px-2 py-0.5 text-[10px] font-medium text-blue-400`,title:e.title??e.label??t(`emptyState.uploadFile`),children:[(0,Z.jsx)(Ie,{className:`h-2.5 w-2.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`max-w-28 truncate sm:max-w-40`,children:e.label??t(`emptyState.uploadFile`)}),e.time&&(0,Z.jsxs)(`span`,{className:`shrink-0 text-blue-400/60`,children:[`· `,e.time]})]}):(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border/50 bg-muted/50 px-2 py-0.5 text-[10px] font-medium text-muted-foreground`,title:e.title??t(`header.loaded`),children:[(0,Z.jsx)(fe,{className:`h-2.5 w-2.5`}),t(`header.loaded`),e.time&&(0,Z.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[`· `,e.time]})]})}function wr({badge:e}){let{t}=M();return e.active?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-amber-500/20 bg-amber-500/10 px-2 py-0.5 text-[10px] font-medium text-amber-400`,title:e.title??t(`header.autoLoadActive`),children:[(0,Z.jsx)(Ke,{className:`h-2.5 w-2.5`}),t(`header.autoLoadActive`),e.time&&(0,Z.jsxs)(`span`,{className:`text-amber-400/70`,children:[`· `,e.time]})]}):null}function Tr({dateRange:e,isDark:t,currentLanguage:n,streak:r,dataSource:i,startupAutoLoad:a,onHelpOpenChange:o,onLanguageChange:s,onToggleTheme:c,onExportCSV:l,onDelete:u,onUpload:d,onAutoImport:f,settingsButton:p,pdfButton:m}){let{t:h}=M(),g=h(t?`commandPalette.commands.themeLight.label`:`commandPalette.commands.themeDark.label`);return(0,Z.jsxs)(`header`,{className:`space-y-3 px-1 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsxs)(`h1`,{className:`shrink-0 text-2xl font-bold tracking-tight`,children:[(0,Z.jsx)(`span`,{className:`text-primary`,children:`TT`}),`Dash`]}),(0,Z.jsxs)(`a`,{href:et,target:`_blank`,rel:`noopener noreferrer`,className:`shrink-0 rounded-sm font-mono text-xs text-muted-foreground underline-offset-4 transition-colors hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,title:h(`header.versionLinkTitle`,{version:$e}),"aria-label":h(`header.versionLinkTitle`,{version:$e}),children:[`v`,$e]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 md:hidden`,children:[(0,Z.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>o(!0),"aria-label":h(`header.help`),title:h(`header.help`),children:(0,Z.jsx)(Ce,{className:`h-4 w-4`})}),(0,Z.jsx)(U,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":g,title:g,children:t?(0,Z.jsx)(qe,{className:`h-4 w-4`}):(0,Z.jsx)(Ze,{className:`h-4 w-4`})})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e&&(0,Z.jsxs)(`span`,{className:`rounded-md border border-border/50 bg-muted/50 px-2 py-0.5 font-mono text-xs text-muted-foreground`,children:[e.start,` — `,e.end]}),i&&(0,Z.jsx)(Cr,{source:i}),a&&(0,Z.jsx)(wr,{badge:a}),r!=null&&r>1&&(0,Z.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-md border border-orange-500/20 bg-orange-500/10 px-2 py-0.5 text-xs font-medium text-orange-400`,children:[(0,Z.jsx)(ue,{className:`h-3 w-3`}),h(`header.streak`,{count:r})]})]})]}),(0,Z.jsxs)(`div`,{className:`hidden shrink-0 items-center gap-1 md:flex`,children:[(0,Z.jsx)(`div`,{className:`inline-flex items-center rounded-md border border-border/50 bg-muted/20 p-0.5`,children:[`de`,`en`].map(e=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(e),"aria-pressed":n===e,className:`rounded px-2 py-1 text-[10px] font-medium transition-colors ${n===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,title:h(`app.languages.${e}`),children:e.toUpperCase()},e))}),(0,Z.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>o(!0),"aria-label":h(`header.help`),title:h(`header.help`),children:(0,Z.jsx)(Ce,{className:`h-4 w-4`})}),(0,Z.jsx)(`kbd`,{className:`hidden items-center gap-0.5 rounded border border-border/30 bg-muted/20 px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground/50 lg:inline-flex`,children:`⌘K`}),(0,Z.jsx)(U,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":g,title:g,children:t?(0,Z.jsx)(qe,{className:`h-4 w-4`}):(0,Z.jsx)(Ze,{className:`h-4 w-4`})})]})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 sm:flex sm:flex-wrap sm:items-center sm:gap-2`,children:[(0,Z.jsxs)(U,{variant:`outline`,size:`sm`,onClick:f,title:h(`emptyState.autoImport`),className:`h-11 justify-start gap-2 px-3 text-xs sm:h-9 sm:text-sm`,children:[(0,Z.jsx)(Ke,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:h(`header.import`)})]}),(0,Z.jsxs)(U,{variant:`outline`,size:`sm`,onClick:d,title:h(`emptyState.uploadFile`),className:`h-11 justify-start gap-2 px-3 text-xs sm:h-9 sm:text-sm`,children:[(0,Z.jsx)(Ue,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:h(`header.upload`)})]}),(0,Z.jsx)(`div`,{className:`contents sm:block sm:h-5 sm:w-px sm:bg-border/50`}),(0,Z.jsx)(`div`,{className:`contents sm:block`,children:p}),(0,Z.jsx)(`div`,{className:`contents sm:block`,children:m}),(0,Z.jsxs)(U,{variant:`outline`,size:`sm`,onClick:l,title:h(`commandPalette.commands.exportCsv.label`),className:`h-11 justify-start gap-2 px-3 text-xs sm:h-9 sm:text-sm`,children:[(0,Z.jsx)(ye,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:h(`header.csv`)})]}),(0,Z.jsx)(`div`,{className:`contents sm:block sm:h-5 sm:w-px sm:bg-border/50`}),(0,Z.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:u,title:h(`commandPalette.commands.delete.label`),className:`h-11 justify-start gap-2 px-3 text-xs text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:h-9 sm:text-sm`,children:[(0,Z.jsx)(Ge,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:h(`header.delete`)})]})]})]})}var Er=e(t()),Dr=S,Or=v,kr=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsxs)(x,{ref:r,className:A(`flex h-9 w-full items-center justify-between gap-2 rounded-md border border-border bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus:ring-2 focus:ring-ring focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1`,e),...n,children:[t,(0,Z.jsx)(y,{asChild:!0,children:(0,Z.jsx)(me,{className:`h-4 w-4 opacity-50`})})]}));kr.displayName=`SelectTrigger`;var Ar=X.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>{let a=O();return(0,Z.jsx)(C,{children:(0,Z.jsx)(E,{ref:i,className:A(`relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border border-border bg-popover text-popover-foreground shadow-md`,k(a,`animate-in fade-in-0 zoom-in-95`),n===`popper`&&`translate-y-1`,e),position:n,...r,children:(0,Z.jsx)(D,{className:A(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]`),children:t})})})});Ar.displayName=`SelectContent`;var jr=X.forwardRef(({className:e,children:t,...n},r)=>(0,Z.jsx)(b,{ref:r,className:A(`relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-none select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:(0,Z.jsx)(w,{children:t})}));jr.displayName=`SelectItem`;function Mr(e){if(!e)return null;let[t,n,r]=e.split(`-`).map(Number);return!t||!n||!r?null:new Date(t,n-1,r)}function Nr(e){let t=e.getFullYear(),n=e.getMonth(),r=new Date(t,n,1),i=new Date(t,n+1,0).getDate(),a=(r.getDay()+6)%7,o=[];for(let e=0;e<a;e++)o.push(null);for(let e=1;e<=i;e++)o.push(new Date(t,n,e));for(;o.length%7!=0;)o.push(null);return o}function Pr(e,t,n){if(e)return null;if(!t&&!n)return`all`;if(!t||!n)return null;let r=new Date;r.setHours(0,0,0,0);let i=N,a=e=>{switch(e){case`7d`:{let e=new Date(r);return e.setDate(r.getDate()-6),t===i(e)&&n===i(r)}case`30d`:{let e=new Date(r);return e.setDate(r.getDate()-29),t===i(e)&&n===i(r)}case`month`:return t===i(new Date(r.getFullYear(),r.getMonth(),1))&&n===i(r);case`year`:return t===i(new Date(r.getFullYear(),0,1))&&n===i(r);default:return!1}};for(let e of[`7d`,`30d`,`month`,`year`])if(a(e))return e;return null}function Fr({label:e,value:t,onChange:n}){let{t:r}=M(),i=(0,X.useId)(),a=(0,X.useId)(),o=(0,X.useId)(),[s,c]=(0,X.useState)(!1),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useRef)(null),f=(0,X.useRef)(new Map),[p,m]=(0,X.useState)({top:0,left:0,width:292}),h=(0,X.useMemo)(()=>Mr(t),[t]),[g,_]=(0,X.useState)(()=>h??Mr(ne())??new Date),v=(0,X.useMemo)(()=>Array.from({length:7},(e,t)=>new Intl.DateTimeFormat(ce(),{weekday:`short`}).format(new Date(Date.UTC(2024,0,1+t))).replace(`.`,``).slice(0,2)),[]),y=(0,X.useMemo)(()=>g.toLocaleDateString(ce(),{month:`long`,year:`numeric`}),[g]),b=(0,X.useMemo)(()=>Nr(g),[g]),x=(0,X.useMemo)(()=>b.filter(e=>e!==null).map(e=>N(e)),[b]),S=ne(),[C,w]=(0,X.useState)(t??S),T=(0,X.useCallback)(e=>{if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){window.requestAnimationFrame(e);return}setTimeout(e,0)},[]),E=(0,X.useCallback)(e=>{let t=e.getFullYear(),n=e.getMonth(),r=e.getDate(),i=new Date(t,n+1,0).getDate();return new Date(t,n,Math.min(r,i))},[]),D=(0,X.useCallback)((e=!0)=>{c(!1),e&&T(()=>{u.current?.focus()})},[T]),O=(0,X.useCallback)(e=>e&&x.includes(e)?e:t&&x.includes(t)?t:x.includes(S)?S:x[0]??null,[x,S,t]),k=(0,X.useCallback)(e=>{e&&(w(e),T(()=>{f.current.get(e)?.focus()}))},[T]),j=(0,X.useCallback)(e=>{let n=Mr(C??t??S)??new Date,r=E(new Date(n.getFullYear(),n.getMonth()+e,n.getDate()));_(new Date(r.getFullYear(),r.getMonth(),1)),w(N(r))},[E,C,S,t]),P=(0,X.useCallback)(e=>{n(e),D()},[D,n]);(0,X.useEffect)(()=>{h&&_(new Date(h.getFullYear(),h.getMonth(),1))},[h]),(0,X.useEffect)(()=>{if(!s)return;w(e=>O(e));let e=()=>{let e=u.current?.getBoundingClientRect();if(!e)return;let t=window.innerWidth,n=window.innerHeight,r=Math.min(Math.max(12,e.left),Math.max(12,t-292-12));m({top:e.bottom+330>n-12&&e.top>330?Math.max(12,e.top-330-8):Math.min(n-330-12,e.bottom+8),left:r,width:292})};e();let t=e=>{let t=e.target;!l.current?.contains(t)&&!d.current?.contains(t)&&D(!1)},n=e=>{e.key===`Escape`&&D()};return window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),document.addEventListener(`mousedown`,t),document.addEventListener(`keydown`,n),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0),document.removeEventListener(`mousedown`,t),document.removeEventListener(`keydown`,n)}},[D,s,O]),(0,X.useEffect)(()=>{if(!s)return;let e=O(C);if(e!==C){w(e);return}e&&T(()=>{f.current.get(e)?.focus()})},[C,s,O,T]);let ee=(0,X.useCallback)((e,t)=>{let n=x.indexOf(t);if(n<0)return;let r=b.find(e=>e&&N(e)===t),i=e=>{let t=x[Math.max(0,Math.min(e,x.length-1))];k(t??null)};switch(e.key){case`ArrowLeft`:e.preventDefault(),i(n-1);break;case`ArrowRight`:e.preventDefault(),i(n+1);break;case`ArrowUp`:e.preventDefault(),i(n-7);break;case`ArrowDown`:e.preventDefault(),i(n+7);break;case`Home`:if(!r)return;e.preventDefault(),i(n-(r.getDay()+6)%7);break;case`End`:if(!r)return;e.preventDefault(),i(n+(6-(r.getDay()+6)%7));break;case`PageUp`:e.preventDefault(),j(-1);break;case`PageDown`:e.preventDefault(),j(1);break;case`Enter`:case` `:e.preventDefault(),P(t);break;default:break}},[b,k,P,x,j]);return(0,Z.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,Z.jsx)(`button`,{ref:u,type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-controls":s?i:void 0,onClick:()=>{c(e=>{let n=!e;return n&&w(O(t)),n})},className:`flex h-10 w-full items-center justify-between gap-3 rounded-md border border-border bg-background px-3 pr-14 text-left text-sm transition-colors hover:bg-accent/40`,children:(0,Z.jsx)(`span`,{className:A(`truncate`,t?`text-foreground`:`text-muted-foreground`),children:t?L(t,`long`):e})}),t&&(0,Z.jsx)(`button`,{type:`button`,"aria-label":r(`filterBar.clearDate`,{label:e}),onClick:()=>n(void 0),className:`absolute top-1/2 right-8 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:(0,Z.jsx)(ze,{className:`h-3.5 w-3.5`})}),(0,Z.jsx)(De,{className:`pointer-events-none absolute top-1/2 right-3 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),s&&typeof document<`u`&&(0,Er.createPortal)((0,Z.jsxs)(`div`,{id:i,ref:d,role:`dialog`,"aria-modal":`false`,"aria-labelledby":a,"aria-describedby":o,className:`fixed z-[999] rounded-xl border border-border/80 bg-card/98 p-3 shadow-2xl backdrop-blur-xl`,style:{top:p.top,left:p.left,width:p.width},children:[(0,Z.jsx)(`div`,{id:a,className:`sr-only`,children:e}),(0,Z.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>j(-1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background/70 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,"aria-label":r(`common.previousMonth`),children:(0,Z.jsx)(we,{className:`h-4 w-4`})}),(0,Z.jsx)(`div`,{id:o,className:`text-sm font-medium capitalize`,children:y}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>j(1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background/70 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,"aria-label":r(`common.nextMonth`),children:(0,Z.jsx)(Se,{className:`h-4 w-4`})})]}),(0,Z.jsx)(`div`,{className:`mb-2 grid grid-cols-7 gap-1`,children:v.map(e=>(0,Z.jsx)(`div`,{className:`px-1 py-1 text-center text-[11px] font-medium tracking-wide text-muted-foreground uppercase`,children:e},e))}),(0,Z.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:b.map((e,n)=>{if(!e)return(0,Z.jsx)(`div`,{className:`h-9`},`empty-${n}`);let r=N(e),i=t===r,a=r===S,o=L(r,`long`);return(0,Z.jsx)(`button`,{ref:e=>{e?f.current.set(r,e):f.current.delete(r)},type:`button`,tabIndex:C===r?0:-1,"aria-label":o,"aria-current":a?`date`:void 0,"aria-pressed":i,onFocus:()=>w(r),onKeyDown:e=>ee(e,r),onClick:()=>P(r),className:A(`h-9 rounded-md text-sm font-medium transition-colors`,i?`bg-primary text-primary-foreground shadow-sm`:a?`border border-primary/50 bg-primary/10 text-foreground hover:bg-primary/15`:`text-foreground hover:bg-accent`),children:e.getDate()},r)})}),(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2 border-t border-border/70 pt-3`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{n(void 0),D()},className:`rounded-md px-2.5 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:r(`common.reset`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{let e=S;_(Mr(e)??new Date),P(e)},className:`rounded-md bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90`,children:r(`common.today`)})]})]}),document.body)]})}function Ir(e,t){return e?`selected`:t?`inactive`:`included`}function Lr({viewMode:e,onViewModeChange:t,selectedMonth:n,onMonthChange:r,availableMonths:i,availableProviders:a,selectedProviders:o,onToggleProvider:s,onClearProviders:c,allModels:l,selectedModels:u,onToggleModel:d,onClearModels:f,startDate:p,endDate:m,onStartDateChange:h,onEndDateChange:g,onApplyPreset:_,onResetAll:v}){let{t:y}=M(),b=(0,X.useMemo)(()=>Pr(n,p,m),[n,p,m]),x=n!==null||o.length>0||u.length>0||!!(p||m)||e!==`daily`;return(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/50 bg-card/40 px-3 py-3 backdrop-blur-xl`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{className:`font-semibold tracking-[0.14em] uppercase`,children:y(`filterBar.status`)}),(0,Z.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:o.length>0?y(`filterBar.providersActive`,{count:o.length}):y(`common.allProviders`)}),(0,Z.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:u.length>0?y(`filterBar.modelsActive`,{count:u.length}):y(`common.allModels`)}),(p||m)&&(0,Z.jsx)(`span`,{className:`rounded-full bg-muted/30 px-2 py-0.5`,children:y(`filterBar.dateFilterActive`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>v(),className:`ml-auto inline-flex items-center rounded-full border border-border px-2.5 py-0.5 text-[11px] font-medium text-foreground transition-all duration-200 hover:border-accent hover:bg-accent disabled:opacity-40 disabled:hover:border-border disabled:hover:bg-transparent`,disabled:!x,children:y(`filterBar.resetAll`)})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 xl:grid-cols-[160px_190px_1fr]`,children:[(0,Z.jsxs)(Dr,{value:e,onValueChange:e=>t(e),children:[(0,Z.jsx)(kr,{className:`w-full`,"aria-label":y(`filterBar.viewModeLabel`),children:(0,Z.jsx)(Or,{})}),(0,Z.jsx)(Ar,{children:[`daily`,`monthly`,`yearly`].map(e=>(0,Z.jsx)(jr,{value:e,children:y(`viewModes.${e}`)},e))})]}),(0,Z.jsxs)(Dr,{value:n??`all`,onValueChange:e=>r(e===`all`?null:e),children:[(0,Z.jsx)(kr,{className:`w-full`,"aria-label":y(`filterBar.focusMonthLabel`),children:(0,Z.jsx)(Or,{})}),(0,Z.jsxs)(Ar,{children:[(0,Z.jsx)(jr,{value:`all`,children:y(`common.allMonths`)}),i.map(e=>(0,Z.jsx)(jr,{value:e,children:te(e)},e))]})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[{key:`7d`,label:y(`filterBar.presets.7d`)},{key:`30d`,label:y(`filterBar.presets.30d`)},{key:`month`,label:y(`filterBar.presets.month`)},{key:`year`,label:y(`filterBar.presets.year`)},{key:`all`,label:y(`filterBar.presets.all`)}].map(e=>(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":b===e.key,onClick:()=>_(e.key),className:A(`min-w-[48px] rounded-full border px-3 py-1.5 text-xs font-medium transition-all duration-200`,b===e.key?`border-primary bg-primary text-primary-foreground shadow-[0_0_0_1px_rgba(255,255,255,0.06)]`:`border-border hover:border-accent hover:bg-accent`),children:e.label},e.key))})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 md:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)_auto] md:items-center`,children:[(0,Z.jsx)(Fr,{label:y(`common.startDate`),onChange:h,...p?{value:p}:{}}),(0,Z.jsx)(`span`,{className:`hidden text-xs text-muted-foreground md:inline`,children:y(`filterBar.until`)}),(0,Z.jsx)(Fr,{label:y(`common.endDate`),onChange:g,...m?{value:m}:{}}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{h(void 0),g(void 0)},className:`rounded-full border border-border px-3 py-2 text-xs font-medium transition-all duration-200 hover:border-accent hover:bg-accent`,children:y(`filterBar.resetDateRange`)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[0.14em] text-muted-foreground uppercase`,children:y(`filterBar.providers`)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[a.map(e=>{let t=o.includes(e),n=Ir(t,o.length>0),r=tt(e);return(0,Z.jsx)(`button`,{type:`button`,"data-filter-state":n,"aria-pressed":t,onClick:()=>s(e),className:A(`inline-flex cursor-pointer items-center rounded-full border px-2.5 py-1 text-xs font-semibold transition-all duration-200`,n===`selected`?nt(e):n===`included`?`border-border/70 bg-background/70 hover:bg-accent`:`border-border text-muted-foreground hover:bg-accent hover:text-foreground`),style:n===`selected`?r:n===`included`?{color:r.color,backgroundColor:r.backgroundColor.replace(/0\.10\)$/,`0.05)`),borderColor:r.borderColor.replace(/0\.20\)$/,`0.14)`)}:void 0,children:e},e)}),o.length>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:c,className:`inline-flex items-center rounded-full border border-border px-2.5 py-1 text-xs font-medium transition-all duration-200 hover:bg-accent`,children:y(`common.reset`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-semibold tracking-[0.14em] text-muted-foreground uppercase`,children:y(`filterBar.models`)}),u.length>0&&(0,Z.jsx)(`button`,{type:`button`,onClick:f,className:`inline-flex items-center rounded-full border border-border px-2.5 py-1 text-xs font-medium transition-all duration-200 hover:bg-accent`,children:y(`filterBar.resetModels`)})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:l.map(e=>{let t=u.includes(e),n=st(e),r=Ir(t,u.length>0);return(0,Z.jsxs)(`button`,{type:`button`,"data-filter-state":r,"aria-pressed":t,onClick:()=>d(e),className:A(`inline-flex cursor-pointer items-center rounded-full px-2.5 py-1 text-xs font-medium`,`border transition-all duration-200 hover:scale-[1.03]`,r===`selected`?`opacity-100`:r===`included`?`opacity-85`:`opacity-40 hover:opacity-70`),style:{borderColor:n,backgroundColor:r===`selected`?it(e,.16):r===`included`?it(e,.08):`transparent`,color:n},children:[(0,Z.jsx)(`span`,{className:`mr-1.5 h-2 w-2 rounded-full`,style:{backgroundColor:n}}),e]},e)})})]})]})]})})}function Rr({children:e,delay:t=0,duration:n=.5,className:r,direction:i=`up`}){return O()?(0,Z.jsx)(`div`,{className:r,children:e}):(0,Z.jsx)(_.div,{initial:{opacity:0,...{up:{y:20},down:{y:-20},left:{x:20},right:{x:-20},none:{}}[i]},whileInView:{opacity:1,x:0,y:0},viewport:{once:!0,amount:.2},transition:{duration:n,delay:t,ease:`easeOut`},className:r,children:e})}function zr({onUpload:e,onAutoImport:t,onOpenSettings:n}){let{t:r}=M();return(0,Z.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:(0,Z.jsx)(Rr,{delay:0,duration:.45,children:(0,Z.jsxs)(mt,{className:`w-full max-w-md space-y-6 border-primary/20 p-10 text-center shadow-xl shadow-primary/5`,children:[(0,Z.jsx)(`div`,{className:`mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-primary/10`,children:(0,Z.jsx)(ge,{className:`h-8 w-8 text-primary`})}),(0,Z.jsxs)(`div`,{className:`space-y-1`,children:[(0,Z.jsxs)(`h1`,{className:`text-3xl font-bold tracking-tight`,children:[(0,Z.jsx)(`span`,{className:`text-primary`,children:`TT`}),`Dash`]}),(0,Z.jsxs)(`p`,{className:`font-mono text-xs text-muted-foreground`,children:[`v`,$e]})]}),(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:r(`emptyState.description`)}),(0,Z.jsxs)(U,{onClick:t,size:`lg`,className:`w-full gap-2`,children:[(0,Z.jsx)(Ke,{className:`h-4 w-4`}),r(`emptyState.autoImport`)]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`emptyState.or`)}),(0,Z.jsxs)(U,{onClick:e,variant:`outline`,size:`lg`,className:`w-full gap-2`,children:[(0,Z.jsx)(Ue,{className:`h-4 w-4`}),r(`emptyState.uploadFile`)]}),(0,Z.jsxs)(U,{onClick:n,variant:`ghost`,size:`lg`,className:`w-full gap-2`,children:[(0,Z.jsx)(Ne,{className:`h-4 w-4`}),r(`emptyState.openSettings`)]})]})})})}function Br({title:e,description:t,details:n,detailLabel:r,actions:i}){return(0,Z.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background p-4`,children:(0,Z.jsx)(Rr,{delay:0,duration:.45,children:(0,Z.jsxs)(mt,{className:`w-full max-w-xl space-y-6 border-destructive/20 p-8 shadow-xl shadow-destructive/5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,Z.jsx)(`div`,{className:`mt-1 flex h-12 w-12 items-center justify-center rounded-2xl bg-destructive/10 text-destructive`,children:(0,Z.jsx)(Fe,{className:`h-6 w-6`})}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:e}),(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:t})]})]}),n.length>0?(0,Z.jsxs)(`div`,{className:`rounded-2xl border border-border/60 bg-muted/20 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium tracking-[0.14em] text-muted-foreground uppercase`,children:r}),(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-foreground`,children:n.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})]}):null,(0,Z.jsx)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:flex-wrap`,children:i.map((e,t)=>(0,Z.jsxs)(U,{onClick:e.onClick,variant:e.variant??`outline`,className:`gap-2`,children:[t===0?(0,Z.jsx)(Oe,{className:`h-4 w-4`}):null,e.label]},`${e.label}-${t}`))})]})})})}var Vr={insights:(0,Z.jsx)(Ve,{className:`h-4 w-4`}),metrics:(0,Z.jsx)(ge,{className:`h-4 w-4`}),today:(0,Z.jsx)(Ee,{className:`h-4 w-4`}),currentMonth:(0,Z.jsx)(Te,{className:`h-4 w-4`}),activity:(0,Z.jsx)(Ee,{className:`h-4 w-4`}),forecastCache:(0,Z.jsx)(_e,{className:`h-4 w-4`}),limits:(0,Z.jsx)(Ne,{className:`h-4 w-4`}),costAnalysis:(0,Z.jsx)(He,{className:`h-4 w-4`}),tokenAnalysis:(0,Z.jsx)(de,{className:`h-4 w-4`}),requestAnalysis:(0,Z.jsx)(_e,{className:`h-4 w-4`}),advancedAnalysis:(0,Z.jsx)(Ve,{className:`h-4 w-4`}),comparisons:(0,Z.jsx)(_e,{className:`h-4 w-4`}),tables:(0,Z.jsx)(Re,{className:`h-4 w-4`})},Hr={insights:[`summary`,`insight`],metrics:[`kpi`,`zahlen`],today:[`today`,`heute`],currentMonth:[`monat`,`current month`],activity:[`heatmap`,`aktivität`],forecastCache:[`forecast`,`cache`,`roi`],limits:[`limits`,`subscriptions`,`budget`,`anbieter limits`],costAnalysis:[`charts`,`kostenanalyse`],tokenAnalysis:[`tokens`,`token analyse`],requestAnalysis:[`requests`,`request analyse`,`anfragen`],advancedAnalysis:[`advanced analysis`,`distributions`,`risk`,`verteilungen`],comparisons:[`anomalie`,`vergleich`],tables:[`table`,`details`]},Ur={limits:[`limits sektion`,`subscriptions sektion`],tokenAnalysis:[`token chart`],requestAnalysis:[`request chart`,`request donut`]};function Wr(e){return e.toLowerCase().normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).replace(/[^\p{L}\p{N}]+/gu,` `).trim()}function Gr(e){return Wr([e.label,e.description,...e.keywords??[],...e.aliases??[]].filter(Boolean).join(` `))}function Kr(e,t){if(!t)return 1;let n=Wr(t);if(!n)return 1;let r=Gr(e),i=n.split(/\s+/).filter(Boolean);if(i.length===0)return 1;let a=0;for(let t of i){if(!r.includes(t))return 0;if(Wr(e.label)===t){a+=120;continue}if(Wr(e.label).startsWith(t)){a+=80;continue}if((e.aliases??[]).some(e=>Wr(e)===t)){a+=70;continue}if((e.keywords??[]).some(e=>Wr(e).startsWith(t))){a+=55;continue}if(r.includes(` ${t}`)||r.startsWith(t)){a+=35;continue}a+=15}return a}function qr({isDark:e,availableProviders:t,selectedProviders:n,availableModels:r,selectedModels:i,hasTodaySection:a,hasMonthSection:o,hasRequestSection:s,sectionVisibility:c,sectionOrder:l,reportGenerating:u,onToggleTheme:d,onExportCSV:f,onGenerateReport:p,onDelete:m,onUpload:h,onAutoImport:g,onOpenSettings:_,onScrollTo:v,onViewModeChange:y,onApplyPreset:b,onToggleProvider:x,onToggleModel:S,onClearProviders:C,onClearModels:w,onClearDateRange:E,onResetAll:D,onHelp:O,onLanguageChange:k}){let{t:A}=M(),[j,N]=(0,X.useState)(!1),[P,ee]=(0,X.useState)(``),te=(0,X.useMemo)(()=>({insights:!0,metrics:!0,today:a,currentMonth:o,activity:!0,forecastCache:!0,limits:!0,costAnalysis:!0,tokenAnalysis:!0,requestAnalysis:s,advancedAnalysis:!0,comparisons:!0,tables:!0}),[o,s,a]);(0,X.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),N(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]);let F=(0,X.useMemo)(()=>l.flatMap(e=>{let t=yt[e];if(!c[e]||!te[e])return[];let n=A(t.labelKey);return[{id:`section-${t.id}`,label:A(`commandPalette.commands.goToSection.label`,{section:n}),description:A(`commandPalette.commands.goToSection.description`,{section:n}),keywords:[n,t.domId,...Hr[t.id]],icon:Vr[t.id],action:()=>v(t.domId),group:A(`commandPalette.groups.navigation`),testId:`command-section-${t.id}`,...Ur[t.id]?{aliases:Ur[t.id]}:{}}]}),[v,te,l,c,A]),I=(0,X.useMemo)(()=>[{id:`auto-import`,label:A(`commandPalette.commands.autoImport.label`),description:A(`commandPalette.commands.autoImport.description`),keywords:[`toktrack`,`import`,`load`,`sync`],aliases:[`auto import`,`daten importieren`],icon:(0,Z.jsx)(Ke,{className:`h-4 w-4`}),action:g,group:A(`commandPalette.groups.actions`)},{id:`settings-open`,label:A(`commandPalette.commands.openSettings.label`),description:A(`commandPalette.commands.openSettings.description`),keywords:[`settings`,`limits`,`subscription`,`anbieter limit`,`backup`],aliases:[`settings dialog`,`einstellungen öffnen`,`provider limits`],icon:(0,Z.jsx)(Ne,{className:`h-4 w-4`}),action:_,group:A(`commandPalette.groups.actions`)},{id:`csv`,label:A(`commandPalette.commands.exportCsv.label`),description:A(`commandPalette.commands.exportCsv.description`),keywords:[`download`,`export`,`csv`],aliases:[`csv download`,`daten exportieren`],shortcut:`⌘E`,icon:(0,Z.jsx)(ye,{className:`h-4 w-4`}),action:f,group:A(`commandPalette.groups.actions`)},{id:`report`,label:A(u?`commandPalette.commands.generateReport.labelLoading`:`commandPalette.commands.generateReport.label`),description:A(`commandPalette.commands.generateReport.description`),keywords:[`pdf`,`report`,`bericht`,`export`],aliases:[`report export`,`pdf export`,`bericht generieren`],icon:(0,Z.jsx)(ye,{className:`h-4 w-4`}),action:p,group:A(`commandPalette.groups.actions`)},{id:`upload`,label:A(`commandPalette.commands.upload.label`),description:A(`commandPalette.commands.upload.description`),keywords:[`upload`,`file`,`json`,`import`],aliases:[`datei laden`,`json import`],shortcut:`⌘U`,icon:(0,Z.jsx)(Ue,{className:`h-4 w-4`}),action:h,group:A(`commandPalette.groups.actions`)},{id:`delete`,label:A(`commandPalette.commands.delete.label`),description:A(`commandPalette.commands.delete.description`),keywords:[`reset data`,`clear data`,`delete`],aliases:[`daten reset`,`alles loeschen`],icon:(0,Z.jsx)(Ge,{className:`h-4 w-4`}),action:m,group:A(`commandPalette.groups.actions`)},{id:`view-daily`,label:A(`commandPalette.commands.viewDaily.label`),description:A(`commandPalette.commands.viewDaily.description`),keywords:[`daily`,`tage`,`tag`,`tagesansicht`],aliases:[`daily view`],icon:(0,Z.jsx)(Ee,{className:`h-4 w-4`}),action:()=>y(`daily`),group:A(`commandPalette.groups.filters`)},{id:`view-monthly`,label:A(`commandPalette.commands.viewMonthly.label`),description:A(`commandPalette.commands.viewMonthly.description`),keywords:[`monthly`,`monate`,`monat`,`monatsansicht`],aliases:[`monthly view`],icon:(0,Z.jsx)(He,{className:`h-4 w-4`}),action:()=>y(`monthly`),group:A(`commandPalette.groups.filters`)},{id:`view-yearly`,label:A(`commandPalette.commands.viewYearly.label`),description:A(`commandPalette.commands.viewYearly.description`),keywords:[`yearly`,`jahre`,`jahr`,`jahresansicht`],aliases:[`yearly view`],icon:(0,Z.jsx)(de,{className:`h-4 w-4`}),action:()=>y(`yearly`),group:A(`commandPalette.groups.filters`)},{id:`preset-7d`,label:A(`commandPalette.commands.preset7d.label`),description:A(`commandPalette.commands.preset7d.description`),keywords:[`7d`,`7 tage`],icon:(0,Z.jsx)(Te,{className:`h-4 w-4`}),action:()=>b(`7d`),group:A(`commandPalette.groups.filters`)},{id:`preset-30d`,label:A(`commandPalette.commands.preset30d.label`),description:A(`commandPalette.commands.preset30d.description`),keywords:[`30d`,`30 tage`],icon:(0,Z.jsx)(Te,{className:`h-4 w-4`}),action:()=>b(`30d`),group:A(`commandPalette.groups.filters`)},{id:`preset-month`,label:A(`commandPalette.commands.presetMonth.label`),description:A(`commandPalette.commands.presetMonth.description`),keywords:[`current month`,`monat`],icon:(0,Z.jsx)(Te,{className:`h-4 w-4`}),action:()=>b(`month`),group:A(`commandPalette.groups.filters`)},{id:`preset-year`,label:A(`commandPalette.commands.presetYear.label`),description:A(`commandPalette.commands.presetYear.description`),keywords:[`current year`,`jahr`],icon:(0,Z.jsx)(Te,{className:`h-4 w-4`}),action:()=>b(`year`),group:A(`commandPalette.groups.filters`)},{id:`preset-all`,label:A(`commandPalette.commands.presetAll.label`),description:A(`commandPalette.commands.presetAll.description`),keywords:[`all`,`alles`],icon:(0,Z.jsx)(Je,{className:`h-4 w-4`}),action:()=>b(`all`),group:A(`commandPalette.groups.filters`)},{id:`clear-providers`,label:A(`commandPalette.commands.clearProviders.label`),description:A(`commandPalette.commands.clearProviders.description`),keywords:[`provider`,`anbieter`,`clear`],icon:(0,Z.jsx)(Le,{className:`h-4 w-4`}),action:C,group:A(`commandPalette.groups.filters`)},{id:`clear-models`,label:A(`commandPalette.commands.clearModels.label`),description:A(`commandPalette.commands.clearModels.description`),keywords:[`models`,`modelle`,`clear`],icon:(0,Z.jsx)(Le,{className:`h-4 w-4`}),action:w,group:A(`commandPalette.groups.filters`)},{id:`clear-dates`,label:A(`commandPalette.commands.clearDates.label`),description:A(`commandPalette.commands.clearDates.description`),keywords:[`date`,`datum`,`range`,`clear`],icon:(0,Z.jsx)(Je,{className:`h-4 w-4`}),action:E,group:A(`commandPalette.groups.filters`)},{id:`reset-all`,label:A(`commandPalette.commands.resetAll.label`),description:A(`commandPalette.commands.resetAll.description`),keywords:[`reset all`,`alles zurücksetzen`,`default`,`clear filters`],aliases:[`reset dashboard`,`alles reset`,`filter reset`],icon:(0,Z.jsx)(Je,{className:`h-4 w-4`}),action:D,group:A(`commandPalette.groups.filters`)},{id:`top`,label:A(`commandPalette.commands.scrollTop.label`),description:A(`commandPalette.commands.scrollTop.description`),keywords:[`top`,`start`,`anfang`],shortcut:`⌘↑`,icon:(0,Z.jsx)(Me,{className:`h-4 w-4`}),action:()=>window.scrollTo({top:0,behavior:`smooth`}),group:A(`commandPalette.groups.navigation`)},{id:`bottom`,label:A(`commandPalette.commands.scrollBottom.label`),description:A(`commandPalette.commands.scrollBottom.description`),keywords:[`bottom`,`ende`],icon:(0,Z.jsx)(We,{className:`h-4 w-4`}),action:()=>window.scrollTo({top:document.body.scrollHeight,behavior:`smooth`}),group:A(`commandPalette.groups.navigation`)},{id:`filters`,label:A(`commandPalette.commands.filters.label`),description:A(`commandPalette.commands.filters.description`),keywords:[`filterbar`,`filter`],icon:(0,Z.jsx)(Le,{className:`h-4 w-4`}),action:()=>v(`filters`),group:A(`commandPalette.groups.navigation`)},...F,{id:`theme`,label:A(e?`commandPalette.commands.themeLight.label`:`commandPalette.commands.themeDark.label`),description:A(`commandPalette.commands.themeDark.description`),keywords:[`theme`,`dark`,`light`],shortcut:`⌘D`,icon:e?(0,Z.jsx)(qe,{className:`h-4 w-4`}):(0,Z.jsx)(Ze,{className:`h-4 w-4`}),action:d,group:A(`commandPalette.groups.view`)},{id:`language-de`,label:A(`commandPalette.commands.languageGerman.label`),description:A(`commandPalette.commands.languageGerman.description`),keywords:[`language`,`sprache`,`deutsch`,`german`,`locale`],aliases:[`switch german`,`auf deutsch`,`sprache deutsch`],icon:(0,Z.jsx)(Ye,{className:`h-4 w-4`}),action:()=>k(`de`),group:A(`commandPalette.groups.language`)},{id:`language-en`,label:A(`commandPalette.commands.languageEnglish.label`),description:A(`commandPalette.commands.languageEnglish.description`),keywords:[`language`,`sprache`,`english`,`englisch`,`locale`],aliases:[`switch english`,`auf englisch`,`sprache english`],icon:(0,Z.jsx)(Ye,{className:`h-4 w-4`}),action:()=>k(`en`),group:A(`commandPalette.groups.language`)},{id:`help`,label:A(`commandPalette.commands.help.label`),description:A(`commandPalette.commands.help.description`),keywords:[`shortcut`,`hilfe`],shortcut:`?`,icon:(0,Z.jsx)(Ce,{className:`h-4 w-4`}),action:O,group:A(`commandPalette.groups.help`)}],[e,g,_,f,p,h,m,y,b,C,w,E,D,v,F,u,d,k,O,A]),L=(0,X.useMemo)(()=>t.map(e=>{let t=n.includes(e);return{id:`provider-${e}`,label:`${A(t?`commandPalette.commands.clearProviders.label`:`common.provider`)}: ${e}`,description:t?`${A(`commandPalette.commands.clearProviders.description`)}: ${e}`:`${A(`common.provider`)} ${e}`,keywords:[`anbieter`,`provider`,e.toLowerCase()],aliases:[`filter ${e.toLowerCase()}`,`${e.toLowerCase()} daten`],icon:(0,Z.jsx)(Le,{className:`h-4 w-4`}),action:()=>x(e),group:A(`commandPalette.groups.providers`)}}),[t,n,x,A]),R=(0,X.useMemo)(()=>r.map(e=>{let t=i.includes(e);return{id:`model-${e}`,label:`${A(t?`commandPalette.commands.clearModels.label`:`common.model`)}: ${e}`,description:t?`${A(`commandPalette.commands.clearModels.description`)}: ${e}`:`${A(`common.model`)} ${e}`,keywords:[`modell`,`model`,e.toLowerCase()],aliases:[`filter ${e.toLowerCase()}`,`${e.toLowerCase()} requests`,`${e.toLowerCase()} kosten`],icon:(0,Z.jsx)(de,{className:`h-4 w-4`}),action:()=>S(e),group:A(`commandPalette.groups.models`)}}),[r,i,S,A]),ne=(0,X.useMemo)(()=>[...I,...L,...R],[I,L,R]),z=(0,X.useMemo)(()=>ne.map((e,t)=>({cmd:e,score:Kr(e,P),index:t})).filter(e=>e.score>0).sort((e,t)=>t.score-e.score||e.index-t.index).map(e=>e.cmd),[ne,P]),re=(0,X.useMemo)(()=>z.slice(0,9),[z]),B=(0,X.useMemo)(()=>Array.from(new Set(z.map(e=>e.group))),[z]),ie=e=>{N(!1),ee(``),e.action()};return(0,X.useEffect)(()=>{if(!j)return;let e=e=>{if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key))return;let t=re[Number(e.key)-1];t&&(e.preventDefault(),ie(t))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[j,re]),(0,X.useEffect)(()=>{!j&&P&&ee(``)},[j,P]),(0,Z.jsx)(vt,{open:j,onOpenChange:N,children:(0,Z.jsxs)(gt,{className:`max-w-md overflow-hidden p-0`,children:[(0,Z.jsx)(ht,{className:`sr-only`,children:A(`commandPalette.title`)}),(0,Z.jsx)(_t,{className:`sr-only`,children:A(`commandPalette.description`)}),(0,Z.jsxs)(T,{className:`bg-transparent`,shouldFilter:!1,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3`,children:[(0,Z.jsx)(Pe,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Z.jsx)(T.Input,{placeholder:A(`commandPalette.placeholder`),value:P,onValueChange:ee,className:`flex h-11 w-full bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground`})]}),(0,Z.jsxs)(T.List,{className:`max-h-[300px] overflow-y-auto p-2`,children:[(0,Z.jsx)(T.Empty,{className:`py-6 text-center text-sm text-muted-foreground`,children:A(`commandPalette.empty`)}),B.map(e=>(0,Z.jsx)(T.Group,{heading:e,className:`[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,children:z.filter(t=>t.group===e).map(e=>{let t=re.findIndex(t=>t.id===e.id);return(0,Z.jsxs)(T.Item,{value:e.id,"data-testid":e.testId??`command-${e.id}`,onSelect:()=>ie(e),className:`flex cursor-pointer items-center gap-2 rounded-md px-2 py-2 text-sm aria-selected:bg-accent`,children:[e.icon,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{children:e.label}),e.description&&(0,Z.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.description})]}),e.shortcut&&(0,Z.jsx)(`kbd`,{className:`hidden items-center gap-0.5 rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground sm:inline-flex`,children:e.shortcut}),t>=0&&(0,Z.jsx)(`kbd`,{className:`inline-flex min-w-6 items-center justify-center rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground`,children:t+1})]},e.id)})},e))]})]})]})})}function Jr({generating:e,onGenerate:t}){let{t:n}=M();return(0,Z.jsxs)(U,{variant:`outline`,size:`sm`,onClick:t,disabled:e,title:n(`commandPalette.commands.generateReport.label`),className:`h-11 justify-start gap-2 px-3 text-xs sm:h-9 sm:text-sm`,children:[e?(0,Z.jsx)(Xe,{className:`h-4 w-4 animate-spin`}):(0,Z.jsx)(ve,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:n(`header.report`)})]})}function Yr({metrics:e,totalCalendarDays:t,viewMode:n=`daily`}){let{t:r}=M(),i=ce(),a=e.totalInput>0&&e.totalOutput>0?new Intl.NumberFormat(i,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e.totalInput/e.totalOutput):null,o=t&&n===`daily`?e.activeDays/t*100:null,s=e.topModel?`${z(e.topModel.cost)} · ${r(`metricCards.primary.share`,{value:V(e.topModelShare,0)})}${e.topRequestModel?` · ${r(`metricCards.primary.requestLead`,{value:e.topRequestModel.name})}`:``}`:null,c=e.totalTokens>0?r(`metricCards.primary.allTokensViaCacheRead`,{value:V(e.totalCacheRead/e.totalTokens*100)}):null,l=e.totalTokens>0?r(`metricCards.primary.thinkingShareOfVolume`,{value:V(e.totalThinking/e.totalTokens*100)}):null,u=e.totalTokens>0?r(`metricCards.primary.thinkingSubtitle`,{share:V(e.totalThinking/e.totalTokens*100),tokens:F(e.totalThinking/Math.max(e.totalRequests,1))}):null;return(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4 xl:grid-cols-8`,children:[(0,Z.jsx)(G,{order:0,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.totalCost`),value:(0,Z.jsx)(q,{value:e.totalCost,type:`currency`,label:r(`metricCards.primary.totalCost`),insight:r(`metricCards.primary.avgPerPeriod`,{value:z(e.avgDailyCost),unit:I(n)})}),subtitle:r(`metricCards.primary.totalCostSubtitle`,{average:z(e.avgDailyCost),unit:I(n),costPerRequest:z(e.avgCostPerRequest)}),icon:(0,Z.jsx)(pe,{className:`h-4 w-4`}),trend:e.weekOverWeekChange===null?null:{value:e.weekOverWeekChange},info:Et.totalCost})}),(0,Z.jsx)(G,{order:1,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.totalTokens`),value:(0,Z.jsx)(q,{value:e.totalTokens,type:`tokens`,label:r(`metricCards.primary.totalTokens`),insight:r(`metricCards.primary.tokensPerRequestAvg`,{value:F(e.avgTokensPerRequest)})}),subtitle:a?r(`metricCards.primary.totalTokensSubtitleWithRatio`,{ratio:a,tokensPerRequest:F(e.avgTokensPerRequest)}):r(`metricCards.primary.totalTokensSubtitle`,{tokensPerRequest:F(e.avgTokensPerRequest)}),icon:(0,Z.jsx)(Qe,{className:`h-4 w-4`}),info:Et.totalTokens})}),(0,Z.jsx)(G,{order:2,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.activeDays`),value:String(e.activeDays),subtitle:o===null?r(`metricCards.primary.providersActive`,{count:e.providerCount}):r(`metricCards.primary.coverageOfDays`,{coverage:V(o,0),days:t}),icon:(0,Z.jsx)(Ee,{className:`h-4 w-4`}),info:Et.activeDays})}),(0,Z.jsx)(G,{order:3,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.topModel`),value:e.topModel?.name??`–`,icon:(0,Z.jsx)(xe,{className:`h-4 w-4`}),info:Et.topModel,...s?{subtitle:s}:{}})}),(0,Z.jsx)(G,{order:4,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.cacheHitRate`),value:(0,Z.jsx)(q,{value:e.cacheHitRate,type:`percent`}),icon:(0,Z.jsx)(he,{className:`h-4 w-4`}),info:Et.cacheHitRate,...c?{subtitle:c}:{}})}),(0,Z.jsx)(G,{order:5,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.costPerMillion`),value:(0,Z.jsx)(q,{value:e.costPerMillion,type:`currency`}),icon:(0,Z.jsx)(Be,{className:`h-4 w-4`}),info:Et.costPerMillion})}),(0,Z.jsx)(G,{order:6,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.requests`),value:e.hasRequestData?(0,Z.jsx)(q,{value:e.totalRequests,type:`number`,label:r(`metricCards.primary.requests`),insight:r(`insights.requestEconomy.summary`,{cost:z(e.avgCostPerRequest),tokens:F(e.avgTokensPerRequest),leader:``}).trim()}):r(`common.notAvailable`),subtitle:e.hasRequestData?r(`metricCards.primary.requestsSubtitle`,{requests:e.avgRequestsPerDay.toFixed(1),unit:I(n),cost:z(e.avgCostPerRequest),volatility:Math.round(e.requestVolatility)}):r(`metricCards.primary.requestCountersMissing`),icon:(0,Z.jsx)(H,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:7,children:(0,Z.jsx)(K,{label:r(`metricCards.primary.thinking`),value:(0,Z.jsx)(q,{value:e.totalThinking,type:`tokens`,label:r(`metricCards.primary.thinking`),...l?{insight:l}:{}}),icon:(0,Z.jsx)(le,{className:`h-4 w-4`}),...u?{subtitle:u}:{}})})]})}function Xr({metrics:e,dailyCosts:t,viewMode:n=`daily`}){let{t:r}=M(),i=e.topDay&&e.cheapestDay?e.topDay.cost-e.cheapestDay.cost:null,a=(()=>{if(!t||t.length===0)return null;let e=[...t].sort((e,t)=>e-t),n=Math.floor(e.length/2),r=e[n];if(r===void 0)return null;if(e.length%2)return r;let i=e[n-1];return i===void 0?null:(i+r)/2})(),o=e.topRequestModel?r(`metricCards.secondary.requestLeader`,{model:e.topRequestModel.name,requests:R(e.topRequestModel.requests)}):null,s=e.topDay?L(e.topDay.date,`long`):null,c=e.topProvider?r(`metricCards.secondary.dominantProviderSubtitle`,{share:V(e.topProvider.share,0),cost:z(e.topProvider.cost),requestLeader:o?` · ${o}`:``}):null,l=n===`daily`&&e.busiestWeek?`${L(e.busiestWeek.start)} – ${L(e.busiestWeek.end)}`:i===null?null:r(`metricCards.secondary.spread`,{value:z(i)}),u=a!==null&&e.avgDailyCost>0?r(`metricCards.secondary.vsAverageWithVolatility`,{direction:a<e.avgDailyCost?`↓`:`↑`,value:Math.abs((a-e.avgDailyCost)/e.avgDailyCost*100).toFixed(0),volatility:Math.round(e.requestVolatility)}):null,d=n===`yearly`?Et.mostExpensiveYear:n===`monthly`?Et.mostExpensiveMonth:Et.mostExpensiveDay,f=n===`yearly`?Et.avgCostPerYear:n===`monthly`?Et.avgCostPerMonth:Et.avgCostPerDay,p=n===`daily`?Et.peak7Days:f;return(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,Z.jsx)(G,{order:0,children:(0,Z.jsx)(K,{label:r(n===`yearly`?`metricCards.secondary.mostExpensiveYear`:n===`monthly`?`metricCards.secondary.mostExpensiveMonth`:`metricCards.secondary.mostExpensiveDay`),value:e.topDay?(0,Z.jsx)(q,{value:e.topDay.cost,type:`currency`}):`–`,icon:(0,Z.jsx)(ke,{className:`h-4 w-4`}),info:d,...s?{subtitle:s}:{}})}),(0,Z.jsx)(G,{order:1,children:(0,Z.jsx)(K,{label:r(`metricCards.secondary.dominantProvider`),value:e.topProvider?.name??`–`,icon:(0,Z.jsx)(be,{className:`h-4 w-4`}),info:r(`metricCards.secondary.dominantProviderInfo`),...c?{subtitle:c}:{}})}),(0,Z.jsx)(G,{order:2,children:(0,Z.jsx)(K,{label:n===`daily`?r(`metricCards.secondary.peak7Days`):r(`metricCards.secondary.avgCostPerUnit`,{unit:I(n)}),value:n===`daily`&&e.busiestWeek?(0,Z.jsx)(q,{value:e.busiestWeek.cost,type:`currency`}):(0,Z.jsx)(q,{value:e.avgDailyCost,type:`currency`}),icon:(0,Z.jsx)(ge,{className:`h-4 w-4`}),info:p,...l?{subtitle:l}:{}})}),(0,Z.jsx)(G,{order:3,children:(0,Z.jsx)(K,{label:r(`metricCards.secondary.medianPerUnit`,{unit:I(n)}),value:a===null?`–`:(0,Z.jsx)(q,{value:a,type:`currency`}),icon:(0,Z.jsx)(Ve,{className:`h-4 w-4`}),info:r(`metricCards.secondary.medianInfo`),...u?{subtitle:u}:{}})})]})}function Zr({today:e,metrics:t}){let{t:n}=M(),r=e.modelsUsed?.length??0,i=e.cacheReadTokens+e.cacheCreationTokens>0?e.cacheReadTokens/(e.cacheReadTokens+e.cacheCreationTokens+e.inputTokens+e.outputTokens+e.thinkingTokens)*100:0,a=e.modelBreakdowns?.length?e.modelBreakdowns.reduce((e,t)=>e.cost>t.cost?e:t):null,o=t.avgDailyCost>0?(e.totalCost-t.avgDailyCost)/t.avgDailyCost*100:null,s=o===null?null:n(`metricCards.today.avgPerDay`,{value:z(t.avgDailyCost)}),c=e.inputTokens>0&&e.outputTokens>0?n(`metricCards.today.ioRatio`,{value:(e.inputTokens/e.outputTokens).toFixed(1)}):null,l=a?n(`metricCards.today.topModel`,{value:W(a.modelName)}):null,u=t.costPerMillion>0?n(`metricCards.today.overallAverage`,{value:z(t.costPerMillion)}):null,d=e.requestCount>0&&r>0?n(`metricCards.today.requestsSubtitle`,{value:(e.requestCount/r).toFixed(1),cost:z(e.totalCost/e.requestCount)}):n(`metricCards.today.requestCountersMissing`),f=e.totalTokens>0?n(`metricCards.today.thinkingSubtitle`,{value:V(e.thinkingTokens/e.totalTokens*100)}):null;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(kt,{title:n(`metricCards.today.title`,{date:L(e.date,`long`)}),description:n(`metricCards.today.description`),info:wt.today}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4 xl:grid-cols-6`,children:[(0,Z.jsx)(G,{order:0,children:(0,Z.jsx)(K,{label:n(`metricCards.today.costToday`),value:(0,Z.jsx)(q,{value:e.totalCost,type:`currency`}),icon:(0,Z.jsx)(pe,{className:`h-4 w-4`}),trend:o===null?null:{value:o,label:n(`metricCards.today.vsAverageShort`)},...s?{subtitle:s}:{}})}),(0,Z.jsx)(G,{order:1,children:(0,Z.jsx)(K,{label:n(`metricCards.today.tokensToday`),value:(0,Z.jsx)(q,{value:e.totalTokens,type:`tokens`,label:n(`metricCards.today.tokensToday`),insight:n(`metricCards.today.tokensInsight`,{value:F(e.requestCount>0?e.totalTokens/e.requestCount:0)})}),icon:(0,Z.jsx)(Qe,{className:`h-4 w-4`}),...c?{subtitle:c}:{}})}),(0,Z.jsx)(G,{order:2,children:(0,Z.jsx)(K,{label:n(`metricCards.today.models`),value:String(r),icon:(0,Z.jsx)(xe,{className:`h-4 w-4`}),...l?{subtitle:l}:{}})}),(0,Z.jsx)(G,{order:3,children:(0,Z.jsx)(K,{label:n(`metricCards.today.costPerMillion`),value:(0,Z.jsx)(q,{value:e.totalTokens>0?e.totalCost/(e.totalTokens/1e6):0,type:`currency`}),icon:(0,Z.jsx)(Be,{className:`h-4 w-4`}),...u?{subtitle:u}:{}})}),(0,Z.jsx)(G,{order:4,children:(0,Z.jsx)(K,{label:n(`metricCards.today.cacheHitRate`),value:(0,Z.jsx)(q,{value:i,type:`percent`}),subtitle:n(`metricCards.today.cacheShare`,{value:V(e.cacheReadTokens/(e.totalTokens||1)*100)}),icon:(0,Z.jsx)(he,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:5,children:(0,Z.jsx)(K,{label:n(`metricCards.today.requests`),value:e.requestCount>0?(0,Z.jsx)(q,{value:e.requestCount,type:`number`,label:n(`metricCards.today.requestsToday`),insight:n(`metricCards.today.requestsInsight`,{value:z(e.totalCost/e.requestCount)})}):n(`common.notAvailable`),subtitle:d,icon:(0,Z.jsx)(H,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:6,children:(0,Z.jsx)(K,{label:n(`metricCards.today.thinking`),value:(0,Z.jsx)(q,{value:e.thinkingTokens,type:`tokens`}),icon:(0,Z.jsx)(le,{className:`h-4 w-4`}),...f?{subtitle:f}:{}})})]})]})}function Qr({daily:e,metrics:t}){let{t:n}=M(),r=ce(),i=B(),a=new Intl.NumberFormat(r,{minimumFractionDigits:1,maximumFractionDigits:1}),o=new Intl.NumberFormat(r,{style:`percent`,minimumFractionDigits:1,maximumFractionDigits:1}),s=new Intl.NumberFormat(r,{style:`percent`,minimumFractionDigits:0,maximumFractionDigits:0}),c=(0,X.useMemo)(()=>e.filter(e=>e.date.startsWith(i)),[e,i]),l=(0,X.useMemo)(()=>{let[t=0,n=1]=i.split(`-`).map(Number),r=n===1?`${t-1}-12`:`${t}-${String(n-1).padStart(2,`0`)}`;return e.filter(e=>e.date.startsWith(r))},[e,i]),u=(0,X.useMemo)(()=>{if(c.length===0)return null;let e=c.reduce((e,t)=>e+t.totalCost,0),t=c.reduce((e,t)=>e+t.totalTokens,0),n=c.reduce((e,t)=>e+t.inputTokens,0),r=c.reduce((e,t)=>e+t.outputTokens,0),i=c.reduce((e,t)=>e+t.cacheReadTokens,0),a=c.reduce((e,t)=>e+t.cacheCreationTokens,0),o=c.reduce((e,t)=>e+t.thinkingTokens,0),s=c.reduce((e,t)=>e+t.requestCount,0),l=i+a+n+r+o,u=l>0?i/l*100:0,d=t>0?e/(t/1e6):0,f=new Set,p=new Map;for(let e of c)for(let t of e.modelBreakdowns){let e=W(t.modelName);f.add(e),p.set(e,(p.get(e)??0)+t.cost)}let m=null;for(let[e,t]of p)(!m||t>m.cost)&&(m={name:e,cost:t});let h=new Date().getDate();return{totalCost:e,totalTokens:t,inputTokens:n,outputTokens:r,cacheRead:i,cacheCreate:a,thinkingTokens:o,requestCount:s,cacheHitRate:u,costPerMillion:d,activeDays:c.length,dayOfMonth:h,modelCount:f.size,topModel:m}},[c]),d=(0,X.useMemo)(()=>l.reduce((e,t)=>e+t.totalCost,0),[l]);if(!u)return null;let f=d>0?(u.totalCost-d)/d*100:null,p=u.inputTokens+u.outputTokens,m=u.inputTokens>0&&u.outputTokens>0?n(`metricCards.month.ioRatio`,{value:a.format(u.inputTokens/u.outputTokens)}):null,h=u.topModel?n(`metricCards.month.topModel`,{value:u.topModel.name}):null,g=t.costPerMillion>0?n(`metricCards.today.overallAverage`,{value:z(t.costPerMillion)}):null,_=u.totalTokens>0?n(`metricCards.month.thinkingSubtitle`,{value:o.format(u.thinkingTokens/u.totalTokens)}):null;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(kt,{title:n(`metricCards.month.title`,{date:te(i)}),badge:n(`metricCards.month.badge`,{count:u.activeDays}),description:n(`metricCards.month.description`),info:wt.currentMonth}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4 xl:grid-cols-8`,children:[(0,Z.jsx)(G,{order:0,children:(0,Z.jsx)(K,{label:n(`metricCards.month.costMonth`),value:(0,Z.jsx)(q,{value:u.totalCost,type:`currency`}),subtitle:n(`metricCards.month.avgPerDay`,{value:z(u.totalCost/u.activeDays)}),icon:(0,Z.jsx)(pe,{className:`h-4 w-4`}),trend:f===null?null:{value:f,label:n(`metricCards.month.vsPreviousMonth`)}})}),(0,Z.jsx)(G,{order:1,children:(0,Z.jsx)(K,{label:n(`metricCards.month.tokensMonth`),value:(0,Z.jsx)(q,{value:u.totalTokens,type:`tokens`}),icon:(0,Z.jsx)(Qe,{className:`h-4 w-4`}),...m?{subtitle:m}:{}})}),(0,Z.jsx)(G,{order:2,children:(0,Z.jsx)(K,{label:n(`metricCards.month.activeDays`),value:`${u.activeDays} / ${u.dayOfMonth}`,subtitle:n(`metricCards.month.coverage`,{value:s.format(u.activeDays/u.dayOfMonth)}),icon:(0,Z.jsx)(De,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:3,children:(0,Z.jsx)(K,{label:n(`metricCards.month.models`),value:String(u.modelCount),icon:(0,Z.jsx)(xe,{className:`h-4 w-4`}),...h?{subtitle:h}:{}})}),(0,Z.jsx)(G,{order:4,children:(0,Z.jsx)(K,{label:n(`metricCards.month.costPerMillion`),value:(0,Z.jsx)(q,{value:u.costPerMillion,type:`currency`}),icon:(0,Z.jsx)(Be,{className:`h-4 w-4`}),...g?{subtitle:g}:{}})}),(0,Z.jsx)(G,{order:5,children:(0,Z.jsx)(K,{label:n(`metricCards.month.cacheHitRate`),value:(0,Z.jsx)(q,{value:u.cacheHitRate,type:`percent`}),subtitle:n(`metricCards.month.cacheMix`,{input:s.format(p>0?u.inputTokens/p:0),output:s.format(p>0?u.outputTokens/p:0)}),icon:(0,Z.jsx)(he,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:6,children:(0,Z.jsx)(K,{label:n(`metricCards.month.requests`),value:u.requestCount>0?(0,Z.jsx)(q,{value:u.requestCount,type:`number`,label:n(`metricCards.month.requestsInMonth`),insight:n(`metricCards.month.costPerRequest`,{value:z(u.totalCost/u.requestCount)})}):n(`common.notAvailable`),subtitle:u.requestCount>0?n(`metricCards.month.requestsSubtitle`,{value:(u.requestCount/u.activeDays).toFixed(1),cost:z(u.totalCost/u.requestCount)}):n(`metricCards.month.requestCountersMissing`),icon:(0,Z.jsx)(H,{className:`h-4 w-4`})})}),(0,Z.jsx)(G,{order:7,children:(0,Z.jsx)(K,{label:n(`metricCards.month.thinking`),value:(0,Z.jsx)(q,{value:u.thinkingTokens,type:`tokens`}),icon:(0,Z.jsx)(le,{className:`h-4 w-4`}),..._?{subtitle:_}:{}})})]})]})}function $r({data:e,onClickDay:t}){let{t:n}=M(),o=(0,X.useId)().replace(/:/g,``),s=(0,X.useMemo)(()=>{if(e.length===0)return null;let t=e[e.length-1],n=e[0];for(let t=1;t<e.length;t+=1){let r=e[t];r&&n&&r.cost>n.cost&&(n=r)}return!t||!n?null:{latest:t.cost,peak:n.cost,peakDate:n.date}},[e]);return(0,Z.jsx)(It,{title:n(`charts.costOverTime.title`),subtitle:s?n(`charts.costOverTime.summary`,{latest:z(s.latest),peak:z(s.peak),date:P(s.peakDate)}):n(`charts.costOverTime.subtitle`),info:Dt.costOverTime,chartData:e,valueKey:`cost`,valueFormatter:z,children:(0,Z.jsx)(Rt,{children:s=>(0,Z.jsx)(Lt,{variant:`line`,children:(0,Z.jsx)(r,{width:`100%`,height:300,children:(0,Z.jsxs)(d,{data:e,margin:Nt,onClick:n=>{if(t&&n?.activeTooltipIndex!=null&&typeof n.activeTooltipIndex==`number`){let r=e[n.activeTooltipIndex];r?.date&&t(r.date)}},children:[(0,Z.jsx)(`defs`,{children:(0,Z.jsxs)(`linearGradient`,{id:`${o}-gradCostLine`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Z.jsx)(`stop`,{offset:`0%`,stopColor:jt.cost,stopOpacity:.3}),(0,Z.jsx)(`stop`,{offset:`100%`,stopColor:jt.cost,stopOpacity:0})]})}),(0,Z.jsx)(l,{strokeDasharray:`3 3`,stroke:jt.grid,opacity:.3}),(0,Z.jsx)(c,{dataKey:`date`,tickFormatter:P,stroke:jt.axis,fontSize:11,tickLine:!1}),(0,Z.jsx)(i,{tickFormatter:e=>{let t=ae(e);return t===null?``:z(t)},stroke:jt.axis,fontSize:11,tickLine:!1,axisLine:!1}),(0,Z.jsx)(f,{content:(0,Z.jsx)(Bt,{formatter:e=>z(e)}),cursor:{fill:`hsl(var(--muted))`,opacity:.15}}),(0,Z.jsx)(m,{content:(0,Z.jsx)(zt,{})}),(0,Z.jsx)(a,{type:`monotone`,dataKey:`cost`,stroke:jt.cost,fill:`url(#${o}-gradCostLine)`,name:n(`charts.costOverTime.cost`),strokeWidth:1.5,activeDot:{r:5,strokeWidth:2,stroke:jt.cost,fill:`hsl(var(--background))`},dot:!1,...At(s)}),(0,Z.jsx)(u,{type:`monotone`,dataKey:`ma7`,stroke:jt.ma7,name:n(`charts.costOverTime.movingAverage`),dot:!1,strokeWidth:2,strokeDasharray:`5 5`,connectNulls:!0,...Mt(s,{role:`secondary`})})]})})})})})}function ei({viewBox:e,total:t}){let{t:n}=M();if(!e)return null;let{cx:r,cy:i}=e;return(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(`text`,{x:r,y:i-6,textAnchor:`middle`,className:`fill-muted-foreground`,fontSize:11,children:n(`charts.costByModel.total`)}),(0,Z.jsx)(`text`,{x:r,y:i+14,textAnchor:`middle`,className:`fill-foreground`,fontSize:16,fontWeight:600,children:t})]})}function ti({data:e}){let{t}=M(),i=e.reduce((e,t)=>e+t.value,0),a=[...e].sort((e,t)=>t.value-e.value),c=a.slice(0,3).map(e=>({...e,share:i>0?e.value/i*100:0})),l=a.slice(3).reduce((e,t)=>e+t.value,0),u=c[0]??null;return(0,Z.jsx)(It,{title:t(`charts.costByModel.title`),subtitle:t(`charts.costByModel.subtitle`),summary:u?(0,Z.jsxs)(`span`,{className:`max-w-[10rem] truncate`,children:[u.name,` · `,V(u.share,0)]}):void 0,info:Dt.costByModel,chartData:e,valueKey:`value`,valueFormatter:z,children:a=>{let u=a?560:320,d=a?`66%`:`57%`,p=a?84:58,h=a?134:92;return(0,Z.jsx)(Rt,{children:g=>(0,Z.jsxs)(`div`,{className:`flex h-full flex-col gap-4`,children:[(0,Z.jsx)(Lt,{variant:`radial`,children:(0,Z.jsx)(r,{width:`100%`,height:u,children:(0,Z.jsxs)(s,{children:[(0,Z.jsxs)(o,{data:e,cx:`50%`,cy:d,innerRadius:p,outerRadius:h,paddingAngle:2,dataKey:`value`,nameKey:`name`,...Pt(g),label:!1,children:[e.map(e=>(0,Z.jsx)(n,{fill:st(e.name)},e.name)),(0,Z.jsx)(ei,{total:z(i)})]}),(0,Z.jsx)(f,{content:(0,Z.jsx)(Bt,{formatter:e=>z(e)})}),(0,Z.jsx)(m,{content:(0,Z.jsx)(zt,{className:a?`pt-[22px]`:`pt-2`,renderLabel:t=>{let n=String(t.value??``),r=e.find(e=>e.name===n);return r?`${n} (${z(r.value)})`:n}})})]})})}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:[c.map(e=>(0,Z.jsx)(`div`,{className:`rounded-lg border border-border/60 bg-muted/20 px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(`span`,{className:`mt-1 h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:st(e.name)}}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.name}),(0,Z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[V(e.share,0),` · `,z(e.value)]})]})]})},e.name)),l>0&&(0,Z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/60 bg-muted/10 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:t(`charts.costByModel.otherModels`)}),(0,Z.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[V(l/i*100,0),` ·`,` `,z(l)]})]})]})]})})}})}var ni=14,ri=ni+2,ii=30,ai=26,oi=12,si=6,ci=90;function li(e,t){return e<.15?t?28:88:e<.3?t?36:80:e<.45?t?44:72:e<.6?t?52:64:e<.75?t?60:56:e<.9?t?68:48:t?76:40}function ui(e,t,n,r){if(e===0||t<=0)return`hsl(var(--muted))`;let i=Math.min(e/t,1);return`hsl(${n}, ${r?68:78}%, ${li(i,r)}%)`}function di({data:e,viewMode:t=`daily`,metric:n=`cost`,isDark:r=!1}){let{t:i}=M(),a=ce(),o=(0,X.useRef)(null),s=(0,X.useRef)(new Map),[c,l]=(0,X.useState)(null),u=(0,X.useRef)(null),d=ut(o,{kind:`chart`,amount:.32}),f=(0,X.useMemo)(()=>Array.from({length:7},(e,t)=>t).map(e=>e%2==1?``:new Intl.DateTimeFormat(a,{weekday:`short`}).format(new Date(Date.UTC(2024,0,1+e))).slice(0,2)),[a]),p=(0,X.useMemo)(()=>new Intl.DateTimeFormat(a,{year:`numeric`,month:`long`,day:`numeric`}),[a]),m={cost:{title:i(`charts.heatmap.costTitle`),empty:i(`charts.heatmap.costEmpty`),formatter:z,accessor:e=>e.totalCost,hue:215},requests:{title:i(`charts.heatmap.requestsTitle`),empty:i(`charts.heatmap.requestsEmpty`),formatter:R,accessor:e=>e.requestCount,hue:160},tokens:{title:i(`charts.heatmap.tokensTitle`),empty:i(`charts.heatmap.tokensEmpty`),formatter:F,accessor:e=>e.totalTokens,hue:35}}[n],h=n===`cost`?Dt.heatmap:n===`requests`?Dt.requestHeatmap:Dt.tokenHeatmap,{cells:g,weeks:v,months:y,maxValue:b}=(0,X.useMemo)(()=>{if(e.length===0)return{cells:[],weeks:0,months:[],maxValue:0};let t=new Map,n=0;for(let r of e){let e=m.accessor(r);t.set(r.date,e),e>n&&(n=e)}let r=[...e].sort((e,t)=>e.date.localeCompare(t.date)),i=r[0],o=r[r.length-1];if(!i||!o)return{cells:[],weeks:0,months:[],maxValue:0};let s=new Date(i.date+`T00:00:00`),c=new Date(o.date+`T00:00:00`),l=(s.getDay()+6)%7,u=new Date(s);u.setDate(u.getDate()-l);let d=[],f=[],p=new Date(u),h=0,g=-1;for(;p<=c||h===0;){let e=N(p),n=(p.getDay()+6)%7,r=t.get(e)??0;if(n===0){let e=p.getMonth();e!==g&&(f.push({label:p.toLocaleDateString(a,{month:`short`}),week:h}),g=e)}if(d.push({date:e,value:r,week:h,day:n}),p.setDate(p.getDate()+1),n===6&&h++,p>c&&n===6)break}return{cells:d,weeks:h+1,months:f,maxValue:n}},[m,e,a]),x=ne(),S=d.shouldReduceMotion,C=!S&&d.active,w=d.delayMs,T=`hsl(var(--muted-foreground))`,[E,D]=(0,X.useState)(null),O=(0,X.useCallback)(e=>{if(typeof window<`u`&&typeof window.requestAnimationFrame==`function`){window.requestAnimationFrame(e);return}setTimeout(e,0)},[]),k=(0,X.useMemo)(()=>g.map(e=>e.date),[g]),A=(0,X.useMemo)(()=>Array.from({length:7},(e,t)=>g.filter(e=>e.day===t)),[g]),j=(0,X.useMemo)(()=>(k.includes(x)?x:void 0)??g.find(e=>e.value>0)?.date??k[0]??null,[k,g,x]),P=(0,X.useCallback)(e=>{e&&(D(e),O(()=>{s.current.get(e)?.focus()}))},[O]);(0,X.useEffect)(()=>{j&&(!E||!k.includes(E))&&D(j)},[k,j,E]);let ee=(0,X.useCallback)((e,t)=>{let n=g.find(e=>e.date===t);if(!n)return;let r=n.day,i=n.week,a=(e,t)=>{let n=A[Math.max(0,Math.min(e,A.length-1))];if(!n||n.length===0)return;let r=n[Math.max(0,Math.min(t,n.length-1))];P(r?.date??null)},o=e=>{let t=A[r];!t||t.length===0||P((e===0?t[0]:t[t.length-1])?.date??null)};switch(e.key){case`ArrowLeft`:e.preventDefault(),a(r,i-1);break;case`ArrowRight`:e.preventDefault(),a(r,i+1);break;case`ArrowUp`:e.preventDefault(),a(r-1,i);break;case`ArrowDown`:e.preventDefault(),a(r+1,i);break;case`Home`:e.preventDefault(),o(0);break;case`End`:e.preventDefault(),o(`end`);break;default:break}},[A,g,P]);if(t!==`daily`)return(0,Z.jsxs)(mt,{children:[(0,Z.jsx)(lt,{className:`pb-2`,children:(0,Z.jsx)(Ot,{info:h,children:(0,Z.jsx)(ct,{className:`text-sm font-medium text-muted-foreground`,children:m.title})})}),(0,Z.jsx)(dt,{children:(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m.empty}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground/60`,children:i(`charts.heatmap.switchToDaily`)})]})})]});if(g.length===0)return null;let te=v*ri+ii,I=7*ri+ai+8;return(0,Z.jsxs)(mt,{ref:o,className:`overflow-visible`,children:[(0,Z.jsx)(lt,{className:`pb-2`,children:(0,Z.jsx)(Ot,{info:h,children:(0,Z.jsx)(ct,{className:`text-sm font-medium text-muted-foreground`,children:m.title})})}),(0,Z.jsx)(dt,{className:`overflow-visible`,children:(0,Z.jsxs)(`div`,{ref:u,className:`relative z-10 overflow-visible`,children:[(0,Z.jsx)(`div`,{className:`overflow-x-auto overflow-y-hidden`,children:(0,Z.jsxs)(`svg`,{width:te,height:I,className:`block`,role:`grid`,"aria-label":m.title,"aria-rowcount":7,"aria-colcount":v,children:[f.map((e,t)=>e&&(0,Z.jsx)(`text`,{x:0,y:ai+t*ri+ni-2,fontSize:9,fill:T,className:`font-mono`,children:e},t)),y.map((e,t)=>(0,Z.jsx)(`text`,{x:ii+e.week*ri,y:12,fontSize:9,fill:T,className:`font-mono`,children:e.label},t)),A.map((e,t)=>(0,Z.jsx)(`g`,{role:`row`,children:e.map(e=>{let t=e.date===x,n=p.format(new Date(`${e.date}T00:00:00`)),a=i(`charts.heatmap.cellLabel`,{date:n,value:m.formatter(e.value)}),o=S?{}:{initial:{opacity:0,fillOpacity:0,scale:.96},animate:{opacity:+!!C,fillOpacity:+!!C,scale:C?1:.96},transition:{duration:.28,delay:(C?w+e.week*(pt.itemStaggerMs+oi)+e.day*si:0)/1e3,ease:[.22,1,.36,1]}},c=S?{}:{initial:{opacity:0},animate:{opacity:+!!C},transition:{duration:.2,delay:(C?w+e.week*(pt.itemStaggerMs+oi)+e.day*si+ci:0)/1e3,ease:[.22,1,.36,1]}};return(0,Z.jsxs)(`g`,{children:[(0,Z.jsx)(_.rect,{ref:t=>{t?s.current.set(e.date,t):s.current.delete(e.date)},x:ii+e.week*ri,y:ai+e.day*ri,width:ni,height:ni,rx:2,fill:ui(e.value,b,m.hue,r),stroke:`transparent`,strokeWidth:1.5,className:`transition-all duration-150 focus-visible:stroke-primary`,tabIndex:E===e.date?0:-1,role:`gridcell`,"aria-label":a,"aria-current":t?`date`:void 0,onKeyDown:t=>ee(t,e.date),onMouseEnter:t=>{let r=u.current?.getBoundingClientRect();r&&l({x:t.clientX-r.left,y:t.clientY-r.top-12,date:n,value:e.value})},onFocus:t=>{D(e.date);let r=u.current?.getBoundingClientRect();if(!r)return;let i=t.currentTarget.getBoundingClientRect();l({x:i.left-r.left+i.width/2,y:i.top-r.top-8,date:n,value:e.value})},onBlur:()=>l(null),onMouseLeave:()=>l(null),...o,children:(0,Z.jsx)(`title`,{children:a})}),t&&(0,Z.jsx)(_.rect,{x:ii+e.week*ri-1,y:ai+e.day*ri-1,width:ni+2,height:ni+2,rx:3,fill:`none`,stroke:`hsl(var(--primary))`,strokeWidth:1.5,...c})]},e.date)})},t))]})}),c&&(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute z-30 -translate-x-1/2 -translate-y-full rounded-md border border-border bg-popover px-2 py-1 text-xs whitespace-nowrap shadow-lg`,style:{left:c.x,top:c.y},children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:m.formatter(c.value)}),(0,Z.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:c.date})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:i(`charts.heatmap.less`)}),[0,.15,.3,.45,.6,.75,.9,1].map((e,t)=>(0,Z.jsx)(`div`,{className:`h-3 w-3 rounded-sm`,style:{backgroundColor:ui(e*b,b,m.hue,r)}},t)),(0,Z.jsx)(`span`,{children:i(`charts.heatmap.more`)})]})]})})]})}function fi({title:e,icon:t,value:n,summary:r,details:i,className:a,testId:o}){return(0,Z.jsxs)(mt,{className:`h-full overflow-hidden p-5 ${a??``}`.trim(),"data-testid":o,children:[(0,Z.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-primary/40 to-transparent`}),(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-semibold tracking-[0.18em] text-muted-foreground uppercase`,children:e}),(0,Z.jsx)(`div`,{className:`mt-2 text-3xl font-semibold tracking-tight`,children:n})]}),(0,Z.jsx)(`div`,{className:`rounded-2xl border border-border/60 bg-muted/30 p-2.5 text-muted-foreground`,children:t})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:r}),(0,Z.jsx)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/20 px-3 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:e.label}),(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium text-foreground`,children:e.value})]},e.label))})]})}function pi({metrics:e,viewMode:t,totalCalendarDays:n}){let{t:r}=M(),i=n&&t===`daily`?e.activeDays/n*100:null,a=r(t===`yearly`?`periods.years`:t===`monthly`?`periods.months`:`periods.days`),o=e.topThreeModelsShare>=80?r(`insights.peakWindow.signalStrong`):e.topThreeModelsShare>=55?r(`insights.peakWindow.signalModerate`):r(`insights.peakWindow.signalWide`);return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(kt,{title:r(`dashboard.insights.title`),badge:r(`dashboard.insights.badge`),description:r(`dashboard.insights.description`),info:wt.insights}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-4`,"data-testid":`usage-insights-grid`,children:[(0,Z.jsx)(G,{order:0,className:`h-full`,"data-testid":`usage-insight-motion-item`,children:(0,Z.jsx)(fi,{testId:`usage-insight-card`,title:r(`insights.concentration.title`),icon:(0,Z.jsx)(be,{className:`h-5 w-5`}),value:e.topProvider?V(e.topProvider.share,0):`–`,summary:e.topProvider?r(`insights.concentration.summary`,{provider:e.topProvider.name,model:e.topModel?.name??r(`metricCards.primary.topModel`)}):r(`insights.concentration.fallback`),details:[{label:r(`insights.concentration.topProvider`),value:e.topProvider?.name??`–`},{label:r(`insights.concentration.topModel`),value:e.topModel?.name??`–`},{label:r(`insights.concentration.topModelShare`),value:V(e.topModelShare,0)},{label:r(`insights.concentration.topThreeModels`),value:V(e.topThreeModelsShare,0)}]})}),(0,Z.jsx)(G,{order:1,className:`h-full`,"data-testid":`usage-insight-motion-item`,children:(0,Z.jsx)(fi,{testId:`usage-insight-card`,title:r(`insights.requestEconomy.title`),icon:(0,Z.jsx)(H,{className:`h-5 w-5`}),value:e.hasRequestData?(0,Z.jsx)(q,{value:e.avgCostPerRequest,type:`currency`,label:r(`insights.requestEconomy.valueLabel`),insight:r(`metricCards.primary.tokensPerRequestAvg`,{value:F(e.avgTokensPerRequest)})}):r(`common.notAvailable`),summary:e.hasRequestData?r(`insights.requestEconomy.summary`,{cost:z(e.avgCostPerRequest),tokens:F(e.avgTokensPerRequest),leader:e.topRequestModel?r(`insights.requestEconomy.leader`,{model:e.topRequestModel.name}):``}).trim():r(`insights.requestEconomy.fallback`),details:[{label:r(`insights.requestEconomy.avgRequests`,{unit:I(t)}),value:e.hasRequestData?e.avgRequestsPerDay.toFixed(1):r(`common.notAvailable`)},{label:r(`insights.requestEconomy.avgTokensPerRequest`),value:e.hasRequestData?F(e.avgTokensPerRequest):r(`common.notAvailable`)},{label:r(`insights.requestEconomy.costPerMillion`),value:z(e.costPerMillion)},{label:r(`insights.requestEconomy.totalRequests`),value:e.hasRequestData?R(e.totalRequests):r(`common.notAvailable`)}]})}),(0,Z.jsx)(G,{order:2,className:`h-full`,"data-testid":`usage-insight-motion-item`,children:(0,Z.jsx)(fi,{testId:`usage-insight-card`,title:r(`insights.usagePatterns.title`),icon:(0,Z.jsx)(de,{className:`h-5 w-5`}),value:i===null?R(e.activeDays):V(i,0),summary:i===null?r(`insights.usagePatterns.summaryWithoutCoverage`,{activeDays:e.activeDays,unit:a}):r(`insights.usagePatterns.summaryWithCoverage`,{activeDays:e.activeDays,totalDays:n,volatility:R(Math.round(e.requestVolatility))}),details:[{label:r(`insights.usagePatterns.avgModels`),value:e.avgModelsPerEntry.toFixed(1)},{label:r(`insights.usagePatterns.providersActive`),value:R(e.providerCount)},{label:r(`insights.usagePatterns.weekendShare`),value:e.weekendCostShare===null?`–`:V(e.weekendCostShare,0)},{label:r(`insights.usagePatterns.thinkingShare`),value:e.totalTokens>0?V(e.totalThinking/e.totalTokens*100,1):`–`}]})}),(0,Z.jsx)(G,{order:3,className:`h-full`,"data-testid":`usage-insight-motion-item`,children:(0,Z.jsx)(fi,{testId:`usage-insight-card`,title:r(`insights.peakWindow.title`),icon:(0,Z.jsx)(ke,{className:`h-5 w-5`}),value:e.busiestWeek?z(e.busiestWeek.cost):z(e.topDay?.cost??0),summary:e.busiestWeek?r(`insights.peakWindow.summary`,{start:L(e.busiestWeek.start),end:L(e.busiestWeek.end)}):r(`insights.peakWindow.fallback`),details:[{label:r(`insights.peakWindow.peakDay`),value:e.topDay?`${L(e.topDay.date)} · ${z(e.topDay.cost)}`:`–`},{label:r(`insights.peakWindow.avgPerUnit`,{unit:I(t)}),value:z(e.avgDailyCost)},{label:r(`insights.peakWindow.peak7DayAverage`),value:e.busiestWeek?z(e.busiestWeek.cost/7):`–`},{label:r(`insights.peakWindow.signal`),value:o}]})})]}),(0,Z.jsx)(G,{order:4,children:(0,Z.jsxs)(`div`,{className:`mt-4 rounded-2xl border border-border/60 bg-gradient-to-r from-primary/[0.08] via-transparent to-chart-3/[0.08] px-4 py-3 text-sm text-muted-foreground`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-2 font-medium text-foreground`,children:[(0,Z.jsx)(je,{className:`h-4 w-4 text-primary`}),r(`dashboard.insights.quickRead`)]}),(0,Z.jsx)(`span`,{className:`ml-2`,children:e.topProvider?r(`insights.quickRead.summary`,{provider:e.topProvider.name,providerShare:V(e.topProvider.share,0),topThreeShare:V(e.topThreeModelsShare,0),requestLeader:e.topRequestModel?r(`insights.quickRead.requestLeader`,{requestModel:e.topRequestModel.name,tokenModel:e.topTokenModel?.name??r(`metricCards.primary.topModel`)}):``}).trim():r(`insights.quickRead.fallback`)})]})})]})}function mi(e){return e>=.6?{label:`high`,tone:`text-red-400 bg-red-400/10 border-red-400/20`}:e>=.35?{label:`medium`,tone:`text-amber-300 bg-amber-400/10 border-amber-400/20`}:{label:`low`,tone:`text-green-400 bg-green-400/10 border-green-400/20`}}function hi({topModelShare:e,topProviderShare:t,modelConcentrationIndex:n,providerConcentrationIndex:r}){let{t:i}=M(),a=mi(n),o=mi(r);return(0,Z.jsxs)(mt,{children:[(0,Z.jsx)(lt,{children:(0,Z.jsx)(Ot,{info:Tt.concentrationRisk,children:(0,Z.jsx)(ct,{className:`text-sm font-medium text-muted-foreground`,children:i(`risk.title`)})})}),(0,Z.jsx)(dt,{className:`space-y-4`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:i(`risk.modelDependency`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:V(e,1)})]}),(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium ${a.tone}`,children:i(`risk.${a.label}`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 h-2 overflow-hidden rounded-full bg-muted/40`,children:(0,Z.jsx)(Vt,{className:`h-full rounded-full bg-primary`,width:`${Math.min(e,100)}%`})}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`risk.modelHint`,{value:n.toFixed(2)})})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-muted/15 p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] tracking-[0.14em] text-muted-foreground uppercase`,children:i(`risk.providerDependency`)}),(0,Z.jsx)(`div`,{className:`mt-1 text-lg font-semibold`,children:V(t,1)})]}),(0,Z.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium ${o.tone}`,children:i(`risk.${o.label}`)})]}),(0,Z.jsx)(`div`,{className:`mt-3 h-2 overflow-hidden rounded-full bg-muted/40`,children:(0,Z.jsx)(Vt,{className:`h-full rounded-full bg-chart-3`,width:`${Math.min(t,100)}%`})}),(0,Z.jsx)(`div`,{className:`mt-2 text-xs text-muted-foreground`,children:i(`risk.providerHint`,{value:r.toFixed(2)})})]})]})})]})}function gi({children:e,title:t,className:n,expandedClassName:r,stats:i}){let{t:a}=M(),[o,s]=(0,X.useState)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:A(`group relative`,n),children:[e,(0,Z.jsx)(`button`,{type:`button`,onClick:()=>s(!0),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:a(`common.expand`),"aria-label":t?a(`common.expandWithTitle`,{title:t}):a(`common.expand`),children:(0,Z.jsx)(Ae,{className:`h-3.5 w-3.5`})})]}),(0,Z.jsx)(vt,{open:o,onOpenChange:s,children:(0,Z.jsxs)(gt,{className:A(`h-[92vh] max-h-[92vh] w-[96vw] max-w-[96vw] overflow-auto p-4 sm:h-[90vh] sm:max-h-[90vh] sm:w-[95vw] sm:max-w-[95vw] sm:p-6`,r),children:[(0,Z.jsx)(ht,{className:`sr-only`,children:t??a(`common.expand`)}),(0,Z.jsx)(_t,{className:`sr-only`,children:a(`common.expandedCardDescription`)}),(0,Z.jsxs)(`div`,{className:`h-full`,children:[i&&i.length>0&&(0,Z.jsx)(`div`,{className:`mb-4 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:i.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-muted/20 p-2.5 text-center`,children:[(0,Z.jsx)(`div`,{className:`text-[10px] tracking-wider text-muted-foreground uppercase`,children:e.label}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-medium`,children:e.value})]},e.label))}),e]})]})})]})}function _i({className:e,...t}){return(0,Z.jsx)(`div`,{className:A(`animate-pulse rounded-lg bg-muted/60`,e),...t})}function vi(){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border border-border/50 bg-card/80 p-4 backdrop-blur-xl`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Z.jsx)(_i,{className:`h-3 w-20`}),(0,Z.jsx)(_i,{className:`h-4 w-4 rounded`})]}),(0,Z.jsx)(_i,{className:`h-8 w-28`}),(0,Z.jsx)(_i,{className:`h-3 w-24`})]})}function yi({className:e,bodyClassName:t}){return(0,Z.jsxs)(`div`,{className:A(`rounded-xl border border-border/50 bg-card/80 backdrop-blur-xl`,e),children:[(0,Z.jsx)(`div`,{className:`p-4 pb-2`,children:(0,Z.jsx)(_i,{className:`h-4 w-32`})}),(0,Z.jsx)(`div`,{className:`p-4 pt-0`,children:(0,Z.jsx)(_i,{className:A(`h-[300px] w-full rounded-lg`,t)})})]})}function bi(){return(0,Z.jsxs)(`div`,{className:`mx-auto min-h-screen max-w-7xl px-4 pb-8`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between px-1 py-4`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(_i,{className:`h-8 w-32`}),(0,Z.jsx)(_i,{className:`h-4 w-16`})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(_i,{className:`h-8 w-20 rounded-lg`}),(0,Z.jsx)(_i,{className:`h-8 w-20 rounded-lg`}),(0,Z.jsx)(_i,{className:`h-8 w-8 rounded-lg`})]})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 px-1 py-2`,children:[(0,Z.jsx)(_i,{className:`h-9 w-[160px] rounded-lg`}),(0,Z.jsx)(_i,{className:`h-9 w-[180px] rounded-lg`}),(0,Z.jsx)(`div`,{className:`flex gap-1.5`,children:[1,2,3].map(e=>(0,Z.jsx)(_i,{className:`h-7 w-20 rounded-full`},e))})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-3 xl:grid-cols-6`,children:[1,2,3,4,5,6].map(e=>(0,Z.jsx)(vi,{},e))}),(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[1,2,3,4].map(e=>(0,Z.jsx)(vi,{},e))}),(0,Z.jsx)(yi,{className:`h-[200px]`}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[(0,Z.jsx)(yi,{}),(0,Z.jsx)(yi,{})]}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,Z.jsx)(yi,{className:`lg:col-span-2`}),(0,Z.jsx)(yi,{})]})]})]})}var xi=class extends X.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`ErrorBoundary caught render failure.`,e,t)}render(){return this.state.hasError?this.props.fallback:this.props.children}},Si=`modulepreload`,Ci=function(e){return`/`+e},wi={},Q=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Ci(t,n),t in wi)return;wi[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Si,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function $(e){let t=(0,X.lazy)(e);return t.preload=e,t}function Ti(...e){return Promise.all(e.map(e=>e.preload()))}var Ei=$(()=>Q(()=>import(`./CostForecast-fwd7SRIn.js`).then(e=>({default:e.CostForecast})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21]))),Di=$(()=>Q(()=>import(`./CostByModelOverTime-BDvnsdLO.js`).then(e=>({default:e.CostByModelOverTime})),__vite__mapDeps([22,2,1,3,5,20,13,4,14,7,8,9,10,11,12,15,16,17,21]))),Oi=$(()=>Q(()=>import(`./CumulativeCost-CwiklwFD.js`).then(e=>({default:e.CumulativeCost})),__vite__mapDeps([23,1,2,3,5,13,4,14,7,8,9,10,11,12,15,17,19,20,21]))),ki=$(()=>Q(()=>import(`./CostByWeekday-BPU1qW5f.js`).then(e=>({default:e.CostByWeekday})),__vite__mapDeps([24,1,2,3,5,13,4,14,7,8,9,10,11,12,15,17,21]))),Ai=$(()=>Q(()=>import(`./TokenEfficiency-6dfn-4_1.js`).then(e=>({default:e.TokenEfficiency})),__vite__mapDeps([25,1,2,3,5,13,4,14,7,8,9,10,11,12,15,17,19,20,21]))),ji=$(()=>Q(()=>import(`./ModelMix-BgCzWf9V.js`).then(e=>({default:e.ModelMix})),__vite__mapDeps([26,1,2,3,5,20,13,4,14,7,8,9,10,11,12,15,21]))),Mi=$(()=>Q(()=>import(`./TokensOverTime-C1858Oi-.js`).then(e=>({default:e.TokensOverTime})),__vite__mapDeps([27,1,2,3,5,13,4,14,7,8,9,10,11,12,15,17,18,21]))),Ni=$(()=>Q(()=>import(`./TokenTypes-Dx67irJb.js`).then(e=>({default:e.TokenTypes})),__vite__mapDeps([28,2,1,3,5,13,4,14,7,8,9,10,11,12,15,16,17,21]))),Pi=$(()=>Q(()=>import(`./RequestsOverTime-Bv3riiRF.js`).then(e=>({default:e.RequestsOverTime})),__vite__mapDeps([29,1,2,3,12,5,20,13,4,14,7,8,9,10,11,15,16,17,18,21]))),Fi=$(()=>Q(()=>import(`./RequestCacheHitRateByModel-DD2j4dXY.js`).then(e=>({default:e.RequestCacheHitRateByModel})),__vite__mapDeps([30,1,2,3,5,20,13,4,14,7,8,9,10,11,12,15,16,17,19,21]))),Ii=$(()=>Q(()=>import(`./CacheROI-BLADEjtP.js`).then(e=>({default:e.CacheROI})),__vite__mapDeps([31,1,2,3,4,5,20,7,32,33,8,9,10,11,12,18,34,21]))),Li=$(()=>Q(()=>import(`./ProviderLimitsSection-BxaczEFO.js`).then(e=>({default:e.ProviderLimitsSection})),__vite__mapDeps([35,1,2,3,12,5,4,20,13,14,7,8,9,10,11,15,16,32,36,33,21,37]))),Ri=$(()=>Q(()=>import(`./RequestQuality-CUy5BQzj.js`).then(e=>({default:e.RequestQuality})),__vite__mapDeps([38,3,1,2,5,7,32,33,8,4,9,10,11,12,21]))),zi=$(()=>Q(()=>import(`./DistributionAnalysis-B8pjQMNj.js`).then(e=>({default:e.DistributionAnalysis})),__vite__mapDeps([39,1,2,3,5,13,4,14,7,8,9,10,11,12,15,21]))),Bi=$(()=>Q(()=>import(`./CorrelationAnalysis-CI9eGa8R.js`).then(e=>({default:e.CorrelationAnalysis})),__vite__mapDeps([40,1,2,3,5,14,7,33,8,4,9,10,11,12,21]))),Vi=$(()=>Q(()=>import(`./PeriodComparison-BIoF7n2v.js`).then(e=>({default:e.PeriodComparison})),__vite__mapDeps([41,1,2,42,10,11,3,5,4,7,33,8,9,12,19,20,21]))),Hi=$(()=>Q(()=>import(`./AnomalyDetection-DKM--5-J.js`).then(e=>({default:e.AnomalyDetection})),__vite__mapDeps([43,1,2,3,4,5,7,33,8,9,10,11,12,19,20,21]))),Ui=$(()=>Q(()=>import(`./ModelEfficiency-Di3fDAn7.js`).then(e=>({default:e.ModelEfficiency})),__vite__mapDeps([44,1,2,3,4,5,20,7,33,8,9,10,11,12,18,21]))),Wi=$(()=>Q(()=>import(`./ProviderEfficiency-BFUYfBkW.js`).then(e=>({default:e.ProviderEfficiency})),__vite__mapDeps([45,1,2,3,4,5,20,7,33,8,9,10,11,12,18,21]))),Gi=$(()=>Q(()=>import(`./RecentDays-Bac6HOtv.js`).then(e=>({default:e.RecentDays})),__vite__mapDeps([46,1,2,42,10,11,3,5,4,20,7,32,33,8,9,12,18,21])));function Ki({sectionOrder:e,sectionVisibility:t,metrics:n,viewMode:r,totalCalendarDays:i,filteredData:a,filteredDailyData:o,todayData:s,hasCurrentMonthData:c,visibleLimitProviders:l,providerLimits:u,selectedMonth:d,allModels:f,costChartData:p,modelPieData:m,modelCostChartData:h,weekdayData:g,tokenChartData:_,tokenPieData:v,requestChartData:y,comparisonData:b,modelCosts:x,providerMetrics:S,isDark:C,onDrillDownDateChange:w}){let{t:T}=M(),E=e=>(0,Z.jsx)(yi,{className:e??`h-[360px]`,bodyClassName:e??`h-[360px]`}),D=e=>(0,Z.jsxs)(`div`,{role:`alert`,className:A(`flex min-h-[280px] flex-col items-center justify-center rounded-xl border border-border/50 bg-card/80 px-6 py-8 text-center backdrop-blur-xl`,e),children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:T(`dashboard.lazySectionError.title`)}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-sm text-xs text-muted-foreground`,children:T(`dashboard.lazySectionError.description`)})]}),O=(e,t)=>(0,Z.jsx)(xi,{fallback:D(t),children:(0,Z.jsx)(X.Suspense,{fallback:E(t),children:e})}),k={insights:`min-h-[260px]`,metrics:`min-h-[320px]`,today:`min-h-[320px]`,currentMonth:`min-h-[360px]`,activity:`min-h-[360px]`,forecastCache:`min-h-[420px]`,limits:`min-h-[480px]`,costAnalysis:`min-h-[980px]`,tokenAnalysis:`min-h-[380px]`,requestAnalysis:`min-h-[760px]`,advancedAnalysis:`min-h-[760px]`,comparisons:`min-h-[420px]`,tables:`min-h-[900px]`},j={costAnalysis:`charts`,currentMonth:`current-month`,tokenAnalysis:`token-analysis`,requestAnalysis:`request-analysis`,advancedAnalysis:`advanced-analysis`},N=(e,t,{eager:n=!1,onPreload:r}={})=>(0,Z.jsx)(ft,{id:j[e]??e,eager:n,placeholderClassName:k[e],onPreload:r,children:t}),P=e=>{switch(e){case`insights`:return t.insights?N(`insights`,(0,Z.jsx)(pi,{metrics:n,viewMode:r,totalCalendarDays:i}),{eager:!0}):null;case`metrics`:return t.metrics?N(`metrics`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.metrics.title`),badge:T(`dashboard.metrics.badge`),description:T(`dashboard.metrics.description`),info:wt.metrics}),(0,Z.jsx)(Yr,{metrics:n,totalCalendarDays:i,viewMode:r}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(Xr,{metrics:n,dailyCosts:a.map(e=>e.totalCost),viewMode:r})})]}),{eager:!0}):null;case`today`:return t.today&&s?N(`today`,(0,Z.jsx)(Zr,{today:s,metrics:n}),{eager:!0}):null;case`currentMonth`:return t.currentMonth&&c?N(`currentMonth`,(0,Z.jsx)(Qr,{daily:o,metrics:n}),{eager:!0}):null;case`activity`:return t.activity?N(`activity`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.activity.title`),description:T(r===`daily`?`dashboard.activity.dailyDescription`:r===`monthly`?`dashboard.activity.monthlyDescription`:`dashboard.activity.yearlyDescription`),info:wt.activity}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-3`,children:[(0,Z.jsx)(di,{data:a,viewMode:r,metric:`cost`,isDark:C}),(0,Z.jsx)(di,{data:a,viewMode:r,metric:`requests`,isDark:C}),(0,Z.jsx)(di,{data:a,viewMode:r,metric:`tokens`,isDark:C})]})]})):null;case`forecastCache`:return t.forecastCache?N(`forecastCache`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.forecastCache.title`),description:T(`dashboard.forecastCache.description`),info:wt.forecastCache}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[O((0,Z.jsx)(gi,{title:T(`dashboard.cards.costForecast`),children:(0,Z.jsx)(Ei,{data:a,viewMode:r})}),`h-[360px]`),O((0,Z.jsx)(gi,{title:T(`dashboard.cards.cacheRoi`),stats:[{label:T(`dashboard.stats.cacheHitRate`),value:V(n.cacheHitRate)},{label:T(`dashboard.stats.totalTokens`),value:F(n.totalTokens)},{label:T(`dashboard.stats.cacheRead`),value:F(n.totalCacheRead)}],children:(0,Z.jsx)(Ii,{data:a,viewMode:r})}),`h-[360px]`)]})]}),{onPreload:()=>Ti(Ei,Ii)}):null;case`limits`:return t.limits?N(`limits`,O((0,Z.jsx)(Li,{data:o,providers:l,limits:u,selectedMonth:d}),`h-[420px]`),{onPreload:()=>Ti(Li)}):null;case`costAnalysis`:return t.costAnalysis?N(`costAnalysis`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.costAnalysis.title`),badge:`${f.length} ${T(`common.models`)}`,description:T(`dashboard.costAnalysis.description`),info:wt.costAnalysis}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-2`,children:(0,Z.jsx)($r,{data:p,onClickDay:w})}),(0,Z.jsx)(ti,{data:m})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Di,{data:h,models:f}),`h-[320px]`)}),(0,Z.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[O((0,Z.jsx)(Oi,{data:p,rawData:a}),`h-[320px]`),O((0,Z.jsx)(ki,{data:g}),`h-[320px]`)]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[O((0,Z.jsx)(Ai,{data:a}),`h-[320px]`),O((0,Z.jsx)(ji,{data:a}),`h-[320px]`)]})]}),{onPreload:()=>Ti(Di,Oi,ki,Ai,ji)}):null;case`tokenAnalysis`:return t.tokenAnalysis?N(`tokenAnalysis`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.tokenAnalysis.title`),description:T(`dashboard.tokenAnalysis.description`),info:wt.tokenAnalysis}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-3`,children:[O((0,Z.jsx)(Mi,{data:_,onClickDay:w}),`h-[320px]`),O((0,Z.jsx)(Ni,{data:v}),`h-[320px]`)]})]}),{onPreload:()=>Ti(Mi,Ni)}):null;case`requestAnalysis`:return t.requestAnalysis&&n.hasRequestData?N(`requestAnalysis`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.requestAnalysis.title`),description:T(`dashboard.requestAnalysis.description`),info:wt.requestAnalysis}),O((0,Z.jsx)(Pi,{data:y,viewMode:r,onClickDay:w}),`h-[320px]`),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Fi,{timelineData:a,summaryData:o,viewMode:r}),`h-[320px]`)}),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Ri,{metrics:n,viewMode:r}),`h-[280px]`)})]}),{onPreload:()=>Ti(Pi,Fi,Ri)}):null;case`advancedAnalysis`:return t.advancedAnalysis?N(`advancedAnalysis`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.advancedAnalysis.title`),description:T(`dashboard.advancedAnalysis.description`),info:wt.advancedAnalysis}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 xl:grid-cols-2`,children:[O((0,Z.jsx)(zi,{data:a,viewMode:r}),`h-[320px]`),(0,Z.jsx)(hi,{topModelShare:n.topModelShare,topProviderShare:n.topProvider?.share??0,modelConcentrationIndex:n.modelConcentrationIndex,providerConcentrationIndex:n.providerConcentrationIndex})]}),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Bi,{data:a}),`h-[320px]`)})]}),{onPreload:()=>Ti(zi,Bi)}):null;case`comparisons`:return t.comparisons?N(`comparisons`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.comparisons.title`),description:T(`dashboard.comparisons.description`),info:wt.comparisons}),(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 lg:grid-cols-2`,children:[O((0,Z.jsx)(gi,{title:T(`dashboard.cards.periodComparison`),stats:[{label:T(`dashboard.stats.dataPoints`),value:String(a.length)},{label:T(`dashboard.stats.avgCostPerUnit`,{unit:I(r)}),value:z(n.avgDailyCost)}],children:(0,Z.jsx)(Vi,{data:b})}),`h-[360px]`),O((0,Z.jsx)(gi,{title:T(`dashboard.cards.anomalyDetection`),stats:[{label:T(`dashboard.stats.total`),value:z(n.totalCost)},{label:T(`dashboard.stats.avgPerUnit`,{unit:I(r)}),value:z(n.avgDailyCost)}],children:(0,Z.jsx)(Hi,{data:a,onClickDay:w,viewMode:r})}),`h-[360px]`)]})]}),{onPreload:()=>Ti(Vi,Hi)}):null;case`tables`:return t.tables?N(`tables`,(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(kt,{title:T(`dashboard.tables.title`),description:T(`dashboard.tables.description`),info:wt.tables}),O((0,Z.jsx)(Ui,{modelCosts:x,totalCost:n.totalCost,viewMode:r}),`h-[320px]`),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Wi,{providerMetrics:S,totalCost:n.totalCost,viewMode:r}),`h-[320px]`)}),(0,Z.jsx)(`div`,{className:`mt-4`,children:O((0,Z.jsx)(Gi,{data:a,onClickDay:w,viewMode:r}),`h-[360px]`)})]}),{onPreload:()=>Ti(Ui,Wi,Gi)}):null;default:return null}};return(0,Z.jsx)(Z.Fragment,{children:e.map(e=>(0,Z.jsx)(X.Fragment,{children:P(e)},e))})}async function qi(e){return await e.json()}async function Ji(e,t){try{let n=await qi(e);return typeof n.message==`string`&&n.message.trim()?n.message:t}catch{return t}}async function Yi(){let e=await fetch(`/api/usage`);if(!e.ok)throw Error(await Ji(e,se.t(`api.fetchUsageFailed`)));return qi(e)}async function Xi(e){let t=await fetch(`/api/upload`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Ji(t,se.t(`api.uploadFailed`)));return qi(t)}async function Zi(){if(!(await fetch(`/api/usage`,{method:`DELETE`})).ok)throw Error(se.t(`api.deleteFailed`))}async function Qi(e){let t=await fetch(`/api/usage/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Ji(t,se.t(`api.importUsageFailed`)));return qi(t)}async function $i(){let e=await fetch(`/api/settings`);if(!e.ok)throw Error(await Ji(e,se.t(`api.fetchSettingsFailed`)));return xt(await qi(e))}async function ea(){try{let e=Date.now(),t=await fetch(`/api/settings`);return t.ok?{settings:xt(await qi(t)),errorMessage:null,loadedFromServer:!0,fetchedAt:e}:{settings:Ct,errorMessage:await Ji(t,se.t(`api.fetchSettingsFailed`)),loadedFromServer:!1,fetchedAt:null}}catch{return{settings:Ct,errorMessage:null,loadedFromServer:!1,fetchedAt:null}}}async function ta(e){let t=await fetch(`/api/settings`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Ji(t,se.t(`api.saveSettingsFailed`)));return xt(await qi(t))}async function na(){let e=await fetch(`/api/settings`,{method:`DELETE`});if(!e.ok)throw Error(await Ji(e,se.t(`api.deleteSettingsFailed`)));return xt((await qi(e)).settings)}async function ra(e){let t=await fetch(`/api/settings/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Ji(t,se.t(`api.importSettingsFailed`)));return xt(await qi(t))}async function ia(e){let t=await fetch(`/api/report/pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok)throw Error(await Ji(t,se.t(`api.pdfFailed`)));return t.blob()}function aa(){return _r({queryKey:[`usage`],queryFn:Yi,staleTime:1e3*60*5})}function oa(){let e=nr();return vr({mutationFn:e=>Xi(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`usage`]})}})}function sa(){let e=nr();return vr({mutationFn:Zi,onSuccess:()=>{e.invalidateQueries({queryKey:[`usage`]})}})}function ca(e,t){return xt({...e,...t,providerLimits:t.providerLimits??e.providerLimits})}function la(e,t=Ct,n=!1,r=null){let i=nr(),a=_r({queryKey:[`settings`],queryFn:$i,staleTime:1e3*60*5,initialData:t,initialDataUpdatedAt:n&&typeof r==`number`?r:0}),o=vr({mutationFn:e=>ta(e),onMutate:async e=>{await i.cancelQueries({queryKey:[`settings`]});let t=i.getQueryData([`settings`])??Ct;return i.setQueryData([`settings`],ca(t,e)),{previous:t}},onError:(e,t,n)=>{n?.previous&&i.setQueryData([`settings`],n.previous)},onSuccess:e=>{i.setQueryData([`settings`],e)}}),s=a.data??Ct;return{settings:s,providerLimits:(0,X.useMemo)(()=>Ht(e,s.providerLimits),[e,s.providerLimits]),setTheme:(0,X.useCallback)(e=>o.mutateAsync({theme:e}),[o]),setLanguage:(0,X.useCallback)(e=>o.mutateAsync({language:e}),[o]),setProviderLimits:(0,X.useCallback)(e=>o.mutateAsync({providerLimits:e}),[o]),setReducedMotionPreference:(0,X.useCallback)(e=>o.mutateAsync({reducedMotionPreference:e}),[o]),setDefaultFilters:(0,X.useCallback)(e=>o.mutateAsync({defaultFilters:e}),[o]),setSectionVisibility:(0,X.useCallback)(e=>o.mutateAsync({sectionVisibility:e}),[o]),setSectionOrder:(0,X.useCallback)(e=>o.mutateAsync({sectionOrder:e}),[o]),saveSettings:(0,X.useCallback)(e=>o.mutateAsync(e),[o]),isLoading:a.isLoading,isSaving:o.isPending,error:a.error,isError:a.isError,hasFetchedAfterMount:a.isFetchedAfterMount}}var ua=rt();function da(e,t,n){return(0,ua.filterByDateRange)(e,t,n)}function fa(e,t){return(0,ua.filterByModels)(e,t)}function pa(e,t){return(0,ua.filterByProviders)(e,t)}function ma(e,t){return(0,ua.filterByMonth)(e,t)}function ha(e){return(0,ua.sortByDate)(e)}function ga(e){let t=new Set;for(let n of e)t.add(n.date.slice(0,7));return Array.from(t).sort()}function _a(e){if(e.length===0)return null;let t=null;for(let n of e)if(n){t=n;break}if(!t)return null;let n=t.date,r=t.date;for(let t=0;t<e.length;t++){let i=e[t];if(!i)continue;let a=i.date;a<n&&(n=a),a>r&&(r=a)}return{start:n,end:r}}function va(e){return ha(e)}function ya(e){let t=new Intl.DateTimeFormat(e,{weekday:`short`,timeZone:`UTC`});return Array.from({length:7},(e,n)=>t.format(new Date(Date.UTC(2024,0,1+n))).replace(`.`,``).slice(0,2))}function ba(e,t=ce()){let n=va(e);if(n.length===0)return{costChartData:[],modelCostChartData:[],tokenChartData:[],requestChartData:[],weekdayData:ya(t).map(e=>({day:e,cost:0}))};let r=n.map(e=>e.totalCost),i=n.map(e=>e.totalTokens),a=n.map(e=>e.inputTokens),o=n.map(e=>e.outputTokens),s=n.map(e=>e.cacheCreationTokens),c=n.map(e=>e.cacheReadTokens),l=n.map(e=>e.thinkingTokens),u=n.map(e=>e.requestCount),d=Gt(r),f=Gt(i),p=Gt(a),m=Gt(o),h=Gt(s),g=Gt(c),_=Gt(l),v=Gt(u),y=Array.from(new Set(n.flatMap(e=>e.modelBreakdowns.map(e=>W(e.modelName))))).sort(),b={},x={};for(let e of y)b[e]=[],x[e]=[];let S=ya(t),C={0:[],1:[],2:[],3:[],4:[],5:[],6:[]},w=n.map(e=>{let t={},n={};for(let r of e.modelBreakdowns){let e=W(r.modelName);t[e]=(t[e]??0)+r.cost,n[e]=(n[e]??0)+r.requestCount}for(let e of y)b[e]?.push(t[e]??0),x[e]?.push(n[e]??0);return e.date.length===10&&C[(new Date(e.date+`T00:00:00`).getDay()+6)%7]?.push(e.totalCost),{costsByModel:t,requestsByModel:n}}),T={},E={};for(let e of y)T[e]=Gt(b[e]??[]),E[e]=Gt(x[e]??[]);let D=0,O=[],k=[],A=[],j=[];return n.forEach((e,t)=>{D+=e.totalCost;let r=t>0?n[t-1]:void 0,i=w[t],a={date:e.date,cost:e.totalCost,cumulative:D};r&&(a.costPrev=r.totalCost),d[t]!==void 0&&(a.ma7=d[t]),O.push(a);let o={date:e.date,cost:e.totalCost},s={date:e.date,totalRequests:e.requestCount};r&&(s.totalRequestsPrev=r.requestCount),v[t]!==void 0&&(s.totalRequestsMA7=v[t]);for(let e of y)o[e]=i?.costsByModel[e]??0,o[`${e}_ma7`]=T[e]?.[t],s[e]=i?.requestsByModel[e]??0,s[`${e}_ma7`]=E[e]?.[t];k.push(o),j.push(s);let c={date:e.date,Input:e.inputTokens,Output:e.outputTokens,"Cache Write":e.cacheCreationTokens,"Cache Read":e.cacheReadTokens,Thinking:e.thinkingTokens,totalTokens:e.totalTokens};r&&(c.totalTokensPrev=r.totalTokens),f[t]!==void 0&&(c.tokenMA7=f[t]),p[t]!==void 0&&(c.inputMA7=p[t]),m[t]!==void 0&&(c.outputMA7=m[t]),h[t]!==void 0&&(c.cacheWriteMA7=h[t]),g[t]!==void 0&&(c.cacheReadMA7=g[t]),_[t]!==void 0&&(c.thinkingMA7=_[t]),A.push(c)}),{costChartData:O,modelCostChartData:k,tokenChartData:A,requestChartData:j,weekdayData:S.map((e,t)=>{let n=C[t]??[];return{day:e,cost:n.length>0?n.reduce((e,t)=>e+t,0)/n.length:0}})}}function xa(e,t){return(0,ua.aggregateToDailyFormat)(e,t)}function Sa(e){let t=new Date;t.setHours(0,0,0,0);let n=N;switch(e){case`7d`:{let e=new Date(t);return e.setDate(t.getDate()-6),{startDate:n(e),endDate:n(t)}}case`30d`:{let e=new Date(t);return e.setDate(t.getDate()-29),{startDate:n(e),endDate:n(t)}}case`month`:return{startDate:n(new Date(t.getFullYear(),t.getMonth(),1)),endDate:n(t)};case`year`:return{startDate:n(new Date(t.getFullYear(),0,1)),endDate:n(t)};default:return{startDate:void 0,endDate:void 0}}}function Ca(e,t){let n=new Set(ot(e.map(e=>e.modelsUsed))),r=new Set(at(e.map(e=>e.modelsUsed)));return{viewMode:t.viewMode,datePreset:t.datePreset,providers:t.providers.filter(e=>n.has(e)),models:t.models.filter(e=>r.has(e))}}function wa(e,t=St){let n=(0,X.useMemo)(()=>ha(e),[e]),r=(0,X.useMemo)(()=>Ca(n,t),[n,t]),i=(0,X.useMemo)(()=>Sa(r.datePreset),[r.datePreset]),a=(0,X.useMemo)(()=>JSON.stringify(r),[r]),[o,s]=(0,X.useState)(r.viewMode),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(r.providers),[f,p]=(0,X.useState)(r.models),[m,h]=(0,X.useState)(i.startDate),[g,_]=(0,X.useState)(i.endDate),v=(0,X.useRef)(!1),y=(0,X.useRef)(a),b=(0,X.useCallback)((e=t)=>{let r=Ca(n,e),i=Sa(r.datePreset);v.current=!1,y.current=JSON.stringify(r),s(r.viewMode),l(null),d(r.providers),p(r.models),h(i.startDate),_(i.endDate)},[t,n]);(0,X.useEffect)(()=>{y.current===a||v.current||(y.current=a,s(r.viewMode),l(null),d(r.providers),p(r.models),h(i.startDate),_(i.endDate))},[a,r,i]);let x=(0,X.useCallback)(e=>{v.current=!0,s(e)},[]),S=(0,X.useCallback)(e=>{v.current=!0,l(e)},[]),C=(0,X.useCallback)(e=>{v.current=!0,h(e)},[]),w=(0,X.useCallback)(e=>{v.current=!0,_(e)},[]),T=(0,X.useCallback)(e=>{v.current=!0,d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),p([])},[]),E=(0,X.useCallback)(()=>{v.current=!0,d([]),p([])},[]),D=(0,X.useCallback)(e=>{v.current=!0,p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),O=(0,X.useCallback)(()=>{v.current=!0,p([])},[]),k=(0,X.useCallback)(()=>{b()},[b]),A=(0,X.useCallback)(e=>{v.current=!0,l(null);let t=Sa(e);h(t.startDate),_(t.endDate)},[]),j=(0,X.useMemo)(()=>{let e=n;return e=da(e,m,g),e=ma(e,c),e},[n,m,g,c]),M=(0,X.useMemo)(()=>{let e=j;return e=pa(e,u),e},[j,u]),N=(0,X.useMemo)(()=>{let e=M;return e=fa(e,f),e},[M,f]);return{viewMode:o,setViewMode:x,selectedMonth:c,setSelectedMonth:S,selectedProviders:u,toggleProvider:T,clearProviders:E,selectedModels:f,toggleModel:D,clearModels:O,startDate:m,setStartDate:C,endDate:g,setEndDate:w,resetAll:k,applyDefaultFilters:b,applyPreset:A,filteredDailyData:N,filteredData:(0,X.useMemo)(()=>{let e=N;return e=xa(e,o),e},[N,o]),availableMonths:(0,X.useMemo)(()=>ga(n),[n]),availableProviders:(0,X.useMemo)(()=>ot(j.map(e=>e.modelsUsed)),[j]),availableModels:(0,X.useMemo)(()=>at(M.map(e=>e.modelsUsed)),[M]),dateRange:(0,X.useMemo)(()=>_a(N),[N])}}function Ta(e,t){let n=(0,X.useMemo)(()=>Wt(e),[e]),r=(0,X.useMemo)(()=>Ut(e),[e]),i=(0,X.useMemo)(()=>Kt(e),[e]),a=(0,X.useMemo)(()=>ba(e,t),[e,t]),o=(0,X.useMemo)(()=>at(e.map(e=>e.modelsUsed)),[e]),s=(0,X.useMemo)(()=>Array.from(r.entries()).map(([e,t])=>({name:e,value:t.cost})).sort((e,t)=>t.value-e.value),[r]),c=(0,X.useMemo)(()=>[{name:`Input`,value:n.totalInput},{name:`Output`,value:n.totalOutput},{name:`Cache Write`,value:n.totalCacheCreate},{name:`Cache Read`,value:n.totalCacheRead},{name:`Thinking`,value:n.totalThinking}],[n]);return{metrics:n,modelCosts:r,providerMetrics:i,costChartData:a.costChartData,modelCostChartData:a.modelCostChartData,tokenChartData:a.tokenChartData,requestChartData:a.requestChartData,weekdayData:a.weekdayData,allModels:o,modelPieData:s,tokenPieData:c}}function Ea(e){return[Ft([`date`,`totalCost`,`totalTokens`,`inputTokens`,`outputTokens`,`cacheCreationTokens`,`cacheReadTokens`,`thinkingTokens`,`requestCount`,`models`]),...e.map(e=>{let t=e.modelBreakdowns.map(e=>W(e.modelName)).filter((e,t,n)=>n.indexOf(e)===t).join(`; `);return Ft([e.date,e.totalCost.toFixed(2),e.totalTokens,e.inputTokens,e.outputTokens,e.cacheCreationTokens,e.cacheReadTokens,e.thinkingTokens,e.requestCount,t])})].join(`
|
|
3
|
+
`)}function Da(e){let t=Ea(e),n=new Blob([t],{type:`text/csv;charset=utf-8;`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`ttdash-export-${ne()}.csv`,i.click(),URL.revokeObjectURL(r)}var Oa=`ttdash-settings-backup`,ka=`ttdash-usage-backup`,Aa=1,ja=`Settings file is unreadable or corrupted.`,Ma=`Usage data file is unreadable or corrupted.`;function Na(e){return e instanceof Error&&e.message.trim()?e.message:null}function Pa(e,t){return e===ja||e===Ma?t:e}function Fa(e,t){let n=JSON.stringify(t,null,2),r=new Blob([n],{type:`application/json`});window.__TTDASH_TEST_HOOKS__?.onJsonDownload?.({filename:e,mimeType:r.type,size:r.size,text:n});let i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,document.body.appendChild(a),a.click(),a.remove(),window.setTimeout(()=>URL.revokeObjectURL(i),1e3)}function Ia(e,t=!1,n=null,r=null){let{t:i,i18n:a}=M(),{data:o,isLoading:s,error:c}=aa(),l=oa(),u=sa(),d=nr(),{addToast:f}=Sr(),p=(0,X.useRef)(null),m=(0,X.useRef)(null),h=(0,X.useRef)(null),[g,_]=(0,X.useState)(null),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null),[P,ee]=(0,X.useState)(0),[te,F]=(0,X.useState)(r),I=(0,X.useMemo)(()=>o?.daily??[],[o]),L=I.length>0,R=(0,X.useMemo)(()=>ot(I.map(e=>e.modelsUsed)),[I]),z=(0,X.useMemo)(()=>at(I.map(e=>e.modelsUsed)),[I]),{settings:B,providerLimits:ae,setTheme:V,setLanguage:oe,saveSettings:se,isSaving:le,isLoading:ue,error:de,hasFetchedAfterMount:fe}=la(R,e,t,n),pe=B.theme===`dark`;(0,X.useEffect)(()=>{te&&fe&&!de&&F(null)},[te,fe,de]),(0,X.useEffect)(()=>{bt(B.theme)},[B.theme]),(0,X.useEffect)(()=>{a.resolvedLanguage!==B.language&&a.changeLanguage(B.language)},[a,B.language]),(0,X.useEffect)(()=>{let e=window;if(e.__TTDASH_TEST_HOOKS__)return e.__TTDASH_TEST_HOOKS__.openSettings=()=>{C(!0)},()=>{e.__TTDASH_TEST_HOOKS__?.openSettings&&delete e.__TTDASH_TEST_HOOKS__.openSettings}},[]);let me=(0,X.useMemo)(()=>B.lastLoadedAt?re(B.lastLoadedAt):void 0,[B.lastLoadedAt]),he=(0,X.useMemo)(()=>B.lastLoadedAt?i(`header.loadedAt`,{time:ie(B.lastLoadedAt)}):void 0,[B.lastLoadedAt,i]),ge=(0,X.useMemo)(()=>L?{type:`stored`,...me?{time:me}:{},...he?{title:he}:{}}:null,[L,me,he]),_e=A??ge,ve=(0,X.useMemo)(()=>B.cliAutoLoadActive?{active:!0,...me?{time:me}:{},title:B.lastLoadedAt?i(`header.autoLoadAt`,{time:ie(B.lastLoadedAt)}):i(`header.autoLoadActive`)}:null,[B.cliAutoLoadActive,B.lastLoadedAt,me,i]),{viewMode:ye,setViewMode:be,selectedMonth:xe,setSelectedMonth:Se,selectedProviders:Ce,toggleProvider:we,clearProviders:Te,selectedModels:Ee,toggleModel:De,clearModels:Oe,startDate:ke,setStartDate:Ae,endDate:je,setEndDate:Me,resetAll:Ne,applyDefaultFilters:Pe,applyPreset:Fe,filteredDailyData:H,filteredData:Ie,availableMonths:Le,availableProviders:Re,availableModels:ze,dateRange:Be}=wa(I,B.defaultFilters),{metrics:Ve,modelCosts:He,providerMetrics:Ue,costChartData:We,modelCostChartData:Ge,tokenChartData:Ke,requestChartData:qe,weekdayData:Je,allModels:Ye,modelPieData:Xe,tokenPieData:Ze}=Ta(Ie,a.resolvedLanguage??a.language),Qe=H,U=(0,X.useMemo)(()=>{if(!Be||ye!==`daily`)return 0;let e=new Date(Be.start+`T00:00:00`),t=new Date(Be.end+`T00:00:00`);return Math.round((t.getTime()-e.getTime())/(1e3*60*60*24))+1},[Be,ye]),et=ne(),tt=(0,X.useMemo)(()=>H.find(e=>e.date===et)??null,[H,et]),W=(0,X.useMemo)(()=>H.some(e=>e.date.startsWith(et.slice(0,7))),[H,et]),nt=(0,X.useMemo)(()=>Ce.length>0?Ce:R,[Ce,R]),rt=(0,X.useMemo)(()=>[...new Set([...R,...B.defaultFilters.providers])].sort((e,t)=>e.localeCompare(t)),[R,B.defaultFilters.providers]),it=(0,X.useMemo)(()=>[...new Set([...z,...B.defaultFilters.models])].sort((e,t)=>e.localeCompare(t)),[z,B.defaultFilters.models]),st=B.sectionVisibility,ct=B.sectionOrder,G=(0,X.useMemo)(()=>{let e=new Set(H.map(e=>e.date)),t=0,n=new Date(et+`T00:00:00`);for(;e.has(N(n));)t+=1,n.setDate(n.getDate()-1);return t},[H,et]),lt=(0,X.useMemo)(()=>g?Ie.find(e=>e.date===g)??null:null,[g,Ie]),ut=(0,X.useCallback)(()=>{p.current?.click()},[]),dt=(0,X.useCallback)(()=>{C(!0)},[]),ft=(0,X.useCallback)(async()=>{await Promise.all([d.invalidateQueries({queryKey:[`settings`]}),d.invalidateQueries({queryKey:[`usage`]})])},[d]),pt=(0,X.useCallback)(async()=>{try{let e=await na();d.setQueryData([`settings`],e),F(null),await d.invalidateQueries({queryKey:[`settings`]}),f(i(`toasts.settingsReset`),`success`)}catch(e){f(e instanceof Error?e.message:i(`api.deleteSettingsFailed`),`error`)}},[d,f,i]),mt=(0,X.useCallback)(()=>{V(pe?`light`:`dark`)},[pe,V]),ht=(0,X.useCallback)(async e=>{Pe((await se(e)).defaultFilters),f(i(`toasts.settingsSaved`),`success`)},[se,Pe,f,i]),gt=(0,X.useCallback)(e=>{B.language!==e&&oe(e),a.resolvedLanguage!==e&&a.changeLanguage(e)},[a,oe,B.language]),_t=(0,X.useCallback)(async e=>{let t=e.target.files?.[0];if(t){try{let e=JSON.parse(await t.text());try{await l.mutateAsync(e)}catch(e){f(Na(e)??i(`toasts.fileReadFailed`),`error`);return}d.invalidateQueries({queryKey:[`settings`]}),ee(e=>e+1);let n=new Date,r=n.toLocaleTimeString(ce(),{hour:`2-digit`,minute:`2-digit`});j({type:`file`,label:t.name,time:r,title:`${t.name} · ${i(`header.loadedAt`,{time:ie(n.toISOString())})}`}),f(i(`toasts.fileLoaded`,{name:t.name}),`success`)}catch{f(i(`toasts.fileReadFailed`),`error`)}e.target.value=``}},[l,d,f,i]),vt=(0,X.useCallback)(async()=>{try{await u.mutateAsync(),d.invalidateQueries({queryKey:[`settings`]}),ee(e=>e+1),j(null),f(i(`toasts.dataDeleted`),`info`)}catch(e){f(Na(e)??i(`toasts.deleteFailed`),`error`)}},[u,d,f,i]),yt=te??Na(de)??null,xt=Na(c);return{fileInputRef:p,settingsImportInputRef:m,dataImportInputRef:h,settings:B,providerLimits:ae,isLoading:s,settingsLoading:ue,isSaving:le,isDark:pe,hasData:L,helpOpen:v,setHelpOpen:y,autoImportOpen:b,setAutoImportOpen:x,settingsOpen:S,setSettingsOpen:C,drillDownDate:g,setDrillDownDate:_,drillDownDay:lt,reportGenerating:w,settingsTransferBusy:E,dataTransferBusy:O,dataSource:A,headerDataSource:_e,startupAutoLoadBadge:ve,animationSeed:P,daily:I,usageData:o,allProviders:R,allModelsFromData:z,settingsProviderOptions:rt,settingsModelOptions:it,viewMode:ye,setViewMode:be,selectedMonth:xe,setSelectedMonth:Se,selectedProviders:Ce,toggleProvider:we,clearProviders:Te,selectedModels:Ee,toggleModel:De,clearModels:Oe,startDate:ke,setStartDate:Ae,endDate:je,setEndDate:Me,resetAll:Ne,applyPreset:Fe,filteredDailyData:H,filteredData:Ie,availableMonths:Le,availableProviders:Re,availableModels:ze,dateRange:Be,metrics:Ve,modelCosts:He,providerMetrics:Ue,costChartData:We,modelCostChartData:Ge,tokenChartData:Ke,requestChartData:qe,weekdayData:Je,allModels:Ye,modelPieData:Xe,tokenPieData:Ze,comparisonData:Qe,totalCalendarDays:U,todayData:tt,hasCurrentMonthData:W,visibleLimitProviders:nt,sectionVisibility:st,sectionOrder:ct,streak:G,fatalLoadState:(0,X.useMemo)(()=>{let e=[],t=!!yt,n=!!xt;return yt&&e.push(Pa(yt,i(`loadError.settingsCorrupted`))),xt&&e.push(Pa(xt,i(`loadError.usageCorrupted`))),!t&&!n?null:{title:i(`loadError.title`),description:i(t&&n?`loadError.multipleDescription`:t?`loadError.settingsDescription`:`loadError.usageDescription`),details:e,canResetSettings:t,canResetUsage:n}},[yt,xt,i]),handleUpload:ut,handleOpenSettings:dt,handleRetryLoad:ft,handleResetSettings:pt,handleToggleTheme:mt,handleSaveSettings:ht,handleLanguageChange:gt,handleFileChange:_t,handleDelete:vt,handleExportCSV:(0,X.useCallback)(()=>{Da(Ie),f(i(`toasts.csvExported`),`success`)},[Ie,f,i]),handleGenerateReport:(0,X.useCallback)(async()=>{if(!w){T(!0);try{let e=await ia({viewMode:ye,selectedMonth:xe,selectedProviders:Ce,selectedModels:Ee,language:a.language===`en`?`en`:`de`,...ke?{startDate:ke}:{},...je?{endDate:je}:{}}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`ttdash-report-${new Date().toISOString().slice(0,10)}.pdf`,document.body.appendChild(n),n.click(),n.remove(),window.setTimeout(()=>URL.revokeObjectURL(t),1e3),f(i(`commandPalette.commands.generateReport.label`),`success`)}catch(e){console.error(`PDF generation failed:`,e),f(`${i(`api.pdfFailed`)}: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}finally{T(!1)}}},[w,ye,xe,Ce,Ee,ke,je,f,a.language,i]),handleAutoImport:(0,X.useCallback)(()=>{x(!0)},[]),handleAutoImportSuccess:(0,X.useCallback)(()=>{d.invalidateQueries({queryKey:[`usage`]}),d.invalidateQueries({queryKey:[`settings`]}),ee(e=>e+1);let e=new Date,t=e.toLocaleTimeString(ce(),{hour:`2-digit`,minute:`2-digit`});j({type:`auto-import`,...t?{time:t}:{},title:i(`header.loadedAt`,{time:ie(e.toISOString())})}),f(i(`toasts.dataImported`),`success`)},[d,f,i]),handleExportSettings:(0,X.useCallback)(()=>{Fa(`ttdash-settings-backup-${ne()}.json`,{kind:Oa,version:Aa,exportedAt:new Date().toISOString(),appVersion:$e,settings:{language:B.language,theme:B.theme,reducedMotionPreference:B.reducedMotionPreference,providerLimits:B.providerLimits,defaultFilters:B.defaultFilters,sectionVisibility:B.sectionVisibility,sectionOrder:B.sectionOrder,lastLoadedAt:B.lastLoadedAt,lastLoadSource:B.lastLoadSource}}),f(i(`toasts.settingsExported`),`success`)},[B,f,i]),handleExportData:(0,X.useCallback)(()=>{if(!o||o.daily.length===0){f(i(`toasts.noDataToExport`),`info`);return}Fa(`ttdash-data-backup-${ne()}.json`,{kind:ka,version:Aa,exportedAt:new Date().toISOString(),appVersion:$e,data:o}),f(i(`toasts.dataExported`),`success`)},[o,f,i]),handleImportSettings:(0,X.useCallback)(()=>{m.current?.click()},[]),handleImportData:(0,X.useCallback)(()=>{h.current?.click()},[]),handleSettingsImportChange:(0,X.useCallback)(async e=>{let t=e.target.files?.[0];if(t){D(!0);try{let e=await ra(JSON.parse(await t.text()));d.setQueryData([`settings`],e),Pe(e.defaultFilters),f(i(`toasts.settingsImported`,{name:t.name}),`success`)}catch(e){f(e instanceof Error?e.message:i(`toasts.fileReadFailed`),`error`)}finally{D(!1),e.target.value=``}}},[d,Pe,f,i]),handleDataImportChange:(0,X.useCallback)(async e=>{let t=e.target.files?.[0];if(t){k(!0);try{let e=await Qi(JSON.parse(await t.text()));await d.invalidateQueries({queryKey:[`usage`]}),await d.invalidateQueries({queryKey:[`settings`]}),ee(e=>e+1);let n=new Date,r=n.toLocaleTimeString(ce(),{hour:`2-digit`,minute:`2-digit`});j({type:`file`,label:t.name,...r?{time:r}:{},title:`${t.name} · ${i(`header.loadedAt`,{time:ie(n.toISOString())})}`});let a=e.conflictingDays>0?`info`:`success`;f(i(e.conflictingDays>0?`toasts.dataBackupImportedWithConflicts`:`toasts.dataBackupImported`,{added:e.addedDays,unchanged:e.unchangedDays,conflicts:e.conflictingDays}),a)}catch(e){f(e instanceof Error?e.message:i(`toasts.fileReadFailed`),`error`)}finally{k(!1),e.target.value=``}}},[d,f,i]),handleScrollTo:(0,X.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`})},[])}}var La=(0,X.lazy)(()=>Q(()=>import(`./DrillDownModal-kczVCwfa.js`).then(e=>({default:e.DrillDownModal})),__vite__mapDeps([47,1,2,42,10,11,3,5,4,20,17,15,18,9,12]))),Ra=(0,X.lazy)(()=>Q(()=>import(`./AutoImportModal-Cqefa6n_.js`).then(e=>({default:e.AutoImportModal})),__vite__mapDeps([48,1,2,42,10,11,3,5,4,15]))),za=(0,X.lazy)(()=>Q(()=>import(`./SettingsModal-4uENZ87D.js`).then(e=>({default:e.SettingsModal})),__vite__mapDeps([49,1,2,42,10,11,3,5,12,4,20,50,37,33,8,9,15,21]))),Ba=(0,X.lazy)(()=>Q(()=>import(`./HelpPanel-D4zNwrI2.js`).then(e=>({default:e.HelpPanel})),__vite__mapDeps([51,1,2,3,4,5,15,10,11,34,21,12])));function Va({initialSettings:e,initialSettingsError:t=null,initialSettingsLoadedFromServer:n=!1,initialSettingsFetchedAt:r=null}){let{t:i}=M(),{fileInputRef:a,settingsImportInputRef:o,dataImportInputRef:s,settings:c,providerLimits:l,isLoading:u,settingsLoading:d,isSaving:f,isDark:p,hasData:m,helpOpen:h,setHelpOpen:g,autoImportOpen:_,setAutoImportOpen:v,settingsOpen:y,setSettingsOpen:b,drillDownDate:x,setDrillDownDate:S,drillDownDay:C,reportGenerating:w,settingsTransferBusy:T,dataTransferBusy:E,headerDataSource:D,startupAutoLoadBadge:O,animationSeed:k,allProviders:A,settingsProviderOptions:j,settingsModelOptions:N,viewMode:P,setViewMode:ee,selectedMonth:te,setSelectedMonth:F,selectedProviders:I,toggleProvider:L,clearProviders:R,selectedModels:ne,toggleModel:z,clearModels:re,startDate:B,setStartDate:ie,endDate:ae,setEndDate:V,resetAll:oe,applyPreset:se,filteredDailyData:ce,filteredData:le,availableMonths:ue,availableProviders:de,availableModels:fe,dateRange:pe,metrics:me,modelCosts:he,providerMetrics:ge,costChartData:_e,modelCostChartData:ve,tokenChartData:ye,requestChartData:be,weekdayData:xe,allModels:Se,modelPieData:Ce,tokenPieData:we,comparisonData:Te,totalCalendarDays:Ee,todayData:De,hasCurrentMonthData:Oe,visibleLimitProviders:ke,sectionVisibility:Ae,sectionOrder:je,streak:Me,fatalLoadState:Pe,handleUpload:Fe,handleOpenSettings:H,handleRetryLoad:Ie,handleResetSettings:Le,handleToggleTheme:Re,handleSaveSettings:ze,handleLanguageChange:Be,handleFileChange:Ve,handleDelete:He,handleExportCSV:Ue,handleGenerateReport:We,handleAutoImport:Ge,handleAutoImportSuccess:Ke,handleExportSettings:qe,handleExportData:Je,handleImportSettings:Ye,handleImportData:Xe,handleSettingsImportChange:Ze,handleDataImportChange:Qe,handleScrollTo:$e}=Ia(e,n,r,t),et=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`input`,{ref:a,type:`file`,accept:`.json`,className:`hidden`,onChange:Ve,"data-testid":`usage-upload-input`}),(0,Z.jsx)(`input`,{ref:o,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:Ze,"data-testid":`settings-import-input`}),(0,Z.jsx)(`input`,{ref:s,type:`file`,accept:`.json,application/json`,className:`hidden`,onChange:Qe,"data-testid":`data-import-input`})]}),tt=(0,X.useMemo)(()=>[...le].sort((e,t)=>e.date.localeCompare(t.date)),[le]),W=(0,X.useMemo)(()=>x===null?-1:tt.findIndex(e=>e.date===x),[x,tt]),nt=W>0,rt=W>=0&&W<tt.length-1,it=(0,X.useCallback)(()=>{nt&&S(tt[W-1]?.date??null)},[W,tt,nt,S]),at=(0,X.useCallback)(()=>{rt&&S(tt[W+1]?.date??null)},[W,tt,rt,S]),ot=(0,Z.jsx)(X.Suspense,{fallback:null,children:_&&(0,Z.jsx)(Ra,{open:_,onOpenChange:v,onSuccess:Ke})}),st=(0,Z.jsx)(X.Suspense,{fallback:null,children:y&&(0,Z.jsx)(za,{open:y,onOpenChange:b,language:c.language,reducedMotionPreference:c.reducedMotionPreference,limitProviders:A,filterProviders:j,models:N,limits:c.providerLimits,defaultFilters:c.defaultFilters,sectionVisibility:c.sectionVisibility,sectionOrder:c.sectionOrder,lastLoadedAt:c.lastLoadedAt,lastLoadSource:c.lastLoadSource,cliAutoLoadActive:c.cliAutoLoadActive,hasData:m,onSaveSettings:ze,onExportSettings:qe,onImportSettings:Ye,onExportData:Je,onImportData:Xe,settingsBusy:T||f,dataBusy:E})}),ct=(0,Z.jsx)(X.Suspense,{fallback:null,children:h&&(0,Z.jsx)(Ba,{open:h,onOpenChange:g})});if(!Pe&&(u||d))return(0,Z.jsx)(bi,{});if(Pe){let e=[{label:i(`loadError.retry`),onClick:()=>void Ie(),variant:`default`},...Pe.canResetSettings?[{label:i(`loadError.resetSettings`),onClick:()=>void Le()}]:[],...Pe.canResetUsage?[{label:i(`loadError.deleteData`),onClick:()=>void He()}]:[]];return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Br,{title:Pe.title,description:Pe.description,details:Pe.details,detailLabel:i(`loadError.details`),actions:e}),et,ct]})}return m?(0,Z.jsxs)(`div`,{className:`mx-auto min-h-screen max-w-7xl px-4 pb-8`,children:[et,ot,st,ct,(0,Z.jsx)(Tr,{dateRange:pe,isDark:p,currentLanguage:c.language,streak:Me,dataSource:D,startupAutoLoad:O,onHelpOpenChange:g,onLanguageChange:Be,onToggleTheme:Re,onExportCSV:Ue,onDelete:He,onUpload:Fe,onAutoImport:Ge,settingsButton:(0,Z.jsxs)(U,{variant:`outline`,size:`sm`,onClick:H,title:i(`header.settings`),className:`h-11 justify-start gap-2 px-3 text-xs sm:h-9 sm:text-sm`,children:[(0,Z.jsx)(Ne,{className:`h-4 w-4`}),(0,Z.jsx)(`span`,{children:i(`header.settings`)})]}),pdfButton:(0,Z.jsx)(Jr,{generating:w,onGenerate:We})}),(0,Z.jsx)(`div`,{id:`filters`,children:(0,Z.jsx)(Lr,{viewMode:P,onViewModeChange:ee,selectedMonth:te,onMonthChange:F,availableMonths:ue,availableProviders:de,selectedProviders:I,onToggleProvider:L,onClearProviders:R,allModels:fe,selectedModels:ne,onToggleModel:z,onClearModels:re,...B?{startDate:B}:{},...ae?{endDate:ae}:{},onStartDateChange:ie,onEndDateChange:V,onApplyPreset:se,onResetAll:oe})}),(0,Z.jsx)(`div`,{className:`mt-4 space-y-4`,children:(0,Z.jsx)(Ki,{sectionOrder:je,sectionVisibility:Ae,metrics:me,viewMode:P,totalCalendarDays:Ee,filteredData:le,filteredDailyData:ce,todayData:De,hasCurrentMonthData:Oe,visibleLimitProviders:ke,providerLimits:l,selectedMonth:te,allModels:Se,costChartData:_e,modelPieData:Ce,modelCostChartData:ve,weekdayData:xe,tokenChartData:ye,tokenPieData:we,requestChartData:be,comparisonData:Te,modelCosts:he,providerMetrics:ge,isDark:p,onDrillDownDateChange:S})},k),(0,Z.jsx)(X.Suspense,{fallback:null,children:x!==null&&(0,Z.jsx)(La,{day:C,contextData:le,open:!0,hasPrevious:nt,hasNext:rt,currentIndex:W>=0?W+1:0,totalCount:tt.length,onPrevious:it,onNext:at,onClose:()=>S(null)})}),(0,Z.jsx)(qr,{isDark:p,availableProviders:de,selectedProviders:I,availableModels:fe,selectedModels:ne,hasTodaySection:!!De,hasMonthSection:Oe,hasRequestSection:me.hasRequestData,sectionVisibility:Ae,sectionOrder:je,reportGenerating:w,onToggleTheme:Re,onExportCSV:Ue,onGenerateReport:We,onDelete:He,onUpload:Fe,onAutoImport:Ge,onOpenSettings:H,onScrollTo:$e,onViewModeChange:ee,onApplyPreset:se,onToggleProvider:L,onToggleModel:z,onClearProviders:R,onClearModels:re,onClearDateRange:()=>{ie(void 0),V(void 0)},onResetAll:oe,onHelp:()=>g(!0),onLanguageChange:Be})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(zr,{onUpload:Fe,onAutoImport:Ge,onOpenSettings:H}),et,ot,st,ct]})}function Ha({initialSettings:e,initialSettingsLoadedFromServer:t,initialSettingsFetchedAt:n,children:r}){return(0,Z.jsx)(j,{preference:(_r({queryKey:[`settings`],queryFn:$i,staleTime:1e3*60*5,initialData:e,initialDataUpdatedAt:t&&typeof n==`number`?n:0}).data??e).reducedMotionPreference,children:r})}function Ua({initialSettings:e,initialSettingsError:t=null,initialSettingsLoadedFromServer:n=!1,initialSettingsFetchedAt:r=null}){let[i]=(0,X.useState)(()=>new er({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}}));return(0,Z.jsx)(rr,{client:i,children:(0,Z.jsx)(Ha,{initialSettings:e,initialSettingsLoadedFromServer:n,initialSettingsFetchedAt:r,children:(0,Z.jsx)(xr,{children:(0,Z.jsx)(ee,{delayDuration:100,children:(0,Z.jsx)(Va,{initialSettings:e,initialSettingsError:t,initialSettingsLoadedFromServer:n,initialSettingsFetchedAt:r})})})})})}async function Wa(){let{settings:e,errorMessage:t,loadedFromServer:n,fetchedAt:r}=await ea();bt(e.theme),await oe(e.language),(0,yr.createRoot)(document.getElementById(`root`)).render((0,Z.jsx)(X.StrictMode,{children:(0,Z.jsx)(Ua,{initialSettings:e,initialSettingsError:t,initialSettingsLoadedFromServer:n,initialSettingsFetchedAt:r})}))}Wa();
|