tokentracker-cli 0.72.1 → 0.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.de.md +5 -4
  2. package/README.ja.md +5 -4
  3. package/README.ko.md +5 -4
  4. package/README.md +5 -4
  5. package/README.zh-CN.md +5 -4
  6. package/dashboard/dist/assets/{ActivityHeatmap-CtDL5OPO.js → ActivityHeatmap-DkoSqxrd.js} +1 -1
  7. package/dashboard/dist/assets/{Card-C5lKqKNT.js → Card-DleS-r54.js} +1 -1
  8. package/dashboard/dist/assets/{CommunityStatsModal-XnEef7Ra.js → CommunityStatsModal-DV41-F9D.js} +1 -1
  9. package/dashboard/dist/assets/{ConfirmModal-CkZvn-sV.js → ConfirmModal-Dgp07Uka.js} +1 -1
  10. package/dashboard/dist/assets/{DashboardPage-TmZBLaB9.js → DashboardPage-EKy2BzUx.js} +1 -1
  11. package/dashboard/dist/assets/{DevicePage-BhDh3VIP.js → DevicePage-eJInQ2UX.js} +1 -1
  12. package/dashboard/dist/assets/{DialogClose-CddI1gcT.js → DialogClose-DEfesqFq.js} +1 -1
  13. package/dashboard/dist/assets/DialogDescription-D6txiEc4.js +1 -0
  14. package/dashboard/dist/assets/{DialogTitle-Cvpx9Lfv.js → DialogTitle-v1JrTvr4.js} +1 -1
  15. package/dashboard/dist/assets/{FadeIn-BojLJcFD.js → FadeIn-hqIBbKaJ.js} +1 -1
  16. package/dashboard/dist/assets/{HeaderGithubStar-BrSt1RIj.js → HeaderGithubStar-C4zauuP2.js} +1 -1
  17. package/dashboard/dist/assets/{IpCheckPage-DxuF-1tF.js → IpCheckPage-CiRcccks.js} +1 -1
  18. package/dashboard/dist/assets/{LandingPage-DmCjJVwh.js → LandingPage-CbOHycnd.js} +1 -1
  19. package/dashboard/dist/assets/{LeaderboardAvatar-B8SGUidW.js → LeaderboardAvatar-CQL1iOTS.js} +1 -1
  20. package/dashboard/dist/assets/{LeaderboardPage-D7CQCdDr.js → LeaderboardPage-BuEp247d.js} +2 -2
  21. package/dashboard/dist/assets/{LeaderboardProfileModal-Dv7CQVqB.js → LeaderboardProfileModal-DT8hrPkI.js} +1 -1
  22. package/dashboard/dist/assets/{LeaderboardProfilePage-BtGLbQnT.js → LeaderboardProfilePage-B-M0AXMb.js} +1 -1
  23. package/dashboard/dist/assets/{LimitsPage-DRf6h5_2.js → LimitsPage-Df2es3Xs.js} +1 -1
  24. package/dashboard/dist/assets/{LocalOnlyNotice-BnlODmxA.js → LocalOnlyNotice-DJIfKTKo.js} +1 -1
  25. package/dashboard/dist/assets/{LoginPage-CYXdV0X0.js → LoginPage-DtaaIy_8.js} +1 -1
  26. package/dashboard/dist/assets/{PopoverPopup-x5vYN3uF.js → PopoverPopup-CqWH6aB9.js} +1 -1
  27. package/dashboard/dist/assets/{ResetPasswordPage-D8ifLVwK.js → ResetPasswordPage-DCH5GU1c.js} +1 -1
  28. package/dashboard/dist/assets/{Select-CaaIuo5M.js → Select-BwyliVKJ.js} +1 -1
  29. package/dashboard/dist/assets/{SelectItemText-CdJ-E-d1.js → SelectItemText-B5_DKKEv.js} +1 -1
  30. package/dashboard/dist/assets/{SettingsPage-Dc7v5PEC.js → SettingsPage-BoAFdOUa.js} +1 -1
  31. package/dashboard/dist/assets/{SkillsPage-CRbEMatQ.js → SkillsPage-BVdre-kF.js} +1 -1
  32. package/dashboard/dist/assets/{WidgetsPage-xgy8mLMV.js → WidgetsPage-CtjV405P.js} +1 -1
  33. package/dashboard/dist/assets/{WrappedPage-BdpfOWJu.js → WrappedPage-DGmPdtHt.js} +1 -1
  34. package/dashboard/dist/assets/{agent-logos-CrxAAMko.js → agent-logos-DqevdWvx.js} +1 -1
  35. package/dashboard/dist/assets/{arrow-up-right-D23bZC75.js → arrow-up-right-DA5Pybq1.js} +1 -1
  36. package/dashboard/dist/assets/check-BWzAT1oX.js +1 -0
  37. package/dashboard/dist/assets/{copy-hiVk9JEl.js → copy-CsQRTd89.js} +1 -1
  38. package/dashboard/dist/assets/{download-CqLiBDG-.js → download-TEHkAKT0.js} +1 -1
  39. package/dashboard/dist/assets/{format-tokens-Ck5lRlFd.js → format-tokens-CtFO_jkz.js} +1 -1
  40. package/dashboard/dist/assets/{info-CxDHBJXB.js → info-Dxn3fiaX.js} +1 -1
  41. package/dashboard/dist/assets/main-Dxi4sSXf.js +1128 -0
  42. package/dashboard/dist/assets/{use-community-stats-CeaLHlCk.js → use-community-stats-BLNxr-bQ.js} +1 -1
  43. package/dashboard/dist/assets/{use-limits-display-prefs-CvDWYfjp.js → use-limits-display-prefs-CC7gb303.js} +1 -1
  44. package/dashboard/dist/assets/{use-native-settings-HuxDwmn6.js → use-native-settings-SYtjLlxZ.js} +1 -1
  45. package/dashboard/dist/assets/{use-ordered-list-KIV2M5tf.js → use-ordered-list-_O8onJV7.js} +1 -1
  46. package/dashboard/dist/assets/{use-quality-per-dollar-pref-BbsMhRJt.js → use-quality-per-dollar-pref-tuspH_6n.js} +1 -1
  47. package/dashboard/dist/assets/{use-usage-limits-COBOepfU.js → use-usage-limits-whCVzQbf.js} +1 -1
  48. package/dashboard/dist/assets/{useCurrency-DbBq0Fal.js → useCurrency-BiDjYxfm.js} +1 -1
  49. package/dashboard/dist/assets/{useScrollLock-C4eBSnib.js → useScrollLock-DK-ndHcw.js} +1 -1
  50. package/dashboard/dist/index.html +1 -1
  51. package/dashboard/dist/share.html +1 -1
  52. package/package.json +1 -1
  53. package/src/commands/status.js +47 -4
  54. package/src/commands/sync.js +72 -18
  55. package/src/lib/local-api.js +24 -2
  56. package/src/lib/pricing/curated-overrides.json +7 -2
  57. package/src/lib/pricing/seed-snapshot.json +1 -1
  58. package/src/lib/rollout.js +385 -0
  59. package/src/lib/sqlite-reader.js +24 -6
  60. package/src/lib/usage-limits.js +200 -29
  61. package/src/lib/zcode-limits.js +375 -40
  62. package/dashboard/dist/assets/DialogDescription-DeEet5bz.js +0 -1
  63. package/dashboard/dist/assets/check-fkZxgcVQ.js +0 -1
  64. package/dashboard/dist/assets/main-B0LYKUIY.js +0 -1127
package/README.de.md CHANGED
@@ -162,7 +162,8 @@ Aktualisieren mit `brew upgrade --cask mm7894215/tokentracker/tokentracker`. Der
162
162
  | **OpenClaw** | ✅ Auto | Session-Plugin |
163
163
  | **Every Code** | ✅ Auto | TOML-Notify-Hook |
164
164
  | **Hermes Agent** | ✅ Auto | SQLite Sessions-Tabelle (`~/.hermes/state.db`) |
165
- | **GitHub Copilot** | ✅ Auto | OpenTelemetry-Datei-Exporter (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
165
+ | **GitHub Copilot App** | ✅ Auto | Passiver Session-Summary-Reader (`~/.copilot/data.db` oder `COPILOT_HOME/data.db`) |
166
+ | **GitHub Copilot CLI / Chat-Erweiterung** | ✅ Auto | OpenTelemetry-Datei-Exporter (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
166
167
  | **Kimi Code** | ✅ Auto | Passiver `wire.jsonl`-Reader (`~/.kimi/sessions/**/wire.jsonl`) |
167
168
  | **oh-my-pi (Pi Coding Agent)** | ✅ Auto | Passiver Reader (`~/.omp/agent/sessions/**/*.jsonl`) |
168
169
  | **CodeBuddy** (Tencent) | ✅ Auto | SessionEnd-Hook in `~/.codebuddy/settings.json` (Claude-Code-Fork) |
@@ -182,7 +183,7 @@ Aktualisieren mit `brew upgrade --cask mm7894215/tokentracker/tokentracker`. Der
182
183
  > **Muss ich Plugins oder Hooks manuell installieren?** Nein. `tokentracker` (oder `tokentracker init`) erledigt alles beim ersten Start:
183
184
  > - **Hook-basiert** (Claude Code, Codex, Gemini, Every Code, CodeBuddy, WorkBuddy, Grok Build) — wir schreiben einen SessionEnd-Hook oder TOML-Notify-Eintrag in die Konfiguration des Tools.
184
185
  > - **Plugin-basiert** (OpenCode, OpenClaw) — das Plugin ist im npm-Paket enthalten (`~/.tokentracker/app/openclaw-plugin/`). Wir verlinken es per CLI (`openclaw plugins install --link …` + `enable`). Kein Download, kein Drag-and-Drop.
185
- > - **Passive Reader** (Cursor, Kiro, Hermes, Kimi Code, Copilot, Grok Build, oh-my-pi, pi, Craft Agents, Kilo CLI, Kilo Code, Roo Code, Antigravity, Zed Agent, Goose, Mimo Code, ZCode) — wir installieren nichts in diesen Tools. Wir lesen nur Dateien, die sie bereits produzieren (SQLite-DB, JSONL, OTEL-Export, Session-Logs).
186
+ > - **Passive Reader** (Cursor, Kiro, Hermes, Kimi Code, Copilot, Grok Build, oh-my-pi, pi, Craft Agents, Kilo CLI, Kilo Code, Roo Code, Antigravity, Zed Agent, Goose, Mimo Code, ZCode) — wir installieren nichts in diesen Tools. Wir lesen nur Dateien, die sie bereits produzieren (SQLite-DB, JSONL, OTEL-Export, Session-Logs). Die Copilot-App-Nutzung wird ausschließlich aus den `sessions.total_*`-Token-Zusammenfassungen in `~/.copilot/data.db` gelesen und fließt in die bestehende `copilot`-Gesamtstatistik ein (Summen, Trends, Modellaufschlüsselung, Kosten). Copilot CLI / Chat-Erweiterung bleibt OTEL-basiert; beide Pfade führen getrennte Sync-Cursor, um Doppelzählungen zu vermeiden.
186
187
  >
187
188
  > Führe `tokentracker status` aus, um den Status jeder Integration zu prüfen. Zeigt ein Tool `skipped`, erklärt die `detail`-Spalte warum.
188
189
  >
@@ -237,7 +238,7 @@ flowchart LR
237
238
  | **Kein Content-Upload** | Nur Token-Zahlen und Zeitstempel. Nie Prompts, Responses oder Dateiinhalte. |
238
239
  | **Standardmäßig lokal** | Alle Daten bleiben auf deinem Rechner. Das Leaderboard ist vollständig optional. |
239
240
  | **Überprüfbar** | Open Source. Sieh selbst in [`src/lib/rollout.js`](src/lib/rollout.js) – nur Zahlen und Zeitstempel. |
240
- | **Nur anonymer Heartbeat** | Um aktive Installationen zu zählen, sendet die App höchstens einen anonymen Ping pro Tag: ein Einweg-Hash der Maschinen-ID, App-Version, OS-Plattform und App-Shell (cli/mac/win). Niemals Token-Zahlen, Modellnamen, Prompts oder Pfade. Auditierbar in [`src/lib/telemetry.js`](src/lib/telemetry.js); Deaktivierung über `TOKENTRACKER_NO_TELEMETRY=1` oder `DO_NOT_TRACK=1`. |
241
+ | **Nur anonyme Nutzungsstatistiken** | Nur zwei anonyme Übertragungen: (1) höchstens ein täglicher Heartbeat ein Einweg-Hash der Maschinen-ID, App-Version, OS-Plattform und App-Shell (cli/mac/win); (2) anonyme Dashboard-Seiten-/Feature-Events (PostHog — Autocapture und Session-Recording deaktiviert, Browser-Do-Not-Track respektiert). Niemals Token-Zahlen, Modellnamen, Prompts oder Pfade. Auditierbar in [`src/lib/telemetry.js`](src/lib/telemetry.js) und [`dashboard/src/lib/analytics.js`](dashboard/src/lib/analytics.js); ein Schalter deaktiviert beides: `TOKENTRACKER_NO_TELEMETRY=1` (oder `DO_NOT_TRACK=1`). |
241
242
 
242
243
  ---
243
244
 
@@ -248,7 +249,7 @@ Die meisten Nutzer brauchen das nie – die Standardwerte sind sinnvoll. Für fo
248
249
  | Variable | Beschreibung | Standard |
249
250
  |---|---|---|
250
251
  | `TOKENTRACKER_DEBUG` | Debug-Ausgabe aktivieren (`1` zum Aktivieren) | — |
251
- | `TOKENTRACKER_NO_TELEMETRY` | Anonymen täglichen Heartbeat deaktivieren (`1` zum Deaktivieren; der `DO_NOT_TRACK`-Standard wird ebenfalls respektiert) | — |
252
+ | `TOKENTRACKER_NO_TELEMETRY` | Alle anonyme Telemetrie deaktivieren — täglicher Heartbeat und Dashboard-Analytics (`1` zum Deaktivieren; der `DO_NOT_TRACK`-Standard wird ebenfalls respektiert) | — |
252
253
  | `TOKENTRACKER_HTTP_TIMEOUT_MS` | HTTP-Timeout in Millisekunden | `20000` |
253
254
  | `CODEX_HOME` | Codex CLI-Verzeichnis überschreiben | `~/.codex` |
254
255
  | `GEMINI_HOME` | Gemini CLI-Verzeichnis überschreiben | `~/.gemini` |
package/README.ja.md CHANGED
@@ -163,7 +163,8 @@ brew install mm7894215/tokentracker/tokentracker
163
163
  | **OpenClaw** | ✅ 自動 | セッションプラグイン |
164
164
  | **Every Code** | ✅ 自動 | TOML notify hook |
165
165
  | **Hermes Agent** | ✅ 自動 | SQLite の sessions テーブル (`~/.hermes/state.db`) |
166
- | **GitHub Copilot** | ✅ 自動 | OpenTelemetry のファイルエクスポーター (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
166
+ | **GitHub Copilot App** | ✅ 自動 | パッシブなセッションサマリー読み取り (`~/.copilot/data.db`、または `COPILOT_HOME/data.db`) |
167
+ | **GitHub Copilot CLI / Chat 拡張** | ✅ 自動 | OpenTelemetry のファイルエクスポーター (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
167
168
  | **Kimi Code** | ✅ 自動 | パッシブな `wire.jsonl` リーダー (`~/.kimi/sessions/**/wire.jsonl`) |
168
169
  | **oh-my-pi (Pi Coding Agent)** | ✅ 自動 | パッシブリーダー (`~/.omp/agent/sessions/**/*.jsonl`) |
169
170
  | **CodeBuddy** (Tencent) | ✅ 自動 | `~/.codebuddy/settings.json` 内の SessionEnd hook(Claude-Code fork) |
@@ -183,7 +184,7 @@ brew install mm7894215/tokentracker/tokentracker
183
184
  > **プラグインや hook を手動でインストールする必要はありますか?** いいえ。`tokentracker`(または `tokentracker init`)が初回実行ですべて処理します:
184
185
  > - **Hook ベース**のツール (Claude Code、Codex、Gemini、Every Code、**CodeBuddy**、**WorkBuddy**、**Grok Build**) — ツール自身の設定に SessionEnd hook または TOML notify エントリーを書き込みます。
185
186
  > - **プラグインベース**のツール (OpenCode、**OpenClaw**) — プラグインは npm パッケージ内に同梱されています。OpenClaw のセッションプラグインは `~/.tokentracker/tracker/openclaw-plugin/openclaw-session-sync/` にあり、OpenClaw 自身の CLI でリンクして有効化したうえで、同期を起動するセッション終了イベントを許可するために `hooks.allowConversationAccess=true` を設定します。ダウンロードもドラッグ&ドロップも不要です。
186
- > - **パッシブリーダー** (Cursor、Kiro、Hermes、Kimi Code、Copilot、**Grok Build**、**oh-my-pi**、**pi**、**Craft Agents**、**Kilo CLI**、**Kilo Code**、**Roo Code**、**Antigravity**、**Zed Agent**、**Goose**、**Mimo Code**、**ZCode**) — これらのツールには何もインストールしません。ツールがすでに出力しているファイル (SQLite DB、JSONL、OTEL エクスポート、session logs) を読むだけです。
187
+ > - **パッシブリーダー** (Cursor、Kiro、Hermes、Kimi Code、Copilot、**Grok Build**、**oh-my-pi**、**pi**、**Craft Agents**、**Kilo CLI**、**Kilo Code**、**Roo Code**、**Antigravity**、**Zed Agent**、**Goose**、**Mimo Code**、**ZCode**) — これらのツールには何もインストールしません。ツールがすでに出力しているファイル (SQLite DB、JSONL、OTEL エクスポート、session logs) を読むだけです。Copilot App の使用量は `~/.copilot/data.db` の `sessions.total_*` トークンサマリーのみを読み取り、既存の `copilot` 集計統計 (合計、トレンド、モデル別内訳、コスト) に反映されます。Copilot CLI / Chat 拡張は引き続き OTEL ベースで、両者は重複カウントを避けるため別々の同期カーソルを保持します。
187
188
  > - **Grok Build の推定** — 現在のローカルテレメトリは `updates.jsonl` の累積 `totalTokens` を公開していますが、安定したプロンプト/出力/キャッシュの内訳はありません。`signals.json` は `contextTokensUsed` のスナップショットを使ったフォールバックとして残っています。コールごとの利用詳細が利用可能になるまで、TokenTracker は Grok のコストを推定します。
188
189
  >
189
190
  > いつでも `tokentracker status` を実行すれば、各統合の状態を確認できます。`skipped` と表示されている場合、`detail` 列にその理由が示されます(例: ツール CLI が `PATH` にない、設定が読めない)。
@@ -234,7 +235,7 @@ flowchart LR
234
235
  | **コンテンツをアップロードしない** | トークン数とタイムスタンプのみ。プロンプト、レスポンス、ファイル内容は扱いません。 |
235
236
  | **デフォルトでローカル限定** | すべてのデータはマシン上に留まります。リーダーボードは完全にオプトインです。 |
236
237
  | **監査可能** | オープンソース。[`src/lib/rollout.js`](src/lib/rollout.js) を読んでください — 数字とタイムスタンプだけです。 |
237
- | **匿名ハートビートのみ** | アクティブインストール数を把握するため、1 日最大 1 回の匿名 ping を送信します:マシン ID の一方向ハッシュ、アプリバージョン、OS プラットフォーム、実行形態(cli/mac/win)のみ。トークン数、モデル名、プロンプト、パスは一切含まれません。[`src/lib/telemetry.js`](src/lib/telemetry.js) で監査可能。`TOKENTRACKER_NO_TELEMETRY=1` または `DO_NOT_TRACK=1` で無効化できます。 |
238
+ | **匿名利用統計のみ** | 外部送信は匿名の 2 種類だけ:(1) 1 日最大 1 回のハートビート——マシン ID の一方向ハッシュ、アプリバージョン、OS プラットフォーム、実行形態(cli/mac/win);(2) 匿名のダッシュボードのページ/機能イベント(PostHog——autocapture とセッション録画は無効、ブラウザの Do-Not-Track を尊重)。トークン数、モデル名、プロンプト、パスは一切含まれません。[`src/lib/telemetry.js`](src/lib/telemetry.js) と [`dashboard/src/lib/analytics.js`](dashboard/src/lib/analytics.js) で監査可能。`TOKENTRACKER_NO_TELEMETRY=1` または `DO_NOT_TRACK=1` で両方を無効化できます。 |
238
239
 
239
240
  ---
240
241
 
@@ -245,7 +246,7 @@ flowchart LR
245
246
  | 変数 | 説明 | デフォルト |
246
247
  |---|---|---|
247
248
  | `TOKENTRACKER_DEBUG` | デバッグ出力を有効化(`1` で有効) | — |
248
- | `TOKENTRACKER_NO_TELEMETRY` | 匿名の日次ハートビートを無効化(`1` で無効。`DO_NOT_TRACK` 標準にも対応) | — |
249
+ | `TOKENTRACKER_NO_TELEMETRY` | すべての匿名テレメトリ(日次ハートビート + ダッシュボード分析)を無効化(`1` で無効。`DO_NOT_TRACK` 標準にも対応) | — |
249
250
  | `TOKENTRACKER_HTTP_TIMEOUT_MS` | HTTP タイムアウト(ミリ秒) | `20000` |
250
251
  | `CODEX_HOME` | Codex CLI ディレクトリの上書き | `~/.codex` |
251
252
  | `GEMINI_HOME` | Gemini CLI ディレクトリの上書き | `~/.gemini` |
package/README.ko.md CHANGED
@@ -163,7 +163,8 @@ brew install mm7894215/tokentracker/tokentracker
163
163
  | **OpenClaw** | ✅ 자동 | 세션 플러그인 |
164
164
  | **Every Code** | ✅ 자동 | TOML notify hook |
165
165
  | **Hermes Agent** | ✅ 자동 | SQLite sessions 테이블 (`~/.hermes/state.db`) |
166
- | **GitHub Copilot** | ✅ 자동 | OpenTelemetry 파일 익스포터 (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
166
+ | **GitHub Copilot App** | ✅ 자동 | 패시브 세션 요약 리더 (`~/.copilot/data.db`, 또는 `COPILOT_HOME/data.db`) |
167
+ | **GitHub Copilot CLI / Chat 확장** | ✅ 자동 | OpenTelemetry 파일 익스포터 (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
167
168
  | **Kimi Code** | ✅ 자동 | 패시브 `wire.jsonl` 리더 (`~/.kimi/sessions/**/wire.jsonl`) |
168
169
  | **oh-my-pi (Pi Coding Agent)** | ✅ 자동 | 패시브 리더 (`~/.omp/agent/sessions/**/*.jsonl`) |
169
170
  | **CodeBuddy** (Tencent) | ✅ 자동 | `~/.codebuddy/settings.json`의 SessionEnd hook (Claude-Code fork) |
@@ -183,7 +184,7 @@ brew install mm7894215/tokentracker/tokentracker
183
184
  > **플러그인이나 hook을 수동으로 설치해야 하나요?** 아니요. `tokentracker` (또는 `tokentracker init`)가 첫 실행에서 모든 것을 처리합니다:
184
185
  > - **Hook 기반** 도구 (Claude Code, Codex, Gemini, Every Code, **CodeBuddy**, **WorkBuddy**, **Grok Build**) — 도구 자체의 설정에 SessionEnd hook 또는 TOML notify 엔트리를 작성합니다.
185
186
  > - **플러그인 기반** 도구 (OpenCode, **OpenClaw**) — 플러그인은 npm 패키지 안에 포함되어 있습니다. OpenClaw 세션 플러그인은 `~/.tokentracker/tracker/openclaw-plugin/openclaw-session-sync/`에 있으며, OpenClaw 자체 CLI로 링크하고 활성화한 뒤 동기화를 트리거하는 세션 종료 이벤트를 허용하도록 `hooks.allowConversationAccess=true`를 설정합니다. 다운로드, 드래그 앤 드롭 불필요.
186
- > - **패시브 리더** (Cursor, Kiro, Hermes, Kimi Code, Copilot, **Grok Build**, **oh-my-pi**, **pi**, **Craft Agents**, **Kilo CLI**, **Kilo Code**, **Roo Code**, **Antigravity**, **Zed Agent**, **Goose**, **Mimo Code**, **ZCode**) — 이들 도구에는 아무것도 설치하지 않습니다. 도구가 이미 생성하는 파일 (SQLite DB, JSONL, OTEL export, session logs)만 읽습니다.
187
+ > - **패시브 리더** (Cursor, Kiro, Hermes, Kimi Code, Copilot, **Grok Build**, **oh-my-pi**, **pi**, **Craft Agents**, **Kilo CLI**, **Kilo Code**, **Roo Code**, **Antigravity**, **Zed Agent**, **Goose**, **Mimo Code**, **ZCode**) — 이들 도구에는 아무것도 설치하지 않습니다. 도구가 이미 생성하는 파일 (SQLite DB, JSONL, OTEL export, session logs)만 읽습니다. Copilot App 사용량은 `~/.copilot/data.db`의 `sessions.total_*` 토큰 요약만 읽어 기존 `copilot` 집계 통계 (합계, 추이, 모델별 분석, 비용)에 반영됩니다. Copilot CLI / Chat 확장은 계속 OTEL 기반이며, 중복 집계를 피하기 위해 두 경로는 별도의 동기화 커서를 유지합니다.
187
188
  > - **Grok Build 추정** — 현재 로컬 텔레메트리는 `updates.jsonl`의 누적 `totalTokens`를 노출하지만, 안정적인 프롬프트/출력/캐시 분할은 제공하지 않습니다; `signals.json`은 `contextTokensUsed` 스냅샷을 사용한 폴백으로 남아 있습니다. 호출별 사용 상세 정보가 제공될 때까지 TokenTracker는 Grok 비용을 추정합니다.
188
189
  >
189
190
  > 언제든 `tokentracker status`로 각 통합의 상태를 확인할 수 있습니다. `skipped`로 표시되면 `detail` 컬럼이 이유를 설명합니다 (예: 도구 CLI가 `PATH`에 없음, 설정 읽기 불가).
@@ -234,7 +235,7 @@ flowchart LR
234
235
  | **콘텐츠 업로드 없음** | 토큰 수치와 타임스탬프만. 프롬프트, 응답, 파일 내용은 절대 다루지 않습니다. |
235
236
  | **기본적으로 로컬 전용** | 모든 데이터는 기기에 머뭅니다. 리더보드는 완전히 옵트인. |
236
237
  | **감사 가능** | 오픈 소스. [`src/lib/rollout.js`](src/lib/rollout.js)를 읽어보세요 — 숫자와 타임스탬프뿐입니다. |
237
- | **익명 하트비트만** | 활성 설치 집계를 위해 하루 최대 1회 익명 ping을 전송합니다: 머신 ID의 단방향 해시, 앱 버전, OS 플랫폼, 실행 형태(cli/mac/win) 포함. 토큰 수, 모델명, 프롬프트, 경로는 절대 포함되지 않습니다. [`src/lib/telemetry.js`](src/lib/telemetry.js)에서 감사 가능하며 `TOKENTRACKER_NO_TELEMETRY=1` 또는 `DO_NOT_TRACK=1`로 비활성화할 있습니다. |
238
+ | **익명 사용 통계만** | 외부 전송은 익명 2가지뿐: (1) 하루 최대 1회 하트비트——머신 ID의 단방향 해시, 앱 버전, OS 플랫폼, 실행 형태(cli/mac/win); (2) 익명 대시보드 페이지/기능 이벤트(PostHog——autocapture와 세션 녹화 비활성화, 브라우저 Do-Not-Track 존중). 토큰 수, 모델명, 프롬프트, 경로는 절대 포함되지 않습니다. [`src/lib/telemetry.js`](src/lib/telemetry.js)와 [`dashboard/src/lib/analytics.js`](dashboard/src/lib/analytics.js)에서 감사 가능하며 `TOKENTRACKER_NO_TELEMETRY=1` 또는 `DO_NOT_TRACK=1` 하나로 비활성화됩니다. |
238
239
 
239
240
  ---
240
241
 
@@ -245,7 +246,7 @@ flowchart LR
245
246
  | 변수 | 설명 | 기본값 |
246
247
  |---|---|---|
247
248
  | `TOKENTRACKER_DEBUG` | 디버그 출력 활성화 (`1`로 활성화) | — |
248
- | `TOKENTRACKER_NO_TELEMETRY` | 익명 일일 하트비트 비활성화 (`1`로 비활성화, `DO_NOT_TRACK` 표준도 지원) | — |
249
+ | `TOKENTRACKER_NO_TELEMETRY` | 모든 익명 텔레메트리(일일 하트비트 + 대시보드 분석) 비활성화 (`1`로 비활성화, `DO_NOT_TRACK` 표준도 지원) | — |
249
250
  | `TOKENTRACKER_HTTP_TIMEOUT_MS` | HTTP 타임아웃 (밀리초) | `20000` |
250
251
  | `CODEX_HOME` | Codex CLI 디렉토리 오버라이드 | `~/.codex` |
251
252
  | `GEMINI_HOME` | Gemini CLI 디렉토리 오버라이드 | `~/.gemini` |
package/README.md CHANGED
@@ -167,7 +167,8 @@ Upgrade with `brew upgrade --cask mm7894215/tokentracker/tokentracker`. The tap
167
167
  | **OpenClaw** | ✅ Auto | Session plugin |
168
168
  | **Every Code** | ✅ Auto | TOML notify hook |
169
169
  | **Hermes Agent** | ✅ Auto | SQLite sessions table (`~/.hermes/state.db`) |
170
- | **GitHub Copilot** | ✅ Auto | OpenTelemetry file exporter (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
170
+ | **GitHub Copilot App** | ✅ Auto | Passive session-summary reader (`~/.copilot/data.db`, or `COPILOT_HOME/data.db`) |
171
+ | **GitHub Copilot CLI / Chat extension** | ✅ Auto | OpenTelemetry file exporter (`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
171
172
  | **Kimi Code** | ✅ Auto | Passive `wire.jsonl` reader (`~/.kimi/sessions/**/wire.jsonl`) |
172
173
  | **oh-my-pi (Pi Coding Agent)** | ✅ Auto | Passive reader (`~/.omp/agent/sessions/**/*.jsonl`) |
173
174
  | **CodeBuddy** (Tencent) | ✅ Auto | SessionEnd hook in `~/.codebuddy/settings.json` (Claude-Code fork) |
@@ -187,7 +188,7 @@ Upgrade with `brew upgrade --cask mm7894215/tokentracker/tokentracker`. The tap
187
188
  > **Do I need to install any plugin or hook manually?** No. `tokentracker` (or `tokentracker init`) handles everything on first run:
188
189
  > - **Hook-based** tools (Claude Code, Codex, Gemini, Every Code, **CodeBuddy**, **WorkBuddy**, **Grok Build**) — we write a SessionEnd hook or TOML notify entry into the tool's own config.
189
190
  > - **Plugin-based** tools (OpenCode, **OpenClaw**) — plugins ship inside the npm package. OpenClaw's session plugin lives at `~/.tokentracker/tracker/openclaw-plugin/openclaw-session-sync/`; we link and enable it via OpenClaw's own CLI, then set `hooks.allowConversationAccess=true` so OpenClaw permits the session-finished event that triggers sync. No download, no drag-and-drop.
190
- > - **Passive readers** (Cursor, Kiro, Hermes, Kimi Code, Copilot, **Grok Build**, **oh-my-pi**, **pi**, **Craft Agents**, **Kilo CLI**, **Kilo Code**, **Roo Code**, **Antigravity**, **Zed Agent**, **Goose**, **Mimo Code**, **ZCode**) — nothing is installed into those tools. We only read files they already produce (SQLite DB, JSONL, OTEL export, session logs).
191
+ > - **Passive readers** (Cursor, Kiro, Hermes, Kimi Code, Copilot, **Grok Build**, **oh-my-pi**, **pi**, **Craft Agents**, **Kilo CLI**, **Kilo Code**, **Roo Code**, **Antigravity**, **Zed Agent**, **Goose**, **Mimo Code**, **ZCode**) — nothing is installed into those tools. We only read files they already produce (SQLite DB, JSONL, OTEL export, session logs). Copilot App usage is read from `~/.copilot/data.db` `sessions.total_*` token summaries only and feeds the existing `copilot` aggregate statistics (totals, trends, model breakdown, cost). Copilot CLI / Chat extension usage remains OTEL-based; both surfaces keep separate sync cursors to avoid duplicate counting.
191
192
  > - **Grok Build estimate** — current local telemetry exposes cumulative `updates.jsonl` `totalTokens`, but not a stable prompt/output/cache split; `signals.json` remains a fallback with `contextTokensUsed` snapshots. TokenTracker estimates Grok cost until per-call usage details are available.
192
193
  >
193
194
  > Run `tokentracker status` anytime to verify every integration's state. If something shows `skipped`, the `detail` column explains why (e.g. tool CLI not on `PATH`, config unreadable).
@@ -243,7 +244,7 @@ flowchart LR
243
244
  | **No content upload** | Only token counts and timestamps. Never prompts, responses, or file contents. |
244
245
  | **Local-only by default** | All data stays on your machine. The leaderboard is fully opt-in. |
245
246
  | **Auditable** | Open source. Read [`src/lib/rollout.js`](src/lib/rollout.js) — only numbers and timestamps. |
246
- | **Anonymous heartbeat only** | To count active installs, the app sends at most one anonymous ping per day: a one-way hash of the machine id, app version, OS platform, and app shell (cli/mac/win). Never token counts, model names, prompts, or paths. Audit it in [`src/lib/telemetry.js`](src/lib/telemetry.js); opt out with `TOKENTRACKER_NO_TELEMETRY=1` or `DO_NOT_TRACK=1`. |
247
+ | **Anonymous usage stats only** | Two things phone home, both anonymous: (1) at most one daily heartbeat a one-way hash of the machine id, app version, OS platform, and app shell (cli/mac/win); (2) anonymous dashboard pageview/feature events (PostHog — autocapture and session recording disabled, browser Do-Not-Track respected). Never token counts, model names, prompts, or paths. Audit [`src/lib/telemetry.js`](src/lib/telemetry.js) and [`dashboard/src/lib/analytics.js`](dashboard/src/lib/analytics.js); one switch disables both on your machine: `TOKENTRACKER_NO_TELEMETRY=1` (or `DO_NOT_TRACK=1`). |
247
248
 
248
249
  ---
249
250
 
@@ -254,7 +255,7 @@ Most users never need this — defaults are sensible. For advanced setups:
254
255
  | Variable | Description | Default |
255
256
  |---|---|---|
256
257
  | `TOKENTRACKER_DEBUG` | Enable debug output (`1` to enable) | — |
257
- | `TOKENTRACKER_NO_TELEMETRY` | Disable the anonymous daily heartbeat (`1` to disable; the `DO_NOT_TRACK` standard is also respected) | — |
258
+ | `TOKENTRACKER_NO_TELEMETRY` | Disable all anonymous telemetry — daily heartbeat and dashboard analytics (`1` to disable; the `DO_NOT_TRACK` standard is also respected) | — |
258
259
  | `TOKENTRACKER_HTTP_TIMEOUT_MS` | HTTP timeout in milliseconds | `20000` |
259
260
  | `CODEX_HOME` | Override Codex CLI directory | `~/.codex` |
260
261
  | `GEMINI_HOME` | Override Gemini CLI directory | `~/.gemini` |
package/README.zh-CN.md CHANGED
@@ -166,7 +166,8 @@ brew install mm7894215/tokentracker/tokentracker
166
166
  | **OpenClaw** | ✅ 自动 | Session 插件 |
167
167
  | **Every Code** | ✅ 自动 | TOML notify hook |
168
168
  | **Hermes Agent** | ✅ 自动 | SQLite sessions 表(`~/.hermes/state.db`) |
169
- | **GitHub Copilot** | ✅ 自动 | OpenTelemetry 文件导出(`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
169
+ | **GitHub Copilot App** | ✅ 自动 | 被动会话汇总读取(`~/.copilot/data.db`,或 `COPILOT_HOME/data.db`) |
170
+ | **GitHub Copilot CLI / Chat 扩展** | ✅ 自动 | OpenTelemetry 文件导出(`COPILOT_OTEL_FILE_EXPORTER_PATH`) |
170
171
  | **Kimi Code** | ✅ 自动 | 被动读取 `wire.jsonl`(`~/.kimi/sessions/**/wire.jsonl`) |
171
172
  | **oh-my-pi (Pi Coding Agent)** | ✅ 自动 | 被动读取(`~/.omp/agent/sessions/**/*.jsonl`) |
172
173
  | **CodeBuddy** (腾讯) | ✅ 自动 | 写入 `~/.codebuddy/settings.json` 的 SessionEnd hook(Claude-Code fork) |
@@ -185,7 +186,7 @@ brew install mm7894215/tokentracker/tokentracker
185
186
  > **需要手动装什么插件 / hook 吗?** 不需要。`tokentracker`(或 `tokentracker init`)第一次跑的时候会全部搞定:
186
187
  > - **基于 hook 的工具**(Claude Code、Codex、Gemini、Every Code、**CodeBuddy**、**WorkBuddy**、**Grok Build**)—— 我们把 SessionEnd hook 或 TOML notify 条目写入它们自己的配置文件
187
188
  > - **基于插件的工具**(OpenCode、**OpenClaw**)—— 插件随 npm 包一起分发。OpenClaw 的 session plugin 位于 `~/.tokentracker/tracker/openclaw-plugin/openclaw-session-sync/`;TokenTracker 会通过 OpenClaw 自己的 CLI 挂接并启用它,然后写入 `hooks.allowConversationAccess=true`,让 OpenClaw 放行触发同步的会话结束事件。无需下载、无需拖拽
188
- > - **被动读取类**(Cursor、Kiro、Hermes、Kimi Code、Copilot、**Grok Build**、**oh-my-pi**、**pi**、**Craft Agents**、**Kilo CLI**、**Kilo Code**、**Roo Code**、**Antigravity**、**Zed Agent**、**Goose**、**Mimo Code**、**ZCode**)—— 完全不往它们里面塞东西,只读取它们自己产生的文件(SQLite DB、JSONL、OTEL 导出、会话轨迹日志)
189
+ > - **被动读取类**(Cursor、Kiro、Hermes、Kimi Code、Copilot、**Grok Build**、**oh-my-pi**、**pi**、**Craft Agents**、**Kilo CLI**、**Kilo Code**、**Roo Code**、**Antigravity**、**Zed Agent**、**Goose**、**Mimo Code**、**ZCode**)—— 完全不往它们里面塞东西,只读取它们自己产生的文件(SQLite DB、JSONL、OTEL 导出、会话轨迹日志)。Copilot App 的用量只读取 `~/.copilot/data.db` 中 `sessions.total_*` 的 token 汇总列,并入现有 `copilot` 聚合统计(总量、趋势、模型拆分、成本);Copilot CLI / Chat 扩展仍走 OTEL,两条数据面各自维护独立的同步游标以避免重复计数
189
190
  > - **Grok Build 估算说明** —— Grok 当前本地遥测提供 `updates.jsonl` 里的累计 `totalTokens`,但还没有稳定的输入/输出/cache 拆分;`signals.json` 仍作为 `contextTokensUsed` 快照兜底。所以在 Grok 提供按调用粒度的用量明细之前,TokenTracker 对 Grok 成本仍是估算值
190
191
  >
191
192
  > 任何时候都可以用 `tokentracker status` 查看每个集成的状态。如果显示 `skipped`,`detail` 列会解释原因(例如某工具 CLI 不在 `PATH` 上、config 不可读等)。
@@ -236,7 +237,7 @@ flowchart LR
236
237
  | **不上传内容** | 只记录 token 数量和时间戳。**绝不**记录 prompt、回复或文件内容 |
237
238
  | **默认纯本地** | 所有数据保留在你的机器上。排行榜是完全 opt-in |
238
239
  | **可审计** | 代码开源。[`src/lib/rollout.js`](src/lib/rollout.js) 里只有数字和时间戳 |
239
- | **仅匿名心跳** | 为统计活跃安装量,应用每天最多发送一次匿名心跳:机器 ID 的单向哈希、应用版本、操作系统平台、运行形态(cli/mac/win)。绝不包含 token 数量、模型名、prompt 或路径。可在 [`src/lib/telemetry.js`](src/lib/telemetry.js) 审计;设置 `TOKENTRACKER_NO_TELEMETRY=1` `DO_NOT_TRACK=1` 即可关闭 |
240
+ | **仅匿名使用统计** | 只有两类匿名上报:(1) 每天最多一次的心跳——机器 ID 的单向哈希、应用版本、操作系统平台、运行形态(cli/mac/win);(2) 匿名的 dashboard 页面/功能事件(PostHog——已关闭 autocapture 和会话录制,尊重浏览器 Do-Not-Track)。绝不包含 token 数量、模型名、prompt 或路径。可在 [`src/lib/telemetry.js`](src/lib/telemetry.js) [`dashboard/src/lib/analytics.js`](dashboard/src/lib/analytics.js) 审计;一个开关同时关闭两者:`TOKENTRACKER_NO_TELEMETRY=1`(或 `DO_NOT_TRACK=1`) |
240
241
 
241
242
  ---
242
243
 
@@ -247,7 +248,7 @@ flowchart LR
247
248
  | 变量 | 说明 | 默认值 |
248
249
  |---|---|---|
249
250
  | `TOKENTRACKER_DEBUG` | 打开 debug 日志(`1` 表示打开) | — |
250
- | `TOKENTRACKER_NO_TELEMETRY` | 关闭匿名每日心跳(`1` 表示关闭;同样尊重 `DO_NOT_TRACK` 标准) | — |
251
+ | `TOKENTRACKER_NO_TELEMETRY` | 关闭全部匿名遥测——每日心跳与 dashboard 分析(`1` 表示关闭;同样尊重 `DO_NOT_TRACK` 标准) | — |
251
252
  | `TOKENTRACKER_HTTP_TIMEOUT_MS` | HTTP 超时时间(毫秒) | `20000` |
252
253
  | `CODEX_HOME` | 覆盖 Codex CLI 目录 | `~/.codex` |
253
254
  | `GEMINI_HOME` | 覆盖 Gemini CLI 目录 | `~/.gemini` |
@@ -1,4 +1,4 @@
1
- import{c as ue,r as i,j as e,N as n,_ as We,s as Fe,P as He,X as Ie,aG as Ge,Q as Oe}from"./main-B0LYKUIY.js";import{u as qe}from"./useCurrency-DbBq0Fal.js";import{I as Ze}from"./info-CxDHBJXB.js";const Ke=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ve=ue("maximize-2",Ke);const Qe=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Je=ue("pause",Qe);const et=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],tt=ue("play",et);const at=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],rt=ue("rotate-ccw",at);const ot=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],nt=ue("terminal",ot),J={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function st(l,x){const h=/^#([0-9a-f]{6})$/i.exec(l);if(!h)return l;const c=parseInt(h[1],16),M=c>>16&255,P=c>>8&255,$=c&255,S=E=>Math.max(0,Math.min(255,Math.round(E*x)));return`rgb(${S(M)}, ${S(P)}, ${S($)})`}function O(l,x,h,c,M){const P=Math.cos(c),$=Math.sin(c),S=l*P-x*$,E=l*$+x*P,L=h,_=Math.cos(M),m=Math.sin(M),N=S,ee=E*_-L*m,F=E*m+L*_;return{x:N,y:ee,z:F}}function lt(l,x,h,c,M){return O(l,x,h,c,M)}function Se(l,x){const h=Number(x).toLocaleString();if(l>=4){const c=Math.floor(Math.random()*3)+1;return n(`heatmap.3d.voxel.joke.${c}`,{value:h})}else return l===3?n("heatmap.3d.voxel.level3",{value:h}):l===2?n("heatmap.3d.voxel.level2",{value:h}):l===1?n("heatmap.3d.voxel.level1",{value:h}):n("heatmap.3d.voxel.level0")}function _e({weeks:l,palette:x="auto",isDark:h=!1,interactive:c=!1,autoRotateInit:M=!1,onResetViewRef:P=null}){const $=J[x]||(x==="auto"?J.emerald:null),S=$?h?$.dark:$.light:Array.isArray(x)?x:h?J.emerald.dark:J.emerald.light,E=$?h?$.gridColor.dark:$.gridColor.light:h?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",L=-.2,_=.88,[m,N]=i.useState({yaw:L,pitch:_}),[ee,F]=i.useState(M),[pe,A]=i.useState(1),j=c?13:10.5,he=i.useMemo(()=>{const t=[],r=l.length;if(r===0||!c)return[];for(let s=0;s<=7;s++){const o=(s-3.5)*j,d=O(-r/2*j,o,0,m.yaw,m.pitch),p=O(r/2*j,o,0,m.yaw,m.pitch);t.push({d:`M${d.x},${d.y} L${p.x},${p.y}`,key:`horiz-${s}`})}for(let s=0;s<=r;s+=4){const o=(s-r/2)*j,d=O(o,-3.5*j,0,m.yaw,m.pitch),p=O(o,3.5*j,0,m.yaw,m.pitch);t.push({d:`M${d.x},${d.y} L${p.x},${p.y}`,key:`vert-${s}`})}if(r%4!==0){const s=(r-r/2)*j,o=O(s,-3.5*j,0,m.yaw,m.pitch),d=O(s,3.5*j,0,m.yaw,m.pitch);t.push({d:`M${o.x},${o.y} L${d.x},${d.y}`,key:"vert-last"})}return t},[l.length,m,j,c]);i.useEffect(()=>{P&&(P.current={reset:()=>{N({yaw:L,pitch:_}),F(!1),A(1),ye()},toggleAutoRotate:t=>{F(t)}})},[P]);const q=i.useRef(null),H=i.useRef(null),W=i.useRef(!1),ie=i.useRef({x:0,y:0}),Z=i.useRef({yaw:L,pitch:_}),Y=i.useRef({x:0,y:0}),re=i.useRef({x:0,y:0,time:0}),oe=i.useRef(null),[fe,ge]=i.useState(0),K=i.useRef(null),ne=i.useRef(!0);i.useEffect(()=>(ne.current=!0,()=>{ne.current=!1}),[]);const ye=()=>{K.current&&cancelAnimationFrame(K.current),ge(0);const t=performance.now(),r=1200,s=o=>{if(!ne.current)return;const d=o-t,p=Math.min(1,d/r),k=1-Math.pow(1-p,3);ge(k),p<1?K.current=requestAnimationFrame(s):K.current=null};K.current=requestAnimationFrame(s)};i.useEffect(()=>(ye(),()=>{K.current&&cancelAnimationFrame(K.current)}),[c]),i.useEffect(()=>{if(!ee||W.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let r;const s=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){r=requestAnimationFrame(s);return}N(o=>({yaw:o.yaw+.002,pitch:o.pitch})),r=requestAnimationFrame(s)};return r=requestAnimationFrame(s),()=>cancelAnimationFrame(r)},[ee]);const ce=(t,r)=>{c&&(W.current=!0,ie.current={x:t,y:r},Z.current={yaw:m.yaw,pitch:m.pitch},Y.current={x:0,y:0},re.current={x:t,y:r,time:performance.now()},oe.current&&cancelAnimationFrame(oe.current))},U=(t,r)=>{if(!W.current)return;const s=t-ie.current.x,o=r-ie.current.y,d=performance.now(),p=d-re.current.time;p>0&&(Y.current={x:(t-re.current.x)/p,y:(r-re.current.y)/p}),re.current={x:t,y:r,time:d};const k=.005,f=Z.current.yaw-s*k,g=Math.PI/2.3,D=Math.max(-g,Math.min(g,Z.current.pitch-o*k));N({yaw:f,pitch:D})},be=()=>{if(!W.current)return;W.current=!1;let t=-Y.current.x*12,r=-Y.current.y*12;const s=.95,o=()=>{W.current||(t*=s,r*=s,!(Math.abs(t)<.01&&Math.abs(r)<.01)&&(N(d=>{const p=d.yaw+t*.005,k=Math.PI/2.3,f=Math.max(-k,Math.min(k,d.pitch+r*.005));return{yaw:p,pitch:f}}),oe.current=requestAnimationFrame(o)))};oe.current=requestAnimationFrame(o)},[b,de]=i.useState(null),[V,xe]=i.useState({x:0,y:0,shiftX:0}),y=i.useRef(null);i.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),i.useEffect(()=>{if(!c||!H.current)return;const t=s=>{s.preventDefault();const o=-s.deltaY*.0025;A(d=>{const p=d+o;return Math.max(.5,Math.min(3,p))})},r=H.current;return r.addEventListener("wheel",t,{passive:!1}),()=>{r.removeEventListener("wheel",t)}},[c]);const C=i.useMemo(()=>{const t=[];return l.forEach((r,s)=>{(Array.isArray(r)?r:[]).forEach((o,d)=>{o&&t.push({key:o.day||`${s}-${d}`,col:s,row:d,level:o.level||0,value:o.value||0,day:o.day,models:o.models||null})})}),t},[l]),ve=j-(c?1.8:1.5),ke=c?38:28,Q=t=>Math.max(1.8,Number(t)/4*ke),te=i.useMemo(()=>{if(C.length===0)return[];const t=l.length;return C.map(r=>{const s=Q(r.level),o=Math.sqrt(Math.pow(r.col-t/2,2)+Math.pow(r.row-3.5,2)),d=Math.sqrt(Math.pow(t/2,2)+Math.pow(3.5,2)),p=o/d*.4,k=Math.min(1,Math.max(0,(fe-p)*(1/.6))),f=s*k,g=(r.col-t/2)*j,D=(r.row-3.5)*j,w=ve/2,G=[{x:g-w,y:D-w,z:0},{x:g+w,y:D-w,z:0},{x:g+w,y:D+w,z:0},{x:g-w,y:D+w,z:0},{x:g-w,y:D-w,z:f},{x:g+w,y:D-w,z:f},{x:g+w,y:D+w,z:f},{x:g-w,y:D+w,z:f}].map(B=>O(B.x,B.y,B.z,m.yaw,m.pitch)),me=O(g,D,f/2,m.yaw,m.pitch),Le=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],Re=S[Math.min(4,Math.max(0,Number(r.level)||0))],Ne=[],Ae=.35,De=-.4,Pe=.83;return Le.forEach(B=>{const we=lt(B.normal[0],B.normal[1],B.normal[2],m.yaw,m.pitch);if(we.z>.001){const Ce=G[B.indices[0]],ze=G[B.indices[1]],Me=G[B.indices[2]],Te=G[B.indices[3]],Ye=`M${Ce.x},${Ce.y} L${ze.x},${ze.y} L${Me.x},${Me.y} L${Te.x},${Te.y} Z`,Ue=we.x*Ae+we.y*De+we.z*Pe,Xe=h?.18:0,Be=B.scale*(.82+.28*Math.max(0,Ue))+Xe;Ne.push({name:B.name,d:Ye,fill:st(Re,Be)})}}),{...r,centerProj:me,renderedFaces:Ne}})},[C,m,S,l.length,fe,j,ve,ke]),se=i.useMemo(()=>[...te].sort((t,r)=>t.centerProj.z-r.centerProj.z),[te]),T=i.useMemo(()=>{if(se.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let t=1/0,r=1/0,s=-1/0,o=-1/0;return se.forEach(d=>{const p=j*2,k=d.centerProj.x,f=d.centerProj.y;k-p<t&&(t=k-p),k+p>s&&(s=k+p),f-p<r&&(r=f-p),f+p>o&&(o=f+p)}),{minX:t,minY:r,maxX:s,maxY:o}},[se,j]),R=12,a=T.maxX-T.minX+R*2,u=T.maxY-T.minY+R*2,z=a/pe,v=u/pe,X=T.minX-R+(a-z)/2,I=T.minY-R+(u-v)/2,le=`${X} ${I} ${z} ${v}`;return C.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")}):e.jsxs("div",{ref:H,className:`relative select-none outline-none ${c?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:t=>{if(!c)return;ce(t.clientX,t.clientY);const r=o=>U(o.clientX,o.clientY),s=()=>{be(),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},onTouchStart:t=>{!c||t.touches.length===0||ce(t.touches[0].clientX,t.touches[0].clientY)},onTouchMove:t=>{!c||t.touches.length===0||U(t.touches[0].clientX,t.touches[0].clientY)},onTouchEnd:()=>{c&&be()},children:[e.jsxs("svg",{ref:q,viewBox:le,width:c?"95%":"100%",height:c?"95%":"auto",role:"img","aria-label":n("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:c?"none":`${a}px`,maxHeight:c?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[c&&he.map(t=>e.jsx("path",{d:t.d,fill:"none",stroke:E,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},t.key)),se.map(t=>{const r=b&&b.key===t.key;return e.jsxs("g",{onMouseEnter:s=>{if(y.current&&(clearTimeout(y.current),y.current=null),de(t),c&&q.current){const o=O((t.col-l.length/2)*j,(t.row-3.5)*j,Q(t.level),m.yaw,m.pitch);let d=0,p=0;const k=q.current;if(H.current&&typeof k.createSVGPoint=="function"&&typeof k.getScreenCTM=="function")try{const w=k.createSVGPoint();w.x=o.x,w.y=o.y;const ae=k.getScreenCTM();if(ae){const G=w.matrixTransform(ae),me=H.current.getBoundingClientRect();d=G.x-me.left,p=G.y-me.top}}catch{const ae=k.getBoundingClientRect(),G=T.maxX-T.minX+R*2,me=T.maxY-T.minY+R*2;d=(o.x-(T.minX-R))/G*ae.width,p=(o.y-(T.minY-R))/me*ae.height}else{const w=k.getBoundingClientRect(),ae=T.maxX-T.minX+R*2,G=T.maxY-T.minY+R*2;d=(o.x-(T.minX-R))/ae*w.width,p=(o.y-(T.minY-R))/G*w.height}const f=140;let g=0;const D=H.current?H.current.getBoundingClientRect().width:k.getBoundingClientRect().width;d<f?g=f-d:d>D-f&&(g=D-f-d),xe({x:d,y:p,shiftX:g})}},onMouseLeave:()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{de(null)},150)},className:"transition-all duration-200",style:{filter:r?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:c?"pointer":"default"},children:[!c&&t.day&&e.jsx("title",{children:`${t.day}: ${Number(t.value).toLocaleString()} tokens`}),t.renderedFaces.map((s,o)=>e.jsx("path",{d:s.d,fill:s.fill,stroke:s.fill,strokeWidth:.25,strokeLinejoin:"round"},o))]},t.key)})]}),c&&b&&e.jsxs("div",{onMouseEnter:()=>{y.current&&(clearTimeout(y.current),y.current=null)},onMouseLeave:()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{de(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${V.x}px`,top:`${V.y}px`},children:[e.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${V.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:b.day}),(()=>{const t=b.level===0?h?"#9ca3af":"#6b7280":S[b.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"22",color:t,border:`1px solid ${t}44`},children:["Level ",b.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(b.value).toLocaleString()}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),b.models&&Object.keys(b.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(b.models).map(([t,r])=>({name:t,val:Number(r)})).sort((t,r)=>r.val-t.val).map(({name:t,val:r})=>{const s=Number(b.value)||1,o=Math.round(r/s*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:t,children:t}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:r.toLocaleString()}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[o,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,backgroundColor:S[4],boxShadow:`0 0 4px ${S[4]}55`}})})]},t)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Se(b.level,b.value)})]})]}),e.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const it=12,ct=3,dt=26,mt=["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],xt=["#30363d","#065f46","#059669","#10b981","#34d399"];function $e(l){const x=Number(l);return Number.isFinite(x)?x<1e3?x.toLocaleString():Oe(x,{decimals:2}):"0"}function ut(l){if(typeof l!="string")return null;const x=/^(\d{4})-(\d{2})-(\d{2})$/.exec(l.trim());if(!x)return null;const h=new Date(Date.UTC(Number(x[1]),Number(x[2])-1,Number(x[3])));return Number.isFinite(h.getTime())?h:null}function Ee(l,x){return new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()+x))}function pt(l,x){return Math.floor((Date.UTC(x.getUTCFullYear(),x.getUTCMonth(),x.getUTCDate())-Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))/864e5)}function ht(l,x){const h=x==="mon"?1:0,c=l.getUTCDay();return Ee(l,-((c-h+7)%7))}function ft(l,x,h,c){if(!l)return[];const M=ut(x)||new Date,P=[];for(let _=11;_>=0;_-=1)P.push(new Date(Date.UTC(M.getUTCFullYear(),M.getUTCMonth()-_,1)));const $=ht(M,h),S=Ee($,-(l-1)*7),E=[],L=new Set;for(const _ of P){const m=Math.floor(pt(S,_)/7);m<0||m>=l||L.has(m)||(L.add(m),E.push({label:c[_.getUTCMonth()],index:m}))}return E}function vt({heatmap:l,timeZoneLabel:x,timeZoneShortLabel:h,hideLegend:c=!1,embedded:M=!1}){const{resolvedTheme:P}=We(),{currency:$,rate:S}=qe(),E=P==="dark",L=E?xt:mt,_=i.useRef(null),m=i.useRef(null),[N,ee]=i.useState(null),[F,pe]=i.useState({x:0,y:0,shiftX:0,flipY:!1}),A=i.useRef(null);i.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]);const[j,he]=i.useState(!1),[q,H]=i.useState(!1),[W,ie]=i.useState(!1),Z=i.useRef(null),[Y,re]=i.useState("emerald"),oe=[n("heatmap.month.jan"),n("heatmap.month.feb"),n("heatmap.month.mar"),n("heatmap.month.apr"),n("heatmap.month.may"),n("heatmap.month.jun"),n("heatmap.month.jul"),n("heatmap.month.aug"),n("heatmap.month.sep"),n("heatmap.month.oct"),n("heatmap.month.nov"),n("heatmap.month.dec")],fe=(a,u)=>{if(!u||!u.day)return;A.current&&(clearTimeout(A.current),A.current=null),ee(u);const z=a.currentTarget.getBoundingClientRect(),v=typeof window<"u"?window.innerWidth:1024,X=z.left+z.width/2,I=z.top<300,le=I?z.bottom:z.top,t=140;let r=0;X<t?r=t-X:X>v-t&&(r=v-t-X),pe({x:X,y:le,shiftX:r,flipY:I})},ge=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{ee(null)},150)},K=()=>{H(!1),he(!0)},ne=()=>{H(!0)},ye=a=>{a.target===a.currentTarget&&q&&(he(!1),H(!1))};i.useEffect(()=>{if(!j||q)return;const a=u=>{u.key==="Escape"&&ne()};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[j,q]);const ce=i.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),U=ce[Y]||ce.emerald,be=J[Y]?E?J[Y].dark:J[Y].light:E?J.emerald.dark:J.emerald.light,[b,de]=i.useState(()=>{if(M)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});i.useEffect(()=>{if(!M)try{window.localStorage?.setItem("tt:heatmap-view",b)}catch{}},[b,M]),i.useEffect(()=>{if(b!=="2d")return;const a=_.current;a&&(a.scrollLeft=a.scrollWidth)},[l?.weeks,b]),i.useEffect(()=>{const a=_.current;if(!a)return;const u=()=>{A.current&&(clearTimeout(A.current),A.current=null),ee(null)};return a.addEventListener("scroll",u),()=>a.removeEventListener("scroll",u)},[]);const V=l?.week_starts_on==="mon"?"mon":"sun",xe=i.useMemo(()=>{const a=Array.isArray(l?.weeks)?l.weeks:[];if(!a.length)return{weeks:[]};const u=[];for(const z of a)for(const v of Array.isArray(z)?z:[])v?.day&&u.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0,models:v.models??null});return Fe({dailyRows:u,weeks:Math.max(52,a.length),to:l?.to,weekStartsOn:V})},[l?.to,l?.weeks,V]),y=xe?.weeks||[],C=i.useMemo(()=>{let a=0,u=0,z={day:"无数据",value:0},v=0,X=0;const I=[];y.forEach(f=>{(Array.isArray(f)?f:[]).forEach(g=>{g&&g.day&&I.push(g)})}),I.sort((f,g)=>f.day.localeCompare(g.day)),I.forEach(f=>{const g=Number(f.value)||0;a+=g,g>0?(u++,v++,v>X&&(X=v)):v=0,g>z.value&&(z={day:f.day,value:g})});const le=I.length||365,t=(u/le*100).toFixed(1);let r="heatmap.3d.modal.ai.eval.default",s="heatmap.3d.modal.ai.title.default";a>=15e6?(s="heatmap.3d.modal.ai.title.peak",r="heatmap.3d.modal.ai.eval.peak"):a>=5e6?(s="heatmap.3d.modal.ai.title.heavy",r="heatmap.3d.modal.ai.eval.heavy"):a>=1e6?(s="heatmap.3d.modal.ai.title.core",r="heatmap.3d.modal.ai.eval.core"):a>=2e4&&(s="heatmap.3d.modal.ai.title.steady",r="heatmap.3d.modal.ai.eval.steady");const o=l?.total_cost_usd,d=Number(o),k=o!=null&&(typeof o!="string"||o.trim()!=="")&&Number.isFinite(d)?d:a/15e5;return{totalTokens:a,activeDays:u,activeRate:t,maxSingleDay:z,maxStreak:X,aiEvaluationTitleKey:s,aiEvaluationKey:r,totalCostUsd:k}},[y,l?.total_cost_usd]),je=i.useMemo(()=>He(C.totalCostUsd,{currency:$,rate:S}),[C.totalCostUsd,$,S]),ve=V==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)),ke=i.useMemo(()=>ft(y.length,xe?.to,V,oe),[xe?.to,y.length,V,oe]);if(!y.length)return e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")});const Q=M?10:it,te=M?2:ct,se=M?22:dt,T=se+y.length*Q+Math.max(0,y.length-1)*te,R=`${se}px repeat(${y.length}, ${Q}px)`;return e.jsxs("div",{ref:m,className:M?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!M&&e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:n("heatmap.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":b==="2d",onClick:()=>de("2d"),className:b==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.2d")}),e.jsx("button",{type:"button",role:"tab","aria-selected":b==="3d",onClick:()=>de("3d"),className:b==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.3d")})]}),e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:h||n("heatmap.legend.utc")})]})]}),b==="3d"&&e.jsxs("div",{onClick:K,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:n("heatmap.3d.hover_tip"),children:[e.jsx(_e,{weeks:y,isDark:E,palette:Y}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:e.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[e.jsx(Ve,{size:9}),n("heatmap.3d.hover_tip")]})})]}),b==="2d"&&e.jsx("div",{ref:_,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:e.jsxs("div",{style:{minWidth:T},children:[e.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:R,columnGap:te},children:[e.jsx("span",{}),ke.map(a=>e.jsx("span",{style:{gridColumnStart:a.index+2},className:"whitespace-nowrap",children:a.label},`${a.label}-${a.index}`))]}),e.jsxs("div",{className:"grid",style:{gridTemplateColumns:R,columnGap:te},children:[e.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${Q}px)`,rowGap:te},children:ve.map(a=>e.jsx("span",{className:"leading-none",children:a},a))}),e.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Q}px)`,gap:te},children:y.map((a,u)=>(Array.isArray(a)?a:[]).map((z,v)=>{if(!z)return null;const X=z.day||`e-${u}-${v}`,I=Number(z.level)||0,le=L[I]||L[0];return e.jsx("span",{onMouseEnter:t=>fe(t,z),onMouseLeave:ge,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:Q,height:Q,background:le}},X)}))})]})]})}),!c&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.less")}),e.jsx("div",{className:"flex gap-0.5",children:L.map((a,u)=>e.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:a}},u))}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.more")})]}),j&&e.jsx("div",{onAnimationEnd:ye,onClick:a=>{a.target===a.currentTarget&&ne()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${q?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:e.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${q?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[e.jsx("button",{type:"button",onClick:ne,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:e.jsx(Ie,{size:16})}),e.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:U.rawColor}}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:U.rawColor}})]}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),e.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:n("heatmap.3d.modal.title")}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:n("heatmap.3d.modal.desc")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[e.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_total_tokens")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[C.totalTokens.toLocaleString()," Tokens"]})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.total_tokens")}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:$e(C.totalTokens)}),e.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:e.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:U.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.estimated_cost")}),e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:je})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.active_rate_days")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.activeRate,"% ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",C.activeDays,"D)"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.max_streak")}),e.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.maxStreak," ",e.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:n("heatmap.3d.modal.stats.days_suffix")})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_peak_value")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[C.maxSingleDay.value>0?C.maxSingleDay.value.toLocaleString():n("heatmap.3d.modal.stats.no_data")," Tokens"]}),e.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:C.maxSingleDay.day!=="无数据"?C.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data")})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.peak_day")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.maxSingleDay.value>0?$e(C.maxSingleDay.value):n("heatmap.3d.modal.stats.no_data")," ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",C.maxSingleDay.day!=="无数据"?C.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsx(nt,{size:11,style:{color:U.rawColor}}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:U.rawColor},children:n(C.aiEvaluationTitleKey)})]}),e.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:U.rawColor},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:U.rawColor}}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:n(C.aiEvaluationKey)})]})]}),e.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.legend.title")}),e.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:n(`heatmap.3d.modal.palette.${Y}`)})]}),e.jsx("div",{className:"flex gap-1",children:be.map((a,u)=>e.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:a},title:`Level ${u}`},u))})]})})]}),e.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[e.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:U.rawColor+"15"}}),e.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[e.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(ce).map(a=>{const u=Y===a;return e.jsx("button",{type:"button",onClick:()=>re(a),title:n(`heatmap.3d.modal.palette.${a}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${a==="emerald"?"bg-[#10b981]":a==="ocean"?"bg-[#3b82f6]":a==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:u&&e.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},a)})}),e.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[e.jsx("button",{type:"button",onClick:()=>{const a=!W;ie(a),Z.current&&Z.current.toggleAutoRotate(a)},title:W?n("heatmap.3d.modal.control.pause"):n("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${W?U.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:W?e.jsx(Je,{size:12}):e.jsx(tt,{size:12})}),e.jsx("button",{type:"button",onClick:()=>{ie(!1),Z.current&&Z.current.reset()},title:n("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:e.jsx(rt,{size:12})})]})]}),e.jsx(_e,{weeks:y,isDark:E,interactive:!0,palette:Y,autoRotateInit:W,onResetViewRef:Z}),e.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[e.jsx(Ze,{size:10,className:U.accentText}),e.jsx("span",{children:n("heatmap.3d.modal.footer.tip")})]})]})]})}),N&&!j&&typeof document<"u"&&Ge.createPortal(e.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{position:"fixed",left:`${F.x}px`,top:`${F.y}px`},children:[e.jsxs("div",{className:`absolute left-0 ${F.flipY?"top-[10px]":"bottom-[10px]"} backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100`,style:{transform:`translateX(calc(-50% + ${F.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:N.day}),(()=>{const a=N.level===0?E?"#9ca3af":"#6b7280":L[N.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:a+"22",color:a,border:`1px solid ${a}44`},children:["Level ",N.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(N.total_tokens??N.value).toLocaleString()}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),N.models&&Object.keys(N.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(N.models).map(([a,u])=>({name:a,val:Number(u)})).sort((a,u)=>u.val-a.val).map(({name:a,val:u})=>{const z=Number(N.total_tokens??N.value)||1,v=Math.round(u/z*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:u.toLocaleString()}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[v,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${v}%`,backgroundColor:L[4],boxShadow:`0 0 4px ${L[4]}55`}})})]},a)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Se(N.level,N.total_tokens??N.value)})]})]}),e.jsx("div",{className:`absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 shadow-sm ${F.flipY?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"} border-oai-gray-200/50 dark:border-oai-gray-800/50`,style:F.flipY?{marginTop:"1px"}:{marginBottom:"1px"}})]}),document.body),e.jsx("style",{children:`
1
+ import{c as ue,r as i,j as e,N as n,_ as We,s as Fe,P as He,X as Ie,aG as Ge,Q as Oe}from"./main-Dxi4sSXf.js";import{u as qe}from"./useCurrency-BiDjYxfm.js";import{I as Ze}from"./info-Dxn3fiaX.js";const Ke=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],Ve=ue("maximize-2",Ke);const Qe=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],Je=ue("pause",Qe);const et=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],tt=ue("play",et);const at=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],rt=ue("rotate-ccw",at);const ot=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],nt=ue("terminal",ot),J={emerald:{light:["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],dark:["#2d333b","#065f46","#059669","#10b981","#34d399"],gridColor:{light:"rgba(16, 185, 129, 0.12)",dark:"rgba(52, 211, 153, 0.08)"}},ocean:{light:["#f1f5f9","#93c5fd","#60a5fa","#3b82f6","#1d4ed8"],dark:["#1e293b","#1e3a8a","#2563eb","#3b82f6","#60a5fa"],gridColor:{light:"rgba(59, 130, 246, 0.12)",dark:"rgba(96, 165, 250, 0.08)"}},neon:{light:["#faf5ff","#ebd5ff","#c084fc","#a855f7","#7e22ce"],dark:["#2e1065","#581c87","#8b5cf6","#a855f7","#c084fc"],gridColor:{light:"rgba(168, 85, 247, 0.12)",dark:"rgba(192, 132, 252, 0.08)"}},amber:{light:["#fffbeb","#fde68a","#f59e0b","#d97706","#b45309"],dark:["#451a03","#78350f","#b45309","#d97706","#f59e0b"],gridColor:{light:"rgba(245, 158, 11, 0.12)",dark:"rgba(245, 158, 11, 0.08)"}}};function st(l,x){const h=/^#([0-9a-f]{6})$/i.exec(l);if(!h)return l;const c=parseInt(h[1],16),M=c>>16&255,P=c>>8&255,$=c&255,S=E=>Math.max(0,Math.min(255,Math.round(E*x)));return`rgb(${S(M)}, ${S(P)}, ${S($)})`}function O(l,x,h,c,M){const P=Math.cos(c),$=Math.sin(c),S=l*P-x*$,E=l*$+x*P,L=h,_=Math.cos(M),m=Math.sin(M),N=S,ee=E*_-L*m,F=E*m+L*_;return{x:N,y:ee,z:F}}function lt(l,x,h,c,M){return O(l,x,h,c,M)}function Se(l,x){const h=Number(x).toLocaleString();if(l>=4){const c=Math.floor(Math.random()*3)+1;return n(`heatmap.3d.voxel.joke.${c}`,{value:h})}else return l===3?n("heatmap.3d.voxel.level3",{value:h}):l===2?n("heatmap.3d.voxel.level2",{value:h}):l===1?n("heatmap.3d.voxel.level1",{value:h}):n("heatmap.3d.voxel.level0")}function _e({weeks:l,palette:x="auto",isDark:h=!1,interactive:c=!1,autoRotateInit:M=!1,onResetViewRef:P=null}){const $=J[x]||(x==="auto"?J.emerald:null),S=$?h?$.dark:$.light:Array.isArray(x)?x:h?J.emerald.dark:J.emerald.light,E=$?h?$.gridColor.dark:$.gridColor.light:h?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",L=-.2,_=.88,[m,N]=i.useState({yaw:L,pitch:_}),[ee,F]=i.useState(M),[pe,A]=i.useState(1),j=c?13:10.5,he=i.useMemo(()=>{const t=[],r=l.length;if(r===0||!c)return[];for(let s=0;s<=7;s++){const o=(s-3.5)*j,d=O(-r/2*j,o,0,m.yaw,m.pitch),p=O(r/2*j,o,0,m.yaw,m.pitch);t.push({d:`M${d.x},${d.y} L${p.x},${p.y}`,key:`horiz-${s}`})}for(let s=0;s<=r;s+=4){const o=(s-r/2)*j,d=O(o,-3.5*j,0,m.yaw,m.pitch),p=O(o,3.5*j,0,m.yaw,m.pitch);t.push({d:`M${d.x},${d.y} L${p.x},${p.y}`,key:`vert-${s}`})}if(r%4!==0){const s=(r-r/2)*j,o=O(s,-3.5*j,0,m.yaw,m.pitch),d=O(s,3.5*j,0,m.yaw,m.pitch);t.push({d:`M${o.x},${o.y} L${d.x},${d.y}`,key:"vert-last"})}return t},[l.length,m,j,c]);i.useEffect(()=>{P&&(P.current={reset:()=>{N({yaw:L,pitch:_}),F(!1),A(1),ye()},toggleAutoRotate:t=>{F(t)}})},[P]);const q=i.useRef(null),H=i.useRef(null),W=i.useRef(!1),ie=i.useRef({x:0,y:0}),Z=i.useRef({yaw:L,pitch:_}),Y=i.useRef({x:0,y:0}),re=i.useRef({x:0,y:0,time:0}),oe=i.useRef(null),[fe,ge]=i.useState(0),K=i.useRef(null),ne=i.useRef(!0);i.useEffect(()=>(ne.current=!0,()=>{ne.current=!1}),[]);const ye=()=>{K.current&&cancelAnimationFrame(K.current),ge(0);const t=performance.now(),r=1200,s=o=>{if(!ne.current)return;const d=o-t,p=Math.min(1,d/r),k=1-Math.pow(1-p,3);ge(k),p<1?K.current=requestAnimationFrame(s):K.current=null};K.current=requestAnimationFrame(s)};i.useEffect(()=>(ye(),()=>{K.current&&cancelAnimationFrame(K.current)}),[c]),i.useEffect(()=>{if(!ee||W.current||typeof window>"u"||typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;let r;const s=()=>{if(typeof document<"u"&&document.visibilityState==="hidden"){r=requestAnimationFrame(s);return}N(o=>({yaw:o.yaw+.002,pitch:o.pitch})),r=requestAnimationFrame(s)};return r=requestAnimationFrame(s),()=>cancelAnimationFrame(r)},[ee]);const ce=(t,r)=>{c&&(W.current=!0,ie.current={x:t,y:r},Z.current={yaw:m.yaw,pitch:m.pitch},Y.current={x:0,y:0},re.current={x:t,y:r,time:performance.now()},oe.current&&cancelAnimationFrame(oe.current))},U=(t,r)=>{if(!W.current)return;const s=t-ie.current.x,o=r-ie.current.y,d=performance.now(),p=d-re.current.time;p>0&&(Y.current={x:(t-re.current.x)/p,y:(r-re.current.y)/p}),re.current={x:t,y:r,time:d};const k=.005,f=Z.current.yaw-s*k,g=Math.PI/2.3,D=Math.max(-g,Math.min(g,Z.current.pitch-o*k));N({yaw:f,pitch:D})},be=()=>{if(!W.current)return;W.current=!1;let t=-Y.current.x*12,r=-Y.current.y*12;const s=.95,o=()=>{W.current||(t*=s,r*=s,!(Math.abs(t)<.01&&Math.abs(r)<.01)&&(N(d=>{const p=d.yaw+t*.005,k=Math.PI/2.3,f=Math.max(-k,Math.min(k,d.pitch+r*.005));return{yaw:p,pitch:f}}),oe.current=requestAnimationFrame(o)))};oe.current=requestAnimationFrame(o)},[b,de]=i.useState(null),[V,xe]=i.useState({x:0,y:0,shiftX:0}),y=i.useRef(null);i.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),i.useEffect(()=>{if(!c||!H.current)return;const t=s=>{s.preventDefault();const o=-s.deltaY*.0025;A(d=>{const p=d+o;return Math.max(.5,Math.min(3,p))})},r=H.current;return r.addEventListener("wheel",t,{passive:!1}),()=>{r.removeEventListener("wheel",t)}},[c]);const C=i.useMemo(()=>{const t=[];return l.forEach((r,s)=>{(Array.isArray(r)?r:[]).forEach((o,d)=>{o&&t.push({key:o.day||`${s}-${d}`,col:s,row:d,level:o.level||0,value:o.value||0,day:o.day,models:o.models||null})})}),t},[l]),ve=j-(c?1.8:1.5),ke=c?38:28,Q=t=>Math.max(1.8,Number(t)/4*ke),te=i.useMemo(()=>{if(C.length===0)return[];const t=l.length;return C.map(r=>{const s=Q(r.level),o=Math.sqrt(Math.pow(r.col-t/2,2)+Math.pow(r.row-3.5,2)),d=Math.sqrt(Math.pow(t/2,2)+Math.pow(3.5,2)),p=o/d*.4,k=Math.min(1,Math.max(0,(fe-p)*(1/.6))),f=s*k,g=(r.col-t/2)*j,D=(r.row-3.5)*j,w=ve/2,G=[{x:g-w,y:D-w,z:0},{x:g+w,y:D-w,z:0},{x:g+w,y:D+w,z:0},{x:g-w,y:D+w,z:0},{x:g-w,y:D-w,z:f},{x:g+w,y:D-w,z:f},{x:g+w,y:D+w,z:f},{x:g-w,y:D+w,z:f}].map(B=>O(B.x,B.y,B.z,m.yaw,m.pitch)),me=O(g,D,f/2,m.yaw,m.pitch),Le=[{name:"top",indices:[4,5,6,7],scale:1,normal:[0,0,1]},{name:"bottom",indices:[3,2,1,0],scale:.4,normal:[0,0,-1]},{name:"left",indices:[3,0,4,7],scale:.55,normal:[-1,0,0]},{name:"right",indices:[1,2,6,5],scale:.75,normal:[1,0,0]},{name:"front",indices:[0,1,5,4],scale:.85,normal:[0,-1,0]},{name:"back",indices:[2,3,7,6],scale:.65,normal:[0,1,0]}],Re=S[Math.min(4,Math.max(0,Number(r.level)||0))],Ne=[],Ae=.35,De=-.4,Pe=.83;return Le.forEach(B=>{const we=lt(B.normal[0],B.normal[1],B.normal[2],m.yaw,m.pitch);if(we.z>.001){const Ce=G[B.indices[0]],ze=G[B.indices[1]],Me=G[B.indices[2]],Te=G[B.indices[3]],Ye=`M${Ce.x},${Ce.y} L${ze.x},${ze.y} L${Me.x},${Me.y} L${Te.x},${Te.y} Z`,Ue=we.x*Ae+we.y*De+we.z*Pe,Xe=h?.18:0,Be=B.scale*(.82+.28*Math.max(0,Ue))+Xe;Ne.push({name:B.name,d:Ye,fill:st(Re,Be)})}}),{...r,centerProj:me,renderedFaces:Ne}})},[C,m,S,l.length,fe,j,ve,ke]),se=i.useMemo(()=>[...te].sort((t,r)=>t.centerProj.z-r.centerProj.z),[te]),T=i.useMemo(()=>{if(se.length===0)return{minX:-100,minY:-100,maxX:100,maxY:100};let t=1/0,r=1/0,s=-1/0,o=-1/0;return se.forEach(d=>{const p=j*2,k=d.centerProj.x,f=d.centerProj.y;k-p<t&&(t=k-p),k+p>s&&(s=k+p),f-p<r&&(r=f-p),f+p>o&&(o=f+p)}),{minX:t,minY:r,maxX:s,maxY:o}},[se,j]),R=12,a=T.maxX-T.minX+R*2,u=T.maxY-T.minY+R*2,z=a/pe,v=u/pe,X=T.minX-R+(a-z)/2,I=T.minY-R+(u-v)/2,le=`${X} ${I} ${z} ${v}`;return C.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")}):e.jsxs("div",{ref:H,className:`relative select-none outline-none ${c?"cursor-grab active:cursor-grabbing w-full h-full flex items-center justify-center":"w-full overflow-hidden flex justify-center"}`,onMouseDown:t=>{if(!c)return;ce(t.clientX,t.clientY);const r=o=>U(o.clientX,o.clientY),s=()=>{be(),window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},onTouchStart:t=>{!c||t.touches.length===0||ce(t.touches[0].clientX,t.touches[0].clientY)},onTouchMove:t=>{!c||t.touches.length===0||U(t.touches[0].clientX,t.touches[0].clientY)},onTouchEnd:()=>{c&&be()},children:[e.jsxs("svg",{ref:q,viewBox:le,width:c?"95%":"100%",height:c?"95%":"auto",role:"img","aria-label":n("heatmap.iso.aria")||"3D interactive activity heatmap",style:{display:"block",width:"100%",height:"auto",maxWidth:c?"none":`${a}px`,maxHeight:c?"78vh":"none"},className:"transition-transform duration-300 ease-out",children:[c&&he.map(t=>e.jsx("path",{d:t.d,fill:"none",stroke:E,strokeWidth:.25,strokeDasharray:"1.5 2.5",strokeLinecap:"round"},t.key)),se.map(t=>{const r=b&&b.key===t.key;return e.jsxs("g",{onMouseEnter:s=>{if(y.current&&(clearTimeout(y.current),y.current=null),de(t),c&&q.current){const o=O((t.col-l.length/2)*j,(t.row-3.5)*j,Q(t.level),m.yaw,m.pitch);let d=0,p=0;const k=q.current;if(H.current&&typeof k.createSVGPoint=="function"&&typeof k.getScreenCTM=="function")try{const w=k.createSVGPoint();w.x=o.x,w.y=o.y;const ae=k.getScreenCTM();if(ae){const G=w.matrixTransform(ae),me=H.current.getBoundingClientRect();d=G.x-me.left,p=G.y-me.top}}catch{const ae=k.getBoundingClientRect(),G=T.maxX-T.minX+R*2,me=T.maxY-T.minY+R*2;d=(o.x-(T.minX-R))/G*ae.width,p=(o.y-(T.minY-R))/me*ae.height}else{const w=k.getBoundingClientRect(),ae=T.maxX-T.minX+R*2,G=T.maxY-T.minY+R*2;d=(o.x-(T.minX-R))/ae*w.width,p=(o.y-(T.minY-R))/G*w.height}const f=140;let g=0;const D=H.current?H.current.getBoundingClientRect().width:k.getBoundingClientRect().width;d<f?g=f-d:d>D-f&&(g=D-f-d),xe({x:d,y:p,shiftX:g})}},onMouseLeave:()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{de(null)},150)},className:"transition-all duration-200",style:{filter:r?"brightness(1.15) drop-shadow(0 4px 6px rgba(0,0,0,0.15))":"none",cursor:c?"pointer":"default"},children:[!c&&t.day&&e.jsx("title",{children:`${t.day}: ${Number(t.value).toLocaleString()} tokens`}),t.renderedFaces.map((s,o)=>e.jsx("path",{d:s.d,fill:s.fill,stroke:s.fill,strokeWidth:.25,strokeLinejoin:"round"},o))]},t.key)})]}),c&&b&&e.jsxs("div",{onMouseEnter:()=>{y.current&&(clearTimeout(y.current),y.current=null)},onMouseLeave:()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{de(null)},150)},className:"absolute z-[9999] w-0 h-0 transition-all duration-100 ease-out",style:{left:`${V.x}px`,top:`${V.y}px`},children:[e.jsxs("div",{className:"absolute left-0 bottom-[10px] backdrop-blur-md bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",style:{transform:`translateX(calc(-50% + ${V.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:b.day}),(()=>{const t=b.level===0?h?"#9ca3af":"#6b7280":S[b.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:t+"22",color:t,border:`1px solid ${t}44`},children:["Level ",b.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(b.value).toLocaleString()}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),b.models&&Object.keys(b.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 scrollbar-thin",children:Object.entries(b.models).map(([t,r])=>({name:t,val:Number(r)})).sort((t,r)=>r.val-t.val).map(({name:t,val:r})=>{const s=Number(b.value)||1,o=Math.round(r/s*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:t,children:t}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:r.toLocaleString()}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[o,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${o}%`,backgroundColor:S[4],boxShadow:`0 0 4px ${S[4]}55`}})})]},t)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Se(b.level,b.value)})]})]}),e.jsx("div",{className:"absolute bottom-[6px] left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-r border-b border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",style:{marginBottom:"1px"}})]})]})}const it=12,ct=3,dt=26,mt=["#ebedf0","#a7f3d0","#6ee7b7","#34d399","#10b981"],xt=["#30363d","#065f46","#059669","#10b981","#34d399"];function $e(l){const x=Number(l);return Number.isFinite(x)?x<1e3?x.toLocaleString():Oe(x,{decimals:2}):"0"}function ut(l){if(typeof l!="string")return null;const x=/^(\d{4})-(\d{2})-(\d{2})$/.exec(l.trim());if(!x)return null;const h=new Date(Date.UTC(Number(x[1]),Number(x[2])-1,Number(x[3])));return Number.isFinite(h.getTime())?h:null}function Ee(l,x){return new Date(Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()+x))}function pt(l,x){return Math.floor((Date.UTC(x.getUTCFullYear(),x.getUTCMonth(),x.getUTCDate())-Date.UTC(l.getUTCFullYear(),l.getUTCMonth(),l.getUTCDate()))/864e5)}function ht(l,x){const h=x==="mon"?1:0,c=l.getUTCDay();return Ee(l,-((c-h+7)%7))}function ft(l,x,h,c){if(!l)return[];const M=ut(x)||new Date,P=[];for(let _=11;_>=0;_-=1)P.push(new Date(Date.UTC(M.getUTCFullYear(),M.getUTCMonth()-_,1)));const $=ht(M,h),S=Ee($,-(l-1)*7),E=[],L=new Set;for(const _ of P){const m=Math.floor(pt(S,_)/7);m<0||m>=l||L.has(m)||(L.add(m),E.push({label:c[_.getUTCMonth()],index:m}))}return E}function vt({heatmap:l,timeZoneLabel:x,timeZoneShortLabel:h,hideLegend:c=!1,embedded:M=!1}){const{resolvedTheme:P}=We(),{currency:$,rate:S}=qe(),E=P==="dark",L=E?xt:mt,_=i.useRef(null),m=i.useRef(null),[N,ee]=i.useState(null),[F,pe]=i.useState({x:0,y:0,shiftX:0,flipY:!1}),A=i.useRef(null);i.useEffect(()=>()=>{A.current&&clearTimeout(A.current)},[]);const[j,he]=i.useState(!1),[q,H]=i.useState(!1),[W,ie]=i.useState(!1),Z=i.useRef(null),[Y,re]=i.useState("emerald"),oe=[n("heatmap.month.jan"),n("heatmap.month.feb"),n("heatmap.month.mar"),n("heatmap.month.apr"),n("heatmap.month.may"),n("heatmap.month.jun"),n("heatmap.month.jul"),n("heatmap.month.aug"),n("heatmap.month.sep"),n("heatmap.month.oct"),n("heatmap.month.nov"),n("heatmap.month.dec")],fe=(a,u)=>{if(!u||!u.day)return;A.current&&(clearTimeout(A.current),A.current=null),ee(u);const z=a.currentTarget.getBoundingClientRect(),v=typeof window<"u"?window.innerWidth:1024,X=z.left+z.width/2,I=z.top<300,le=I?z.bottom:z.top,t=140;let r=0;X<t?r=t-X:X>v-t&&(r=v-t-X),pe({x:X,y:le,shiftX:r,flipY:I})},ge=()=>{A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{ee(null)},150)},K=()=>{H(!1),he(!0)},ne=()=>{H(!0)},ye=a=>{a.target===a.currentTarget&&q&&(he(!1),H(!1))};i.useEffect(()=>{if(!j||q)return;const a=u=>{u.key==="Escape"&&ne()};return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[j,q]);const ce=i.useMemo(()=>({emerald:{accentText:"text-emerald-500 dark:text-emerald-400",accentBg:"bg-emerald-500/10 dark:bg-emerald-400/10",accentBorder:"border-emerald-500/20 dark:border-emerald-400/15",hoverBorder:"hover:border-emerald-500/30 dark:hover:border-emerald-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(16,185,129,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(52,211,153,0.25)]",rawColor:"#10b981"},ocean:{accentText:"text-blue-500 dark:text-blue-400",accentBg:"bg-blue-500/10 dark:bg-blue-400/10",accentBorder:"border-blue-500/20 dark:border-blue-400/15",hoverBorder:"hover:border-blue-500/30 dark:hover:border-blue-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(59,130,246,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(96,165,250,0.25)]",rawColor:"#3b82f6"},neon:{accentText:"text-purple-500 dark:text-purple-400",accentBg:"bg-purple-500/10 dark:bg-purple-400/10",accentBorder:"border-purple-500/20 dark:border-purple-400/15",hoverBorder:"hover:border-purple-500/30 dark:hover:border-purple-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(168,85,247,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(192,132,252,0.25)]",rawColor:"#a855f7"},amber:{accentText:"text-amber-500 dark:text-amber-400",accentBg:"bg-amber-500/10 dark:bg-amber-400/10",accentBorder:"border-amber-500/20 dark:border-amber-400/15",hoverBorder:"hover:border-amber-500/30 dark:hover:border-amber-400/30",hoverGlow:"hover:shadow-[0_0_20px_-3px_rgba(245,158,11,0.15)] hover:dark:shadow-[0_0_20px_-3px_rgba(245,158,11,0.25)]",rawColor:"#f59e0b"}}),[]),U=ce[Y]||ce.emerald,be=J[Y]?E?J[Y].dark:J[Y].light:E?J.emerald.dark:J.emerald.light,[b,de]=i.useState(()=>{if(M)return"2d";try{return window.localStorage?.getItem("tt:heatmap-view")==="3d"?"3d":"2d"}catch{return"2d"}});i.useEffect(()=>{if(!M)try{window.localStorage?.setItem("tt:heatmap-view",b)}catch{}},[b,M]),i.useEffect(()=>{if(b!=="2d")return;const a=_.current;a&&(a.scrollLeft=a.scrollWidth)},[l?.weeks,b]),i.useEffect(()=>{const a=_.current;if(!a)return;const u=()=>{A.current&&(clearTimeout(A.current),A.current=null),ee(null)};return a.addEventListener("scroll",u),()=>a.removeEventListener("scroll",u)},[]);const V=l?.week_starts_on==="mon"?"mon":"sun",xe=i.useMemo(()=>{const a=Array.isArray(l?.weeks)?l.weeks:[];if(!a.length)return{weeks:[]};const u=[];for(const z of a)for(const v of Array.isArray(z)?z:[])v?.day&&u.push({day:v.day,total_tokens:v.total_tokens??v.value??0,billable_total_tokens:v.billable_total_tokens??v.value??v.total_tokens??0,models:v.models??null});return Fe({dailyRows:u,weeks:Math.max(52,a.length),to:l?.to,weekStartsOn:V})},[l?.to,l?.weeks,V]),y=xe?.weeks||[],C=i.useMemo(()=>{let a=0,u=0,z={day:"无数据",value:0},v=0,X=0;const I=[];y.forEach(f=>{(Array.isArray(f)?f:[]).forEach(g=>{g&&g.day&&I.push(g)})}),I.sort((f,g)=>f.day.localeCompare(g.day)),I.forEach(f=>{const g=Number(f.value)||0;a+=g,g>0?(u++,v++,v>X&&(X=v)):v=0,g>z.value&&(z={day:f.day,value:g})});const le=I.length||365,t=(u/le*100).toFixed(1);let r="heatmap.3d.modal.ai.eval.default",s="heatmap.3d.modal.ai.title.default";a>=15e6?(s="heatmap.3d.modal.ai.title.peak",r="heatmap.3d.modal.ai.eval.peak"):a>=5e6?(s="heatmap.3d.modal.ai.title.heavy",r="heatmap.3d.modal.ai.eval.heavy"):a>=1e6?(s="heatmap.3d.modal.ai.title.core",r="heatmap.3d.modal.ai.eval.core"):a>=2e4&&(s="heatmap.3d.modal.ai.title.steady",r="heatmap.3d.modal.ai.eval.steady");const o=l?.total_cost_usd,d=Number(o),k=o!=null&&(typeof o!="string"||o.trim()!=="")&&Number.isFinite(d)?d:a/15e5;return{totalTokens:a,activeDays:u,activeRate:t,maxSingleDay:z,maxStreak:X,aiEvaluationTitleKey:s,aiEvaluationKey:r,totalCostUsd:k}},[y,l?.total_cost_usd]),je=i.useMemo(()=>He(C.totalCostUsd,{currency:$,rate:S}),[C.totalCostUsd,$,S]),ve=V==="mon"?["Mon","Tue","Wed","Thu","Fri","Sat","Sun"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)):["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(a=>n(`heatmap.day.${a.toLowerCase()}`)),ke=i.useMemo(()=>ft(y.length,xe?.to,V,oe),[xe?.to,y.length,V,oe]);if(!y.length)return e.jsx("div",{className:"py-8 text-center text-sm text-oai-gray-500",children:n("heatmap.empty")});const Q=M?10:it,te=M?2:ct,se=M?22:dt,T=se+y.length*Q+Math.max(0,y.length-1)*te,R=`${se}px repeat(${y.length}, ${Q}px)`;return e.jsxs("div",{ref:m,className:M?"relative":"relative rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",children:[!M&&e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:n("heatmap.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{role:"tablist","aria-label":"Heatmap view",className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[10px]",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":b==="2d",onClick:()=>de("2d"),className:b==="2d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.2d")}),e.jsx("button",{type:"button",role:"tab","aria-selected":b==="3d",onClick:()=>de("3d"),className:b==="3d"?"px-2 py-0.5 rounded bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"px-2 py-0.5 rounded text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200",children:n("heatmap.view.3d")})]}),e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-450",children:h||n("heatmap.legend.utc")})]})]}),b==="3d"&&e.jsxs("div",{onClick:K,className:"cursor-pointer group relative overflow-hidden rounded-lg hover:border-oai-gray-350 dark:hover:border-oai-gray-700 border border-transparent transition-all",title:n("heatmap.3d.hover_tip"),children:[e.jsx(_e,{weeks:y,isDark:E,palette:Y}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-oai-gray-900/5 to-transparent pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity flex items-end justify-center pb-2",children:e.jsxs("span",{className:"text-[10px] bg-white/95 dark:bg-oai-gray-900/95 shadow border border-oai-gray-200/60 dark:border-oai-gray-800/80 px-2.5 py-1 rounded-full font-medium text-oai-gray-500 dark:text-oai-gray-400 flex items-center gap-1 transform translate-y-2 group-hover:translate-y-0 transition-transform duration-200",children:[e.jsx(Ve,{size:9}),n("heatmap.3d.hover_tip")]})})]}),b==="2d"&&e.jsx("div",{ref:_,className:"overflow-x-auto overflow-y-hidden heatmap-scroll-thin",children:e.jsxs("div",{style:{minWidth:T},children:[e.jsxs("div",{className:"grid text-[10px] uppercase text-oai-gray-400 dark:text-oai-gray-400 mb-1",style:{gridTemplateColumns:R,columnGap:te},children:[e.jsx("span",{}),ke.map(a=>e.jsx("span",{style:{gridColumnStart:a.index+2},className:"whitespace-nowrap",children:a.label},`${a.label}-${a.index}`))]}),e.jsxs("div",{className:"grid",style:{gridTemplateColumns:R,columnGap:te},children:[e.jsx("div",{className:"grid text-[10px] text-oai-gray-400 dark:text-oai-gray-400 sticky left-0 bg-white dark:bg-oai-gray-900 pr-2",style:{gridTemplateRows:`repeat(7, ${Q}px)`,rowGap:te},children:ve.map(a=>e.jsx("span",{className:"leading-none",children:a},a))}),e.jsx("div",{className:"grid",style:{gridAutoFlow:"column",gridTemplateRows:`repeat(7, ${Q}px)`,gap:te},children:y.map((a,u)=>(Array.isArray(a)?a:[]).map((z,v)=>{if(!z)return null;const X=z.day||`e-${u}-${v}`,I=Number(z.level)||0,le=L[I]||L[0];return e.jsx("span",{onMouseEnter:t=>fe(t,z),onMouseLeave:ge,className:"rounded-[2px] transition-transform hover:scale-125 hover:z-10 cursor-pointer",style:{width:Q,height:Q,background:le}},X)}))})]})]})}),!c&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-3",children:[e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.less")}),e.jsx("div",{className:"flex gap-0.5",children:L.map((a,u)=>e.jsx("span",{className:"rounded-[1px]",style:{width:10,height:10,background:a}},u))}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-400",children:n("heatmap.legend.more")})]}),j&&e.jsx("div",{onAnimationEnd:ye,onClick:a=>{a.target===a.currentTarget&&ne()},className:`fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40 ${q?"animate-tt-fade-out":"animate-tt-fade-in"}`,children:e.jsxs("div",{className:`relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden ${q?"animate-tt-modal-exit":"animate-tt-modal"}`,children:[e.jsx("button",{type:"button",onClick:ne,className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:e.jsx(Ie,{size:16})}),e.jsxs("div",{className:"w-full md:w-[340px] border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:U.rawColor}}),e.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:U.rawColor}})]}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:"3D Insight"})]}),e.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:n("heatmap.3d.modal.title")}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:n("heatmap.3d.modal.desc")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[e.jsxs("div",{className:"flex flex-col gap-1 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_total_tokens")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[C.totalTokens.toLocaleString()," Tokens"]})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.total_tokens")}),e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:$e(C.totalTokens)}),e.jsx("div",{className:"opacity-30 group-hover:opacity-60 transition-opacity",children:e.jsx("svg",{width:"24",height:"10",viewBox:"0 0 24 10",fill:"none",children:e.jsx("path",{d:"M1 9C3 7 5 7 7 4C9 1 11 0 13 2C15 4 17 0 23 0",stroke:U.rawColor,strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.estimated_cost")}),e.jsx("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:je})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.active_rate_days")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.activeRate,"% ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",C.activeDays,"D)"]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 group cursor-default",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.max_streak")}),e.jsxs("span",{className:"text-xl font-black text-amber-500 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.maxStreak," ",e.jsx("span",{className:"text-[10px] font-bold text-amber-500/80 font-mono",children:n("heatmap.3d.modal.stats.days_suffix")})]})]}),e.jsxs("div",{className:"flex flex-col gap-1 col-span-2 relative group cursor-help",children:[e.jsx("div",{className:"absolute left-0 bottom-full mb-2 pointer-events-none opacity-0 translate-y-1 group-hover:opacity-100 group-hover:translate-y-0 transition-all duration-200 z-50",children:e.jsxs("div",{className:"bg-white dark:bg-zinc-950 text-zinc-900 dark:text-zinc-50 text-[10px] font-semibold font-mono rounded-lg px-2.5 py-1.5 shadow-xl border border-zinc-200 dark:border-zinc-800/80 whitespace-nowrap flex flex-col",children:[e.jsx("span",{className:"text-[9px] text-zinc-400 dark:text-zinc-500",children:n("heatmap.3d.modal.stats.precision_peak_value")}),e.jsxs("span",{className:"mt-0.5 font-bold text-zinc-900 dark:text-zinc-50",children:[C.maxSingleDay.value>0?C.maxSingleDay.value.toLocaleString():n("heatmap.3d.modal.stats.no_data")," Tokens"]}),e.jsx("span",{className:"text-[8px] text-zinc-400 dark:text-zinc-500 mt-0.5",children:C.maxSingleDay.day!=="无数据"?C.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data")})]})}),e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.stats.peak_day")}),e.jsxs("span",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight font-mono transition-transform duration-200 group-hover:-translate-y-[1px]",children:[C.maxSingleDay.value>0?$e(C.maxSingleDay.value):n("heatmap.3d.modal.stats.no_data")," ",e.jsxs("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono",children:["(",C.maxSingleDay.day!=="无数据"?C.maxSingleDay.day:n("heatmap.3d.modal.stats.no_data"),")"]})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-2.5 py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[e.jsx(nt,{size:11,style:{color:U.rawColor}}),e.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:U.rawColor},children:n(C.aiEvaluationTitleKey)})]}),e.jsxs("div",{className:"pl-3.5 border-l-2 relative transition-all duration-300 group",style:{borderColor:U.rawColor},children:[e.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:U.rawColor}}),e.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:n(C.aiEvaluationKey)})]})]}),e.jsx("div",{className:"mt-auto border-t border-zinc-200/50 dark:border-zinc-800/50 pt-4 select-none",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[9px] font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest font-mono",children:n("heatmap.3d.modal.legend.title")}),e.jsx("span",{className:"text-[10px] font-medium text-zinc-500 dark:text-zinc-400",children:n(`heatmap.3d.modal.palette.${Y}`)})]}),e.jsx("div",{className:"flex gap-1",children:be.map((a,u)=>e.jsx("div",{className:"flex-1 h-1 rounded-[2px]",style:{backgroundColor:a},title:`Level ${u}`},u))})]})})]}),e.jsxs("div",{className:"flex-1 h-full relative flex items-center justify-center overflow-hidden p-4",children:[e.jsx("div",{className:"absolute top-1/4 left-1/3 w-96 h-96 rounded-full blur-[130px] pointer-events-none -translate-x-1/2 -translate-y-1/2 transition-all duration-500",style:{backgroundColor:U.rawColor+"15"}}),e.jsx("div",{className:"absolute bottom-1/4 right-1/3 w-80 h-80 rounded-full blur-[120px] pointer-events-none translate-x-1/2 translate-y-1/2 bg-purple-500/[0.04] dark:bg-purple-500/[0.08]"}),e.jsxs("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 flex items-center gap-3 p-1.5 backdrop-blur-md bg-white/70 dark:bg-oai-gray-900/75 border border-oai-gray-200/60 dark:border-oai-gray-800/80 rounded-full shadow-lg z-30 select-none",children:[e.jsx("div",{className:"flex items-center gap-1.5 px-2",children:Object.keys(ce).map(a=>{const u=Y===a;return e.jsx("button",{type:"button",onClick:()=>re(a),title:n(`heatmap.3d.modal.palette.${a}`),className:`w-3.5 h-3.5 rounded-full transition-all duration-200 relative hover:scale-125 ${a==="emerald"?"bg-[#10b981]":a==="ocean"?"bg-[#3b82f6]":a==="neon"?"bg-[#a855f7]":"bg-[#f59e0b]"}`,children:u&&e.jsx("span",{className:"absolute inset-0 rounded-full ring-2 ring-offset-1 ring-offset-white dark:ring-offset-oai-gray-900 ring-oai-gray-900 dark:ring-white scale-110"})},a)})}),e.jsx("div",{className:"w-[1px] h-4 bg-oai-gray-200 dark:bg-oai-gray-800"}),e.jsxs("div",{className:"flex items-center gap-1 pr-1",children:[e.jsx("button",{type:"button",onClick:()=>{const a=!W;ie(a),Z.current&&Z.current.toggleAutoRotate(a)},title:W?n("heatmap.3d.modal.control.pause"):n("heatmap.3d.modal.control.play"),className:`p-1.5 rounded-full transition-all duration-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 ${W?U.accentText:"text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250"}`,children:W?e.jsx(Je,{size:12}):e.jsx(tt,{size:12})}),e.jsx("button",{type:"button",onClick:()=>{ie(!1),Z.current&&Z.current.reset()},title:n("heatmap.3d.modal.control.reset"),className:"p-1.5 rounded-full text-oai-gray-400 hover:text-oai-gray-600 dark:hover:text-oai-gray-250 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-all duration-200",children:e.jsx(rt,{size:12})})]})]}),e.jsx(_e,{weeks:y,isDark:E,interactive:!0,palette:Y,autoRotateInit:W,onResetViewRef:Z}),e.jsxs("div",{className:"absolute bottom-4 right-4 flex items-center gap-1.5 text-[9px] font-bold text-oai-gray-400 bg-white/80 dark:bg-oai-gray-900/80 border border-oai-gray-200/50 dark:border-oai-gray-800/80 rounded-md px-2.5 py-1.5 select-none pointer-events-none backdrop-blur-md shadow-sm",children:[e.jsx(Ze,{size:10,className:U.accentText}),e.jsx("span",{children:n("heatmap.3d.modal.footer.tip")})]})]})]})}),N&&!j&&typeof document<"u"&&Ge.createPortal(e.jsxs("div",{className:"fixed z-[9999] w-0 h-0 transition-all duration-100 ease-out pointer-events-none",style:{position:"fixed",left:`${F.x}px`,top:`${F.y}px`},children:[e.jsxs("div",{className:`absolute left-0 ${F.flipY?"top-[10px]":"bottom-[10px]"} backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[200px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100`,style:{transform:`translateX(calc(-50% + ${F.shiftX}px))`},children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:N.day}),(()=>{const a=N.level===0?E?"#9ca3af":"#6b7280":L[N.level];return e.jsxs("span",{className:"text-[10px] px-2 py-0.5 rounded-full font-medium",style:{backgroundColor:a+"22",color:a,border:`1px solid ${a}44`},children:["Level ",N.level]})})()]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:Number(N.total_tokens??N.value).toLocaleString()}),e.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:"Tokens"})]}),N.models&&Object.keys(N.models).length>0?e.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[e.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:"Model Breakdown"}),e.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:Object.entries(N.models).map(([a,u])=>({name:a,val:Number(u)})).sort((a,u)=>u.val-a.val).map(({name:a,val:u})=>{const z=Number(N.total_tokens??N.value)||1,v=Math.round(u/z*100);return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[e.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[120px]",title:a,children:a}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:u.toLocaleString()}),e.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[v,"%"]})]})]}),e.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${v}%`,backgroundColor:L[4],boxShadow:`0 0 4px ${L[4]}55`}})})]},a)})})]}):e.jsx("p",{className:"text-[11px] text-oai-gray-600 dark:text-oai-gray-300 leading-relaxed font-normal mt-1 border-t border-dashed border-oai-gray-100 dark:border-oai-gray-800/60 pt-1.5",children:Se(N.level,N.total_tokens??N.value)})]})]}),e.jsx("div",{className:`absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 shadow-sm ${F.flipY?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"} border-oai-gray-200/50 dark:border-oai-gray-800/50`,style:F.flipY?{marginTop:"1px"}:{marginBottom:"1px"}})]}),document.body),e.jsx("style",{children:`
2
2
  @keyframes tt-fade-in {
3
3
  from { opacity: 0; }
4
4
  to { opacity: 1; }
@@ -1 +1 @@
1
- import{j as r}from"./main-B0LYKUIY.js";function t({children:i,title:a,subtitle:o,className:s="",bodyClassName:d=""}){return r.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${s}`,children:[(a||o)&&r.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[a&&r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:a}),o&&r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:o})]}),r.jsx("div",{className:`p-5 ${d}`,children:i})]})}export{t as C};
1
+ import{j as r}from"./main-Dxi4sSXf.js";function t({children:i,title:a,subtitle:o,className:s="",bodyClassName:d=""}){return r.jsxs("div",{className:`rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 transition-colors duration-200 ${s}`,children:[(a||o)&&r.jsxs("div",{className:"px-5 py-4 border-b border-oai-gray-200 dark:border-oai-gray-800 transition-colors duration-200",children:[a&&r.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide transition-colors duration-200",children:a}),o&&r.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-300 mt-1 transition-colors duration-200",children:o})]}),r.jsx("div",{className:`p-5 ${d}`,children:i})]})}export{t as C};
@@ -1 +1 @@
1
- import{j as a,X as y,N as e,$ as b}from"./main-B0LYKUIY.js";import{f as d}from"./format-tokens-Ck5lRlFd.js";import{D as h,a as f,b as v,c as k,d as N,e as j}from"./DialogTitle-Cvpx9Lfv.js";import{D}from"./DialogClose-CddI1gcT.js";import{D as w}from"./DialogDescription-DeEet5bz.js";import"./useScrollLock-C4eBSnib.js";const E=1.75,M=[[/claude|fable|opus|sonnet|haiku/,{provider:"CLAUDE",color:"#d97757"}],[/gpt|codex|o3|o4/,{provider:"CODEX",color:"#3b82f6"}],[/gemini/,{provider:"GEMINI",color:"#2196f3"}],[/composer|cursor/,{provider:"CURSOR",color:"#10b981"}],[/kimi/,{provider:"KIMI",color:"#a78bfa"}],[/mimo/,{provider:"MIMO",color:"#ff6900"}],[/copilot/,{provider:"COPILOT",color:"#6366f1"}],[/kiro/,{provider:"KIRO",color:"#6366f1"}],[/grok/,{provider:"GROK",color:"#f43f5e"}],[/deepseek/,{provider:"DEEPSEEK",color:"#4D6BFE"}],[/glm/,{provider:"ZCODE",color:"#14b8a6"}],[/hy3/,{provider:"WORKBUDDY",color:"#0ea5e9"}],[/minimax/,{provider:"MINIMAX",color:"#f59e0b"}]];function _(i){const l=(i||"").toLowerCase(),t=M.find(([o])=>o.test(l));return t?t[1]:{provider:"",color:"#9ca3af"}}function c({label:i,value:l,title:t,className:o=""}){return a.jsxs("div",{className:`flex min-w-0 flex-col gap-1.5 ${o}`,title:t,children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:i}),a.jsx("span",{className:"truncate text-2xl font-semibold leading-none tracking-tight text-oai-black dark:text-white tabular-nums",children:l})]})}function U({isOpen:i,onClose:l,communityStats:t}){if(!t||t.status!=="ready")return null;const o=Number(t.tokenFloor)||0,m=Number(t.totalEntries)||0,x=o/1e6*E,s=Array.isArray(t.topModels)?t.topModels.slice(0,10):[],u=s.reduce((r,n)=>Math.max(r,Number(n.share)||0),0)||1;return a.jsx(h,{open:i,onOpenChange:r=>!r&&l(),children:a.jsxs(f,{children:[a.jsx(v,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(k,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(N,{className:"relative flex w-full max-w-md flex-col gap-5 max-h-[85vh] overflow-y-auto rounded-2xl bg-white p-6 shadow-2xl ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-900 dark:ring-oai-gray-800",children:[a.jsx(D,{className:"absolute top-4 right-4 p-1.5 rounded-lg text-oai-gray-400 dark:text-oai-gray-500 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors cursor-pointer","aria-label":e("shared.dialog.close"),children:a.jsx(y,{className:"size-4"})}),a.jsxs("div",{className:"pr-8",children:[a.jsx(j,{className:"text-lg font-bold tracking-tight text-oai-black dark:text-white",children:e("leaderboard.community.modal.title")}),a.jsx(w,{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.description")})]}),a.jsxs("div",{className:"grid grid-cols-3 divide-x divide-oai-gray-100 border-y border-oai-gray-100 py-4 dark:divide-oai-gray-800/80 dark:border-oai-gray-800/80",children:[a.jsx(c,{className:"pr-4",label:e("leaderboard.community.modal.total_tokens"),value:d(o),title:e("leaderboard.community.modal.tokens_title",{count:o.toLocaleString("en-US")})}),a.jsx(c,{className:"px-4",label:e("leaderboard.community.modal.active_devs"),value:m.toLocaleString("en-US"),title:e("leaderboard.community.modal.active_devs_detail",{count:m.toLocaleString("en-US")})}),a.jsx(c,{className:"pl-4",label:e("leaderboard.community.modal.global_spend"),value:`$${d(x)}`,title:e("leaderboard.community.modal.global_spend_detail",{amount:Math.round(x).toLocaleString("en-US")})})]}),s.length>0&&a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.top_models")}),a.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.all_time")})]}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map((r,n)=>{const p=_(r.name),g=Number(r.share)||0;return a.jsxs("div",{className:"relative flex h-9 items-center gap-2.5 overflow-hidden px-2.5",children:[a.jsx("div",{className:"absolute inset-y-0 left-0",style:{width:`${Math.max(g/u*100,2)}%`,backgroundColor:`${p.color}24`},"aria-hidden":"true"}),a.jsx("span",{className:"relative w-4 shrink-0 text-right font-mono text-[11px] text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:n+1}),a.jsx(b,{provider:p.provider,size:15,className:"relative shrink-0 text-oai-gray-500 dark:text-oai-gray-400"}),a.jsx("span",{className:"relative min-w-0 flex-1 truncate text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-200",title:r.name,children:r.name}),a.jsx("span",{className:"relative shrink-0 text-xs font-semibold text-oai-black dark:text-white tabular-nums",title:e("leaderboard.community.modal.tokens_title",{count:Number(r.tokens).toLocaleString("en-US")}),children:d(r.tokens)}),a.jsxs("span",{className:"relative w-11 shrink-0 text-right text-[11px] text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:[g,"%"]})]},r.name)})})]}),a.jsx("p",{className:"text-[11px] leading-normal text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.note")})]})})]})})}export{U as CommunityStatsModal};
1
+ import{j as a,X as y,N as e,$ as b}from"./main-Dxi4sSXf.js";import{f as d}from"./format-tokens-CtFO_jkz.js";import{D as h,a as f,b as v,c as k,d as N,e as j}from"./DialogTitle-v1JrTvr4.js";import{D}from"./DialogClose-DEfesqFq.js";import{D as w}from"./DialogDescription-D6txiEc4.js";import"./useScrollLock-DK-ndHcw.js";const E=1.75,M=[[/claude|fable|opus|sonnet|haiku/,{provider:"CLAUDE",color:"#d97757"}],[/gpt|codex|o3|o4/,{provider:"CODEX",color:"#3b82f6"}],[/gemini/,{provider:"GEMINI",color:"#2196f3"}],[/composer|cursor/,{provider:"CURSOR",color:"#10b981"}],[/kimi/,{provider:"KIMI",color:"#a78bfa"}],[/mimo/,{provider:"MIMO",color:"#ff6900"}],[/copilot/,{provider:"COPILOT",color:"#6366f1"}],[/kiro/,{provider:"KIRO",color:"#6366f1"}],[/grok/,{provider:"GROK",color:"#f43f5e"}],[/deepseek/,{provider:"DEEPSEEK",color:"#4D6BFE"}],[/glm/,{provider:"ZCODE",color:"#14b8a6"}],[/hy3/,{provider:"WORKBUDDY",color:"#0ea5e9"}],[/minimax/,{provider:"MINIMAX",color:"#f59e0b"}]];function _(i){const l=(i||"").toLowerCase(),t=M.find(([o])=>o.test(l));return t?t[1]:{provider:"",color:"#9ca3af"}}function c({label:i,value:l,title:t,className:o=""}){return a.jsxs("div",{className:`flex min-w-0 flex-col gap-1.5 ${o}`,title:t,children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:i}),a.jsx("span",{className:"truncate text-2xl font-semibold leading-none tracking-tight text-oai-black dark:text-white tabular-nums",children:l})]})}function U({isOpen:i,onClose:l,communityStats:t}){if(!t||t.status!=="ready")return null;const o=Number(t.tokenFloor)||0,m=Number(t.totalEntries)||0,x=o/1e6*E,s=Array.isArray(t.topModels)?t.topModels.slice(0,10):[],u=s.reduce((r,n)=>Math.max(r,Number(n.share)||0),0)||1;return a.jsx(h,{open:i,onOpenChange:r=>!r&&l(),children:a.jsxs(f,{children:[a.jsx(v,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(k,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(N,{className:"relative flex w-full max-w-md flex-col gap-5 max-h-[85vh] overflow-y-auto rounded-2xl bg-white p-6 shadow-2xl ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-900 dark:ring-oai-gray-800",children:[a.jsx(D,{className:"absolute top-4 right-4 p-1.5 rounded-lg text-oai-gray-400 dark:text-oai-gray-500 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 hover:text-oai-black dark:hover:text-white transition-colors cursor-pointer","aria-label":e("shared.dialog.close"),children:a.jsx(y,{className:"size-4"})}),a.jsxs("div",{className:"pr-8",children:[a.jsx(j,{className:"text-lg font-bold tracking-tight text-oai-black dark:text-white",children:e("leaderboard.community.modal.title")}),a.jsx(w,{className:"mt-1 text-xs text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.description")})]}),a.jsxs("div",{className:"grid grid-cols-3 divide-x divide-oai-gray-100 border-y border-oai-gray-100 py-4 dark:divide-oai-gray-800/80 dark:border-oai-gray-800/80",children:[a.jsx(c,{className:"pr-4",label:e("leaderboard.community.modal.total_tokens"),value:d(o),title:e("leaderboard.community.modal.tokens_title",{count:o.toLocaleString("en-US")})}),a.jsx(c,{className:"px-4",label:e("leaderboard.community.modal.active_devs"),value:m.toLocaleString("en-US"),title:e("leaderboard.community.modal.active_devs_detail",{count:m.toLocaleString("en-US")})}),a.jsx(c,{className:"pl-4",label:e("leaderboard.community.modal.global_spend"),value:`$${d(x)}`,title:e("leaderboard.community.modal.global_spend_detail",{amount:Math.round(x).toLocaleString("en-US")})})]}),s.length>0&&a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.top_models")}),a.jsx("span",{className:"text-[10px] text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.all_time")})]}),a.jsx("div",{className:"flex flex-col gap-0.5",children:s.map((r,n)=>{const p=_(r.name),g=Number(r.share)||0;return a.jsxs("div",{className:"relative flex h-9 items-center gap-2.5 overflow-hidden px-2.5",children:[a.jsx("div",{className:"absolute inset-y-0 left-0",style:{width:`${Math.max(g/u*100,2)}%`,backgroundColor:`${p.color}24`},"aria-hidden":"true"}),a.jsx("span",{className:"relative w-4 shrink-0 text-right font-mono text-[11px] text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:n+1}),a.jsx(b,{provider:p.provider,size:15,className:"relative shrink-0 text-oai-gray-500 dark:text-oai-gray-400"}),a.jsx("span",{className:"relative min-w-0 flex-1 truncate text-[13px] font-medium text-oai-gray-700 dark:text-oai-gray-200",title:r.name,children:r.name}),a.jsx("span",{className:"relative shrink-0 text-xs font-semibold text-oai-black dark:text-white tabular-nums",title:e("leaderboard.community.modal.tokens_title",{count:Number(r.tokens).toLocaleString("en-US")}),children:d(r.tokens)}),a.jsxs("span",{className:"relative w-11 shrink-0 text-right text-[11px] text-oai-gray-400 dark:text-oai-gray-500 tabular-nums",children:[g,"%"]})]},r.name)})})]}),a.jsx("p",{className:"text-[11px] leading-normal text-oai-gray-400 dark:text-oai-gray-500",children:e("leaderboard.community.modal.note")})]})})]})})}export{U as CommunityStatsModal};
@@ -1 +1 @@
1
- import{j as a,T as i,a0 as x}from"./main-B0LYKUIY.js";import{D as p,a as m,b as y,c as b,d as f,e as u}from"./DialogTitle-Cvpx9Lfv.js";import{D as h}from"./DialogDescription-DeEet5bz.js";function _({open:r,title:l,description:t,confirmLabel:o,cancelLabel:n,destructive:d=!1,busy:e=!1,onConfirm:c,onCancel:s}){return a.jsx(p,{open:r,onOpenChange:g=>{!g&&!e&&s?.()},children:a.jsxs(m,{children:[a.jsx(y,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(b,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(f,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[a.jsx(u,{className:"text-base font-semibold text-oai-black dark:text-white",children:l}),t?a.jsx(h,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t}):null,a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx(i,{type:"button",variant:"secondary",size:"sm",disabled:e,onClick:()=>s?.(),children:n}),a.jsx(i,{type:"button",size:"sm",disabled:e,onClick:()=>c?.(),className:x(d&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:o})]})]})})]})})}export{_ as C};
1
+ import{j as a,T as i,a0 as x}from"./main-Dxi4sSXf.js";import{D as p,a as m,b as y,c as b,d as f,e as u}from"./DialogTitle-v1JrTvr4.js";import{D as h}from"./DialogDescription-D6txiEc4.js";function _({open:r,title:l,description:t,confirmLabel:o,cancelLabel:n,destructive:d=!1,busy:e=!1,onConfirm:c,onCancel:s}){return a.jsx(p,{open:r,onOpenChange:g=>{!g&&!e&&s?.()},children:a.jsxs(m,{children:[a.jsx(y,{className:"fixed inset-0 z-[100] bg-black/40 backdrop-blur-[2px] transition-opacity duration-200 ease-out data-[ending-style]:opacity-0 data-[starting-style]:opacity-0"}),a.jsx(b,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:a.jsxs(f,{className:"relative w-full max-w-md rounded-2xl bg-white p-6 shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] ring-1 ring-oai-gray-200 transition-[opacity,transform] duration-[220ms] ease-[cubic-bezier(0.16,1,0.3,1)] data-[ending-style]:translate-y-2 data-[ending-style]:scale-[0.96] data-[ending-style]:opacity-0 data-[starting-style]:translate-y-2 data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0 dark:bg-oai-gray-950 dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)] dark:ring-oai-gray-800",children:[a.jsx(u,{className:"text-base font-semibold text-oai-black dark:text-white",children:l}),t?a.jsx(h,{className:"mt-2 text-sm leading-6 text-oai-gray-600 dark:text-oai-gray-300",children:t}):null,a.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[a.jsx(i,{type:"button",variant:"secondary",size:"sm",disabled:e,onClick:()=>s?.(),children:n}),a.jsx(i,{type:"button",size:"sm",disabled:e,onClick:()=>c?.(),className:x(d&&"!bg-red-600 hover:!bg-red-700 focus-visible:!outline-red-600 dark:!bg-red-600 dark:hover:!bg-red-500"),children:o})]})]})})]})})}export{_ as C};