libre-webui 0.29.0 → 0.31.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 (261) hide show
  1. package/backend/dist/index.d.ts.map +1 -1
  2. package/backend/dist/index.js +24 -7
  3. package/backend/dist/index.js.map +1 -1
  4. package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts +9 -0
  5. package/backend/dist/persistence/postgresAutomationWebhooksMigration.d.ts.map +1 -0
  6. package/backend/dist/persistence/postgresAutomationWebhooksMigration.js +38 -0
  7. package/backend/dist/persistence/postgresAutomationWebhooksMigration.js.map +1 -0
  8. package/backend/dist/persistence/postgresMigrationRegistry.d.ts.map +1 -1
  9. package/backend/dist/persistence/postgresMigrationRegistry.js +4 -0
  10. package/backend/dist/persistence/postgresMigrationRegistry.js.map +1 -1
  11. package/backend/dist/persistence/postgresResourceRepositories.d.ts.map +1 -1
  12. package/backend/dist/persistence/postgresResourceRepositories.js +5 -0
  13. package/backend/dist/persistence/postgresResourceRepositories.js.map +1 -1
  14. package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts +13 -0
  15. package/backend/dist/persistence/postgresWorkApprovalsMigration.d.ts.map +1 -0
  16. package/backend/dist/persistence/postgresWorkApprovalsMigration.js +69 -0
  17. package/backend/dist/persistence/postgresWorkApprovalsMigration.js.map +1 -0
  18. package/backend/dist/persistence/resourceTypes.d.ts +4 -0
  19. package/backend/dist/persistence/resourceTypes.d.ts.map +1 -1
  20. package/backend/dist/persistence/resourceTypes.js.map +1 -1
  21. package/backend/dist/persistence/sqliteMigrations.d.ts +3 -0
  22. package/backend/dist/persistence/sqliteMigrations.d.ts.map +1 -1
  23. package/backend/dist/persistence/sqliteMigrations.js +156 -2
  24. package/backend/dist/persistence/sqliteMigrations.js.map +1 -1
  25. package/backend/dist/persistence/sqliteResourceRepositories.d.ts.map +1 -1
  26. package/backend/dist/persistence/sqliteResourceRepositories.js +7 -0
  27. package/backend/dist/persistence/sqliteResourceRepositories.js.map +1 -1
  28. package/backend/dist/persistence/sqliteToPostgresMigration.d.ts.map +1 -1
  29. package/backend/dist/persistence/sqliteToPostgresMigration.js +32 -1
  30. package/backend/dist/persistence/sqliteToPostgresMigration.js.map +1 -1
  31. package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts +10 -1
  32. package/backend/dist/platform/workPersistence/postgresWorkPersistence.d.ts.map +1 -1
  33. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js +85 -5
  34. package/backend/dist/platform/workPersistence/postgresWorkPersistence.js.map +1 -1
  35. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts +10 -1
  36. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.d.ts.map +1 -1
  37. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js +67 -7
  38. package/backend/dist/platform/workPersistence/sqliteWorkPersistence.js.map +1 -1
  39. package/backend/dist/platform/workPersistence/types.d.ts +37 -0
  40. package/backend/dist/platform/workPersistence/types.d.ts.map +1 -1
  41. package/backend/dist/platform/workPersistence/types.js.map +1 -1
  42. package/backend/dist/routes/automations.d.ts.map +1 -1
  43. package/backend/dist/routes/automations.js +83 -1
  44. package/backend/dist/routes/automations.js.map +1 -1
  45. package/backend/dist/routes/ollama.d.ts.map +1 -1
  46. package/backend/dist/routes/ollama.js +64 -0
  47. package/backend/dist/routes/ollama.js.map +1 -1
  48. package/backend/dist/routes/plugins.d.ts.map +1 -1
  49. package/backend/dist/routes/plugins.js +90 -0
  50. package/backend/dist/routes/plugins.js.map +1 -1
  51. package/backend/dist/routes/work.d.ts.map +1 -1
  52. package/backend/dist/routes/work.js +83 -0
  53. package/backend/dist/routes/work.js.map +1 -1
  54. package/backend/dist/services/authService.d.ts +2 -0
  55. package/backend/dist/services/authService.d.ts.map +1 -1
  56. package/backend/dist/services/authService.js +2 -0
  57. package/backend/dist/services/authService.js.map +1 -1
  58. package/backend/dist/services/automationService.d.ts +13 -1
  59. package/backend/dist/services/automationService.d.ts.map +1 -1
  60. package/backend/dist/services/automationService.js +31 -0
  61. package/backend/dist/services/automationService.js.map +1 -1
  62. package/backend/dist/services/notificationService.d.ts.map +1 -1
  63. package/backend/dist/services/notificationService.js +1 -0
  64. package/backend/dist/services/notificationService.js.map +1 -1
  65. package/backend/dist/services/ollamaService.d.ts +12 -0
  66. package/backend/dist/services/ollamaService.d.ts.map +1 -1
  67. package/backend/dist/services/ollamaService.js +26 -0
  68. package/backend/dist/services/ollamaService.js.map +1 -1
  69. package/backend/dist/services/ollamaSettingsService.d.ts +10 -0
  70. package/backend/dist/services/ollamaSettingsService.d.ts.map +1 -0
  71. package/backend/dist/services/ollamaSettingsService.js +83 -0
  72. package/backend/dist/services/ollamaSettingsService.js.map +1 -0
  73. package/backend/dist/services/workAgentGuidance.d.ts +11 -0
  74. package/backend/dist/services/workAgentGuidance.d.ts.map +1 -1
  75. package/backend/dist/services/workAgentGuidance.js +16 -2
  76. package/backend/dist/services/workAgentGuidance.js.map +1 -1
  77. package/backend/dist/services/workAgentService.d.ts +56 -0
  78. package/backend/dist/services/workAgentService.d.ts.map +1 -1
  79. package/backend/dist/services/workAgentService.js +467 -17
  80. package/backend/dist/services/workAgentService.js.map +1 -1
  81. package/backend/dist/services/workApprovalService.d.ts +67 -0
  82. package/backend/dist/services/workApprovalService.d.ts.map +1 -0
  83. package/backend/dist/services/workApprovalService.js +273 -0
  84. package/backend/dist/services/workApprovalService.js.map +1 -0
  85. package/backend/dist/services/workEventService.d.ts.map +1 -1
  86. package/backend/dist/services/workEventService.js +25 -0
  87. package/backend/dist/services/workEventService.js.map +1 -1
  88. package/backend/dist/services/workPolicyService.d.ts +4 -0
  89. package/backend/dist/services/workPolicyService.d.ts.map +1 -1
  90. package/backend/dist/services/workPolicyService.js +19 -0
  91. package/backend/dist/services/workPolicyService.js.map +1 -1
  92. package/backend/dist/services/workRuntimeShared.d.ts +2 -0
  93. package/backend/dist/services/workRuntimeShared.d.ts.map +1 -1
  94. package/backend/dist/services/workRuntimeShared.js.map +1 -1
  95. package/backend/dist/services/workTaskService.d.ts +3 -1
  96. package/backend/dist/services/workTaskService.d.ts.map +1 -1
  97. package/backend/dist/services/workTaskService.js +21 -4
  98. package/backend/dist/services/workTaskService.js.map +1 -1
  99. package/backend/dist/types/index.d.ts +3 -1
  100. package/backend/dist/types/index.d.ts.map +1 -1
  101. package/backend/dist/types/index.js.map +1 -1
  102. package/backend/dist/types/work.d.ts +32 -11
  103. package/backend/dist/types/work.d.ts.map +1 -1
  104. package/backend/dist/websocketServer.d.ts.map +1 -1
  105. package/backend/dist/websocketServer.js +14 -2
  106. package/backend/dist/websocketServer.js.map +1 -1
  107. package/backend/package.json +2 -2
  108. package/deploy/work-computer/Dockerfile +1 -0
  109. package/deploy/work-computer/tint2rc +1 -0
  110. package/frontend/dist/artifact-runtime/.build-fingerprint +1 -1
  111. package/frontend/dist/artifact-runtime/lucide-react.js +1 -1
  112. package/frontend/dist/artifact-runtime/mermaid.js +8 -8
  113. package/frontend/dist/artifact-runtime/papaparse.js +2 -2
  114. package/frontend/dist/artifact-runtime/plotly.js +371 -652
  115. package/frontend/dist/assets/index-B6xMZpzA.js +76 -0
  116. package/frontend/dist/assets/index-BjipfsCP.css +1 -0
  117. package/frontend/dist/index.html +28 -28
  118. package/frontend/dist/js/{ArtifactContainer-CTXxnWRo.js → ArtifactContainer-Bn6iJtaJ.js} +1 -1
  119. package/frontend/dist/js/{ArtifactDemoPage-CEYuIhJA.js → ArtifactDemoPage-BLF8Ok-o.js} +1 -1
  120. package/frontend/dist/js/{ArtifactSandboxFrame-DLOy2VOm.js → ArtifactSandboxFrame-Cs1Gu1WB.js} +1 -1
  121. package/frontend/dist/js/{ArtifactSlideOutPanel-DnTTc1VY.js → ArtifactSlideOutPanel-CuKq5cL0.js} +1 -1
  122. package/frontend/dist/js/AutomationModal-Dha4KgLI.js +1 -0
  123. package/frontend/dist/js/AutomationsPage-HcMCRV-D.js +1 -0
  124. package/frontend/dist/js/{AvatarUpload-DzL00yOL.js → AvatarUpload-CFrlSszY.js} +1 -1
  125. package/frontend/dist/js/{Button--pDOakZx.js → Button-CgN11mgY.js} +1 -1
  126. package/frontend/dist/js/{CalendarPage-Bls3TBeZ.js → CalendarPage-D_K-XrG9.js} +1 -1
  127. package/frontend/dist/js/ChannelsPage-D3CoImOT.js +1 -0
  128. package/frontend/dist/js/ChatPage-C0iBDbOq.js +14 -0
  129. package/frontend/dist/js/ConnectModels-D_ZbZQub.js +1 -0
  130. package/frontend/dist/js/{EvaluationsPage-DSgj9dT5.js → EvaluationsPage-DOJLpauA.js} +2 -2
  131. package/frontend/dist/js/FirstTimeSetup-DDIP_4Dd.js +1 -0
  132. package/frontend/dist/js/GalleryPage-C8U_F7Ns.js +1 -0
  133. package/frontend/dist/js/{HomePage-BebX3v-x.js → HomePage-B_aotoDU.js} +1 -1
  134. package/frontend/dist/js/LibreClawPage-cr2N6W00.js +1 -0
  135. package/frontend/dist/js/{Logo-BE9SvCC5.js → Logo-B7o7eaPU.js} +1 -1
  136. package/frontend/dist/js/{LogoMark-C8x1yyP3.js → LogoMark-D9g6ls0h.js} +1 -1
  137. package/frontend/dist/js/{ModelManagerModals-CpWAltRA.js → ModelManagerModals-C-J1d7GL.js} +1 -1
  138. package/frontend/dist/js/NotesPage-Bgr7R_Vm.js +3 -0
  139. package/frontend/dist/js/{PasswordStrengthMeter-Cdq2oQbc.js → PasswordStrengthMeter-DR-mGbLF.js} +1 -1
  140. package/frontend/dist/js/PersonasPage-C3D_6lIx.js +13 -0
  141. package/frontend/dist/js/{PluginUsagePage-jMrpL2Jb.js → PluginUsagePage-DK7MgSiu.js} +1 -1
  142. package/frontend/dist/js/RichMessageContent-7FxrZ4A8.js +1 -0
  143. package/frontend/dist/js/{RichMessageContent-CC9QZQKd.js → RichMessageContent-CQkLI7Dt.js} +1 -1
  144. package/frontend/dist/js/SettingsModal-CIV_Bgsf.js +19 -0
  145. package/frontend/dist/js/{SettingsToggle-C16gtVyi.js → SettingsToggle-Cw4OhW7B.js} +1 -1
  146. package/frontend/dist/js/ShareDialog-BCEVgtbN.js +1 -0
  147. package/frontend/dist/js/{SystemPage-Drd1neLN.js → SystemPage-BNVZtLe9.js} +1 -1
  148. package/frontend/dist/js/{UserManagementPage-CquciWKV.js → UserManagementPage-pPC_Svj9.js} +1 -1
  149. package/frontend/dist/js/WorkPage-Q33nIqkM.js +7 -0
  150. package/frontend/dist/js/{api-2DulPtq1.js → api-D-5hpGht.js} +3 -3
  151. package/frontend/dist/js/api-WR1CTYO5.js +1 -0
  152. package/frontend/dist/js/{appNavigation-DAGh98Yj.js → appNavigation-DfHbXBey.js} +1 -1
  153. package/frontend/dist/js/{appStore-Ci1X0yA-.js → appStore-B136FGdu.js} +2 -2
  154. package/frontend/dist/js/appVersion-Ck7dYiHe.js +1 -0
  155. package/frontend/dist/js/ar-Cq-nC6v9.js +2 -0
  156. package/frontend/dist/js/authStore-6AJLgQsD.js +1 -0
  157. package/frontend/dist/js/authStore-Ckz37pwu.js +4 -0
  158. package/frontend/dist/js/axios-CUerAKcc.js +1 -0
  159. package/frontend/dist/js/{babel-D7QYvEns.js → babel-8afoxhZ7.js} +1 -1
  160. package/frontend/dist/js/bn-BFSKytYs.js +2 -0
  161. package/frontend/dist/js/chatStore-Dpm3g_Ln.js +3 -0
  162. package/frontend/dist/js/classPrivateMethodInitSpec-DE0XIqc_.js +1 -0
  163. package/frontend/dist/js/config-DJwXAf8i.js +1 -0
  164. package/frontend/dist/js/cs-BKWXa629.js +2 -0
  165. package/frontend/dist/js/da-Cra_DJnV.js +2 -0
  166. package/frontend/dist/js/de-BQa6_UuE.js +2 -0
  167. package/frontend/dist/js/es-BBOHFrx1.js +2 -0
  168. package/frontend/dist/js/{estree-D7xT4AeP.js → estree-qxY7ACbu.js} +3 -3
  169. package/frontend/dist/js/{evaluationsApi-Cu5PH_qi.js → evaluationsApi-BKY-maUM.js} +1 -1
  170. package/frontend/dist/js/fr-C8kXs5c0.js +2 -0
  171. package/frontend/dist/js/hi-BEef4bjU.js +2 -0
  172. package/frontend/dist/js/{html-HvA9vEyn.js → html-B_cUU1Gi.js} +2 -2
  173. package/frontend/dist/js/id-Djipic7Y.js +2 -0
  174. package/frontend/dist/js/is-pazl6RLG.js +2 -0
  175. package/frontend/dist/js/it-DobPbTwl.js +2 -0
  176. package/frontend/dist/js/ja-DwYNaMNX.js +2 -0
  177. package/frontend/dist/js/ko-BQfXE7_o.js +2 -0
  178. package/frontend/dist/js/{markdown-DaF0SXNk.js → markdown-BAF0w-jL.js} +3 -3
  179. package/frontend/dist/js/{messageCodeStyles-DKq3DH1W.js → messageCodeStyles-CkxF6yil.js} +2 -2
  180. package/frontend/dist/js/ms-CkPQoE5T.js +2 -0
  181. package/frontend/dist/js/nl-X_QsDAtu.js +2 -0
  182. package/frontend/dist/js/pl-CK39gUsy.js +2 -0
  183. package/frontend/dist/js/{postcss-RCIJRrFm.js → postcss-B2vYq4-H.js} +1 -1
  184. package/frontend/dist/js/pt-C0dWyR_I.js +2 -0
  185. package/frontend/dist/js/{router-vendor-BGP0k6Y2.js → router-vendor-CIwPu612.js} +1 -1
  186. package/frontend/dist/js/ru-sNJkEz1G.js +2 -0
  187. package/frontend/dist/js/{standalone-BMD7E0jY.js → standalone-BqZmfuRy.js} +2 -2
  188. package/frontend/dist/js/sv-Bh-uxdF3.js +2 -0
  189. package/frontend/dist/js/{teamEventStream-C4u_py2D.js → teamEventStream-DUodK0-C.js} +1 -1
  190. package/frontend/dist/js/th-DPVtwZj2.js +2 -0
  191. package/frontend/dist/js/tr-BYNM_Tm7.js +2 -0
  192. package/frontend/dist/js/{ttsBatching-C9kQXFB1.js → ttsBatching-7_-p2nxR.js} +1 -1
  193. package/frontend/dist/js/{typescript-LOiqVRM1.js → typescript-DokwN-5Y.js} +1 -1
  194. package/frontend/dist/js/{ui-DUzqxWMk.js → ui-BK53RPmS.js} +2 -2
  195. package/frontend/dist/js/ui-vendor-CPdYrKhz.js +177 -0
  196. package/frontend/dist/js/uk-kvNBuYin.js +2 -0
  197. package/frontend/dist/js/{useChat-6yDWZSTz.js → useChat-Czg2p4Rr.js} +1 -1
  198. package/frontend/dist/js/useDictation-B2lYEYKn.js +1 -0
  199. package/frontend/dist/js/useQuery-ClAiNxQ7.js +1 -0
  200. package/frontend/dist/js/{useTranslation-DrnYb6Cx.js → useTranslation-C7GwbUQA.js} +1 -1
  201. package/frontend/dist/js/{utils-D9UstwTG.js → utils-nNyg0lfc.js} +1 -1
  202. package/frontend/dist/js/utils-vendor-CeUf_ngc.js +9 -0
  203. package/frontend/dist/js/vi-CmLoaP0K.js +2 -0
  204. package/frontend/dist/js/workApi-BoJb9aVF.js +1 -0
  205. package/frontend/dist/js/{workApi-BwDBwG62.js → workApi-CFH097y5.js} +3 -3
  206. package/frontend/dist/js/{yaml-CyhEdlt2.js → yaml-BXEpxPn2.js} +2 -2
  207. package/frontend/dist/js/zh-D2zvmvrj.js +2 -0
  208. package/frontend/dist/sw.js +7 -1
  209. package/package.json +5 -5
  210. package/frontend/dist/assets/index-O8rtJINp.css +0 -1
  211. package/frontend/dist/assets/index-f1s6QpC5.js +0 -93
  212. package/frontend/dist/js/AutomationModal-DB3lrK2K.js +0 -1
  213. package/frontend/dist/js/AutomationsPage-D3v0Cra1.js +0 -1
  214. package/frontend/dist/js/ChannelsPage-BnoCniNf.js +0 -1
  215. package/frontend/dist/js/ChatPage-BMcigJWr.js +0 -14
  216. package/frontend/dist/js/FirstTimeSetup-BRysXCjP.js +0 -1
  217. package/frontend/dist/js/GalleryPage-DUcM4dg0.js +0 -1
  218. package/frontend/dist/js/LibreClawPage-A37KF9_G.js +0 -1
  219. package/frontend/dist/js/ModelSelector-C1ipX-44.js +0 -1
  220. package/frontend/dist/js/NotesPage-CXSz7Hde.js +0 -3
  221. package/frontend/dist/js/PersonasPage-CiOBffF3.js +0 -13
  222. package/frontend/dist/js/RichMessageContent-CU6WTuOs.js +0 -1
  223. package/frontend/dist/js/SettingsModal-DP_wKehV.js +0 -19
  224. package/frontend/dist/js/ShareDialog-BW8iGd_i.js +0 -1
  225. package/frontend/dist/js/WorkPage-BgASwAGs.js +0 -6
  226. package/frontend/dist/js/api-BmIdrQfK.js +0 -1
  227. package/frontend/dist/js/appVersion-BRMnr50t.js +0 -1
  228. package/frontend/dist/js/ar-CpmN0TY8.js +0 -2
  229. package/frontend/dist/js/authStore-DIvsSaOt.js +0 -4
  230. package/frontend/dist/js/authStore-DoxafXFR.js +0 -1
  231. package/frontend/dist/js/axios-C8xWfUG8.js +0 -1
  232. package/frontend/dist/js/bn-BwrMg_Oh.js +0 -2
  233. package/frontend/dist/js/chatStore-DkpmZLOG.js +0 -3
  234. package/frontend/dist/js/classPrivateMethodInitSpec-DUpGnGHL.js +0 -1
  235. package/frontend/dist/js/config-Ckn9cand.js +0 -1
  236. package/frontend/dist/js/cs-f72Fnxz3.js +0 -2
  237. package/frontend/dist/js/da-qp8lOgkJ.js +0 -2
  238. package/frontend/dist/js/de-CpcLHr97.js +0 -2
  239. package/frontend/dist/js/es-gZHsxjG4.js +0 -2
  240. package/frontend/dist/js/fr-BY5aUofi.js +0 -2
  241. package/frontend/dist/js/hi-KCn9gIiT.js +0 -2
  242. package/frontend/dist/js/id-C7U6kS0J.js +0 -2
  243. package/frontend/dist/js/is-N9Ek-Usz.js +0 -2
  244. package/frontend/dist/js/it-CqaqWB8D.js +0 -2
  245. package/frontend/dist/js/ja-C5f9HAm1.js +0 -2
  246. package/frontend/dist/js/ko-BuoboDvb.js +0 -2
  247. package/frontend/dist/js/ms-Cu-UWc6j.js +0 -2
  248. package/frontend/dist/js/nl-nOUc4C_i.js +0 -2
  249. package/frontend/dist/js/pl-BKKwFhxj.js +0 -2
  250. package/frontend/dist/js/pt-B18-KYtS.js +0 -2
  251. package/frontend/dist/js/ru-DflEWNyb.js +0 -2
  252. package/frontend/dist/js/sv-CU-nPjr8.js +0 -2
  253. package/frontend/dist/js/th-dOxm2Hhl.js +0 -2
  254. package/frontend/dist/js/tr-7ThM4F8q.js +0 -2
  255. package/frontend/dist/js/ui-vendor-C0KwbTD4.js +0 -177
  256. package/frontend/dist/js/uk-Cl7Pk0Yf.js +0 -2
  257. package/frontend/dist/js/useQuery-CoWV2PmJ.js +0 -1
  258. package/frontend/dist/js/utils-vendor-DtsgPwcz.js +0 -9
  259. package/frontend/dist/js/vi-eljYUBOk.js +0 -2
  260. package/frontend/dist/js/workApi-uXUZSjsf.js +0 -1
  261. package/frontend/dist/js/zh-B0sinUfQ.js +0 -2
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./useQuery-CoWV2PmJ.js";import{t as i}from"./useTranslation-DrnYb6Cx.js";import{t as a}from"./utils-D9UstwTG.js";import{In as o,Mn as s,Y as c,Z as l,g as u,gr as d,jt as f,mr as p,nr as m,s as h,tn as g,v as _,xn as v}from"./ui-vendor-C0KwbTD4.js";import{n as y}from"./workApi-BwDBwG62.js";import{u as b}from"./api-2DulPtq1.js";import{t as x}from"./Button--pDOakZx.js";import{a as S,o as C}from"./ui-DUzqxWMk.js";var w=e(t(),1),T={getAnalytics:e=>y.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>y.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>y.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>y.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>y.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>y.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>y.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>y.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},E=n(),D=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),O=`w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dark-300 dark:bg-dark-50`,k=({days:e})=>{let{t}=i(),[n,r]=(0,w.useState)(null),[a,o]=(0,w.useState)([]),[s,c]=(0,w.useState)([]),[u,p]=(0,w.useState)(!0),[m,h]=(0,w.useState)(0),[g,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,S]=(0,w.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,w.useEffect)(()=>{let n=!1;return Promise.all([T.getAnalytics(e),T.listTariffs(),T.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&o(t.data),i.success&&i.data&&c(i.data))}).catch(()=>d.error(t(`costs.loadFailed`))).finally(()=>{n||p(!1)}),()=>{n=!0}},[e,m,t]);let C=e=>{if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0},k=async()=>{try{let e=await T.createTariff({pluginId:g.pluginId.trim(),model:g.model.trim()||void 0,inputPerMillion:C(g.inputPerMillion),outputPerMillion:C(g.outputPerMillion),unitPrice:C(g.unitPrice)});if(!e.success)throw Error(e.message);d.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),h(e=>e+1)}catch(e){d.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.createBudget({name:b.name.trim(),principalType:b.principalType,principalId:b.principalType===`instance`?void 0:b.principalId.trim(),period:b.period,amountUsd:Number(b.amountUsd),mode:b.mode});if(!e.success)throw Error(e.message);d.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),h(e=>e+1)}catch(e){d.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await T.exportCsv(e),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`libre-webui-costs.csv`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch{d.error(t(`costs.exportFailed`))}};return u&&!n?(0,E.jsx)(`div`,{className:`flex justify-center rounded-lg border border-gray-200 bg-white p-6 dark:border-dark-300 dark:bg-dark-100`,children:(0,E.jsx)(f,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,E.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,"data-testid":`cost-governance-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,E.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,E.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(v,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:D(n.totalUsd)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,E.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${D(n.byModel[0].usd)})`:`—`})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,E.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,E.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,E.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-gray-500`,children:[t(`costs.mode.${e.mode}`),` ·`,` `,t(`costs.period.${e.period}`),` ·`,` `,e.principalType===`instance`?t(`costs.scope.instance`):`${t(`costs.scope.${e.principalType}`)}: ${e.principalId}`]})]}),(0,E.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[D(e.spentUsd),` / `,D(e.amountUsd)]}),(0,E.jsx)(`button`,{onClick:()=>{T.deleteBudget(e.id).then(()=>h(e=>e+1)).catch(()=>d.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})]}),(0,E.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded bg-gray-200 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:n>=1?`h-full bg-red-500`:n>=.8?`h-full bg-amber-500`:`h-full bg-emerald-500`,style:{width:`${Math.round(n*100)}%`}})})]},e.id)}),s.length===0&&(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>S({...b,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.principalType,onChange:e=>S({...b,principalType:e.target.value}),children:[(0,E.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,E.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,E.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>S({...b,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.period,onChange:e=>S({...b,period:e.target.value}),children:[(0,E.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,E.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,E.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(`input`,{className:O,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>S({...b,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.mode,onChange:e=>S({...b,mode:e.target.value}),children:[(0,E.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,E.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,E.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,E.jsx)(`thead`,{className:`text-gray-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,E.jsx)(`th`,{})]})}),(0,E.jsxs)(`tbody`,{children:[a.map(e=>(0,E.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:D(e.input_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:D(e.output_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:D(e.unit_price)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,E.jsx)(`td`,{className:`py-1`,children:(0,E.jsx)(`button`,{onClick:()=>{T.deleteTariff(e.id).then(()=>h(e=>e+1)).catch(()=>d.error(t(`costs.saveFailed`)))},className:`rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})})]},e.id)),a.length===0&&(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.plugin`),value:g.pluginId,onChange:e=>y({...g,pluginId:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.modelOptional`),value:g.model,onChange:e=>y({...g,model:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:g.inputPerMillion,onChange:e=>y({...g,inputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:g.outputPerMillion,onChange:e=>y({...g,outputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:g.unitPrice,onChange:e=>y({...g,unitPrice:e.target.value})}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},A=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),j=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),M=e=>e>=1e4?j.format(e):A.format(e),N=e=>e?e<1e3?`${A.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,P=(e,t)=>e===0?0:(e-t)/e*100,F=({analytics:e,metric:t,onMetricChange:n})=>{let{t:r}=i(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,E.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:r(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:r(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,E.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),onClick:()=>n(e),children:r(`usageAnalytics.metrics.${e}`)},e))})]}),(0,E.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":r(`usageAnalytics.activity.chartLabel`,{metric:r(`usageAnalytics.metrics.${t}`)}),children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,E.jsxs)(`g`,{children:[(0,E.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,E.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:M(n)})]},e)}),h&&(0,E.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,E.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:i})=>(0,E.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,E.jsx)(`title`,{children:`${g.format(i.timestamp)}: ${M(i[t])} ${r(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},i.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,E.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},I=864e5,L=10,R=12,z=30,B=16,V=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],H=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],U=`fill-gray-400 dark:fill-gray-500`,W=`bg-gray-400 dark:bg-gray-500`,G=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,K=[0,.35,.55,.75,1],q=({heatmap:e})=>{let{t,i18n:n}=i(),[r,o]=(0,w.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,w.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*I,i=n-new Date(n).getUTCDay()*I;return{weeks:Math.ceil((r-i+I)/(7*I)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*I,v=z+s*R,y=[],b=-1;for(let e=0;e<s;e++){let t=c+e*7*I,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==b&&t>=g-6*I&&((b!==-1||t>=g)&&y.push({x:z+e*R,label:p.format(n)}),b=r)}let x=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),S=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?U:V[n]},C=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,E.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,E.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:M(f)})})]}),(0,E.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[y.map(({x:e,label:t})=>(0,E.jsx)(`text`,{x:e,y:10,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:t},`${e}-${t}`)),[1,3,5].map(e=>(0,E.jsx)(`text`,{x:0,y:B+e*R+L-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let i=c+(t*7+n)*I;if(i<g||i>_)return null;let o=l.get(i),s=o?.calls??0,u=x(s);return(0,E.jsx)(`rect`,{x:z+t*R,y:B+n*R,width:L,height:L,rx:2,fillOpacity:u===0?1:K[u],strokeWidth:+(r?.timestamp===i),className:a(`transition-opacity`,u===0||!o?G:S(o),r?.timestamp===i?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,i,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(i)} — ${M(s)}`})},i)}))]})}),r&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -translate-x-1/2 -translate-y-full rounded-lg border border-gray-200/80 bg-white/95 px-3 py-2 shadow-card backdrop-blur-md dark:border-white/[0.1] dark:bg-dark-100/95`,style:{left:r.x,top:r.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(r.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:r.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(r.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),r.models.slice(0,3).map(e=>(0,E.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:a(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?H[d.get(e.model)]:W)}),(0,E.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,E.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:M(e.calls)})]},e.model))]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,H[t])}),(0,E.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,W)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),K.slice(1).map(e=>(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},J=()=>{let{t:e}=i(),[t,n]=(0,w.useState)(30),[l,d]=(0,w.useState)(`calls`),{data:_,error:v,isLoading:y,isFetching:T,refetch:D}=r({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await b.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=v?v instanceof Error?v.message:e(`usageAnalytics.loadFailed`):null,A=_?.totals,j=(0,w.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:M(A?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:A?.uniqueUsers??0}),icon:p},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:g},{label:e(`usageAnalytics.cards.success`),value:`${P(A?.calls??0,(A?.failedCalls??0)+(A?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:A?.failedCalls??0}),icon:o},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:s}],[e,A]);return y&&!_?(0,E.jsx)(C,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(f,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(C,{width:`wide`,children:[(0,E.jsx)(S,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,E.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===r?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`text-gray-500 hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,E.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(c,{className:a(`h-4 w-4`,T&&`animate-spin`)}),(0,E.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),O&&(0,E.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,E.jsx)(u,{className:`h-4 w-4 shrink-0`}),(0,E.jsx)(`span`,{children:O})]}),(0,E.jsx)(`div`,{className:`mb-6`,children:(0,E.jsx)(k,{days:t})}),_&&(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:j.map(e=>{let t=e.icon;return(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,E.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,E.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),_.heatmap&&_.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:_.heatmap}),(0,E.jsx)(F,{analytics:_,metric:l,onMetricChange:d}),_.totals.calls===0?(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,E.jsx)(m,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,E.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,E.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.empty.description`)})]}):(0,E.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,E.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,E.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,E.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:_.models.slice(0,12).map(e=>(0,E.jsxs)(`tr`,{children:[(0,E.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,E.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:M(e.calls)}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?M(e.tokens):`—`}),(0,E.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[P(e.calls,e.errors).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:N(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,E.jsx)(`div`,{className:`mt-5 space-y-4`,children:_.plugins.slice(0,8).map(t=>{let n=_.totals.calls?t.calls/_.totals.calls*100:0;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,E.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[M(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,E.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:M(t.calls)})]}),(0,E.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(h,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,E.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:_.capabilities.map(t=>(0,E.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,E.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:M(t.calls)}),(0,E.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:M(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:M(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:M(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:M(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:M(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:M(t.tokens)})})]},t.capability))})]})]})]}),(0,E.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{J as default};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n}from"./markdown-core-CsTEqgp1.js";import{t as r}from"./useQuery-ClAiNxQ7.js";import{t as i}from"./useTranslation-C7GwbUQA.js";import{t as a}from"./utils-nNyg0lfc.js";import{Cn as o,Nt as s,Pn as c,Q as l,Rn as u,Y as d,g as f,gr as p,ir as m,rn as h,s as g,v as _,vr as v}from"./ui-vendor-CPdYrKhz.js";import{n as y}from"./workApi-CFH097y5.js";import{u as b}from"./api-D-5hpGht.js";import{t as x}from"./Button-CgN11mgY.js";import{a as S,o as C}from"./ui-BK53RPmS.js";var w=e(t(),1),T={getAnalytics:e=>y.get(`/costs/analytics`,{params:{days:e}}).then(e=>e.data),listTariffs:()=>y.get(`/costs/tariffs`).then(e=>e.data),createTariff:e=>y.post(`/costs/tariffs`,e).then(e=>e.data),deleteTariff:e=>y.delete(`/costs/tariffs/${encodeURIComponent(e)}`).then(()=>void 0),listBudgets:()=>y.get(`/costs/budgets`).then(e=>e.data),createBudget:e=>y.post(`/costs/budgets`,e).then(e=>e.data),deleteBudget:e=>y.delete(`/costs/budgets/${encodeURIComponent(e)}`).then(()=>void 0),exportUrl:e=>`/api/costs/export?days=${e}`,exportCsv:e=>y.get(`/costs/export`,{params:{days:e},responseType:`blob`}).then(e=>e.data)},E=n(),D=e=>new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,maximumFractionDigits:e<1?4:2}).format(e),O=`w-full rounded-lg border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-dark-300 dark:bg-dark-50`,k=({days:e})=>{let{t}=i(),[n,r]=(0,w.useState)(null),[a,c]=(0,w.useState)([]),[u,d]=(0,w.useState)([]),[f,p]=(0,w.useState)(!0),[m,h]=(0,w.useState)(0),[g,y]=(0,w.useState)({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),[b,S]=(0,w.useState)({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`});(0,w.useEffect)(()=>{let n=!1;return Promise.all([T.getAnalytics(e),T.listTariffs(),T.listBudgets()]).then(([e,t,i])=>{n||(e.success&&e.data&&r(e.data),t.success&&t.data&&c(t.data),i.success&&i.data&&d(i.data))}).catch(()=>v.error(t(`costs.loadFailed`))).finally(()=>{n||p(!1)}),()=>{n=!0}},[e,m,t]);let C=e=>{if(!e.trim())return;let t=Number(e);return Number.isFinite(t)?t:void 0},k=async()=>{try{let e=await T.createTariff({pluginId:g.pluginId.trim(),model:g.model.trim()||void 0,inputPerMillion:C(g.inputPerMillion),outputPerMillion:C(g.outputPerMillion),unitPrice:C(g.unitPrice)});if(!e.success)throw Error(e.message);v.success(t(`costs.tariffSaved`)),y({pluginId:``,model:``,inputPerMillion:``,outputPerMillion:``,unitPrice:``}),h(e=>e+1)}catch(e){v.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},A=async()=>{try{let e=await T.createBudget({name:b.name.trim(),principalType:b.principalType,principalId:b.principalType===`instance`?void 0:b.principalId.trim(),period:b.period,amountUsd:Number(b.amountUsd),mode:b.mode});if(!e.success)throw Error(e.message);v.success(t(`costs.budgetSaved`)),S({name:``,principalType:`instance`,principalId:``,period:`monthly`,amountUsd:``,mode:`soft`}),h(e=>e+1)}catch(e){v.error(e instanceof Error?e.message:t(`costs.saveFailed`))}},j=async()=>{try{let t=await T.exportCsv(e),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`libre-webui-costs.csv`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(n)}catch{v.error(t(`costs.exportFailed`))}};return f&&!n?(0,E.jsx)(`div`,{className:`flex justify-center rounded-lg border border-gray-200 bg-white p-6 dark:border-dark-300 dark:bg-dark-100`,children:(0,E.jsx)(s,{className:`h-5 w-5 animate-spin text-gray-400`})}):(0,E.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-gray-200 bg-white p-4 dark:border-dark-300 dark:bg-dark-100`,"data-testid":`cost-governance-panel`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-gray-100`,children:t(`costs.title`)}),(0,E.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:t(`costs.description`)})]}),(0,E.jsxs)(x,{size:`sm`,variant:`outline`,onClick:()=>void j(),children:[(0,E.jsx)(o,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.exportCsv`)]})]}),n&&(0,E.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.totalSpend`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:D(n.totalUsd)})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.meteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.meteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.unmeteredEvents`)}),(0,E.jsx)(`p`,{className:`text-lg font-semibold`,children:n.unmeteredEvents})]}),(0,E.jsxs)(`div`,{className:`rounded-lg bg-gray-50 p-3 dark:bg-dark-50`,children:[(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.topModel`)}),(0,E.jsx)(`p`,{className:`truncate text-sm font-medium`,children:n.byModel[0]?`${n.byModel[0].model} (${D(n.byModel[0].usd)})`:`—`})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.budgets`)}),(0,E.jsxs)(`div`,{className:`space-y-2`,children:[n?.budgets.map(e=>{let n=Math.min(1,e.spentUsd/e.amountUsd);return(0,E.jsxs)(`div`,{className:`rounded-lg border border-gray-200 p-2 dark:border-dark-300`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,E.jsxs)(`span`,{className:`min-w-0 truncate font-medium`,children:[e.name,(0,E.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-gray-500`,children:[t(`costs.mode.${e.mode}`),` ·`,` `,t(`costs.period.${e.period}`),` ·`,` `,e.principalType===`instance`?t(`costs.scope.instance`):`${t(`costs.scope.${e.principalType}`)}: ${e.principalId}`]})]}),(0,E.jsxs)(`span`,{className:`shrink-0 text-xs text-gray-600 dark:text-gray-300`,children:[D(e.spentUsd),` / `,D(e.amountUsd)]}),(0,E.jsx)(`button`,{onClick:()=>{T.deleteBudget(e.id).then(()=>h(e=>e+1)).catch(()=>v.error(t(`costs.saveFailed`)))},className:`shrink-0 rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteBudget`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})]}),(0,E.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded bg-gray-200 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:n>=1?`h-full bg-red-500`:n>=.8?`h-full bg-amber-500`:`h-full bg-emerald-500`,style:{width:`${Math.round(n*100)}%`}})})]},e.id)}),u.length===0&&(0,E.jsx)(`p`,{className:`text-xs text-gray-500`,children:t(`costs.noBudgets`)})]}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.budgetName`),value:b.name,onChange:e=>S({...b,name:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.principalType,onChange:e=>S({...b,principalType:e.target.value}),children:[(0,E.jsx)(`option`,{value:`instance`,children:t(`costs.scope.instance`)}),(0,E.jsx)(`option`,{value:`user`,children:t(`costs.scope.user`)}),(0,E.jsx)(`option`,{value:`group`,children:t(`costs.scope.group`)})]}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.principalId`),value:b.principalId,disabled:b.principalType===`instance`,onChange:e=>S({...b,principalId:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.period,onChange:e=>S({...b,period:e.target.value}),children:[(0,E.jsx)(`option`,{value:`daily`,children:t(`costs.period.daily`)}),(0,E.jsx)(`option`,{value:`weekly`,children:t(`costs.period.weekly`)}),(0,E.jsx)(`option`,{value:`monthly`,children:t(`costs.period.monthly`)})]}),(0,E.jsxs)(`div`,{className:`flex gap-2`,children:[(0,E.jsx)(`input`,{className:O,placeholder:`USD`,inputMode:`decimal`,value:b.amountUsd,onChange:e=>S({...b,amountUsd:e.target.value})}),(0,E.jsxs)(`select`,{className:O,value:b.mode,onChange:e=>S({...b,mode:e.target.value}),children:[(0,E.jsx)(`option`,{value:`observe`,children:t(`costs.mode.observe`)}),(0,E.jsx)(`option`,{value:`soft`,children:t(`costs.mode.soft`)}),(0,E.jsx)(`option`,{value:`hard`,children:t(`costs.mode.hard`)})]})]}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void A(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addBudget`)]})]})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:t(`costs.tariffs`)}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,E.jsx)(`thead`,{className:`text-gray-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.plugin`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.model`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.inputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.outputPerMillion`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.unitPrice`)}),(0,E.jsx)(`th`,{className:`py-1 pr-2`,children:t(`costs.effectiveFrom`)}),(0,E.jsx)(`th`,{})]})}),(0,E.jsxs)(`tbody`,{children:[a.map(e=>(0,E.jsxs)(`tr`,{className:`border-t border-gray-100 dark:border-dark-300`,children:[(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.plugin_id}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.model??t(`costs.allModels`)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.input_per_million===null?`—`:D(e.input_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.output_per_million===null?`—`:D(e.output_per_million)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:e.unit_price===null?`—`:D(e.unit_price)}),(0,E.jsx)(`td`,{className:`py-1 pr-2`,children:new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}).format(e.effective_from)}),(0,E.jsx)(`td`,{className:`py-1`,children:(0,E.jsx)(`button`,{onClick:()=>{T.deleteTariff(e.id).then(()=>h(e=>e+1)).catch(()=>v.error(t(`costs.saveFailed`)))},className:`rounded p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-950/30`,"aria-label":t(`costs.deleteTariff`),children:(0,E.jsx)(_,{className:`h-3.5 w-3.5`})})})]},e.id)),a.length===0&&(0,E.jsx)(`tr`,{children:(0,E.jsx)(`td`,{colSpan:7,className:`py-2 text-gray-500`,children:t(`costs.noTariffs`)})})]})]})}),(0,E.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 sm:grid-cols-6`,children:[(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.plugin`),value:g.pluginId,onChange:e=>y({...g,pluginId:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.modelOptional`),value:g.model,onChange:e=>y({...g,model:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.inputPerMillion`),inputMode:`decimal`,value:g.inputPerMillion,onChange:e=>y({...g,inputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.outputPerMillion`),inputMode:`decimal`,value:g.outputPerMillion,onChange:e=>y({...g,outputPerMillion:e.target.value})}),(0,E.jsx)(`input`,{className:O,placeholder:t(`costs.unitPrice`),inputMode:`decimal`,value:g.unitPrice,onChange:e=>y({...g,unitPrice:e.target.value})}),(0,E.jsxs)(x,{size:`sm`,onClick:()=>void k(),children:[(0,E.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),t(`costs.addTariff`)]})]})]})]})},A=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),j=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}),M=e=>e>=1e4?j.format(e):A.format(e),N=e=>e?e<1e3?`${A.format(e)} ms`:`${(e/1e3).toFixed(+(e<1e4))} s`:`—`,P=(e,t)=>e===0?0:(e-t)/e*100,F=({analytics:e,metric:t,onMetricChange:n})=>{let{t:r}=i(),o={top:22,right:18,bottom:42,left:52},s=e.series.map(e=>e[t]),c=Math.max(1,...s),l=960-o.left-o.right,u=280-o.top-o.bottom,d=t=>o.left+(e.series.length<=1?l/2:t/(e.series.length-1)*l),f=e=>o.top+u-e/c*u,p=e.series.map((e,n)=>({x:d(n),y:f(e[t]),point:e})),m=p.map(({x:e,y:t},n)=>`${n===0?`M`:`L`} ${e} ${t}`).join(` `),h=p.length?`${m} L ${p[p.length-1].x} ${o.top+u} L ${p[0].x} ${o.top+u} Z`:``,g=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,timeZone:`UTC`}),_=Array.from(new Set([0,Math.floor((e.series.length-1)/2),e.series.length-1])).filter(e=>e>=0);return(0,E.jsxs)(`div`,{"data-testid":`plugin-usage-chart`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:r(`usageAnalytics.activity.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:r(t===`calls`?`usageAnalytics.activity.callsDescription`:`usageAnalytics.activity.tokensDescription`)})]}),(0,E.jsx)(`div`,{className:`inline-flex w-fit rounded-xl bg-gray-100 p-1 dark:bg-dark-200/80`,children:[`calls`,`tokens`].map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===e?`bg-white text-gray-950 shadow-sm dark:bg-dark-300 dark:text-dark-950`:`text-gray-500 hover:text-gray-800 dark:text-dark-500 dark:hover:text-dark-800`),onClick:()=>n(e),children:r(`usageAnalytics.metrics.${e}`)},e))})]}),(0,E.jsx)(`div`,{className:`px-2 pb-3 pt-4 sm:px-5 sm:pt-6`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 960 280`,className:`h-auto w-full overflow-visible`,role:`img`,"aria-label":r(`usageAnalytics.activity.chartLabel`,{metric:r(`usageAnalytics.metrics.${t}`)}),children:[(0,E.jsx)(`defs`,{children:(0,E.jsxs)(`linearGradient`,{id:`plugin-usage-area`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,E.jsx)(`stop`,{offset:`0%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.28`}),(0,E.jsx)(`stop`,{offset:`100%`,stopColor:`rgb(var(--color-primary-500))`,stopOpacity:`0.015`})]})}),[0,.25,.5,.75,1].map(e=>{let t=o.top+u*e,n=Math.round(c*(1-e));return(0,E.jsxs)(`g`,{children:[(0,E.jsx)(`line`,{x1:o.left,x2:960-o.right,y1:t,y2:t,className:`stroke-gray-200 dark:stroke-white/[0.07]`,strokeDasharray:e===1?void 0:`4 8`}),(0,E.jsx)(`text`,{x:o.left-12,y:t+4,textAnchor:`end`,className:`fill-gray-400 text-[11px] dark:fill-dark-500`,children:M(n)})]},e)}),h&&(0,E.jsx)(`path`,{d:h,fill:`url(#plugin-usage-area)`}),m&&(0,E.jsx)(`path`,{d:m,fill:`none`,className:`stroke-primary-500 dark:stroke-primary-400`,strokeWidth:`3`,strokeLinecap:`round`,strokeLinejoin:`round`}),(e.series.length<=31?p:[]).map(({x:e,y:n,point:i})=>(0,E.jsx)(`circle`,{cx:e,cy:n,r:`4`,className:`fill-white stroke-primary-500 dark:fill-dark-100 dark:stroke-primary-400`,strokeWidth:`2.5`,children:(0,E.jsx)(`title`,{children:`${g.format(i.timestamp)}: ${M(i[t])} ${r(`usageAnalytics.metrics.${t}`).toLocaleLowerCase()}`})},i.timestamp)),_.map(t=>{let n=e.series[t];if(!n)return null;let r=t===0?`start`:t===e.series.length-1?`end`:`middle`;return(0,E.jsx)(`text`,{x:d(t),y:270,textAnchor:r,className:`fill-gray-500 text-[12px] dark:fill-dark-500`,children:g.format(n.timestamp)},n.timestamp)})]})})]})},I=864e5,L=10,R=12,z=30,B=16,V=[`fill-blue-500`,`fill-emerald-500 dark:fill-emerald-600`,`fill-amber-500 dark:fill-amber-600`,`fill-violet-500`,`fill-rose-500`],H=[`bg-blue-500`,`bg-emerald-500 dark:bg-emerald-600`,`bg-amber-500 dark:bg-amber-600`,`bg-violet-500`,`bg-rose-500`],U=`fill-gray-400 dark:fill-gray-500`,W=`bg-gray-400 dark:bg-gray-500`,G=`fill-gray-950/[0.06] dark:fill-white/[0.07]`,K=[0,.35,.55,.75,1],q=({heatmap:e})=>{let{t,i18n:n}=i(),[r,o]=(0,w.useState)(null),{weeks:s,firstColStart:c,cellsByDay:l,maxCalls:u,modelRank:d,totalCalls:f}=(0,w.useMemo)(()=>{let t=new Map(e.cells.map(e=>[e.timestamp,e])),n=e.from,r=e.from+(e.days-1)*I,i=n-new Date(n).getUTCDay()*I;return{weeks:Math.ceil((r-i+I)/(7*I)),firstColStart:i,cellsByDay:t,maxCalls:Math.max(1,...e.cells.map(e=>e.calls)),modelRank:new Map(e.models.map((e,t)=>[e,t])),totalCalls:e.cells.reduce((e,t)=>e+t.calls,0)}},[e]),p=new Intl.DateTimeFormat(n.language,{month:`short`,timeZone:`UTC`}),m=new Intl.DateTimeFormat(n.language,{weekday:`short`,timeZone:`UTC`}),h=new Intl.DateTimeFormat(n.language,{dateStyle:`medium`,timeZone:`UTC`}),g=e.from,_=e.from+(e.days-1)*I,v=z+s*R,y=[],b=-1;for(let e=0;e<s;e++){let t=c+e*7*I,n=Math.max(t,g),r=new Date(n).getUTCMonth();r!==b&&t>=g-6*I&&((b!==-1||t>=g)&&y.push({x:z+e*R,label:p.format(n)}),b=r)}let x=e=>e<=0?0:Math.min(4,Math.max(1,Math.ceil(e/u*4))),S=e=>{let t=e.models[0]?.model,n=t===void 0?void 0:d.get(t);return n===void 0?U:V[n]},C=(e,t,n)=>{let r=e.currentTarget.closest(`[data-heatmap-wrapper]`);if(!r)return;let i=r.getBoundingClientRect(),a=e.currentTarget.getBoundingClientRect(),s=a.left-i.left+a.width/2;o({x:Math.min(Math.max(s,96),Math.max(i.width-96,96)),y:a.top-i.top,timestamp:t,calls:n.calls,models:n.models})};return(0,E.jsxs)(`section`,{"data-testid":`usage-heatmap`,className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:t(`usageAnalytics.heatmap.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.description`)})]}),(0,E.jsx)(`span`,{className:`shrink-0 text-xs tabular-nums text-gray-500 dark:text-dark-500`,children:t(`usageAnalytics.heatmap.yearTotal`,{count:f,formatted:M(f)})})]}),(0,E.jsxs)(`div`,{className:`relative p-4 sm:px-5`,"data-heatmap-wrapper":!0,children:[(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`svg`,{viewBox:`0 0 ${v} 100`,className:`h-auto w-full min-w-[640px]`,role:`img`,"aria-label":t(`usageAnalytics.heatmap.title`),onMouseLeave:()=>o(null),children:[y.map(({x:e,label:t})=>(0,E.jsx)(`text`,{x:e,y:10,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:t},`${e}-${t}`)),[1,3,5].map(e=>(0,E.jsx)(`text`,{x:0,y:B+e*R+L-2,className:`fill-gray-400 text-[8px] dark:fill-dark-500`,children:m.format(new Date(Date.UTC(2023,0,1+e)))},e)),Array.from({length:s},(e,t)=>Array.from({length:7},(e,n)=>{let i=c+(t*7+n)*I;if(i<g||i>_)return null;let o=l.get(i),s=o?.calls??0,u=x(s);return(0,E.jsx)(`rect`,{x:z+t*R,y:B+n*R,width:L,height:L,rx:2,fillOpacity:u===0?1:K[u],strokeWidth:+(r?.timestamp===i),className:a(`transition-opacity`,u===0||!o?G:S(o),r?.timestamp===i?`stroke-gray-500 dark:stroke-white/60`:`stroke-transparent`),onMouseEnter:e=>C(e,i,{calls:s,models:o?.models??[]}),children:(0,E.jsx)(`title`,{children:`${h.format(i)} — ${M(s)}`})},i)}))]})}),r&&(0,E.jsxs)(`div`,{className:`pointer-events-none absolute z-10 min-w-[10rem] -translate-x-1/2 -translate-y-full rounded-lg border border-gray-200/80 bg-white/95 px-3 py-2 shadow-card backdrop-blur-md dark:border-white/[0.1] dark:bg-dark-100/95`,style:{left:r.x,top:r.y-6},children:[(0,E.jsx)(`div`,{className:`text-[11px] font-medium text-gray-900 dark:text-dark-900`,children:h.format(r.timestamp)}),(0,E.jsx)(`div`,{className:`mt-0.5 text-[11px] text-gray-500 dark:text-dark-500`,children:r.calls===0?t(`usageAnalytics.heatmap.noCalls`):`${M(r.calls)} ${t(`usageAnalytics.heatmap.calls`)}`}),r.models.slice(0,3).map(e=>(0,E.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3 text-[11px]`,children:[(0,E.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,E.jsx)(`span`,{className:a(`h-2 w-2 shrink-0 rounded-[3px]`,d.has(e.model)?H[d.get(e.model)]:W)}),(0,E.jsx)(`span`,{className:`truncate font-mono text-gray-700 dark:text-dark-700`,dir:`ltr`,children:e.model})]}),(0,E.jsx)(`span`,{className:`tabular-nums text-gray-500 dark:text-dark-500`,children:M(e.calls)})]},e.model))]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-1.5`,children:[e.models.map((e,t)=>(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,H[t])}),(0,E.jsx)(`span`,{className:`font-mono`,dir:`ltr`,children:e})]},e)),(0,E.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-gray-600 dark:text-dark-600`,children:[(0,E.jsx)(`span`,{className:a(`h-2.5 w-2.5 rounded-[3px]`,W)}),t(`usageAnalytics.heatmap.other`)]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-dark-500`,children:[t(`usageAnalytics.heatmap.less`),(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-gray-950/[0.06] dark:bg-white/[0.07]`}),K.slice(1).map(e=>(0,E.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-[3px] bg-primary-500`,style:{opacity:e}},e)),t(`usageAnalytics.heatmap.more`)]})]})]})]})},J=()=>{let{t:e}=i(),[t,n]=(0,w.useState)(30),[o,l]=(0,w.useState)(`calls`),{data:_,error:v,isLoading:y,isFetching:T,refetch:D}=r({queryKey:[`plugin-usage`,t],queryFn:async()=>{let n=await b.getUsage(t);if(!n.success||!n.data)throw Error(n.error||e(`usageAnalytics.loadFailed`));return n.data}}),O=v?v instanceof Error?v.message:e(`usageAnalytics.loadFailed`):null,A=_?.totals,j=(0,w.useMemo)(()=>[{label:e(`usageAnalytics.cards.calls`),value:M(A?.calls??0),detail:e(`usageAnalytics.cards.callsDetail`,{count:A?.uniqueUsers??0}),icon:p},{label:e(`usageAnalytics.cards.tokens`),value:M(A?.reportedTokens??0),detail:e(`usageAnalytics.cards.tokensDetail`,{count:A?.meteredCalls??0}),icon:h},{label:e(`usageAnalytics.cards.success`),value:`${P(A?.calls??0,(A?.failedCalls??0)+(A?.cancelledCalls??0)).toFixed(1)}%`,detail:e(`usageAnalytics.cards.successDetail`,{count:A?.failedCalls??0}),icon:u},{label:e(`usageAnalytics.cards.latency`),value:N(A?.averageLatencyMs??0),detail:e(`usageAnalytics.cards.latencyDetail`),icon:c}],[e,A]);return y&&!_?(0,E.jsx)(C,{width:`wide`,children:(0,E.jsx)(`div`,{className:`flex min-h-[50vh] items-center justify-center`,children:(0,E.jsx)(s,{className:`h-7 w-7 animate-spin text-primary-500`})})}):(0,E.jsxs)(C,{width:`wide`,children:[(0,E.jsx)(S,{eyebrow:e(`usageAnalytics.eyebrow`),title:e(`usageAnalytics.title`),description:e(`usageAnalytics.description`),actions:(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`inline-flex rounded-xl border border-gray-200 bg-white/70 p-1 dark:border-white/[0.08] dark:bg-dark-100/70`,children:[7,30,90].map(r=>(0,E.jsx)(`button`,{type:`button`,className:a(`rounded-lg px-3 py-1.5 text-xs font-medium transition-colors`,t===r?`bg-gray-950 text-white dark:bg-white dark:text-gray-950`:`text-gray-500 hover:text-gray-900 dark:text-dark-500 dark:hover:text-dark-900`),onClick:()=>n(r),children:e(`usageAnalytics.days`,{count:r})},r))}),(0,E.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void D(),disabled:T,children:[(0,E.jsx)(d,{className:a(`h-4 w-4`,T&&`animate-spin`)}),(0,E.jsx)(`span`,{className:`sr-only`,children:e(`usageAnalytics.refresh`)})]})]})}),O&&(0,E.jsxs)(`div`,{className:`mb-6 flex items-center gap-3 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:[(0,E.jsx)(f,{className:`h-4 w-4 shrink-0`}),(0,E.jsx)(`span`,{children:O})]}),(0,E.jsx)(`div`,{className:`mb-6`,children:(0,E.jsx)(k,{days:t})}),_&&(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:j.map(e=>{let t=e.icon;return(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/75 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/70`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,E.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-[0.12em] text-gray-500 dark:text-dark-500`,children:e.label}),(0,E.jsx)(t,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`})]}),(0,E.jsx)(`div`,{className:`mt-2 text-2xl font-normal tracking-[-0.04em] text-gray-950 dark:text-dark-950`,children:e.value}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-gray-500 dark:text-dark-500`,children:e.detail})]},e.label)})}),_.heatmap&&_.heatmap.cells.length>0&&(0,E.jsx)(q,{heatmap:_.heatmap}),(0,E.jsx)(F,{analytics:_,metric:o,onMetricChange:l}),_.totals.calls===0?(0,E.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-gray-300 px-6 py-10 text-center dark:border-white/[0.12]`,children:[(0,E.jsx)(m,{className:`mx-auto h-8 w-8 text-gray-400 dark:text-dark-500`}),(0,E.jsx)(`h2`,{className:`mt-4 text-base font-medium text-gray-900 dark:text-dark-900`,children:e(`usageAnalytics.empty.title`)}),(0,E.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.empty.description`)})]}):(0,E.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.15fr_0.85fr]`,children:[(0,E.jsxs)(`section`,{className:`overflow-hidden rounded-2xl border border-gray-200/80 bg-white/80 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75`,children:[(0,E.jsxs)(`div`,{className:`border-b border-gray-200/70 px-4 py-3 dark:border-white/[0.07] sm:px-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.models.title`)}),(0,E.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.models.description`)})]}),(0,E.jsx)(`div`,{className:`overflow-x-auto`,children:(0,E.jsxs)(`table`,{className:`w-full min-w-[620px] text-start text-sm`,children:[(0,E.jsx)(`thead`,{className:`text-[11px] uppercase tracking-[0.1em] text-gray-400 dark:text-dark-500`,children:(0,E.jsxs)(`tr`,{children:[(0,E.jsx)(`th`,{className:`px-5 py-2 text-start font-medium`,children:e(`usageAnalytics.models.model`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.calls`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.metrics.tokens`)}),(0,E.jsx)(`th`,{className:`px-4 py-2 text-end font-medium`,children:e(`usageAnalytics.models.success`)}),(0,E.jsx)(`th`,{className:`px-5 py-2 text-end font-medium`,children:e(`usageAnalytics.models.latency`)})]})}),(0,E.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-white/[0.06]`,children:_.models.slice(0,12).map(e=>(0,E.jsxs)(`tr`,{children:[(0,E.jsxs)(`td`,{className:`px-5 py-2.5`,children:[(0,E.jsx)(`div`,{className:`max-w-[260px] truncate font-medium text-gray-900 dark:text-dark-900`,title:e.model,children:e.model}),(0,E.jsx)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:e.pluginName})]}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:M(e.calls)}),(0,E.jsx)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:e.tokens?M(e.tokens):`—`}),(0,E.jsxs)(`td`,{className:`px-4 py-2.5 text-end tabular-nums text-gray-700 dark:text-dark-700`,children:[P(e.calls,e.errors).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:`px-5 py-2.5 text-end tabular-nums text-gray-500 dark:text-dark-500`,children:N(e.averageLatencyMs)})]},`${e.pluginId}:${e.model}`))})]})})]}),(0,E.jsxs)(`div`,{className:`space-y-4`,children:[(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.providers.title`)}),(0,E.jsx)(`div`,{className:`mt-5 space-y-4`,children:_.plugins.slice(0,8).map(t=>{let n=_.totals.calls?t.calls/_.totals.calls*100:0;return(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-sm`,children:[(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`div`,{className:`truncate font-medium text-gray-900 dark:text-dark-900`,children:t.pluginName}),(0,E.jsxs)(`div`,{className:`mt-0.5 text-xs text-gray-500 dark:text-dark-500`,children:[M(t.tokens),` `,e(`usageAnalytics.metrics.tokens`).toLocaleLowerCase()]})]}),(0,E.jsx)(`span`,{className:`shrink-0 tabular-nums text-gray-600 dark:text-dark-600`,children:M(t.calls)})]}),(0,E.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-gray-100 dark:bg-dark-300`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-primary-500 dark:bg-primary-400`,style:{width:`${Math.max(2,n)}%`}})})]},t.pluginId)})})]}),(0,E.jsxs)(`section`,{className:`rounded-2xl border border-gray-200/80 bg-white/80 p-4 shadow-subtle backdrop-blur-md dark:border-white/[0.08] dark:bg-dark-100/75 sm:p-5`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(g,{className:`h-4 w-4 text-primary-500 dark:text-primary-400`}),(0,E.jsx)(`h2`,{className:`text-sm font-medium text-gray-950 dark:text-dark-950`,children:e(`usageAnalytics.capabilities.title`)})]}),(0,E.jsx)(`div`,{className:`mt-5 grid grid-cols-2 gap-3`,children:_.capabilities.map(t=>(0,E.jsxs)(`div`,{className:`rounded-xl bg-gray-50 px-3 py-2.5 dark:bg-dark-200/70`,children:[(0,E.jsx)(`div`,{className:`text-xs font-medium capitalize text-gray-500 dark:text-dark-500`,children:t.capability}),(0,E.jsx)(`div`,{className:`mt-1 text-xl text-gray-950 dark:text-dark-950`,children:M(t.calls)}),(0,E.jsx)(`div`,{className:`mt-1 text-[11px] text-gray-500 dark:text-dark-500`,children:t.capability===`tts`?e(`usageAnalytics.capabilities.characters`,{count:M(t.inputUnits)}):t.capability===`stt`?e(`usageAnalytics.capabilities.bytes`,{count:M(t.inputUnits)}):t.capability===`image`?e(`usageAnalytics.capabilities.images`,{count:M(t.outputUnits)}):t.capability===`video`?e(`usageAnalytics.capabilities.jobs`,{count:M(t.calls)}):t.capability===`embedding`?e(`usageAnalytics.capabilities.inputs`,{count:M(t.inputUnits)}):e(`usageAnalytics.capabilities.reportedTokens`,{count:M(t.tokens)})})]},t.capability))})]})]})]}),(0,E.jsx)(`p`,{className:`px-1 text-xs leading-5 text-gray-500 dark:text-dark-500`,children:e(`usageAnalytics.privacyNote`)})]})]})};export{J as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./RichMessageContent-CQkLI7Dt.js";export{e as RichMessageContent,e as default};
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/OptimizedSyntaxHighlighter-oiyvxgDA.js","js/OptimizedSyntaxHighlighter-BwKLuOu-.js","js/rolldown-runtime-hePW80VL.js","js/markdown-core-CsTEqgp1.js","js/syntax-highlight-DY6Hwrri.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n,l as r,n as i,o as a,r as o,t as s}from"./markdown-core-CsTEqgp1.js";import{a as c}from"./router-vendor-BGP0k6Y2.js";import{t as l}from"./utils-D9UstwTG.js";import{t as u}from"./appStore-Ci1X0yA-.js";import{a as d,i as f,n as p,r as m,s as h,t as g}from"./messageCodeStyles-DKq3DH1W.js";import{n as _,t as v}from"./markdown-math-BhUmos36.js";var y=e(t(),1),b=`clipPath.clipRule.d.dominantBaseline.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.letterSpacing.markerEnd.markerMid.markerStart.mask.opacity.paintOrder.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.transform.vectorEffect`.split(`.`),x=Object.fromEntries(Object.entries({svg:[`viewBox`,`xmlns`,`preserveAspectRatio`,`role`,`ariaLabel`],g:[],defs:[],symbol:[`viewBox`,`preserveAspectRatio`],use:[`href`,`x`,`y`],title:[],desc:[],path:[`pathLength`],circle:[`cx`,`cy`,`r`],ellipse:[`cx`,`cy`,`rx`,`ry`],rect:[`x`,`y`,`rx`,`ry`],line:[`x1`,`y1`,`x2`,`y2`],polyline:[`points`],polygon:[`points`],text:[`x`,`y`,`dx`,`dy`,`rotate`,`textLength`],tspan:[`x`,`y`,`dx`,`dy`,`rotate`],linearGradient:[`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],radialGradient:[`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],stop:[`offset`,`stopColor`,`stopOpacity`],clipPath:[`clipPathUnits`],mask:[`maskUnits`,`maskContentUnits`,`x`,`y`],pattern:[`patternUnits`,`patternContentUnits`,`patternTransform`,`viewBox`,`x`,`y`],marker:[`markerWidth`,`markerHeight`,`markerUnits`,`refX`,`refY`,`orient`,`viewBox`]}).map(([e,t])=>[e,[...b,...t]])),S={...i,clobberPrefix:``,tagNames:[...i.tagNames??[],...Object.keys(x)],attributes:{...i.attributes,...x,code:[[`className`,/^language-./,`math-inline`,`math-display`]]},protocols:{...i.protocols,href:[...i.protocols?.href??[]]}},C=n(),w=y.lazy(()=>c(()=>import(`./OptimizedSyntaxHighlighter-oiyvxgDA.js`),__vite__mapDeps([0,1,2,3,4])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:l(m,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=({content:e,className:t,allowHtml:n=!1})=>{let i=u(e=>e.theme.mode!==`light`),c=y.useMemo(()=>h(e),[e]),m=y.useMemo(()=>n?[o,[s,S],v]:[v],[n]);return(0,C.jsx)(`div`,{dir:`auto`,className:l(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,C.jsx)(r,{remarkPlugins:[a,_],rehypePlugins:m,components:{code({className:e,children:t,node:n,...r}){let a=/language-([^\s]+)/.exec(e||``),o=String(t),s=o.replace(/\n$/,``),c=a?a[1]:null;return c||o.includes(`
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,g as n,l as r,n as i,o as a,r as o,t as s}from"./markdown-core-CsTEqgp1.js";import{a as c}from"./router-vendor-CIwPu612.js";import{t as l}from"./utils-nNyg0lfc.js";import{t as u}from"./appStore-B136FGdu.js";import{a as d,i as f,n as p,r as m,s as h,t as g}from"./messageCodeStyles-CkxF6yil.js";import{n as _,t as v}from"./markdown-math-BhUmos36.js";var y=e(t(),1),b=`clipPath.clipRule.d.dominantBaseline.fill.fillOpacity.fillRule.fontFamily.fontSize.fontStyle.fontWeight.letterSpacing.markerEnd.markerMid.markerStart.mask.opacity.paintOrder.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.textAnchor.transform.vectorEffect`.split(`.`),x=Object.fromEntries(Object.entries({svg:[`viewBox`,`xmlns`,`preserveAspectRatio`,`role`,`ariaLabel`],g:[],defs:[],symbol:[`viewBox`,`preserveAspectRatio`],use:[`href`,`x`,`y`],title:[],desc:[],path:[`pathLength`],circle:[`cx`,`cy`,`r`],ellipse:[`cx`,`cy`,`rx`,`ry`],rect:[`x`,`y`,`rx`,`ry`],line:[`x1`,`y1`,`x2`,`y2`],polyline:[`points`],polygon:[`points`],text:[`x`,`y`,`dx`,`dy`,`rotate`,`textLength`],tspan:[`x`,`y`,`dx`,`dy`,`rotate`],linearGradient:[`x1`,`y1`,`x2`,`y2`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],radialGradient:[`cx`,`cy`,`r`,`fx`,`fy`,`gradientUnits`,`gradientTransform`,`spreadMethod`,`href`],stop:[`offset`,`stopColor`,`stopOpacity`],clipPath:[`clipPathUnits`],mask:[`maskUnits`,`maskContentUnits`,`x`,`y`],pattern:[`patternUnits`,`patternContentUnits`,`patternTransform`,`viewBox`,`x`,`y`],marker:[`markerWidth`,`markerHeight`,`markerUnits`,`refX`,`refY`,`orient`,`viewBox`]}).map(([e,t])=>[e,[...b,...t]])),S={...i,clobberPrefix:``,tagNames:[...i.tagNames??[],...Object.keys(x)],attributes:{...i.attributes,...x,code:[[`className`,/^language-./,`math-inline`,`math-display`]]},protocols:{...i.protocols,href:[...i.protocols?.href??[]]}},C=n(),w=y.lazy(()=>c(()=>import(`./OptimizedSyntaxHighlighter-oiyvxgDA.js`),__vite__mapDeps([0,1,2,3,4])));function T({children:e,className:t}){return(0,C.jsx)(`pre`,{dir:`ltr`,className:l(m,`rounded-lg`,t),children:(0,C.jsx)(`code`,{children:e})})}var E=({content:e,className:t,allowHtml:n=!1})=>{let i=u(e=>e.theme.mode!==`light`),c=y.useMemo(()=>h(e),[e]),m=y.useMemo(()=>n?[o,[s,S],v]:[v],[n]);return(0,C.jsx)(`div`,{dir:`auto`,className:l(`prose prose-sm max-w-none dark:prose-invert prose-gray`,`[&_.katex-display]:overflow-x-auto [&_.katex-display]:overflow-y-hidden [&_.katex-display]:py-2`,`[&_.katex]:text-inherit`,t),children:(0,C.jsx)(r,{remarkPlugins:[a,_],rehypePlugins:m,components:{code({className:e,children:t,node:n,...r}){let a=/language-([^\s]+)/.exec(e||``),o=String(t),s=o.replace(/\n$/,``),c=a?a[1]:null;return c||o.includes(`
3
3
  `)?(0,C.jsx)(d,{code:s,language:c,state:`complete`,children:(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsx)(y.Suspense,{fallback:(0,C.jsx)(T,{className:`!m-0 !rounded-none !border-none`,children:s}),children:(0,C.jsx)(w,{language:c||`text`,isDark:i,codeTheme:`night`,backgroundColor:i?g:p,borderRadius:0,customStyle:f,className:`!m-0 !rounded-none !border-none`,showLineNumbers:!0,children:s})})})}):(0,C.jsx)(`code`,{dir:`ltr`,className:l(`px-1.5 py-0.5 rounded-md bg-gray-100 dark:bg-dark-200 text-gray-800 dark:text-dark-800`,`font-mono text-[0.85em] border border-gray-200 dark:border-dark-300`,e),...r,children:t})},pre({children:e}){return(0,C.jsx)(C.Fragment,{children:e})},p({children:e,...t}){return(0,C.jsx)(`div`,{dir:`auto`,className:`mb-2.5 last:mb-0 leading-relaxed`,...t,children:e})},ul({children:e,...t}){return(0,C.jsx)(`ul`,{dir:`auto`,className:`list-disc list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},ol({children:e,...t}){return(0,C.jsx)(`ol`,{dir:`auto`,className:`list-decimal list-inside mb-2.5 space-y-1 ps-4`,...t,children:e})},li({children:e,...t}){return(0,C.jsx)(`li`,{dir:`auto`,className:`text-gray-700 dark:text-dark-700 leading-relaxed`,...t,children:e})},blockquote({children:e,...t}){return(0,C.jsx)(`blockquote`,{dir:`auto`,className:`border-s-2 border-primary-400 dark:border-primary-500 bg-primary-25 dark:bg-primary-950/30 ps-3 py-2 my-3 rounded-e-lg italic text-gray-700 dark:text-dark-700`,...t,children:e})},h1({children:e,...t}){return(0,C.jsx)(`h1`,{dir:`auto`,className:`text-xl font-bold mb-3 mt-5 first:mt-0 text-gray-900 dark:text-dark-800 border-b border-gray-200 dark:border-dark-300 pb-1.5`,...t,children:e})},h2({children:e,...t}){return(0,C.jsx)(`h2`,{dir:`auto`,className:`text-lg font-semibold mb-2 mt-5 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},h3({children:e,...t}){return(0,C.jsx)(`h3`,{dir:`auto`,className:`text-base font-medium mb-2 mt-4 first:mt-0 text-gray-900 dark:text-dark-800`,...t,children:e})},table({children:e,node:t,...n}){return(0,C.jsx)(`div`,{className:l(`my-4 w-full overflow-x-auto rounded-xl border border-line bg-surface shadow-subtle`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/40`),tabIndex:0,children:(0,C.jsx)(`table`,{dir:`auto`,className:`w-full min-w-[42rem] border-separate border-spacing-0 text-start text-sm`,...n,children:e})})},thead({children:e,node:t,...n}){return(0,C.jsx)(`thead`,{className:`bg-surface-subtle`,...n,children:e})},tbody({children:e,node:t,...n}){return(0,C.jsx)(`tbody`,{...n,children:e})},tr({children:e,node:t,...n}){return(0,C.jsx)(`tr`,{className:`transition-colors hover:bg-black/[0.025] last:[&>td]:border-b-0 dark:hover:bg-white/[0.025]`,...n,children:e})},th({align:e,children:t,node:n,...r}){return(0,C.jsx)(`th`,{className:l(`border-b border-e border-line-strong px-3 py-2.5 align-bottom font-semibold text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})},td({align:e,children:t,node:n,...r}){return(0,C.jsx)(`td`,{className:l(`min-w-40 border-b border-e border-line px-3 py-2.5 align-top leading-relaxed text-ink last:border-e-0`,e===`center`?`text-center`:e===`right`?`text-right`:e===`left`?`text-left`:`text-start`),...r,children:t})}},children:c})})};export{E as t};