specrails-desktop 2.7.0 → 2.9.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 (329) hide show
  1. package/README.md +23 -19
  2. package/client/dist/assets/{ActivityFeedPage-LKqd18-G.js → ActivityFeedPage-DNqnf1fZ.js} +1 -1
  3. package/client/dist/assets/{AgentsPage-Cb-b-6Ot.js → AgentsPage-vmNIEbGM.js} +1 -1
  4. package/client/dist/assets/{AnalyticsPage-HVxQQ1wy.js → AnalyticsPage-CdfN0ofZ.js} +1 -1
  5. package/client/dist/assets/{BarChart-BOyHB0dw.js → BarChart-CIkopHjl.js} +1 -1
  6. package/client/dist/assets/{CodePage-DnOnwKGB.js → CodePage-DDRNU5FN.js} +1 -1
  7. package/client/dist/assets/{DesktopAnalyticsPage-D2auU39x.js → DesktopAnalyticsPage-Cl3sKKSG.js} +1 -1
  8. package/client/dist/assets/{DocsDialog-CTuDX3GK.js → DocsDialog-BGrBOfUr.js} +2 -2
  9. package/client/dist/assets/{DocsPage-DRyMmu0Z.js → DocsPage-CY-2SSzw.js} +2 -2
  10. package/client/dist/assets/{ExportDropdown-DO-GGiMh.js → ExportDropdown-BRHcvP0r.js} +1 -1
  11. package/client/dist/assets/{IntegrationsPage-BhbO4jFT.js → IntegrationsPage-nKdLB4Ub.js} +1 -1
  12. package/client/dist/assets/{JobDetailPage-DJooEg1s.js → JobDetailPage-Bf0A6WWQ.js} +1 -1
  13. package/client/dist/assets/{JobsPage-BbaC-YOg.js → JobsPage-Vg4nXPdL.js} +1 -1
  14. package/client/dist/assets/{dist-js-CiIVMsx3.js → dist-js-0i_klubI.js} +1 -1
  15. package/client/dist/assets/{dist-js-Xc2lRKp2.js → dist-js-CUs5GjwA.js} +1 -1
  16. package/client/dist/assets/{index-DK214dak.js → index-BXoHFtfG.js} +8 -8
  17. package/client/dist/assets/index-D6BaYRRU.css +2 -0
  18. package/client/dist/assets/{integrations-2C7MkGT0.js → integrations-7YyTBuU9.js} +1 -1
  19. package/client/dist/assets/{integrations-CX4p_bij.js → integrations-B9CEpNF0.js} +1 -1
  20. package/client/dist/assets/{integrations-C2jQtv-s.js → integrations-BlvAdewo.js} +1 -1
  21. package/client/dist/assets/{integrations-eQPHAYsE.js → integrations-Bw8UM9Xd.js} +1 -1
  22. package/client/dist/assets/{integrations-BDC670cg.js → integrations-C5SxNKnG.js} +1 -1
  23. package/client/dist/assets/{integrations-BqUmRUef.js → integrations-CJQKMmdW.js} +1 -1
  24. package/client/dist/assets/{integrations-CB98NeH5.js → integrations-DWz1eU_K.js} +1 -1
  25. package/client/dist/assets/{integrations-_SuVeQIG.js → integrations-DiPR8Fzp.js} +1 -1
  26. package/client/dist/assets/{lib-Bo5s6xpe.js → lib-D6M_MvoC.js} +1 -1
  27. package/client/dist/assets/setup-B6egeeTM.js +1 -0
  28. package/client/dist/assets/setup-BHroXlke.js +1 -0
  29. package/client/dist/assets/setup-BIXsWUp1.js +1 -0
  30. package/client/dist/assets/setup-BJRdg1iE.js +1 -0
  31. package/client/dist/assets/setup-C0rVGnCy.js +1 -0
  32. package/client/dist/assets/setup-Cpu17hJv.js +1 -0
  33. package/client/dist/assets/setup-D-1r0uSx.js +1 -0
  34. package/client/dist/assets/setup-Dn2-veYO.js +1 -0
  35. package/client/dist/assets/{useProjectCache-DVNypkmR.js → useProjectCache-BeyBSNpD.js} +1 -1
  36. package/client/dist/index.html +4 -4
  37. package/docs/README.md +5 -2
  38. package/docs/agy-cli-provider-study.md +78 -0
  39. package/docs/cli.md +23 -4
  40. package/docs/codex.md +116 -58
  41. package/docs/creating-specs.md +19 -5
  42. package/docs/customizing.md +27 -6
  43. package/docs/gemini.md +225 -73
  44. package/docs/getting-started.md +18 -9
  45. package/docs/guide/de/agents/1-meet-the-agents.md +38 -0
  46. package/docs/guide/de/agents/2-profiles-and-the-balanced-default.md +45 -0
  47. package/docs/guide/de/agents/3-customizing-models-per-agent.md +60 -0
  48. package/docs/guide/de/agents/4-custom-agents-catalog.md +43 -0
  49. package/docs/guide/de/getting-started/1-what-is-specrails.md +49 -0
  50. package/docs/guide/de/getting-started/2-installing-and-first-run.md +42 -0
  51. package/docs/guide/de/getting-started/3-adding-your-first-project.md +58 -0
  52. package/docs/guide/de/getting-started/4-the-dashboard-tour.md +53 -0
  53. package/docs/guide/de/insights/1-analytics-and-cost-tracking.md +78 -0
  54. package/docs/guide/de/insights/2-the-integrated-terminal.md +46 -0
  55. package/docs/guide/de/insights/3-code-explorer.md +50 -0
  56. package/docs/guide/de/integrations/1-ai-providers.md +64 -0
  57. package/docs/guide/de/integrations/2-plugins.md +44 -0
  58. package/docs/guide/de/integrations/3-jira-integration.md +71 -0
  59. package/docs/guide/de/integrations/4-mobile-companion.md +38 -0
  60. package/docs/guide/de/pipeline/1-rails-and-jobs.md +94 -0
  61. package/docs/guide/de/pipeline/2-the-job-detail-view.md +90 -0
  62. package/docs/guide/de/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  63. package/docs/guide/de/pipeline/4-picking-an-engine-per-rail.md +60 -0
  64. package/docs/guide/de/settings/1-themes.md +37 -0
  65. package/docs/guide/de/settings/2-language.md +39 -0
  66. package/docs/guide/de/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  67. package/docs/guide/de/settings/4-where-your-data-lives.md +48 -0
  68. package/docs/guide/de/specs/1-specs-and-the-backlog.md +52 -0
  69. package/docs/guide/de/specs/2-add-spec-quick-mode.md +45 -0
  70. package/docs/guide/de/specs/3-add-spec-explore-mode.md +68 -0
  71. package/docs/guide/de/specs/4-drafts-and-contract-layer.md +81 -0
  72. package/docs/guide/en/agents/1-meet-the-agents.md +38 -0
  73. package/docs/guide/en/agents/2-profiles-and-the-balanced-default.md +45 -0
  74. package/docs/guide/en/agents/3-customizing-models-per-agent.md +60 -0
  75. package/docs/guide/en/agents/4-custom-agents-catalog.md +43 -0
  76. package/docs/guide/en/getting-started/1-what-is-specrails.md +49 -0
  77. package/docs/guide/en/getting-started/2-installing-and-first-run.md +42 -0
  78. package/docs/guide/en/getting-started/3-adding-your-first-project.md +58 -0
  79. package/docs/guide/en/getting-started/4-the-dashboard-tour.md +53 -0
  80. package/docs/guide/en/insights/1-analytics-and-cost-tracking.md +78 -0
  81. package/docs/guide/en/insights/2-the-integrated-terminal.md +46 -0
  82. package/docs/guide/en/insights/3-code-explorer.md +50 -0
  83. package/docs/guide/en/integrations/1-ai-providers.md +64 -0
  84. package/docs/guide/en/integrations/2-plugins.md +44 -0
  85. package/docs/guide/en/integrations/3-jira-integration.md +71 -0
  86. package/docs/guide/en/integrations/4-mobile-companion.md +38 -0
  87. package/docs/guide/en/pipeline/1-rails-and-jobs.md +94 -0
  88. package/docs/guide/en/pipeline/2-the-job-detail-view.md +90 -0
  89. package/docs/guide/en/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  90. package/docs/guide/en/pipeline/4-picking-an-engine-per-rail.md +60 -0
  91. package/docs/guide/en/settings/1-themes.md +37 -0
  92. package/docs/guide/en/settings/2-language.md +39 -0
  93. package/docs/guide/en/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  94. package/docs/guide/en/settings/4-where-your-data-lives.md +48 -0
  95. package/docs/guide/en/specs/1-specs-and-the-backlog.md +52 -0
  96. package/docs/guide/en/specs/2-add-spec-quick-mode.md +45 -0
  97. package/docs/guide/en/specs/3-add-spec-explore-mode.md +68 -0
  98. package/docs/guide/en/specs/4-drafts-and-contract-layer.md +81 -0
  99. package/docs/guide/es/agents/1-meet-the-agents.md +38 -0
  100. package/docs/guide/es/agents/2-profiles-and-the-balanced-default.md +45 -0
  101. package/docs/guide/es/agents/3-customizing-models-per-agent.md +60 -0
  102. package/docs/guide/es/agents/4-custom-agents-catalog.md +43 -0
  103. package/docs/guide/es/getting-started/1-what-is-specrails.md +49 -0
  104. package/docs/guide/es/getting-started/2-installing-and-first-run.md +42 -0
  105. package/docs/guide/es/getting-started/3-adding-your-first-project.md +58 -0
  106. package/docs/guide/es/getting-started/4-the-dashboard-tour.md +53 -0
  107. package/docs/guide/es/insights/1-analytics-and-cost-tracking.md +78 -0
  108. package/docs/guide/es/insights/2-the-integrated-terminal.md +46 -0
  109. package/docs/guide/es/insights/3-code-explorer.md +50 -0
  110. package/docs/guide/es/integrations/1-ai-providers.md +64 -0
  111. package/docs/guide/es/integrations/2-plugins.md +44 -0
  112. package/docs/guide/es/integrations/3-jira-integration.md +71 -0
  113. package/docs/guide/es/integrations/4-mobile-companion.md +38 -0
  114. package/docs/guide/es/pipeline/1-rails-and-jobs.md +94 -0
  115. package/docs/guide/es/pipeline/2-the-job-detail-view.md +90 -0
  116. package/docs/guide/es/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  117. package/docs/guide/es/pipeline/4-picking-an-engine-per-rail.md +60 -0
  118. package/docs/guide/es/settings/1-themes.md +37 -0
  119. package/docs/guide/es/settings/2-language.md +39 -0
  120. package/docs/guide/es/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  121. package/docs/guide/es/settings/4-where-your-data-lives.md +48 -0
  122. package/docs/guide/es/specs/1-specs-and-the-backlog.md +52 -0
  123. package/docs/guide/es/specs/2-add-spec-quick-mode.md +45 -0
  124. package/docs/guide/es/specs/3-add-spec-explore-mode.md +68 -0
  125. package/docs/guide/es/specs/4-drafts-and-contract-layer.md +81 -0
  126. package/docs/guide/fr/agents/1-meet-the-agents.md +38 -0
  127. package/docs/guide/fr/agents/2-profiles-and-the-balanced-default.md +45 -0
  128. package/docs/guide/fr/agents/3-customizing-models-per-agent.md +60 -0
  129. package/docs/guide/fr/agents/4-custom-agents-catalog.md +43 -0
  130. package/docs/guide/fr/getting-started/1-what-is-specrails.md +49 -0
  131. package/docs/guide/fr/getting-started/2-installing-and-first-run.md +42 -0
  132. package/docs/guide/fr/getting-started/3-adding-your-first-project.md +58 -0
  133. package/docs/guide/fr/getting-started/4-the-dashboard-tour.md +53 -0
  134. package/docs/guide/fr/insights/1-analytics-and-cost-tracking.md +78 -0
  135. package/docs/guide/fr/insights/2-the-integrated-terminal.md +46 -0
  136. package/docs/guide/fr/insights/3-code-explorer.md +50 -0
  137. package/docs/guide/fr/integrations/1-ai-providers.md +64 -0
  138. package/docs/guide/fr/integrations/2-plugins.md +44 -0
  139. package/docs/guide/fr/integrations/3-jira-integration.md +71 -0
  140. package/docs/guide/fr/integrations/4-mobile-companion.md +38 -0
  141. package/docs/guide/fr/pipeline/1-rails-and-jobs.md +94 -0
  142. package/docs/guide/fr/pipeline/2-the-job-detail-view.md +90 -0
  143. package/docs/guide/fr/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  144. package/docs/guide/fr/pipeline/4-picking-an-engine-per-rail.md +60 -0
  145. package/docs/guide/fr/settings/1-themes.md +37 -0
  146. package/docs/guide/fr/settings/2-language.md +39 -0
  147. package/docs/guide/fr/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  148. package/docs/guide/fr/settings/4-where-your-data-lives.md +48 -0
  149. package/docs/guide/fr/specs/1-specs-and-the-backlog.md +52 -0
  150. package/docs/guide/fr/specs/2-add-spec-quick-mode.md +45 -0
  151. package/docs/guide/fr/specs/3-add-spec-explore-mode.md +68 -0
  152. package/docs/guide/fr/specs/4-drafts-and-contract-layer.md +81 -0
  153. package/docs/guide/it/agents/1-meet-the-agents.md +38 -0
  154. package/docs/guide/it/agents/2-profiles-and-the-balanced-default.md +45 -0
  155. package/docs/guide/it/agents/3-customizing-models-per-agent.md +60 -0
  156. package/docs/guide/it/agents/4-custom-agents-catalog.md +43 -0
  157. package/docs/guide/it/getting-started/1-what-is-specrails.md +49 -0
  158. package/docs/guide/it/getting-started/2-installing-and-first-run.md +42 -0
  159. package/docs/guide/it/getting-started/3-adding-your-first-project.md +58 -0
  160. package/docs/guide/it/getting-started/4-the-dashboard-tour.md +53 -0
  161. package/docs/guide/it/insights/1-analytics-and-cost-tracking.md +78 -0
  162. package/docs/guide/it/insights/2-the-integrated-terminal.md +46 -0
  163. package/docs/guide/it/insights/3-code-explorer.md +50 -0
  164. package/docs/guide/it/integrations/1-ai-providers.md +64 -0
  165. package/docs/guide/it/integrations/2-plugins.md +44 -0
  166. package/docs/guide/it/integrations/3-jira-integration.md +71 -0
  167. package/docs/guide/it/integrations/4-mobile-companion.md +38 -0
  168. package/docs/guide/it/pipeline/1-rails-and-jobs.md +94 -0
  169. package/docs/guide/it/pipeline/2-the-job-detail-view.md +90 -0
  170. package/docs/guide/it/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  171. package/docs/guide/it/pipeline/4-picking-an-engine-per-rail.md +60 -0
  172. package/docs/guide/it/settings/1-themes.md +37 -0
  173. package/docs/guide/it/settings/2-language.md +39 -0
  174. package/docs/guide/it/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  175. package/docs/guide/it/settings/4-where-your-data-lives.md +48 -0
  176. package/docs/guide/it/specs/1-specs-and-the-backlog.md +52 -0
  177. package/docs/guide/it/specs/2-add-spec-quick-mode.md +45 -0
  178. package/docs/guide/it/specs/3-add-spec-explore-mode.md +68 -0
  179. package/docs/guide/it/specs/4-drafts-and-contract-layer.md +81 -0
  180. package/docs/guide/ja/agents/1-meet-the-agents.md +38 -0
  181. package/docs/guide/ja/agents/2-profiles-and-the-balanced-default.md +45 -0
  182. package/docs/guide/ja/agents/3-customizing-models-per-agent.md +60 -0
  183. package/docs/guide/ja/agents/4-custom-agents-catalog.md +43 -0
  184. package/docs/guide/ja/getting-started/1-what-is-specrails.md +49 -0
  185. package/docs/guide/ja/getting-started/2-installing-and-first-run.md +42 -0
  186. package/docs/guide/ja/getting-started/3-adding-your-first-project.md +58 -0
  187. package/docs/guide/ja/getting-started/4-the-dashboard-tour.md +53 -0
  188. package/docs/guide/ja/insights/1-analytics-and-cost-tracking.md +78 -0
  189. package/docs/guide/ja/insights/2-the-integrated-terminal.md +46 -0
  190. package/docs/guide/ja/insights/3-code-explorer.md +50 -0
  191. package/docs/guide/ja/integrations/1-ai-providers.md +64 -0
  192. package/docs/guide/ja/integrations/2-plugins.md +44 -0
  193. package/docs/guide/ja/integrations/3-jira-integration.md +71 -0
  194. package/docs/guide/ja/integrations/4-mobile-companion.md +38 -0
  195. package/docs/guide/ja/pipeline/1-rails-and-jobs.md +94 -0
  196. package/docs/guide/ja/pipeline/2-the-job-detail-view.md +90 -0
  197. package/docs/guide/ja/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  198. package/docs/guide/ja/pipeline/4-picking-an-engine-per-rail.md +60 -0
  199. package/docs/guide/ja/settings/1-themes.md +37 -0
  200. package/docs/guide/ja/settings/2-language.md +39 -0
  201. package/docs/guide/ja/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  202. package/docs/guide/ja/settings/4-where-your-data-lives.md +48 -0
  203. package/docs/guide/ja/specs/1-specs-and-the-backlog.md +52 -0
  204. package/docs/guide/ja/specs/2-add-spec-quick-mode.md +45 -0
  205. package/docs/guide/ja/specs/3-add-spec-explore-mode.md +68 -0
  206. package/docs/guide/ja/specs/4-drafts-and-contract-layer.md +81 -0
  207. package/docs/guide/pt/agents/1-meet-the-agents.md +38 -0
  208. package/docs/guide/pt/agents/2-profiles-and-the-balanced-default.md +45 -0
  209. package/docs/guide/pt/agents/3-customizing-models-per-agent.md +60 -0
  210. package/docs/guide/pt/agents/4-custom-agents-catalog.md +43 -0
  211. package/docs/guide/pt/getting-started/1-what-is-specrails.md +49 -0
  212. package/docs/guide/pt/getting-started/2-installing-and-first-run.md +42 -0
  213. package/docs/guide/pt/getting-started/3-adding-your-first-project.md +58 -0
  214. package/docs/guide/pt/getting-started/4-the-dashboard-tour.md +53 -0
  215. package/docs/guide/pt/insights/1-analytics-and-cost-tracking.md +78 -0
  216. package/docs/guide/pt/insights/2-the-integrated-terminal.md +46 -0
  217. package/docs/guide/pt/insights/3-code-explorer.md +50 -0
  218. package/docs/guide/pt/integrations/1-ai-providers.md +64 -0
  219. package/docs/guide/pt/integrations/2-plugins.md +44 -0
  220. package/docs/guide/pt/integrations/3-jira-integration.md +71 -0
  221. package/docs/guide/pt/integrations/4-mobile-companion.md +38 -0
  222. package/docs/guide/pt/pipeline/1-rails-and-jobs.md +94 -0
  223. package/docs/guide/pt/pipeline/2-the-job-detail-view.md +90 -0
  224. package/docs/guide/pt/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  225. package/docs/guide/pt/pipeline/4-picking-an-engine-per-rail.md +60 -0
  226. package/docs/guide/pt/settings/1-themes.md +37 -0
  227. package/docs/guide/pt/settings/2-language.md +39 -0
  228. package/docs/guide/pt/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  229. package/docs/guide/pt/settings/4-where-your-data-lives.md +48 -0
  230. package/docs/guide/pt/specs/1-specs-and-the-backlog.md +52 -0
  231. package/docs/guide/pt/specs/2-add-spec-quick-mode.md +45 -0
  232. package/docs/guide/pt/specs/3-add-spec-explore-mode.md +68 -0
  233. package/docs/guide/pt/specs/4-drafts-and-contract-layer.md +81 -0
  234. package/docs/guide/zh/agents/1-meet-the-agents.md +38 -0
  235. package/docs/guide/zh/agents/2-profiles-and-the-balanced-default.md +45 -0
  236. package/docs/guide/zh/agents/3-customizing-models-per-agent.md +60 -0
  237. package/docs/guide/zh/agents/4-custom-agents-catalog.md +43 -0
  238. package/docs/guide/zh/getting-started/1-what-is-specrails.md +49 -0
  239. package/docs/guide/zh/getting-started/2-installing-and-first-run.md +42 -0
  240. package/docs/guide/zh/getting-started/3-adding-your-first-project.md +58 -0
  241. package/docs/guide/zh/getting-started/4-the-dashboard-tour.md +53 -0
  242. package/docs/guide/zh/insights/1-analytics-and-cost-tracking.md +78 -0
  243. package/docs/guide/zh/insights/2-the-integrated-terminal.md +46 -0
  244. package/docs/guide/zh/insights/3-code-explorer.md +50 -0
  245. package/docs/guide/zh/integrations/1-ai-providers.md +64 -0
  246. package/docs/guide/zh/integrations/2-plugins.md +44 -0
  247. package/docs/guide/zh/integrations/3-jira-integration.md +71 -0
  248. package/docs/guide/zh/integrations/4-mobile-companion.md +38 -0
  249. package/docs/guide/zh/pipeline/1-rails-and-jobs.md +94 -0
  250. package/docs/guide/zh/pipeline/2-the-job-detail-view.md +90 -0
  251. package/docs/guide/zh/pipeline/3-batch-implement-and-multi-feature.md +78 -0
  252. package/docs/guide/zh/pipeline/4-picking-an-engine-per-rail.md +60 -0
  253. package/docs/guide/zh/settings/1-themes.md +37 -0
  254. package/docs/guide/zh/settings/2-language.md +39 -0
  255. package/docs/guide/zh/settings/3-pipeline-telemetry-and-diagnostics.md +46 -0
  256. package/docs/guide/zh/settings/4-where-your-data-lives.md +48 -0
  257. package/docs/guide/zh/specs/1-specs-and-the-backlog.md +52 -0
  258. package/docs/guide/zh/specs/2-add-spec-quick-mode.md +45 -0
  259. package/docs/guide/zh/specs/3-add-spec-explore-mode.md +68 -0
  260. package/docs/guide/zh/specs/4-drafts-and-contract-layer.md +81 -0
  261. package/docs/internals/README.md +1 -1
  262. package/docs/internals/adding-a-provider.md +192 -59
  263. package/docs/internals/api-reference.md +130 -21
  264. package/docs/internals/architecture.md +22 -9
  265. package/docs/internals/bundled-framework-build-plan.md +264 -0
  266. package/docs/internals/configuration.md +33 -8
  267. package/docs/internals/global-artifacts-alignment-contract.md +486 -0
  268. package/docs/internals/global-artifacts-relocation-evaluation.md +294 -0
  269. package/docs/internals/operations-runbook.md +16 -5
  270. package/docs/internals/profiles.md +42 -14
  271. package/docs/platforms/macos.md +27 -8
  272. package/docs/platforms/windows.md +20 -6
  273. package/docs/running-pipelines.md +17 -9
  274. package/docs/terminal.md +9 -3
  275. package/docs/tracking-cost.md +17 -11
  276. package/package.json +1 -1
  277. package/server/dist/agent-refine-manager.js +20 -5
  278. package/server/dist/artifact-registry.js +468 -0
  279. package/server/dist/attachment-manager.js +5 -8
  280. package/server/dist/browser-capture-manager.js +4 -4
  281. package/server/dist/bundled-core.js +72 -0
  282. package/server/dist/bundled-openspec.js +58 -0
  283. package/server/dist/chat-manager.js +42 -5
  284. package/server/dist/code-explorer-router.js +10 -7
  285. package/server/dist/config.js +7 -2
  286. package/server/dist/context-budget.js +17 -6
  287. package/server/dist/context-scope.js +6 -2
  288. package/server/dist/contract-refine-runner.js +31 -9
  289. package/server/dist/desktop-router.js +39 -14
  290. package/server/dist/docs-router.js +210 -132
  291. package/server/dist/file-summary-manager.js +41 -16
  292. package/server/dist/framework-manager.js +248 -0
  293. package/server/dist/framework-migration.js +308 -0
  294. package/server/dist/index.js +30 -0
  295. package/server/dist/install-config-path.js +73 -0
  296. package/server/dist/jira/jira-sync-manager.js +23 -11
  297. package/server/dist/openspec-shim.js +153 -0
  298. package/server/dist/plugins-router.js +19 -8
  299. package/server/dist/profiles-router.js +38 -16
  300. package/server/dist/project-registry.js +101 -3
  301. package/server/dist/project-router-chat.js +1 -1
  302. package/server/dist/project-router-helpers.js +25 -12
  303. package/server/dist/project-router-jobs.js +3 -3
  304. package/server/dist/project-router-settings.js +8 -6
  305. package/server/dist/project-router-setup.js +27 -10
  306. package/server/dist/project-router-spending.js +6 -1
  307. package/server/dist/project-router-tickets.js +30 -10
  308. package/server/dist/project-router.js +16 -1
  309. package/server/dist/providers/gemini-adapter.js +4 -0
  310. package/server/dist/providers/gemini-agent-ack.js +65 -0
  311. package/server/dist/queue-manager.js +156 -12
  312. package/server/dist/setup-manager.js +131 -29
  313. package/server/dist/smash-runner.js +21 -6
  314. package/server/dist/ticket-store.js +6 -2
  315. package/server/dist/ticket-watcher.js +5 -1
  316. package/server/dist/util/stream-display.js +18 -3
  317. package/server/dist/vitest-setup.js +25 -0
  318. package/server/dist/workspace-manager.js +199 -0
  319. package/server/dist/workspace-resolution.js +147 -0
  320. package/client/dist/assets/index-DgKfQFcf.css +0 -2
  321. package/client/dist/assets/setup-BIIkb-_K.js +0 -1
  322. package/client/dist/assets/setup-BeQxu9kD.js +0 -1
  323. package/client/dist/assets/setup-CPa6GnlI.js +0 -1
  324. package/client/dist/assets/setup-CZl4OEJx.js +0 -1
  325. package/client/dist/assets/setup-ChpodNfn.js +0 -1
  326. package/client/dist/assets/setup-D_fjJH6u.js +0 -1
  327. package/client/dist/assets/setup-YzD8DX4O.js +0 -1
  328. package/client/dist/assets/setup-fRpDozmq.js +0 -1
  329. package/docs/adding-a-provider.md +0 -107
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### The local cockpit for shipping software with AI agents
6
6
 
7
- **Draft specs by talking to Claude or Codex → drag them onto execution rails → watch the pipeline ship — all from one window, on your laptop, with every dollar tracked.**
7
+ **Draft specs by talking to Claude, Codex, or Gemini → drag them onto execution rails → watch the pipeline ship — all from one window, on your laptop, with every dollar tracked.**
8
8
 
9
9
  [![npm version](https://img.shields.io/npm/v/specrails-desktop?color=4f46e5&label=npm&logo=npm&logoColor=white&style=flat-square)](https://www.npmjs.com/package/specrails-desktop)
10
10
  [![license](https://img.shields.io/badge/license-MIT-22c55e?style=flat-square)](LICENSE)
@@ -12,7 +12,7 @@
12
12
  [![TypeScript](https://img.shields.io/badge/TypeScript-strict-3178c6?logo=typescript&logoColor=white&style=flat-square)](https://www.typescriptlang.org/)
13
13
  [![React](https://img.shields.io/badge/React-19-61dafb?logo=react&logoColor=black&style=flat-square)](https://react.dev)
14
14
  [![Desktop](https://img.shields.io/badge/Desktop-Tauri-ffc131?logo=tauri&logoColor=black&style=flat-square)](https://tauri.app)
15
- [![providers](https://img.shields.io/badge/agents-Claude%20%2B%20Codex-ff7a59?style=flat-square)](#-bring-your-own-agent)
15
+ [![providers](https://img.shields.io/badge/agents-Claude%20%2B%20Codex%20%2B%20Gemini-ff7a59?style=flat-square)](#-bring-your-own-agent)
16
16
 
17
17
  [Quick start](#-quick-start) · [Features](#-what-you-can-do) · [Architecture](#%EF%B8%8F-how-its-built) · [Docs](#-documentation) · [Desktop app](#%EF%B8%8F-desktop-app)
18
18
 
@@ -60,8 +60,8 @@
60
60
 
61
61
  | | |
62
62
  |---|---|
63
- | 📊 **Analytics** | Every billable AI invocation — across rails, Quick, Explore, AI edits, SMASH, and file summaries — is recorded for **both Claude and Codex**. Burn-rate hero, daily timeline, top tickets, model breakdown, cost-vs-turns scatter. |
64
- | 🧮 **Honest numbers** | Claude cost is the provider-billed figure; Codex cost is **estimated** from a local rate-card (the CLI doesn't report it) and clearly flagged with a `~`. Token totals include the cache tiers, so the figures actually reconcile. |
63
+ | 📊 **Analytics** | Every billable AI invocation — across rails, Quick, Explore, AI edits, SMASH, and file summaries — is recorded for **Claude, Codex, and Gemini**. Burn-rate hero, daily timeline, top tickets, model breakdown, cost-vs-turns scatter. |
64
+ | 🧮 **Honest numbers** | Claude cost is the provider-billed figure; **Codex and Gemini costs are estimated** from a local rate-card (those CLIs don't report cost) and clearly flagged with a `~`. Token totals include the cache tiers, so the figures actually reconcile. |
65
65
  | 📤 **Exports** | One-click CSV/JSON, plus per-ticket spending deep-links. |
66
66
 
67
67
  ### 🛠️ Make it yours
@@ -70,24 +70,27 @@
70
70
  |---|---|
71
71
  | 🖥️ **Terminal panel** | A real VS-Code-style bottom panel (`Cmd/Ctrl+J`) powered by `node-pty` + xterm.js — WebGL rendering, search, ligatures, image inline, drag-drop paths, and OSC 133 shell integration. |
72
72
  | 🎨 **Themes** | Five built-ins — `specrails` (default), `dracula`, `aurora-light`, `obsidian-dark`, `matrix` — applied before React hydrates (no flash). |
73
- | 🧭 **Code explorer** | A read-only, non-developer-friendly file tree + Monaco viewer with plain-language AI summaries and *"touched by AI"* provenance chips. |
73
+ | 🧭 **Code explorer** | A non-developer-friendly file tree + Monaco viewer with plain-language AI summaries and *"touched by AI"* provenance chips, plus opt-in **in-app editing of existing files** (overwrite-only — no create/rename, blocks binaries, respects the deny-list/`.gitignore` and a size cap). |
74
74
  | 💬 **Minimizable chats** | Park an Explore or AI-Edit session into a dock chip and pick it back up later — never lost across refreshes or project switches. |
75
75
 
76
76
  ---
77
77
 
78
78
  ## 🤖 Bring your own agent
79
79
 
80
- specrails-desktop treats **Claude Code** and **Codex CLI** as first-class, interchangeable providers through a single `ProviderAdapter` contract — no manager ever branches on `provider === 'X'`.
80
+ specrails-desktop treats **Claude Code**, **Codex CLI**, and **Gemini CLI** as first-class, interchangeable providers through a single `ProviderAdapter` contract — no manager ever branches on `provider === 'X'`. All three are **enabled by default**.
81
81
 
82
- | | 🟣 Claude Code | 🟢 Codex CLI |
83
- |---|:---:|:---:|
84
- | Native streaming | | |
85
- | Native session resume | ✅ | ✅ |
86
- | Native cost reporting | ✅ | ⚠️ estimated via rate-card |
87
- | Native OTEL telemetry | ✅ | 🔧 synthesized by the app |
88
- | Agent profiles | ✅ | |
82
+ | | 🟣 Claude Code | 🟢 Codex CLI | 🔵 Gemini CLI |
83
+ |---|:---:|:---:|:---:|
84
+ | Minimum CLI version | none pinned | 0.128.0 | 0.11.0 |
85
+ | Native streaming | | ✅ | ✅ |
86
+ | Native session resume | ✅ | | |
87
+ | Native cost reporting | ✅ | ⚠️ estimated via rate-card | ⚠️ estimated via rate-card |
88
+ | Native OTEL telemetry | ✅ | 🔧 synthesized by the app | ✅ native |
89
+ | Agent profiles on rails | ✅ | — *(forced legacy)* | — *(forced legacy)* |
89
90
 
90
- A project can install **one or both**. When both are present, the UI lets you pick the engine per spec, per rail, or per terminal launch. Adding a third provider is *one file + one registry entry* see [`docs/internals/`](docs/internals/).
91
+ A project's **provider set** is chosen at install (one or more of Claude / Codex / Gemini) and is **immutable afterward**; the per-invocation **engine** is picked from that set per spec, per rail, or per terminal launch whenever more than one is installed. To disable Gemini (emergency rollback) set `SPECRAILS_GEMINI_BETA=0`; for Codex it's `SPECRAILS_CODEX_BETA=0` (only the exact string `0` disables either).
92
+
93
+ Adding a fourth provider is *one file + one registry entry* — Gemini already proved the path (adapters may also add an optional `prepareHeadlessSpawn` hook, as Gemini does for headless rails). See [`docs/internals/`](docs/internals/).
91
94
 
92
95
  ---
93
96
 
@@ -139,12 +142,11 @@ If a project doesn't have specrails-core yet, a **3-step setup wizard** (Configu
139
142
  specrails-desktop start | stop | add | remove | list # manage the app
140
143
  specrails-desktop implement #42 # run a specrails verb
141
144
  specrails-desktop --status # manager status
142
- specrails-desktop --jobs # recent job history
143
145
  specrails-desktop --project <name|path> # target a project
144
146
  specrails-desktop --help # full reference
145
147
  ```
146
148
 
147
- When the app is running, the CLI talks to it over HTTP + WebSocket; when it isn't, it spawns the agent directly. Either way you get streamed logs.
149
+ When the app is running, the CLI talks to it over HTTP + WebSocket; when it isn't, it spawns the agent directly — note the offline path always runs `claude` (even for Codex/Gemini projects) and records nothing to Analytics. Either way you get streamed logs. (Job history lives in the dashboard **Jobs** page, per project.)
148
150
 
149
151
  ---
150
152
 
@@ -152,13 +154,14 @@ When the app is running, the CLI talks to it over HTTP + WebSocket; when it isn'
152
154
 
153
155
  - 🟩 **Node.js 20+**
154
156
  - 🤖 **At least one AI CLI** on your `PATH`:
155
- - **[Claude Code](https://claude.com/claude-code)** — the `claude` binary, signed in (via Claude subscription login or an `ANTHROPIC_API_KEY`).
157
+ - **[Claude Code](https://claude.com/claude-code)** — the `claude` binary, signed in (via Claude subscription login or an `ANTHROPIC_API_KEY`). No minimum version pinned.
156
158
  - **[Codex CLI](https://developers.openai.com/codex)** ≥ 0.128.0 — the `codex` binary. Run `codex login` or set `OPENAI_API_KEY`.
159
+ - **[Gemini CLI](https://github.com/google-gemini/gemini-cli)** ≥ 0.11.0 — the `gemini` binary, authenticated (set `GEMINI_API_KEY`).
157
160
  - 🌿 **git**
158
161
  - 🧪 *(optional)* **`uv`** — only if you want the Serena plugin
159
- - 📦 **specrails-core** ≥ 4.6.0 in the project for Codex, 4.2.0 for Claude-only *(the wizard installs it)*
162
+ - 📦 **specrails-core** ≥ 4.8.0 in the project *(the wizard installs it)* — a single shared floor for all providers; 4.8.0 is the release that ships the Gemini target. Agent profiles need core ≥ 4.1.0 in the project.
160
163
 
161
- The provider is chosen **per project at install time** and is immutable afterward. On macOS the desktop app resolves Homebrew/Volta/nvm paths for you.
164
+ A project's **provider set** is chosen at install time (one or more of Claude / Codex / Gemini) and is immutable afterward — you pick the engine per invocation from that set. On macOS the desktop app resolves Homebrew/Volta/nvm paths for you.
162
165
 
163
166
  ---
164
167
 
@@ -266,6 +269,7 @@ BUNDLE_CHROMIUM=true npm run build:desktop:local
266
269
  | ⌨️ [Terminal panel](docs/terminal.md) | Shortcuts, shell integration, drag-and-drop |
267
270
  | 🧑‍💻 [CLI reference](docs/cli.md) | Every command grouped by task |
268
271
  | 🟢 [Codex notes](docs/codex.md) | Auth, sandbox, estimated-cost caveats, rollback |
272
+ | 🔵 [Gemini notes](docs/gemini.md) | Auth, models, estimated-cost caveats, rollback |
269
273
 
270
274
  **Platform notes** — 🍎 [macOS](docs/platforms/macos.md) · 🪟 [Windows](docs/platforms/windows.md)
271
275
 
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,Ct as n,Et as r,F as i,Lt as a,Ot as o,Q as s,Rt as c,dt as l,ft as u,sn as d,wt as f,zt as p}from"./index-DK214dak.js";var m=f(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),h=e(d(),1);function g(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function _({activeProjectId:e,limit:t=50}){let[n,r]=(0,h.useState)([]),[i,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(!0),u=(0,h.useRef)(e);(0,h.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=a();(0,h.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;s(!0),r([]),l(!0);async function i(){let e=p();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||s(!1)}}return i(),()=>{n=!0}},[e,t]);let m=(0,h.useCallback)(async()=>{if(i||!c)return;s(!0);let e=p();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>g([...t,...e])),l(e.length===t),s(!1)}).catch(()=>s(!1)),n})}catch{s(!1)}},[i,c,t]),_=(0,h.useCallback)(e=>{let t=e,n=u.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&r(t=>g([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:o.t(`activity:feed.phaseCommand`,{phase:t.phase,state:t.state}),timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};r(t=>g([e,...t]))}}},[]);return(0,h.useLayoutEffect)(()=>(d(`activity`,_),()=>f(`activity`)),[_,d,f]),{items:n,loading:i,hasMore:c,loadMore:m}}var v=c();function y(e,t){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/1e3);if(r<60)return t(`feed.relativeTime.seconds`,{value:r});let i=Math.floor(r/60);if(i<60)return t(`feed.relativeTime.minutes`,{value:i});let a=Math.floor(i/60);return a<24?t(`feed.relativeTime.hours`,{value:a}):t(`feed.relativeTime.days`,{value:Math.floor(a/24)})}function b({type:e}){switch(e){case`job_completed`:return(0,v.jsx)(u,{className:`w-4 h-4 text-green-500 aurora-light:text-accent-success flex-shrink-0`});case`job_failed`:return(0,v.jsx)(l,{className:`w-4 h-4 text-red-500 aurora-light:text-destructive flex-shrink-0`});case`job_canceled`:return(0,v.jsx)(m,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,v.jsx)(i,{className:`w-4 h-4 text-blue-500 aurora-light:text-accent-info flex-shrink-0`})}}function x(e,t){switch(e){case`job_completed`:return t(`common:status.completed`);case`job_failed`:return t(`common:status.failed`);case`job_canceled`:return t(`common:status.canceled`);default:return t(`feed.typeStarted`)}}function S(e){switch(e){case`job_completed`:return`text-green-500 aurora-light:text-accent-success`;case`job_failed`:return`text-red-500 aurora-light:text-destructive`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500 aurora-light:text-accent-info`}}function C(){let{t:e}=t(`activity`),{activeProjectId:i}=r(),{items:a,loading:o,hasMore:c,loadMore:l}=_({activeProjectId:i}),u=(0,h.useRef)(null);return(0,h.useEffect)(()=>{let e=u.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&c&&!o&&l()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[c,o,l]),(0,v.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,v.jsx)(n,{className:`w-4 h-4 text-muted-foreground`}),(0,v.jsx)(`h1`,{className:`text-sm font-medium`,children:e(`feed.title`)})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[o&&a.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):a.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,v.jsx)(n,{className:`w-8 h-8 opacity-40`}),(0,v.jsx)(`p`,{className:`text-sm`,children:e(`feed.emptyTitle`)}),(0,v.jsx)(`p`,{className:`text-xs opacity-70`,children:e(`feed.emptyHint`)})]}):(0,v.jsx)(`ul`,{className:`divide-y divide-border/50`,children:a.map(t=>(0,v.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,v.jsx)(b,{type:t.type}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:t.jobCommand,children:t.jobCommand}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-xs font-medium ${S(t.type)}`,children:x(t.type,e)}),t.costUsd!=null&&(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,t.costUsd.toFixed(4)]})]})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:y(t.timestamp,e)})]},`${t.type}:${t.jobId}`))}),(0,v.jsx)(`div`,{ref:u,className:`h-1`}),o&&a.length>0&&(0,v.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!c&&a.length>0&&(0,v.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:e(`feed.allLoaded`)})]})]})}export{C as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,Ct as n,Et as r,F as i,Lt as a,Ot as o,Q as s,Rt as c,dt as l,ft as u,sn as d,wt as f,zt as p}from"./index-BXoHFtfG.js";var m=f(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),h=e(d(),1);function g(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function _({activeProjectId:e,limit:t=50}){let[n,r]=(0,h.useState)([]),[i,s]=(0,h.useState)(!1),[c,l]=(0,h.useState)(!0),u=(0,h.useRef)(e);(0,h.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=a();(0,h.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;s(!0),r([]),l(!0);async function i(){let e=p();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||s(!1)}}return i(),()=>{n=!0}},[e,t]);let m=(0,h.useCallback)(async()=>{if(i||!c)return;s(!0);let e=p();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>g([...t,...e])),l(e.length===t),s(!1)}).catch(()=>s(!1)),n})}catch{s(!1)}},[i,c,t]),_=(0,h.useCallback)(e=>{let t=e,n=u.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&r(t=>g([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:o.t(`activity:feed.phaseCommand`,{phase:t.phase,state:t.state}),timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};r(t=>g([e,...t]))}}},[]);return(0,h.useLayoutEffect)(()=>(d(`activity`,_),()=>f(`activity`)),[_,d,f]),{items:n,loading:i,hasMore:c,loadMore:m}}var v=c();function y(e,t){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/1e3);if(r<60)return t(`feed.relativeTime.seconds`,{value:r});let i=Math.floor(r/60);if(i<60)return t(`feed.relativeTime.minutes`,{value:i});let a=Math.floor(i/60);return a<24?t(`feed.relativeTime.hours`,{value:a}):t(`feed.relativeTime.days`,{value:Math.floor(a/24)})}function b({type:e}){switch(e){case`job_completed`:return(0,v.jsx)(u,{className:`w-4 h-4 text-green-500 aurora-light:text-accent-success flex-shrink-0`});case`job_failed`:return(0,v.jsx)(l,{className:`w-4 h-4 text-red-500 aurora-light:text-destructive flex-shrink-0`});case`job_canceled`:return(0,v.jsx)(m,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,v.jsx)(i,{className:`w-4 h-4 text-blue-500 aurora-light:text-accent-info flex-shrink-0`})}}function x(e,t){switch(e){case`job_completed`:return t(`common:status.completed`);case`job_failed`:return t(`common:status.failed`);case`job_canceled`:return t(`common:status.canceled`);default:return t(`feed.typeStarted`)}}function S(e){switch(e){case`job_completed`:return`text-green-500 aurora-light:text-accent-success`;case`job_failed`:return`text-red-500 aurora-light:text-destructive`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500 aurora-light:text-accent-info`}}function C(){let{t:e}=t(`activity`),{activeProjectId:i}=r(),{items:a,loading:o,hasMore:c,loadMore:l}=_({activeProjectId:i}),u=(0,h.useRef)(null);return(0,h.useEffect)(()=>{let e=u.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&c&&!o&&l()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[c,o,l]),(0,v.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,v.jsx)(n,{className:`w-4 h-4 text-muted-foreground`}),(0,v.jsx)(`h1`,{className:`text-sm font-medium`,children:e(`feed.title`)})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[o&&a.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):a.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,v.jsx)(n,{className:`w-8 h-8 opacity-40`}),(0,v.jsx)(`p`,{className:`text-sm`,children:e(`feed.emptyTitle`)}),(0,v.jsx)(`p`,{className:`text-xs opacity-70`,children:e(`feed.emptyHint`)})]}):(0,v.jsx)(`ul`,{className:`divide-y divide-border/50`,children:a.map(t=>(0,v.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,v.jsx)(b,{type:t.type}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:t.jobCommand,children:t.jobCommand}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-xs font-medium ${S(t.type)}`,children:x(t.type,e)}),t.costUsd!=null&&(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,t.costUsd.toFixed(4)]})]})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:y(t.timestamp,e)})]},`${t.type}:${t.jobId}`))}),(0,v.jsx)(`div`,{ref:u,className:`h-1`}),o&&a.length>0&&(0,v.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!c&&a.length>0&&(0,v.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:e(`feed.allLoaded`)})]})]})}export{C as default};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,A as n,B as r,Bt as i,D as a,E as o,Et as s,Gt as c,H as l,Ht as u,I as d,J as f,Jt as p,K as m,Kt as h,L as g,Lt as _,N as v,O as y,Ot as b,Q as x,Qt as S,R as C,Rt as w,St as T,T as E,U as D,Ut as O,Vt as k,Wt as A,X as ee,Xt as j,Yt as M,Z as N,Zt as P,_t as F,ct as I,et as L,f as R,gt as te,ht as z,j as ne,k as B,o as re,ot as V,pt as ie,qt as ae,rt as oe,sn as se,tn as H,w as U,wt as W,xt as ce,yt as le,z as ue,zt as G}from"./index-DK214dak.js";var K=W(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),q=W(`history`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),de=W(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),fe=W(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),J=e(se(),1),Y=w(),X=/^[a-z0-9][a-z0-9-]*$/;function pe({open:e,mode:n=`add`,initial:r,chainAgents:i,onConfirm:s,onCancel:c}){let{t:l}=t(`agents`),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(i[0]??``);(0,J.useEffect)(()=>{e&&(n===`edit`&&r?(d(r.tags.join(`, `)),p(i.includes(r.agent)?r.agent:i[0]??``)):(d(``),p(i[0]??``)))},[e,n,r,i]);let m=u.split(`,`).map(e=>e.trim()).filter(Boolean),h=m.filter(e=>!X.test(e)),g=m.length>0&&h.length===0&&i.includes(f);return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||c()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsxs)(y,{children:[(0,Y.jsx)(B,{children:l(n===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Y.jsx)(o,{children:l(n===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Y.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:l(`routingRule.tagsLabel`)}),(0,Y.jsx)(re,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),placeholder:`frontend, ui`,"aria-label":l(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Y.jsx)(H,{t:l,i18nKey:`routingRule.tagsHint`,components:{code:(0,Y.jsx)(`code`,{})}})}),h.length>0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:l(`routingRule.invalidTags`,{count:h.length,tags:h.join(`, `)})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:l(`routingRule.routeToLabel`)}),(0,Y.jsx)(`select`,{value:f,onChange:e=>p(e.target.value),"aria-label":l(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:i.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:l(`routingRule.routeToHint`)})]})]}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:c,children:l(`common:actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:()=>s(m,f),disabled:!g,children:l(n===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Z=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),me=[`sonnet`,`opus`,`haiku`],he=/^[a-z0-9][a-z0-9-]*$/;function ge({profile:e,onChange:n,footer:r,onValidityChange:a,onSoftWarningsChange:o}){let{t:s}=t(`agentstudio`),[l,m]=(0,J.useState)([]),[g,_]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=!1;return fetch(`${G()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||m(t.agents)}).catch(()=>{e||m([])}),()=>{e=!0}},[]);let C=t=>{let r=JSON.parse(JSON.stringify(e));t(r),n(r)},w=new Set(e.agents.map(e=>e.id)),T=l.filter(e=>!w.has(e.id)),E=(0,J.useMemo)(()=>{let t=[];for(let n of Z)e.agents.some(e=>e.id===n)||t.push(s(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(s(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(s(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(s(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!he.test(e));e.length>0&&t.push(s(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,s]),D=(0,J.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!Z.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),O=(0,J.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,J.useEffect)(()=>{a&&a(E)},[E,a]),(0,J.useEffect)(()=>{o&&o({agentsMissingRouting:D})},[D,o]);let ee=e=>{C(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),_(!1)},N=t=>{let n=e.agents[t];Z.has(n.id)||C(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},P=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=k(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}C(e=>{e.agents=a})},F=j(M(ae,{activationConstraint:{distance:4}}),M(h,{coordinateGetter:u})),I=e=>{let{active:t,over:n}=e;n&&P(String(t.id),String(n.id))},L=(e,t)=>{C(n=>{n.agents[e].model=t})},R=(e,t)=>{C(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),b(!1)},te=()=>{C(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},z=e=>`default`in e&&e.default===!0,ne=(e,t)=>{C(n=>{let r=n.routing[e];r&&(z(r)||(r.agent=t))})},B=(e,t,n)=>{C(r=>{let i=r.routing[e];i&&(z(i)||(i.tags=t,i.agent=n))})},V=e=>{C(t=>{let n=t.routing[e];n&&(z(n)||t.routing.splice(e,1))})},ie=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];z(i)||z(a)||C(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Y.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Y.jsx)(pe,{open:y,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:R,onCancel:()=>b(!1)}),(0,Y.jsx)(pe,{open:x!==null,mode:`edit`,initial:x!==null&&e.routing[x]&&!(`default`in e.routing[x])?{tags:e.routing[x].tags,agent:e.routing[x].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{x!==null&&(B(x,e,t),S(null))},onCancel:()=>S(null)}),E.length>0&&(0,Y.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Y.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.validationSummary`,{count:E.length})}),(0,Y.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:E.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.nameLabel`)}),(0,Y.jsx)(re,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.descriptionLabel`)}),(0,Y.jsx)(re,{value:e.description??``,onChange:e=>C(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:s(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:s(`profileEditor.orchestrator.heading`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:s(`profileEditor.orchestrator.description`)})]}),(0,Y.jsx)(ye,{value:e.orchestrator.model,onChange:e=>C(t=>{t.orchestrator.model=e})})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:()=>_(e=>!e),disabled:T.length===0,title:T.length===0?s(`profileEditor.agentChain.addDisabledTitle`):s(`profileEditor.agentChain.addTitle`),children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`common:actions.add`)]})]}),g&&(0,Y.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`profileEditor.agentChain.pickFromCatalog`,{n:T.length})}),(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>_(!1),title:s(`common:actions.close`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]}),T.length===0?(0,Y.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:s(`profileEditor.agentChain.emptyCatalog`)}):(0,Y.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:T.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ee(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:s(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Y.jsx)(c,{sensors:F,collisionDetection:p,onDragEnd:I,children:(0,Y.jsx)(i,{items:e.agents.map(e=>e.id),strategy:A,children:(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Y.jsx)(_e,{agent:e,canRemove:!Z.has(e.id),onModel:e=>L(t,e),onRemove:()=>N(t)},e.id))})})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!O&&(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:te,disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addDefault`)]}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:()=>b(!0),disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addRule`)]})]})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:s(`profileEditor.routing.explainer`)}),D.length>0&&(0,Y.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Y.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.routing.untargetedTitle`)}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(H,{t:s,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:D.join(`, `)},components:{mono:(0,Y.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Y.jsx)(ve,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>ne(n,e),onEdit:()=>S(n),onUp:()=>ie(n,-1),onDown:()=>ie(n,1),onRemove:()=>V(n)},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`pt-3 border-t border-border`,children:r})]})}function _e({agent:e,canRemove:n,onModel:r,onRemove:i}){let{t:a}=t(`agentstudio`),o=Z.has(e.id),s=e.id===`sr-architect`,c=e.id===`sr-merge-resolver`,{attributes:l,listeners:u,setNodeRef:f,transform:p,transition:m,isDragging:h}=O({id:e.id});return(0,Y.jsxs)(`div`,{ref:f,style:{transform:P.Transform.toString(p),transition:m,opacity:h?.5:void 0,zIndex:h?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:a(`profileEditor.agentRow.dragTitle`),"aria-label":a(`profileEditor.agentRow.dragHandleAria`),...l,...u,children:(0,Y.jsx)(L,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:a(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Y.jsx)(de,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,a(`profileEditor.agentRow.pinnedFirst`)]}),c&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:a(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Y.jsx)(de,{className:`w-2.5 h-2.5 rotate-45`}),` `,a(`profileEditor.agentRow.pinnedLast`)]}),o&&!s&&!c&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:a(`profileEditor.agentRow.required`)}),(0,Y.jsx)(ye,{value:e.model??`sonnet`,onChange:r}),(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:i,disabled:!n,title:a(n?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]})}function ve({rule:e,ordinal:n,isLast:r,canMove:i,canRemove:a,canEdit:o,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:f,onRemove:p}){let{t:m}=t(`agentstudio`),h=`default`in e&&e.default===!0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[n,`.`]}),h?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:m(`profileEditor.routingRow.everythingElse`)}):(0,Y.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),h?(0,Y.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":m(`profileEditor.routingRow.defaultTargetAria`),title:m(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Y.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":m(`profileEditor.routingRow.targetAria`,{ordinal:n}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:s.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[o&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:m(`profileEditor.routingRow.editTitle`),"aria-label":m(`profileEditor.routingRow.editAria`,{ordinal:n}),children:(0,Y.jsx)(ee,{className:`w-3 h-3`})}),i&&!r&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:f,title:m(`profileEditor.routingRow.moveDown`),children:(0,Y.jsx)(T,{className:`w-3 h-3`})}),i&&n>1&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:m(`profileEditor.routingRow.moveUp`),children:(0,Y.jsx)(le,{className:`w-3 h-3`})}),a&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:p,title:m(`common:actions.remove`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]}),h&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:m(`profileEditor.routingRow.coreDefaultTitle`),children:m(`profileEditor.routingRow.coreDefaultBadge`)})]})}function ye({value:e,onChange:t}){return(0,Y.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:me.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})}function be({open:e,title:n,description:r,placeholder:i,initialValue:o=``,confirmLabel:s,inputPattern:c,inputInvalidHint:l,onConfirm:u,onCancel:d}){let{t:f}=t(),[p,m]=(0,J.useState)(o);(0,J.useEffect)(()=>{e&&m(o)},[e,o]);let h=p.trim(),g=!c||c.test(h),_=h.length>0&&g;return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||d()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsx)(y,{children:(0,Y.jsx)(B,{children:n})}),(0,Y.jsxs)(`div`,{className:`py-2 space-y-2`,children:[r&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),(0,Y.jsx)(re,{autoFocus:!0,value:p,placeholder:i,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_&&u(h)},className:`text-sm font-mono`}),h.length>0&&!g&&l&&(0,Y.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:l})]}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:d,children:f(`actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:()=>u(h),disabled:!_,children:s??f(`actions.confirm`)})]})]})})}function xe({open:e,title:n,description:r,confirmLabel:i,destructive:o=!1,onConfirm:s,onCancel:c}){let{t:l}=t();return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||c()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsx)(y,{children:(0,Y.jsx)(B,{children:n})}),r&&(0,Y.jsx)(`div`,{className:`py-2`,children:(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:c,children:l(`actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:s,className:o?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:i??l(`actions.confirm`)})]})]})})}function Se(){let{t:e}=t(`agents`),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!0),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)([]),[_,y]=(0,J.useState)([]),[b,x]=(0,J.useState)(!1),[w,T]=(0,J.useState)(null),[E,O]=(0,J.useState)(null),k=(0,J.useCallback)(async()=>{l(!0),d(null);try{let t=await fetch(`${G()}/profiles`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let n=await t.json();r(n.profiles),n.profiles.length>0&&!i&&a(n.profiles[0].name)}catch(e){d(e.message)}finally{l(!1)}},[i]);(0,J.useEffect)(()=>{k()},[k]),(0,J.useEffect)(()=>{if(!i){s(null);return}let t=!1;return fetch(`${G()}/profiles/${encodeURIComponent(i)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||s(e.profile)}).catch(e=>{t||d(e.message)}),()=>{t=!0}},[i]);let A=(0,J.useCallback)(async()=>{m(!0),d(null);try{let t=await fetch(`${G()}/profiles/migrate-from-settings`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await k(),a(`default`),S.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{m(!1)}},[k]),ee=(0,J.useCallback)(async t=>{x(!1),m(!0),d(null);try{let n={schemaVersion:1,name:t,description:``,orchestrator:{model:`sonnet`},agents:[{id:`sr-architect`,model:`sonnet`,required:!0},{id:`sr-developer`,model:`sonnet`,required:!0},{id:`sr-reviewer`,model:`sonnet`,required:!0},{id:`sr-merge-resolver`,model:`sonnet`,required:!0}],routing:[{default:!0,agent:`sr-developer`}]},r=await fetch(`${G()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await k(),a(t),S.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.createFailed`),{description:n})}finally{m(!1)}},[k]),j=(0,J.useCallback)(async(t,n)=>{T(null),m(!0),d(null);try{let r=await fetch(`${G()}/profiles/${encodeURIComponent(t)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await k(),a(n),S.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{m(!1)}},[k]),M=(0,J.useCallback)(async t=>{O(null),m(!0),d(null);try{let n=await fetch(`${G()}/profiles/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}a(e=>e===t?null:e),await k(),S.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{m(!1)}},[k]),N=(0,J.useCallback)(()=>x(!0),[]),P=(0,J.useCallback)(e=>T({from:e}),[]),F=(0,J.useCallback)(e=>O({name:e}),[]),L=(0,J.useCallback)(async(t,n)=>{m(!0),d(null);try{let r=await fetch(`${G()}/profiles/${encodeURIComponent(t.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}s(t),n.length>0?S.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):S.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{m(!1)}},[e]),R=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(be,{open:b,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void ee(e),onCancel:()=>x(!1)}),w&&(0,Y.jsx)(be,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:w.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${w.from}-copy`,initialValue:`${w.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void j(w.from,e),onCancel:()=>T(null)}),E&&(0,Y.jsx)(xe,{open:!0,title:e(`profiles.deleteDialog.title`,{name:E.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void M(E.name),onCancel:()=>O(null)})]});return c?(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):n.length===0?(0,Y.jsxs)(Y.Fragment,{children:[R,(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Y.jsxs)(v,{size:`sm`,onClick:A,disabled:p,children:[(0,Y.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:N,disabled:p,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Y.jsx)(H,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Y.jsx)(`code`,{className:`text-foreground`})}})}),u&&(0,Y.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:u})]})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[R,(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Y.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Y.jsx)(v,{size:`sm`,variant:`ghost`,onClick:N,disabled:p,children:(0,Y.jsx)(f,{className:`w-3.5 h-3.5`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:n.map(t=>(0,Y.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===i?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>a(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&a(t.name)},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),P(t.name)},children:(0,Y.jsx)(I,{className:`w-3 h-3`})}),!t.isDefault&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),F(t.name)},children:(0,Y.jsx)(C,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Y.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[u&&(0,Y.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:u}),o?(0,Y.jsx)(ge,{profile:o,onChange:s,onValidityChange:g,onSoftWarningsChange:e=>y(e.agentsMissingRouting),footer:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(v,{size:`sm`,onClick:()=>void L(o,_),disabled:p||h.length>0,title:h.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Y.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),p&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),h.length>0&&(0,Y.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:h.length})})]})},o.name):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}function Q(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,A as n,B as r,Bt as i,D as a,E as o,Et as s,Gt as c,H as l,Ht as u,I as d,J as f,Jt as p,K as m,Kt as h,L as g,Lt as _,N as v,O as y,Ot as b,Q as x,Qt as S,R as C,Rt as w,St as T,T as E,U as D,Ut as O,Vt as k,Wt as A,X as ee,Xt as j,Yt as M,Z as N,Zt as P,_t as F,ct as I,et as L,f as R,gt as te,ht as z,j as ne,k as B,o as re,ot as V,pt as ie,qt as ae,rt as oe,sn as se,tn as H,w as U,wt as W,xt as ce,yt as le,z as ue,zt as G}from"./index-BXoHFtfG.js";var K=W(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),q=W(`history`,[[`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`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),de=W(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),fe=W(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),J=e(se(),1),Y=w(),X=/^[a-z0-9][a-z0-9-]*$/;function pe({open:e,mode:n=`add`,initial:r,chainAgents:i,onConfirm:s,onCancel:c}){let{t:l}=t(`agents`),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(i[0]??``);(0,J.useEffect)(()=>{e&&(n===`edit`&&r?(d(r.tags.join(`, `)),p(i.includes(r.agent)?r.agent:i[0]??``)):(d(``),p(i[0]??``)))},[e,n,r,i]);let m=u.split(`,`).map(e=>e.trim()).filter(Boolean),h=m.filter(e=>!X.test(e)),g=m.length>0&&h.length===0&&i.includes(f);return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||c()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsxs)(y,{children:[(0,Y.jsx)(B,{children:l(n===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Y.jsx)(o,{children:l(n===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Y.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:l(`routingRule.tagsLabel`)}),(0,Y.jsx)(re,{autoFocus:!0,value:u,onChange:e=>d(e.target.value),placeholder:`frontend, ui`,"aria-label":l(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Y.jsx)(H,{t:l,i18nKey:`routingRule.tagsHint`,components:{code:(0,Y.jsx)(`code`,{})}})}),h.length>0&&(0,Y.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:l(`routingRule.invalidTags`,{count:h.length,tags:h.join(`, `)})})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:l(`routingRule.routeToLabel`)}),(0,Y.jsx)(`select`,{value:f,onChange:e=>p(e.target.value),"aria-label":l(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:i.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:l(`routingRule.routeToHint`)})]})]}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:c,children:l(`common:actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:()=>s(m,f),disabled:!g,children:l(n===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Z=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),me=[`sonnet`,`opus`,`haiku`],he=/^[a-z0-9][a-z0-9-]*$/;function ge({profile:e,onChange:n,footer:r,onValidityChange:a,onSoftWarningsChange:o}){let{t:s}=t(`agentstudio`),[l,m]=(0,J.useState)([]),[g,_]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(null);(0,J.useEffect)(()=>{let e=!1;return fetch(`${G()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||m(t.agents)}).catch(()=>{e||m([])}),()=>{e=!0}},[]);let C=t=>{let r=JSON.parse(JSON.stringify(e));t(r),n(r)},w=new Set(e.agents.map(e=>e.id)),T=l.filter(e=>!w.has(e.id)),E=(0,J.useMemo)(()=>{let t=[];for(let n of Z)e.agents.some(e=>e.id===n)||t.push(s(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(s(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(s(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(s(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!he.test(e));e.length>0&&t.push(s(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,s]),D=(0,J.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!Z.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),O=(0,J.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,J.useEffect)(()=>{a&&a(E)},[E,a]),(0,J.useEffect)(()=>{o&&o({agentsMissingRouting:D})},[D,o]);let ee=e=>{C(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),_(!1)},N=t=>{let n=e.agents[t];Z.has(n.id)||C(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},P=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=k(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}C(e=>{e.agents=a})},F=j(M(ae,{activationConstraint:{distance:4}}),M(h,{coordinateGetter:u})),I=e=>{let{active:t,over:n}=e;n&&P(String(t.id),String(n.id))},L=(e,t)=>{C(n=>{n.agents[e].model=t})},R=(e,t)=>{C(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),b(!1)},te=()=>{C(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},z=e=>`default`in e&&e.default===!0,ne=(e,t)=>{C(n=>{let r=n.routing[e];r&&(z(r)||(r.agent=t))})},B=(e,t,n)=>{C(r=>{let i=r.routing[e];i&&(z(i)||(i.tags=t,i.agent=n))})},V=e=>{C(t=>{let n=t.routing[e];n&&(z(n)||t.routing.splice(e,1))})},ie=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];z(i)||z(a)||C(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Y.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Y.jsx)(pe,{open:y,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:R,onCancel:()=>b(!1)}),(0,Y.jsx)(pe,{open:x!==null,mode:`edit`,initial:x!==null&&e.routing[x]&&!(`default`in e.routing[x])?{tags:e.routing[x].tags,agent:e.routing[x].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{x!==null&&(B(x,e,t),S(null))},onCancel:()=>S(null)}),E.length>0&&(0,Y.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Y.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.validationSummary`,{count:E.length})}),(0,Y.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:E.map((e,t)=>(0,Y.jsx)(`li`,{children:e},t))})]}),(0,Y.jsxs)(`section`,{className:`space-y-3`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.nameLabel`)}),(0,Y.jsx)(re,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.descriptionLabel`)}),(0,Y.jsx)(re,{value:e.description??``,onChange:e=>C(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:s(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:s(`profileEditor.orchestrator.heading`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:s(`profileEditor.orchestrator.description`)})]}),(0,Y.jsx)(ye,{value:e.orchestrator.model,onChange:e=>C(t=>{t.orchestrator.model=e})})]})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:()=>_(e=>!e),disabled:T.length===0,title:T.length===0?s(`profileEditor.agentChain.addDisabledTitle`):s(`profileEditor.agentChain.addTitle`),children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`common:actions.add`)]})]}),g&&(0,Y.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`profileEditor.agentChain.pickFromCatalog`,{n:T.length})}),(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>_(!1),title:s(`common:actions.close`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]}),T.length===0?(0,Y.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:s(`profileEditor.agentChain.emptyCatalog`)}):(0,Y.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:T.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ee(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:s(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Y.jsx)(c,{sensors:F,collisionDetection:p,onDragEnd:I,children:(0,Y.jsx)(i,{items:e.agents.map(e=>e.id),strategy:A,children:(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Y.jsx)(_e,{agent:e,canRemove:!Z.has(e.id),onModel:e=>L(t,e),onRemove:()=>N(t)},e.id))})})})]}),(0,Y.jsxs)(`section`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!O&&(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:te,disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addDefault`)]}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:()=>b(!0),disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addRule`)]})]})]}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:s(`profileEditor.routing.explainer`)}),D.length>0&&(0,Y.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Y.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.routing.untargetedTitle`)}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(H,{t:s,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:D.join(`, `)},components:{mono:(0,Y.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Y.jsx)(ve,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>ne(n,e),onEdit:()=>S(n),onUp:()=>ie(n,-1),onDown:()=>ie(n,1),onRemove:()=>V(n)},n)})})]}),r&&(0,Y.jsx)(`div`,{className:`pt-3 border-t border-border`,children:r})]})}function _e({agent:e,canRemove:n,onModel:r,onRemove:i}){let{t:a}=t(`agentstudio`),o=Z.has(e.id),s=e.id===`sr-architect`,c=e.id===`sr-merge-resolver`,{attributes:l,listeners:u,setNodeRef:f,transform:p,transition:m,isDragging:h}=O({id:e.id});return(0,Y.jsxs)(`div`,{ref:f,style:{transform:P.Transform.toString(p),transition:m,opacity:h?.5:void 0,zIndex:h?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:a(`profileEditor.agentRow.dragTitle`),"aria-label":a(`profileEditor.agentRow.dragHandleAria`),...l,...u,children:(0,Y.jsx)(L,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:a(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Y.jsx)(de,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,a(`profileEditor.agentRow.pinnedFirst`)]}),c&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:a(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Y.jsx)(de,{className:`w-2.5 h-2.5 rotate-45`}),` `,a(`profileEditor.agentRow.pinnedLast`)]}),o&&!s&&!c&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:a(`profileEditor.agentRow.required`)}),(0,Y.jsx)(ye,{value:e.model??`sonnet`,onChange:r}),(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:i,disabled:!n,title:a(n?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]})}function ve({rule:e,ordinal:n,isLast:r,canMove:i,canRemove:a,canEdit:o,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:f,onRemove:p}){let{t:m}=t(`agentstudio`),h=`default`in e&&e.default===!0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[n,`.`]}),h?(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:m(`profileEditor.routingRow.everythingElse`)}):(0,Y.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Y.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),h?(0,Y.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":m(`profileEditor.routingRow.defaultTargetAria`),title:m(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Y.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":m(`profileEditor.routingRow.targetAria`,{ordinal:n}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:s.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[o&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:m(`profileEditor.routingRow.editTitle`),"aria-label":m(`profileEditor.routingRow.editAria`,{ordinal:n}),children:(0,Y.jsx)(ee,{className:`w-3 h-3`})}),i&&!r&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:f,title:m(`profileEditor.routingRow.moveDown`),children:(0,Y.jsx)(T,{className:`w-3 h-3`})}),i&&n>1&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:m(`profileEditor.routingRow.moveUp`),children:(0,Y.jsx)(le,{className:`w-3 h-3`})}),a&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:p,title:m(`common:actions.remove`),children:(0,Y.jsx)(d,{className:`w-3 h-3`})})]}),h&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:m(`profileEditor.routingRow.coreDefaultTitle`),children:m(`profileEditor.routingRow.coreDefaultBadge`)})]})}function ye({value:e,onChange:t}){return(0,Y.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:me.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))})}function be({open:e,title:n,description:r,placeholder:i,initialValue:o=``,confirmLabel:s,inputPattern:c,inputInvalidHint:l,onConfirm:u,onCancel:d}){let{t:f}=t(),[p,m]=(0,J.useState)(o);(0,J.useEffect)(()=>{e&&m(o)},[e,o]);let h=p.trim(),g=!c||c.test(h),_=h.length>0&&g;return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||d()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsx)(y,{children:(0,Y.jsx)(B,{children:n})}),(0,Y.jsxs)(`div`,{className:`py-2 space-y-2`,children:[r&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),(0,Y.jsx)(re,{autoFocus:!0,value:p,placeholder:i,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_&&u(h)},className:`text-sm font-mono`}),h.length>0&&!g&&l&&(0,Y.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:l})]}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:d,children:f(`actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:()=>u(h),disabled:!_,children:s??f(`actions.confirm`)})]})]})})}function xe({open:e,title:n,description:r,confirmLabel:i,destructive:o=!1,onConfirm:s,onCancel:c}){let{t:l}=t();return(0,Y.jsx)(U,{open:e,onOpenChange:e=>{e||c()},children:(0,Y.jsxs)(E,{className:`max-w-md`,children:[(0,Y.jsx)(y,{children:(0,Y.jsx)(B,{children:n})}),r&&(0,Y.jsx)(`div`,{className:`py-2`,children:(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})}),(0,Y.jsxs)(a,{children:[(0,Y.jsx)(v,{variant:`ghost`,size:`sm`,onClick:c,children:l(`actions.cancel`)}),(0,Y.jsx)(v,{size:`sm`,onClick:s,className:o?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:i??l(`actions.confirm`)})]})]})})}function Se(){let{t:e}=t(`agents`),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!0),[u,d]=(0,J.useState)(null),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)([]),[_,y]=(0,J.useState)([]),[b,x]=(0,J.useState)(!1),[w,T]=(0,J.useState)(null),[E,O]=(0,J.useState)(null),k=(0,J.useCallback)(async()=>{l(!0),d(null);try{let t=await fetch(`${G()}/profiles`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let n=await t.json();r(n.profiles),n.profiles.length>0&&!i&&a(n.profiles[0].name)}catch(e){d(e.message)}finally{l(!1)}},[i]);(0,J.useEffect)(()=>{k()},[k]),(0,J.useEffect)(()=>{if(!i){s(null);return}let t=!1;return fetch(`${G()}/profiles/${encodeURIComponent(i)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||s(e.profile)}).catch(e=>{t||d(e.message)}),()=>{t=!0}},[i]);let A=(0,J.useCallback)(async()=>{m(!0),d(null);try{let t=await fetch(`${G()}/profiles/migrate-from-settings`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await k(),a(`default`),S.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{m(!1)}},[k]),ee=(0,J.useCallback)(async t=>{x(!1),m(!0),d(null);try{let n={schemaVersion:1,name:t,description:``,orchestrator:{model:`sonnet`},agents:[{id:`sr-architect`,model:`sonnet`,required:!0},{id:`sr-developer`,model:`sonnet`,required:!0},{id:`sr-reviewer`,model:`sonnet`,required:!0},{id:`sr-merge-resolver`,model:`sonnet`,required:!0}],routing:[{default:!0,agent:`sr-developer`}]},r=await fetch(`${G()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await k(),a(t),S.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.createFailed`),{description:n})}finally{m(!1)}},[k]),j=(0,J.useCallback)(async(t,n)=>{T(null),m(!0),d(null);try{let r=await fetch(`${G()}/profiles/${encodeURIComponent(t)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await k(),a(n),S.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{m(!1)}},[k]),M=(0,J.useCallback)(async t=>{O(null),m(!0),d(null);try{let n=await fetch(`${G()}/profiles/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}a(e=>e===t?null:e),await k(),S.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{m(!1)}},[k]),N=(0,J.useCallback)(()=>x(!0),[]),P=(0,J.useCallback)(e=>T({from:e}),[]),F=(0,J.useCallback)(e=>O({name:e}),[]),L=(0,J.useCallback)(async(t,n)=>{m(!0),d(null);try{let r=await fetch(`${G()}/profiles/${encodeURIComponent(t.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}s(t),n.length>0?S.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):S.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;d(n),S.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{m(!1)}},[e]),R=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(be,{open:b,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void ee(e),onCancel:()=>x(!1)}),w&&(0,Y.jsx)(be,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:w.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${w.from}-copy`,initialValue:`${w.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void j(w.from,e),onCancel:()=>T(null)}),E&&(0,Y.jsx)(xe,{open:!0,title:e(`profiles.deleteDialog.title`,{name:E.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void M(E.name),onCancel:()=>O(null)})]});return c?(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):n.length===0?(0,Y.jsxs)(Y.Fragment,{children:[R,(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Y.jsxs)(v,{size:`sm`,onClick:A,disabled:p,children:[(0,Y.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Y.jsxs)(v,{size:`sm`,variant:`ghost`,onClick:N,disabled:p,children:[(0,Y.jsx)(f,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Y.jsx)(H,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Y.jsx)(`code`,{className:`text-foreground`})}})}),u&&(0,Y.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:u})]})})]}):(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,children:[R,(0,Y.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Y.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,Y.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Y.jsx)(v,{size:`sm`,variant:`ghost`,onClick:N,disabled:p,children:(0,Y.jsx)(f,{className:`w-3.5 h-3.5`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:n.map(t=>(0,Y.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===i?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>a(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&a(t.name)},children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Y.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),P(t.name)},children:(0,Y.jsx)(I,{className:`w-3 h-3`})}),!t.isDefault&&(0,Y.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),F(t.name)},children:(0,Y.jsx)(C,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Y.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[u&&(0,Y.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:u}),o?(0,Y.jsx)(ge,{profile:o,onChange:s,onValidityChange:g,onSoftWarningsChange:e=>y(e.agentsMissingRouting),footer:(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(v,{size:`sm`,onClick:()=>void L(o,_),disabled:p||h.length>0,title:h.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Y.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),p&&(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),h.length>0&&(0,Y.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:h.length})})]})},o.name):(0,Y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}function Q(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
2
2
  `);return`---
3
3
  name: ${e.id}
4
4
  description: "${e.descriptionOneLine}"
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./clsx-CnH-HMk3.js";import{$t as n,Et as r,K as i,Lt as a,Rt as o,Tt as s,an as c,bt as l,c as u,s as d,sn as f,tn as p,v as m,wt as h,zt as g}from"./index-DK214dak.js";import{t as _}from"./ExportDropdown-DO-GGiMh.js";import{A as v,B as y,C as b,D as x,E as S,F as C,G as w,H as T,I as E,J as D,K as O,L as k,M as A,N as j,O as M,P as N,Q as P,R as F,S as I,T as L,V as R,X as z,Z as B,_ as V,_t as ee,a as H,at as te,b as ne,c as re,ct as ie,et as ae,f as oe,g as se,gt as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as U,m as me,n as he,nt as ge,o as _e,ot as ve,p as ye,pt as W,q as be,r as xe,rt as G,s as Se,st as Ce,t as we,tt as Te,ut as K,v as Ee,x as De,y as Oe,z as ke}from"./BarChart-BOyHB0dw.js";var Ae=h(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),q=e(f(),1),J=o();function Y(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function je(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function Me(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Ne=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`smash`];function Pe({data:e,loading:t}){let{t:r}=n(`analytics`),[i,a]=(0,q.useState)(0),o=(0,q.useRef)(0);if((0,q.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd;if(o.current===0&&t>0){let e=performance.now(),n=r=>{let i=Math.min(1,(r-e)/600),o=1-(1-i)**3;a(0+(t-0)*o),i<1&&requestAnimationFrame(n)};requestAnimationFrame(n)}else a(t);o.current=t},[e]),t&&!e)return(0,J.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let s=e.summary.totalCostUsd,c=e.summary.totalRuns,f=e.summary.totalTokens??0,p=e.summary.totalEstimatedCostUsd??0,m=e.summary.deltaPct,h=e.trackingStartedAt,g=p>0,_=Ne.map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}});return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1`,children:r(`hero.spending`)}),(0,J.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,J.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,children:je(i)}),m!==null&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${m>=0?`text-accent-warning`:`text-accent-success`}`,children:[m>=0?(0,J.jsx)(l,{className:`w-3 h-3`}):(0,J.jsx)(Ae,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(m).toFixed(0)})]})]}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,J.jsx)(`span`,{children:r(`hero.invocations`,{count:c})}),f>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:Me(f)})}),g&&(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:Y(p)}),children:r(`hero.includesEstimated`,{amount:Y(p)})})]})]}),c===0&&h&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:h.slice(0,10)})})]}),c===0?(0,J.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:h?r(`hero.trackingStarted`,{date:h.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:_.map(e=>{let t=s>0?e.costUsd/s*100:0;return t===0?null:(0,J.jsx)(`div`,{className:`h-full ${d[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:u[e.surface],value:Y(e.costUsd)})},e.surface)})}),(0,J.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:_.filter(e=>e.costUsd>0).map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full ${d[e.surface].dot}`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u[e.surface]}),(0,J.jsx)(`span`,{className:`text-foreground font-medium`,children:Y(e.costUsd)}),(0,J.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,J.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Fe={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Ie={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`};function Le(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Re(e){return Fe[e]??e}function ze(e){return Ie[e]??`bg-accent-secondary`}function Be({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let i=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:r(`providerCard.title`)}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,J.jsx)(p,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,J.jsx)(`span`,{className:`font-medium`})}})})]})}),i===0?(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:r(`providerCard.noCost`)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,n=i>0?t/i*100:0;return n===0?null:(0,J.jsx)(`div`,{className:`h-full ${ze(e.provider)}`,style:{width:`${n}%`},title:r(`providerCard.segmentTitle`,{label:Re(e.provider),value:Le(t),count:e.count})},e.provider)})}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.byProvider.map(e=>(0,J.jsx)(Ve,{entry:e},e.provider))})]})]})}function Ve({entry:e}){let{t}=n(`analytics`),r=e.costUsd+e.estimatedCostUsd,i=e.costUsd===0&&e.estimatedCostUsd>0;return(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ze(e.provider)}`}),(0,J.jsx)(`span`,{className:`text-xs font-medium`,children:Re(e.provider)}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),(0,J.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,children:[i?`~`:``,Le(r)]})]})}var He=[`option`,`isActive`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Ue(e,t){if(e==null)return{};var n,r,i=We(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ge(e){var{option:t,isActive:n}=e,r=Ue(e,He);return typeof t==`string`?q.createElement(I,X({option:q.createElement(Ce,X({type:t},r)),isActive:n,shapeType:`symbols`},r)):q.createElement(I,X({option:t,isActive:n,shapeType:`symbols`},r))}var Ke=ae([(e,t,n,r,i,a,o)=>F(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>N(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>N(e,`yAxis`,n,o),(e,t,n,r)=>E(e,`zAxis`,r,!1),ae([C,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return st({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),qe=[`id`],Je=[`onMouseEnter`,`onClick`,`onMouseLeave`],Ye=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Z(e,t){if(e==null)return{};var n,r,i=Xe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(null,arguments)}function Ze(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ze(Object(n),!0).forEach(function(t){Qe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e,t,n){return(t=$e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e){var t=et(e,`string`);return typeof t==`symbol`?t:t+``}function et(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var tt=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:B(n,t),payload:e}]},nt=q.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:B(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return q.createElement(Ee,{tooltipEntrySettings:u})});function rt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=ce(n),s=ee(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ie(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=q.isValidElement(r)?q.cloneElement(r,h):typeof r==`function`?r(h):q.createElement(R,Q({},h,{type:a})),q.createElement(W,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function it(e){var{showLabels:t,points:n,children:r}=e,i=w(),a=(0,q.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return q.createElement(L,{value:t?a:void 0},r)}function at(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Z(n,qe),c=ge(de),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Z(n,Je),p=ne(l,a,o),m=De(d),h=Oe(u,a,o);if(!ve(t))return null;var g=ce(s);return q.createElement(q.Fragment,null,q.createElement(rt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=$($($({},g),e),{},{index:t,[D]:String(o)});return q.createElement(v,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?k.activeDot:void 0},q.createElement(W,Q({className:`recharts-scatter-symbol`},te(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),q.createElement(Ge,Q({option:s,isActive:a},l))))}))}function ot(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=ke(n,`recharts-scatter-`),[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{d(!1)},[]),p=(0,q.useCallback)(()=>{d(!0)},[]),m=!u;return q.createElement(it,{showLabels:m,points:r},n.children,q.createElement(y,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?$($({},t),{},{cx:t.cx==null?void 0:U(r.cx,t.cx,e),cy:t.cy==null?void 0:U(r.cy,t.cy,e),size:U(r.size,t.size,e)}):$($({},t),{},{size:U(0,t.size,e)})});return e>0&&(t.current=i),q.createElement(W,null,q.createElement(at,{points:i,allOtherScatterProps:n,showLabels:m}))}),q.createElement(S,{label:n.label}))}function st(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=K(n.dataKey)?a.dataKey:n.dataKey,u=K(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:A.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=P(e,l),g=P(e,u),_=!K(d)&&P(e,d)||`-`,v=[{name:K(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:K(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=z({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=z({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var ct=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:P(e,t)});function lt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,q.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return q.createElement(v,{zIndex:e.zIndex},q.createElement(W,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&q.createElement(`defs`,null,q.createElement(_e,{clipPathId:d,xAxisId:o,yAxisId:s})),q.createElement(re,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:ct,errorBarOffset:0},q.createElement(W,{key:`recharts-scatter-symbols`},q.createElement(ot,{props:e,previousPointsRef:l})))))}var ut={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:k.scatter};function dt(e){var t=G(e,ut),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=Z(t,Ye),{needClip:h}=Se(d,f),g=(0,q.useMemo)(()=>b(e.children,x),[e.children]),_=be(),v=ge(t=>Ke(t,d,f,p,e.id,g,_));return h==null||v==null?null:q.createElement(q.Fragment,null,q.createElement(nt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),q.createElement(lt,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function ft(e){var t=G(e,ut),n=be();return q.createElement(se,{id:t.id,type:`scatter`},e=>q.createElement(q.Fragment,null,q.createElement(V,{legendPayload:tt(t)}),q.createElement(le,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),q.createElement(dt,Q({},t,{id:e}))))}var pt=q.memo(ft,T);pt.displayName=`Scatter`;function mt(e){var t=Te(),n=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{n.current===null?t(oe(e)):n.current!==e&&t(me({prev:n.current,next:e})),n.current=e},[e,t]),(0,q.useLayoutEffect)(()=>()=>{n.current&&=(t(ye(n.current)),null)},[t]),null}var ht={zAxisId:0,range:A.range,scale:A.scale,type:A.type};function gt(e){var t=G(e,ht);return q.createElement(mt,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:A.allowDuplicatedCategory,allowDataOverflow:A.allowDataOverflow,reversed:A.reversed,includeHidden:A.includeHidden})}gt.displayName=`ZAxis`;var _t=[`item`],vt=(0,q.forwardRef)((e,t)=>q.createElement(he,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_t,tooltipPayloadSearcher:fe,categoricalChartProps:e,ref:t}));function yt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i={jobs:r(`surfaces.job`),explore:r(`surfaces.exploreSpec`),quick:r(`surfaces.quickSpec`),refine:r(`surfaces.aiEdit`),fileSummaries:r(`surfaces.fileSummary`)},a=e.dailyTimeline.map(e=>({date:e.date.slice(5),[i.jobs]:e.jobsCostUsd,[i.explore]:e.exploreCostUsd,[i.quick]:e.quickCostUsd,[i.refine]:e.aiEditCostUsd,[i.fileSummaries]:e.fileSummaryCostUsd??0})),o=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)===0);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`timeline.title`)}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:r(`timeline.subtitle`)})]}),o?(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`timeline.empty`)}):(0,J.jsx)(`div`,{className:`h-[220px]`,children:(0,J.jsx)(O,{width:`100%`,height:`100%`,children:(0,J.jsxs)(we,{data:a,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,J.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,J.jsx)(ue,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,J.jsx)(xe,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,J.jsx)(M,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,J.jsx)(H,{dataKey:i.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,J.jsx)(H,{dataKey:i.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,J.jsx)(H,{dataKey:i.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,J.jsx)(H,{dataKey:i.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,J.jsx)(H,{dataKey:i.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`})]})})})]})}function bt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xt(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function St({values:e}){let t=Math.max(1e-4,...e);return(0,J.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,J.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Ct({mode:e,label:t,accentClass:r}){let{t:i}=n(`analytics`),a=e.mode===`explore`&&e.totalRuns<5;return(0,J.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${r}`}),(0,J.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),a?(0,J.jsxs)(`div`,{className:`py-3`,children:[(0,J.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`quickVsExplore.sparseCta`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:i(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,children:bt(e.avgCostPerSpec)}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:i(`quickVsExplore.perSpec`)}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(St,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,J.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(p,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,J.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,J.jsx)(`div`,{children:i(`quickVsExplore.avgDuration`,{duration:xt(e.avgDurationMs)})}),(0,J.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.byMode.find(e=>e.mode===`quick`),a=e.byMode.find(e=>e.mode===`explore`);if(!i||!a)return null;let o=i.avgCostPerSpec&&a.avgCostPerSpec&&i.avgCostPerSpec>0?a.avgCostPerSpec/i.avgCostPerSpec:null,s=o!==null&&i.totalRuns>=1&&a.totalRuns>=5;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,J.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`quickVsExplore.title`)})}),(0,J.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,J.jsx)(Ct,{mode:i,label:r(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,J.jsx)(Ct,{mode:a,label:r(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,J.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,J.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,J.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,r(`quickVsExplore.ratio`,{ratio:o.toFixed(1)}),` ━━━━━━`]})})})]})}function Tt({data:e,loading:t,onSelectModel:r,activeModel:i}){let{t:a}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let o=e.byModel.reduce((e,t)=>e+t.costUsd,0),s=e.byModel.slice(0,5);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:a(`models.title`)}),s.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:a(`models.empty`)}):(0,J.jsx)(`ul`,{className:`space-y-1.5`,children:s.map(e=>{let t=o>0?e.costUsd/o*100:0,n=i===e.model;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.model),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${n?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,e.costUsd.toFixed(2),` · `,e.count]})]}),(0,J.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full ${n?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},e.model)})})]})}var Et={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`};function Dt({data:e,loading:t,onSelectPoint:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=[`job`,`quick-spec`,`explore-spec`,`ai-edit`,`smash`],o=a.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),s=e.scatter.length===0;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:i(`scatter.title`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:a.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Et[e]}}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u[e]})]},e))})]}),s?(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`scatter.empty`)}):(0,J.jsx)(`div`,{className:`h-[260px]`,children:(0,J.jsx)(O,{width:`100%`,height:`100%`,children:(0,J.jsxs)(vt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,J.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,J.jsx)(ue,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:i(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,J.jsx)(xe,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,J.jsx)(gt,{range:[40,80]}),(0,J.jsx)(M,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,i(`scatter.costLabel`)]:[String(e),n===`turns`?i(`scatter.turnsLabel`):n]}}),o.map(e=>(0,J.jsx)(pt,{data:e.points,fill:Et[e.surface],onClick:e=>{let t=e;t?.raw&&r(t.raw)}},e.surface))]})})})]})}function Ot({data:e,loading:t,onSelectTicket:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.topTickets;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`topTickets.title`)}),a.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`topTickets.empty`)}):(0,J.jsx)(`ul`,{className:`divide-y divide-border/30`,children:a.map((e,t)=>{let n=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>i(`topTickets.breakdownItem`,{n:t.count,label:u[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?i(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:i(`topTickets.deletedTicket`,{id:e.ticketId});return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${!e.ticketTitle&&!a?`opacity-50`:``}`,disabled:a,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:n||`—`})]}),(0,J.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,J.jsxs)(`div`,{className:`text-sm font-medium`,children:[`$`,e.totalCostUsd.toFixed(2)]}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}function kt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function At(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function jt(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function Mt(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function Nt(e,t){if(e.model)return e.model;if(!jt(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Pt({rows:e,loading:t,truncated:r,totalAvailable:i,tableFilters:a,onTableFiltersChange:o}){let{t:s}=n(`analytics`),[c,l]=(0,q.useState)(null),f=Mt(e);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,J.jsxs)(`select`,{value:a.status??``,onChange:e=>o({...a,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":s(`table.statusFilterAria`),children:[(0,J.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,J.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,J.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,J.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,J.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:a.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);o({...a,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":s(`table.minCostFilterAria`)})]})]}),t?(0,J.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,J.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,J.jsxs)(`tr`,{className:`text-left`,children:[(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=d[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=jt(e),a=i?s(`table.contractLayer`):u[t],o=Nt(e,f);return(0,J.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,J.jsx)(`td`,{className:`px-2 py-2`,children:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,J.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,J.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,J.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,J.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,J.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,J.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,J.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,kt(e.total_cost_usd)]}):kt(e.total_cost_usd)}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right`,children:At(e.num_turns)}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?At(r):`—`}),(0,J.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,J.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),(0,J.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,J.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,J.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,J.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),r&&(0,J.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:i.toLocaleString()})})]})}var Ft=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],It=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`}];function Lt(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),t.toString()}function Rt(){let{t:e}=n(`analytics`),{activeProjectId:t,projects:o}=r(),[l,u]=c(),d=o.find(e=>e.id===t),f=d?s(d):[`claude`],p=f.length>1,h=l.get(`period`)??`30d`,v=(l.get(`surface`)??``).split(`,`).filter(Boolean),y=(l.get(`provider`)??``).split(`,`).filter(Boolean),b=l.get(`ticketId`),[x,S]=(0,q.useState)({period:h,surface:v.length>0?v:void 0,provider:y.length>0?y:void 0,ticketId:b?Number(b):void 0}),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!0),[D,O]=(0,q.useState)(null),[k,A]=(0,q.useState)({}),[j,M]=(0,q.useState)(null),N=(0,q.useRef)(new Map),P=(0,q.useRef)(0);(0,q.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,x.period),x.surface&&x.surface.length>0&&e.set(`surface`,x.surface.join(`,`)),x.provider&&x.provider.length>0&&e.set(`provider`,x.provider.join(`,`)),x.ticketId&&e.set(`ticketId`,String(x.ticketId)),u(e,{replace:!0})},[x.period,x.surface,x.provider,x.ticketId,u]);let F=(0,q.useCallback)(async()=>{if(!t)return;let e=++P.current;O(null);let n=`${t}:${Lt(x)}`,r=N.current.get(n);r?(w(r),E(!1)):E(!0);try{let t=await fetch(`${g()}/spending?${Lt(x)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==P.current)return;let r=await t.json();N.current.set(n,r),w(r),E(!1)}catch(t){if(e!==P.current)return;O(t.message),E(!1)}},[t,x]),I=(0,q.useCallback)(async()=>{if(!t)return;let e={...x};k.model&&(e.model=[k.model]),k.status&&(e.status=k.status),typeof k.minCostUsd==`number`&&(e.minCostUsd=k.minCostUsd);try{let t=await fetch(`${g()}/invocations?${Lt(e)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);M(await t.json())}catch{M(null)}},[t,x,k]);(0,q.useEffect)(()=>{F()},[F]),(0,q.useEffect)(()=>{I()},[I]);let L=(0,q.useRef)(null),R=a();(0,q.useEffect)(()=>{let e=`analytics-spending`;return R.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{N.current.clear(),F(),I()},500))}),()=>{R.unregisterHandler(e)}},[R,t,F,I]);function z(e){if(e===`all`){S(e=>({...e,surface:void 0}));return}S(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}function B(e){if(e===`all`){S(e=>({...e,provider:void 0}));return}S(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let V=x.surface,ee=!V||V.length===0,H=x.provider,te=!H||H.length===0,ne=(0,q.useMemo)(()=>{let e={period:x.period};return x.surface&&x.surface.length>0&&(e.surface=x.surface.join(`,`)),x.provider&&x.provider.length>0&&(e.provider=x.provider.join(`,`)),x.ticketId&&(e.ticketId=String(x.ticketId)),e},[x]),re=C?C.summary.totalRuns===0:!1;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),x.ticketId&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>S(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:x.ticketId})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Ft.map(t=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>S(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${x.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,J.jsx)(_,{baseUrl:`${g()}/analytics/export`,params:ne,disabled:re}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{N.current.clear(),F(),I()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,J.jsx)(i,{className:`w-3 h-3`})})]})]}),(0,J.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:It.map(t=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>z(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ee:V?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),p&&(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,J.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>B(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${te?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),f.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>B(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${H?.includes(e)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:m(e)},e))]})]}),D&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,J.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:D})}),(0,J.jsxs)(`button`,{onClick:()=>F(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,J.jsx)(i,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,J.jsx)(Pe,{data:C,loading:T}),(0,J.jsx)(Be,{data:C,loading:T}),(0,J.jsx)(yt,{data:C,loading:T}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,J.jsx)(wt,{data:C,loading:T}),(0,J.jsx)(Tt,{data:C,loading:T,onSelectModel:e=>S(t=>({...t,model:[e]})),activeModel:x.model?.[0]})]}),(0,J.jsx)(Dt,{data:C,loading:T,onSelectPoint:e=>{A(e=>({...e})),S(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,J.jsx)(Ot,{data:C,loading:T,onSelectTicket:e=>S(t=>({...t,ticketId:e??void 0}))}),(0,J.jsx)(Pt,{rows:j?.rows??[],loading:T&&!j,truncated:j?.truncated??!1,totalAvailable:j?.totalAvailable??0,tableFilters:k,onTableFiltersChange:A})]})}export{Rt as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./clsx-CnH-HMk3.js";import{$t as n,Et as r,K as i,Lt as a,Rt as o,Tt as s,an as c,bt as l,c as u,s as d,sn as f,tn as p,v as m,wt as h,zt as g}from"./index-BXoHFtfG.js";import{t as _}from"./ExportDropdown-BRHcvP0r.js";import{A as v,B as y,C as b,D as x,E as S,F as C,G as w,H as T,I as E,J as D,K as O,L as k,M as A,N as j,O as M,P as N,Q as P,R as F,S as I,T as L,V as R,X as z,Z as B,_ as V,_t as ee,a as H,at as te,b as ne,c as re,ct as ie,et as ae,f as oe,g as se,gt as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as U,m as me,n as he,nt as ge,o as _e,ot as ve,p as ye,pt as W,q as be,r as xe,rt as G,s as Se,st as Ce,t as we,tt as Te,ut as K,v as Ee,x as De,y as Oe,z as ke}from"./BarChart-CIkopHjl.js";var Ae=h(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),q=e(f(),1),J=o();function Y(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function je(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function Me(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Ne=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`smash`];function Pe({data:e,loading:t}){let{t:r}=n(`analytics`),[i,a]=(0,q.useState)(0),o=(0,q.useRef)(0);if((0,q.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd;if(o.current===0&&t>0){let e=performance.now(),n=r=>{let i=Math.min(1,(r-e)/600),o=1-(1-i)**3;a(0+(t-0)*o),i<1&&requestAnimationFrame(n)};requestAnimationFrame(n)}else a(t);o.current=t},[e]),t&&!e)return(0,J.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let s=e.summary.totalCostUsd,c=e.summary.totalRuns,f=e.summary.totalTokens??0,p=e.summary.totalEstimatedCostUsd??0,m=e.summary.deltaPct,h=e.trackingStartedAt,g=p>0,_=Ne.map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}});return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1`,children:r(`hero.spending`)}),(0,J.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,J.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,children:je(i)}),m!==null&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${m>=0?`text-accent-warning`:`text-accent-success`}`,children:[m>=0?(0,J.jsx)(l,{className:`w-3 h-3`}):(0,J.jsx)(Ae,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(m).toFixed(0)})]})]}),(0,J.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,J.jsx)(`span`,{children:r(`hero.invocations`,{count:c})}),f>0&&(0,J.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:Me(f)})}),g&&(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:Y(p)}),children:r(`hero.includesEstimated`,{amount:Y(p)})})]})]}),c===0&&h&&(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:h.slice(0,10)})})]}),c===0?(0,J.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:h?r(`hero.trackingStarted`,{date:h.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:_.map(e=>{let t=s>0?e.costUsd/s*100:0;return t===0?null:(0,J.jsx)(`div`,{className:`h-full ${d[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:u[e.surface],value:Y(e.costUsd)})},e.surface)})}),(0,J.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:_.filter(e=>e.costUsd>0).map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full ${d[e.surface].dot}`}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u[e.surface]}),(0,J.jsx)(`span`,{className:`text-foreground font-medium`,children:Y(e.costUsd)}),(0,J.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,J.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Fe={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Ie={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`};function Le(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Re(e){return Fe[e]??e}function ze(e){return Ie[e]??`bg-accent-secondary`}function Be({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let i=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:r(`providerCard.title`)}),(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,J.jsx)(p,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,J.jsx)(`span`,{className:`font-medium`})}})})]})}),i===0?(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:r(`providerCard.noCost`)}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,n=i>0?t/i*100:0;return n===0?null:(0,J.jsx)(`div`,{className:`h-full ${ze(e.provider)}`,style:{width:`${n}%`},title:r(`providerCard.segmentTitle`,{label:Re(e.provider),value:Le(t),count:e.count})},e.provider)})}),(0,J.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.byProvider.map(e=>(0,J.jsx)(Ve,{entry:e},e.provider))})]})]})}function Ve({entry:e}){let{t}=n(`analytics`),r=e.costUsd+e.estimatedCostUsd,i=e.costUsd===0&&e.estimatedCostUsd>0;return(0,J.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,J.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${ze(e.provider)}`}),(0,J.jsx)(`span`,{className:`text-xs font-medium`,children:Re(e.provider)}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),(0,J.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,children:[i?`~`:``,Le(r)]})]})}var He=[`option`,`isActive`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Ue(e,t){if(e==null)return{};var n,r,i=We(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function We(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Ge(e){var{option:t,isActive:n}=e,r=Ue(e,He);return typeof t==`string`?q.createElement(I,X({option:q.createElement(Ce,X({type:t},r)),isActive:n,shapeType:`symbols`},r)):q.createElement(I,X({option:t,isActive:n,shapeType:`symbols`},r))}var Ke=ae([(e,t,n,r,i,a,o)=>F(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>N(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>N(e,`yAxis`,n,o),(e,t,n,r)=>E(e,`zAxis`,r,!1),ae([C,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return st({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),qe=[`id`],Je=[`onMouseEnter`,`onClick`,`onMouseLeave`],Ye=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Z(e,t){if(e==null)return{};var n,r,i=Xe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Q(){return Q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(null,arguments)}function Ze(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ze(Object(n),!0).forEach(function(t){Qe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e,t,n){return(t=$e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e){var t=et(e,`string`);return typeof t==`symbol`?t:t+``}function et(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var tt=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:B(n,t),payload:e}]},nt=q.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:B(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return q.createElement(Ee,{tooltipEntrySettings:u})});function rt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=ce(n),s=ee(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ie(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=q.isValidElement(r)?q.cloneElement(r,h):typeof r==`function`?r(h):q.createElement(R,Q({},h,{type:a})),q.createElement(W,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function it(e){var{showLabels:t,points:n,children:r}=e,i=w(),a=(0,q.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return q.createElement(L,{value:t?a:void 0},r)}function at(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Z(n,qe),c=ge(de),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Z(n,Je),p=ne(l,a,o),m=De(d),h=Oe(u,a,o);if(!ve(t))return null;var g=ce(s);return q.createElement(q.Fragment,null,q.createElement(rt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=$($($({},g),e),{},{index:t,[D]:String(o)});return q.createElement(v,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?k.activeDot:void 0},q.createElement(W,Q({className:`recharts-scatter-symbol`},te(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),q.createElement(Ge,Q({option:s,isActive:a},l))))}))}function ot(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=ke(n,`recharts-scatter-`),[u,d]=(0,q.useState)(!1),f=(0,q.useCallback)(()=>{d(!1)},[]),p=(0,q.useCallback)(()=>{d(!0)},[]),m=!u;return q.createElement(it,{showLabels:m,points:r},n.children,q.createElement(y,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?$($({},t),{},{cx:t.cx==null?void 0:U(r.cx,t.cx,e),cy:t.cy==null?void 0:U(r.cy,t.cy,e),size:U(r.size,t.size,e)}):$($({},t),{},{size:U(0,t.size,e)})});return e>0&&(t.current=i),q.createElement(W,null,q.createElement(at,{points:i,allOtherScatterProps:n,showLabels:m}))}),q.createElement(S,{label:n.label}))}function st(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=K(n.dataKey)?a.dataKey:n.dataKey,u=K(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:A.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=P(e,l),g=P(e,u),_=!K(d)&&P(e,d)||`-`,v=[{name:K(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:K(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=z({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=z({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var ct=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:P(e,t)});function lt(e){var{hide:n,points:r,className:i,needClip:a,xAxisId:o,yAxisId:s,id:c}=e,l=(0,q.useRef)(null);if(n)return null;var u=t(`recharts-scatter`,i),d=c;return q.createElement(v,{zIndex:e.zIndex},q.createElement(W,{className:u,clipPath:a?`url(#clipPath-${d})`:void 0,id:c},a&&q.createElement(`defs`,null,q.createElement(_e,{clipPathId:d,xAxisId:o,yAxisId:s})),q.createElement(re,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:ct,errorBarOffset:0},q.createElement(W,{key:`recharts-scatter-symbols`},q.createElement(ot,{props:e,previousPointsRef:l})))))}var ut={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:k.scatter};function dt(e){var t=G(e,ut),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=Z(t,Ye),{needClip:h}=Se(d,f),g=(0,q.useMemo)(()=>b(e.children,x),[e.children]),_=be(),v=ge(t=>Ke(t,d,f,p,e.id,g,_));return h==null||v==null?null:q.createElement(q.Fragment,null,q.createElement(nt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),q.createElement(lt,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function ft(e){var t=G(e,ut),n=be();return q.createElement(se,{id:t.id,type:`scatter`},e=>q.createElement(q.Fragment,null,q.createElement(V,{legendPayload:tt(t)}),q.createElement(le,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),q.createElement(dt,Q({},t,{id:e}))))}var pt=q.memo(ft,T);pt.displayName=`Scatter`;function mt(e){var t=Te(),n=(0,q.useRef)(null);return(0,q.useLayoutEffect)(()=>{n.current===null?t(oe(e)):n.current!==e&&t(me({prev:n.current,next:e})),n.current=e},[e,t]),(0,q.useLayoutEffect)(()=>()=>{n.current&&=(t(ye(n.current)),null)},[t]),null}var ht={zAxisId:0,range:A.range,scale:A.scale,type:A.type};function gt(e){var t=G(e,ht);return q.createElement(mt,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:A.allowDuplicatedCategory,allowDataOverflow:A.allowDataOverflow,reversed:A.reversed,includeHidden:A.includeHidden})}gt.displayName=`ZAxis`;var _t=[`item`],vt=(0,q.forwardRef)((e,t)=>q.createElement(he,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_t,tooltipPayloadSearcher:fe,categoricalChartProps:e,ref:t}));function yt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i={jobs:r(`surfaces.job`),explore:r(`surfaces.exploreSpec`),quick:r(`surfaces.quickSpec`),refine:r(`surfaces.aiEdit`),fileSummaries:r(`surfaces.fileSummary`)},a=e.dailyTimeline.map(e=>({date:e.date.slice(5),[i.jobs]:e.jobsCostUsd,[i.explore]:e.exploreCostUsd,[i.quick]:e.quickCostUsd,[i.refine]:e.aiEditCostUsd,[i.fileSummaries]:e.fileSummaryCostUsd??0})),o=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)===0);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`timeline.title`)}),(0,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:r(`timeline.subtitle`)})]}),o?(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`timeline.empty`)}):(0,J.jsx)(`div`,{className:`h-[220px]`,children:(0,J.jsx)(O,{width:`100%`,height:`100%`,children:(0,J.jsxs)(we,{data:a,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,J.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,J.jsx)(ue,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,J.jsx)(xe,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,J.jsx)(M,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,J.jsx)(H,{dataKey:i.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,J.jsx)(H,{dataKey:i.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,J.jsx)(H,{dataKey:i.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,J.jsx)(H,{dataKey:i.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,J.jsx)(H,{dataKey:i.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`})]})})})]})}function bt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xt(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function St({values:e}){let t=Math.max(1e-4,...e);return(0,J.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,J.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Ct({mode:e,label:t,accentClass:r}){let{t:i}=n(`analytics`),a=e.mode===`explore`&&e.totalRuns<5;return(0,J.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${r}`}),(0,J.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),a?(0,J.jsxs)(`div`,{className:`py-3`,children:[(0,J.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`quickVsExplore.sparseCta`)}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:i(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,children:bt(e.avgCostPerSpec)}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:i(`quickVsExplore.perSpec`)}),(0,J.jsx)(`div`,{className:`mt-3`,children:(0,J.jsx)(St,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,J.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(p,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,J.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,J.jsx)(`div`,{children:i(`quickVsExplore.avgDuration`,{duration:xt(e.avgDurationMs)})}),(0,J.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wt({data:e,loading:t}){let{t:r}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.byMode.find(e=>e.mode===`quick`),a=e.byMode.find(e=>e.mode===`explore`);if(!i||!a)return null;let o=i.avgCostPerSpec&&a.avgCostPerSpec&&i.avgCostPerSpec>0?a.avgCostPerSpec/i.avgCostPerSpec:null,s=o!==null&&i.totalRuns>=1&&a.totalRuns>=5;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,J.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`quickVsExplore.title`)})}),(0,J.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,J.jsx)(Ct,{mode:i,label:r(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,J.jsx)(Ct,{mode:a,label:r(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,J.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,J.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,J.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,r(`quickVsExplore.ratio`,{ratio:o.toFixed(1)}),` ━━━━━━`]})})})]})}function Tt({data:e,loading:t,onSelectModel:r,activeModel:i}){let{t:a}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let o=e.byModel.reduce((e,t)=>e+t.costUsd,0),s=e.byModel.slice(0,5);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:a(`models.title`)}),s.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:a(`models.empty`)}):(0,J.jsx)(`ul`,{className:`space-y-1.5`,children:s.map(e=>{let t=o>0?e.costUsd/o*100:0,n=i===e.model;return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.model),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${n?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,J.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,e.costUsd.toFixed(2),` · `,e.count]})]}),(0,J.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,J.jsx)(`div`,{className:`h-full ${n?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},e.model)})})]})}var Et={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`};function Dt({data:e,loading:t,onSelectPoint:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=[`job`,`quick-spec`,`explore-spec`,`ai-edit`,`smash`],o=a.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),s=e.scatter.length===0;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:i(`scatter.title`)}),(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:a.map(e=>(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Et[e]}}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:u[e]})]},e))})]}),s?(0,J.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`scatter.empty`)}):(0,J.jsx)(`div`,{className:`h-[260px]`,children:(0,J.jsx)(O,{width:`100%`,height:`100%`,children:(0,J.jsxs)(vt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,J.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,J.jsx)(ue,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:i(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,J.jsx)(xe,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,J.jsx)(gt,{range:[40,80]}),(0,J.jsx)(M,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,i(`scatter.costLabel`)]:[String(e),n===`turns`?i(`scatter.turnsLabel`):n]}}),o.map(e=>(0,J.jsx)(pt,{data:e.points,fill:Et[e.surface],onClick:e=>{let t=e;t?.raw&&r(t.raw)}},e.surface))]})})})]})}function Ot({data:e,loading:t,onSelectTicket:r}){let{t:i}=n(`analytics`);if(t&&!e)return(0,J.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.topTickets;return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`topTickets.title`)}),a.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`topTickets.empty`)}):(0,J.jsx)(`ul`,{className:`divide-y divide-border/30`,children:a.map((e,t)=>{let n=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>i(`topTickets.breakdownItem`,{n:t.count,label:u[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?i(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:i(`topTickets.deletedTicket`,{id:e.ticketId});return(0,J.jsx)(`li`,{children:(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${!e.ticketTitle&&!a?`opacity-50`:``}`,disabled:a,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,J.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:n||`—`})]}),(0,J.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,J.jsxs)(`div`,{className:`text-sm font-medium`,children:[`$`,e.totalCostUsd.toFixed(2)]}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}function kt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function At(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function jt(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function Mt(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function Nt(e,t){if(e.model)return e.model;if(!jt(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Pt({rows:e,loading:t,truncated:r,totalAvailable:i,tableFilters:a,onTableFiltersChange:o}){let{t:s}=n(`analytics`),[c,l]=(0,q.useState)(null),f=Mt(e);return(0,J.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,J.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,J.jsxs)(`select`,{value:a.status??``,onChange:e=>o({...a,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":s(`table.statusFilterAria`),children:[(0,J.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,J.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,J.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,J.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,J.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:a.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);o({...a,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":s(`table.minCostFilterAria`)})]})]}),t?(0,J.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,J.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,J.jsx)(`div`,{className:`overflow-x-auto`,children:(0,J.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,J.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,J.jsxs)(`tr`,{className:`text-left`,children:[(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,J.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,J.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=d[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=jt(e),a=i?s(`table.contractLayer`):u[t],o=Nt(e,f);return(0,J.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,J.jsx)(`td`,{className:`px-2 py-2`,children:(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,J.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,J.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,J.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,J.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,J.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,J.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,J.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,kt(e.total_cost_usd)]}):kt(e.total_cost_usd)}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right`,children:At(e.num_turns)}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?At(r):`—`}),(0,J.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,J.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),(0,J.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,J.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,J.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,J.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,J.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),r&&(0,J.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:i.toLocaleString()})})]})}var Ft=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],It=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`}];function Lt(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),t.toString()}function Rt(){let{t:e}=n(`analytics`),{activeProjectId:t,projects:o}=r(),[l,u]=c(),d=o.find(e=>e.id===t),f=d?s(d):[`claude`],p=f.length>1,h=l.get(`period`)??`30d`,v=(l.get(`surface`)??``).split(`,`).filter(Boolean),y=(l.get(`provider`)??``).split(`,`).filter(Boolean),b=l.get(`ticketId`),[x,S]=(0,q.useState)({period:h,surface:v.length>0?v:void 0,provider:y.length>0?y:void 0,ticketId:b?Number(b):void 0}),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!0),[D,O]=(0,q.useState)(null),[k,A]=(0,q.useState)({}),[j,M]=(0,q.useState)(null),N=(0,q.useRef)(new Map),P=(0,q.useRef)(0);(0,q.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,x.period),x.surface&&x.surface.length>0&&e.set(`surface`,x.surface.join(`,`)),x.provider&&x.provider.length>0&&e.set(`provider`,x.provider.join(`,`)),x.ticketId&&e.set(`ticketId`,String(x.ticketId)),u(e,{replace:!0})},[x.period,x.surface,x.provider,x.ticketId,u]);let F=(0,q.useCallback)(async()=>{if(!t)return;let e=++P.current;O(null);let n=`${t}:${Lt(x)}`,r=N.current.get(n);r?(w(r),E(!1)):E(!0);try{let t=await fetch(`${g()}/spending?${Lt(x)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==P.current)return;let r=await t.json();N.current.set(n,r),w(r),E(!1)}catch(t){if(e!==P.current)return;O(t.message),E(!1)}},[t,x]),I=(0,q.useCallback)(async()=>{if(!t)return;let e={...x};k.model&&(e.model=[k.model]),k.status&&(e.status=k.status),typeof k.minCostUsd==`number`&&(e.minCostUsd=k.minCostUsd);try{let t=await fetch(`${g()}/invocations?${Lt(e)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);M(await t.json())}catch{M(null)}},[t,x,k]);(0,q.useEffect)(()=>{F()},[F]),(0,q.useEffect)(()=>{I()},[I]);let L=(0,q.useRef)(null),R=a();(0,q.useEffect)(()=>{let e=`analytics-spending`;return R.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(L.current&&clearTimeout(L.current),L.current=setTimeout(()=>{N.current.clear(),F(),I()},500))}),()=>{R.unregisterHandler(e)}},[R,t,F,I]);function z(e){if(e===`all`){S(e=>({...e,surface:void 0}));return}S(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}function B(e){if(e===`all`){S(e=>({...e,provider:void 0}));return}S(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let V=x.surface,ee=!V||V.length===0,H=x.provider,te=!H||H.length===0,ne=(0,q.useMemo)(()=>{let e={period:x.period};return x.surface&&x.surface.length>0&&(e.surface=x.surface.join(`,`)),x.provider&&x.provider.length>0&&(e.provider=x.provider.join(`,`)),x.ticketId&&(e.ticketId=String(x.ticketId)),e},[x]),re=C?C.summary.totalRuns===0:!1;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),x.ticketId&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>S(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:x.ticketId})})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Ft.map(t=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>S(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${x.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,J.jsx)(_,{baseUrl:`${g()}/analytics/export`,params:ne,disabled:re}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{N.current.clear(),F(),I()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,J.jsx)(i,{className:`w-3 h-3`})})]})]}),(0,J.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:It.map(t=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>z(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ee:V?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),p&&(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,J.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>B(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${te?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),f.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>B(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${H?.includes(e)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:m(e)},e))]})]}),D&&(0,J.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,J.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:D})}),(0,J.jsxs)(`button`,{onClick:()=>F(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,J.jsx)(i,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,J.jsx)(Pe,{data:C,loading:T}),(0,J.jsx)(Be,{data:C,loading:T}),(0,J.jsx)(yt,{data:C,loading:T}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,J.jsx)(wt,{data:C,loading:T}),(0,J.jsx)(Tt,{data:C,loading:T,onSelectModel:e=>S(t=>({...t,model:[e]})),activeModel:x.model?.[0]})]}),(0,J.jsx)(Dt,{data:C,loading:T,onSelectPoint:e=>{A(e=>({...e})),S(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,J.jsx)(Ot,{data:C,loading:T,onSelectTicket:e=>S(t=>({...t,ticketId:e??void 0}))}),(0,J.jsx)(Pt,{rows:j?.rows??[],loading:T&&!j,truncated:j?.truncated??!1,totalAvailable:j?.totalAvailable??0,tableFilters:k,onTableFiltersChange:A})]})}export{Rt as default};