specrails-desktop 2.32.0 → 2.34.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 (228) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DvnFkjVG.js → ActivityFeedPage-DIDxNsDj.js} +1 -1
  2. package/client/dist/assets/{AgentBrowserCapture-CBjcliD7.js → AgentBrowserCapture-7pJ2G5VY.js} +1 -1
  3. package/client/dist/assets/AgentModeAnalyticsPane-BSSyTnTM.js +2 -0
  4. package/client/dist/assets/{AgentModeCodePane-CokuFVdV.js → AgentModeCodePane-DzW6gvDw.js} +2 -2
  5. package/client/dist/assets/{AgentModeJobsPane-rf_DlWNo.js → AgentModeJobsPane-9wJff15f.js} +1 -1
  6. package/client/dist/assets/AgentsPage-CIA67psb.js +87 -0
  7. package/client/dist/assets/AnalyticsPage-C0LwYELz.js +1 -0
  8. package/client/dist/assets/CodePage-RtKvHmAO.js +2 -0
  9. package/client/dist/assets/{DesktopAnalyticsPage-gBRVqiw6.js → DesktopAnalyticsPage-BU8Y_Ts1.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-BzO5dg2B.js → DocsDialog-DIpoaGlQ.js} +1 -1
  11. package/client/dist/assets/{DocsPage-Db_uxr1j.js → DocsPage-ME47KZpK.js} +1 -1
  12. package/client/dist/assets/InteractiveJobComposer-BGjIe9R6.js +19 -0
  13. package/client/dist/assets/{JobDetailModal-DPHh2WOS.js → JobDetailModal-1UZkqH4I.js} +1 -1
  14. package/client/dist/assets/JobDetailPage-CN65sAf1.js +1 -0
  15. package/client/dist/assets/JobsPage-f-4dqys7.js +1 -0
  16. package/client/dist/assets/LoopBuilderPage-WeiofeL6.js +7 -0
  17. package/client/dist/assets/LoopPreviewModal-DDTnTyH0.js +1 -0
  18. package/client/dist/assets/LoopsPage-BVNchIex.js +1 -0
  19. package/client/dist/assets/MinimizedChatsContext-CHsu3NCX.js +1 -0
  20. package/client/dist/assets/PluginsPage-CdFzGEfQ.js +2 -0
  21. package/client/dist/assets/ProjectSettingsDialog-BkCXBQWk.js +1 -0
  22. package/client/dist/assets/TemplatePreviewModal-RDi0khFG.js +1 -0
  23. package/client/dist/assets/TicketDetailModal-MhJzrqbi.js +14 -0
  24. package/client/dist/assets/{Trans-B2i5HVcM.js → Trans-CTqw6rr9.js} +1 -1
  25. package/client/dist/assets/{addspec-DhmnXER8.js → addspec-A1lDQa4M.js} +1 -1
  26. package/client/dist/assets/{addspec-BRlk8jON.js → addspec-BHZd0N5F.js} +1 -1
  27. package/client/dist/assets/{addspec-CHW9xf_X.js → addspec-BPpZ_olp.js} +1 -1
  28. package/client/dist/assets/{addspec-Di41DpYV.js → addspec-B_TPJt-R.js} +1 -1
  29. package/client/dist/assets/{addspec-4WmLJmBG.js → addspec-CLYLvaVP.js} +1 -1
  30. package/client/dist/assets/{addspec-C7XRejU4.js → addspec-CQBjzt24.js} +1 -1
  31. package/client/dist/assets/{addspec-x3mizDxc.js → addspec-D2YIQ0GU.js} +1 -1
  32. package/client/dist/assets/{addspec-DTmRrWrF.js → addspec-iFdQ6D99.js} +1 -1
  33. package/client/dist/assets/agent-Bd-q3Wqp.js +1 -0
  34. package/client/dist/assets/agent-BlvdW4Hv.js +1 -0
  35. package/client/dist/assets/agent-C-KQhxeM.js +1 -0
  36. package/client/dist/assets/agent-Ca15w5eu.js +1 -0
  37. package/client/dist/assets/agent-D6fKaoMd.js +1 -0
  38. package/client/dist/assets/agent-HFMYMTbB.js +1 -0
  39. package/client/dist/assets/agent-QIEbkBjg.js +1 -0
  40. package/client/dist/assets/agent-mTCsAbCl.js +1 -0
  41. package/client/dist/assets/agentstudio-BNUth0uj.js +1 -0
  42. package/client/dist/assets/agentstudio-BNdB5hkr.js +1 -0
  43. package/client/dist/assets/agentstudio-C7-bt8FO.js +1 -0
  44. package/client/dist/assets/agentstudio-C8uNchpV.js +1 -0
  45. package/client/dist/assets/agentstudio-CKabyMlg.js +1 -0
  46. package/client/dist/assets/agentstudio-CN2pokQu.js +1 -0
  47. package/client/dist/assets/agentstudio-DR7doNBV.js +1 -0
  48. package/client/dist/assets/agentstudio-y2dVDXeM.js +1 -0
  49. package/client/dist/assets/{analytics-C9RaQcE3.js → analytics-47pYygtV.js} +1 -1
  50. package/client/dist/assets/{analytics-B8Qtptbl.js → analytics-B0vt1g5U.js} +1 -1
  51. package/client/dist/assets/analytics-BMzCvrCU.js +1 -0
  52. package/client/dist/assets/{analytics-BPptRY4f.js → analytics-BlFN3Zwx.js} +1 -1
  53. package/client/dist/assets/{analytics-BxDGOIwf.js → analytics-CZYzL-nR.js} +1 -1
  54. package/client/dist/assets/{analytics-D_OZdQ9O.js → analytics-DAsb9MJ8.js} +1 -1
  55. package/client/dist/assets/{analytics-CJIwqrEl.js → analytics-FXQlQ2Yt.js} +1 -1
  56. package/client/dist/assets/{analytics-We6lUMI8.js → analytics-RnFCNkah.js} +1 -1
  57. package/client/dist/assets/{builder-CWYPw7Cw.js → builder-0IWtosUm.js} +1 -1
  58. package/client/dist/assets/{builder-CX1437hF.js → builder-Bf2N6XWn.js} +1 -1
  59. package/client/dist/assets/{builder-BiUG9Z5K.js → builder-BnqaaBkT.js} +1 -1
  60. package/client/dist/assets/{builder-CGRz_-zP.js → builder-BxxfGgAO.js} +1 -1
  61. package/client/dist/assets/{builder-DwDexYRE.js → builder-C5IIgWsq.js} +1 -1
  62. package/client/dist/assets/builder-CHuahItu.js +1 -0
  63. package/client/dist/assets/{builder-Cowk9jtL.js → builder-CjWosXL_.js} +1 -1
  64. package/client/dist/assets/{builder-3bygQtZi.js → builder-CpCIOoKj.js} +1 -1
  65. package/client/dist/assets/dashboard-BHRqsGCV.js +1 -0
  66. package/client/dist/assets/dashboard-Bfr90vOl.js +1 -0
  67. package/client/dist/assets/dashboard-CTsM8x3m.js +1 -0
  68. package/client/dist/assets/dashboard-CqC6wX0h.js +1 -0
  69. package/client/dist/assets/dashboard-CuZtAszc.js +1 -0
  70. package/client/dist/assets/dashboard-DAcqIc-n.js +1 -0
  71. package/client/dist/assets/dashboard-DekiV-86.js +1 -0
  72. package/client/dist/assets/dashboard-DoDczc5S.js +1 -0
  73. package/client/dist/assets/{dist-js-CkTZKBF9.js → dist-js-BmsFWRly.js} +1 -1
  74. package/client/dist/assets/{dist-js-ClShHcGa.js → dist-js-J5W_N5ng.js} +1 -1
  75. package/client/dist/assets/{formatDistanceToNow-BjGwPf6I.js → formatDistanceToNow-BOuXgebD.js} +1 -1
  76. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-CSCbUI4W.js → getTimezoneOffsetInMilliseconds-EjGOpn4b.js} +1 -1
  77. package/client/dist/assets/{i18n-Ch-Db_x2.js → i18n-nJQvD5zJ.js} +2 -2
  78. package/client/dist/assets/index-C_sdsSZt.js +63 -0
  79. package/client/dist/assets/index-DCN5QbDm.css +2 -0
  80. package/client/dist/assets/{jira-BySfUuQZ.js → jira-BNZu8f9O.js} +1 -1
  81. package/client/dist/assets/{jira-gAvOyije.js → jira-BOoaUXbb.js} +1 -1
  82. package/client/dist/assets/{jira-pRaL7JQo.js → jira-BYVN4L2u.js} +1 -1
  83. package/client/dist/assets/jira-CKJg3HZd.js +1 -0
  84. package/client/dist/assets/{jira-Byw2C0F8.js → jira-DDDsZ4ub.js} +1 -1
  85. package/client/dist/assets/{jira-D38Gj7AT.js → jira-DXwYjVE4.js} +1 -1
  86. package/client/dist/assets/{jira-D11gPhxz.js → jira-Dn6U2nRW.js} +1 -1
  87. package/client/dist/assets/{jira-api-BgFIr8eD.js → jira-api-Bhixwn-d.js} +1 -1
  88. package/client/dist/assets/{jira-CNeYi06w.js → jira-j7hVolR5.js} +1 -1
  89. package/client/dist/assets/nav-ApJVg3xu.js +1 -0
  90. package/client/dist/assets/nav-BKNky1Bg.js +1 -0
  91. package/client/dist/assets/nav-C6vWWKYx.js +1 -0
  92. package/client/dist/assets/nav-CXJ6Aw89.js +1 -0
  93. package/client/dist/assets/nav-CsmFBIDf.js +1 -0
  94. package/client/dist/assets/nav-DjkmQJjd.js +1 -0
  95. package/client/dist/assets/nav-iwjCg5FR.js +1 -0
  96. package/client/dist/assets/nav-pYuXq7sf.js +1 -0
  97. package/client/dist/assets/{provider-capabilities-BvoExILy.js → provider-capabilities-Doej9lfa.js} +1 -1
  98. package/client/dist/assets/setup-3jWaoVUO.js +1 -0
  99. package/client/dist/assets/setup-BjgRneb2.js +1 -0
  100. package/client/dist/assets/setup-BzFIjv-f.js +1 -0
  101. package/client/dist/assets/setup-C4VfQsxE.js +1 -0
  102. package/client/dist/assets/setup-DfUkpDbN.js +1 -0
  103. package/client/dist/assets/setup-ECe90Pmu.js +1 -0
  104. package/client/dist/assets/setup-dlqC4Jmm.js +1 -0
  105. package/client/dist/assets/setup-jwfLMiM2.js +1 -0
  106. package/client/dist/assets/{spending-Dq43JYmD.js → spending-BpYPsevQ.js} +1 -1
  107. package/client/dist/assets/tickets-B4rjuSYi.js +1 -0
  108. package/client/dist/assets/tickets-Bc71ce1C.js +1 -0
  109. package/client/dist/assets/tickets-CLg7VTJ8.js +1 -0
  110. package/client/dist/assets/tickets-CP9U1GJt.js +1 -0
  111. package/client/dist/assets/tickets-CZNBiHbq.js +1 -0
  112. package/client/dist/assets/tickets-DlX2mEkD.js +1 -0
  113. package/client/dist/assets/tickets-W6pBmbrX.js +1 -0
  114. package/client/dist/assets/tickets-_yKvCt4Y.js +1 -0
  115. package/client/dist/assets/{useBrowserCaptureSession-TTO8vHtd.js → useBrowserCaptureSession-BBXBN0Na.js} +1 -1
  116. package/client/dist/assets/useDesktop-B6Du2N83.js +1 -0
  117. package/client/dist/assets/{useSharedWebSocket-DaPh7QBL.js → useSharedWebSocket-DK96ctb7.js} +1 -1
  118. package/client/dist/index.html +24 -24
  119. package/docs/guide/de/getting-started/3-adding-your-first-project.md +13 -32
  120. package/docs/guide/de/integrations/1-ai-providers.md +27 -16
  121. package/docs/guide/en/getting-started/3-adding-your-first-project.md +8 -27
  122. package/docs/guide/en/integrations/1-ai-providers.md +21 -18
  123. package/docs/guide/es/getting-started/3-adding-your-first-project.md +12 -31
  124. package/docs/guide/es/integrations/1-ai-providers.md +24 -16
  125. package/docs/guide/fr/getting-started/3-adding-your-first-project.md +15 -34
  126. package/docs/guide/fr/integrations/1-ai-providers.md +25 -16
  127. package/docs/guide/it/getting-started/3-adding-your-first-project.md +16 -35
  128. package/docs/guide/it/integrations/1-ai-providers.md +25 -16
  129. package/docs/guide/ja/getting-started/3-adding-your-first-project.md +16 -35
  130. package/docs/guide/ja/integrations/1-ai-providers.md +7 -12
  131. package/docs/guide/pt/getting-started/3-adding-your-first-project.md +15 -34
  132. package/docs/guide/pt/integrations/1-ai-providers.md +24 -16
  133. package/docs/guide/zh/getting-started/3-adding-your-first-project.md +18 -37
  134. package/docs/guide/zh/integrations/1-ai-providers.md +7 -12
  135. package/docs/internals/project-builder.md +11 -6
  136. package/package.json +1 -1
  137. package/server/dist/ai-invocations.js +35 -0
  138. package/server/dist/blueprint-commit.js +1 -1
  139. package/server/dist/desktop-db.js +22 -1
  140. package/server/dist/desktop-router.js +132 -43
  141. package/server/dist/framework-reseed.js +144 -0
  142. package/server/dist/index.js +41 -2
  143. package/server/dist/jira/jira-sync-manager.js +49 -2
  144. package/server/dist/jira-router.js +21 -0
  145. package/server/dist/job-phase-breakdown.js +132 -0
  146. package/server/dist/legacy-migration.js +395 -0
  147. package/server/dist/loop-executors.js +5 -1
  148. package/server/dist/offline-assemble.js +32 -4
  149. package/server/dist/pr-body.js +13 -0
  150. package/server/dist/project-router-jobs.js +16 -0
  151. package/server/dist/project-router-spending.js +11 -1
  152. package/server/dist/provider-detection.js +222 -0
  153. package/server/dist/provider-selection.js +71 -19
  154. package/server/dist/queue-manager.js +4 -0
  155. package/server/dist/rail-pr-decision.js +10 -0
  156. package/server/dist/rails-router.js +11 -0
  157. package/server/dist/rails-store.js +5 -1
  158. package/server/dist/repo-map.js +293 -0
  159. package/server/dist/setup-manager.js +57 -0
  160. package/server/dist/spending.js +45 -0
  161. package/client/dist/assets/AgentsPage-B648IzGI.js +0 -87
  162. package/client/dist/assets/AnalyticsPage-0rBoULPX.js +0 -1
  163. package/client/dist/assets/CodePage-ju302Vl7.js +0 -2
  164. package/client/dist/assets/InteractiveJobComposer-_jmsE_Az.js +0 -19
  165. package/client/dist/assets/JobDetailPage-7nwHyHGV.js +0 -1
  166. package/client/dist/assets/JobsPage-C_6YrcmE.js +0 -1
  167. package/client/dist/assets/LoopBuilderPage-DJ1UPDwL.js +0 -7
  168. package/client/dist/assets/LoopPreviewModal-12cUnljK.js +0 -1
  169. package/client/dist/assets/LoopsPage-CHYK0Xjr.js +0 -1
  170. package/client/dist/assets/MinimizedChatsContext-Gt6KQySM.js +0 -1
  171. package/client/dist/assets/PluginsPage-E59oQmwc.js +0 -2
  172. package/client/dist/assets/ProjectSettingsDialog-DQTLQ7ie.js +0 -1
  173. package/client/dist/assets/TemplatePreviewModal-nXUcDgfk.js +0 -1
  174. package/client/dist/assets/TicketDetailModal-C-tHW-2s.js +0 -14
  175. package/client/dist/assets/agent-BKsuIgIT.js +0 -1
  176. package/client/dist/assets/agent-Bs9NilfI.js +0 -1
  177. package/client/dist/assets/agent-C23h684q.js +0 -1
  178. package/client/dist/assets/agent-CqEjy3Z2.js +0 -1
  179. package/client/dist/assets/agent-D5DZTks1.js +0 -1
  180. package/client/dist/assets/agent-DE8hUYPl.js +0 -1
  181. package/client/dist/assets/agent-DsTuJGSc.js +0 -1
  182. package/client/dist/assets/agent-DwZM05-x.js +0 -1
  183. package/client/dist/assets/agentstudio-8TQqBenW.js +0 -1
  184. package/client/dist/assets/agentstudio-B8Z_mmEX.js +0 -1
  185. package/client/dist/assets/agentstudio-BZR9YmLs.js +0 -1
  186. package/client/dist/assets/agentstudio-Bge9pAWb.js +0 -1
  187. package/client/dist/assets/agentstudio-Bz169Vzt.js +0 -1
  188. package/client/dist/assets/agentstudio-D6L2jpNi.js +0 -1
  189. package/client/dist/assets/agentstudio-K2-Z7CL0.js +0 -1
  190. package/client/dist/assets/agentstudio-Zmgzthv8.js +0 -1
  191. package/client/dist/assets/analytics-BHqUazhP.js +0 -1
  192. package/client/dist/assets/builder-skfnZ1uC.js +0 -1
  193. package/client/dist/assets/dashboard-BVq6kRJe.js +0 -1
  194. package/client/dist/assets/dashboard-BaKPPmLH.js +0 -1
  195. package/client/dist/assets/dashboard-Bm8e4zYG.js +0 -1
  196. package/client/dist/assets/dashboard-Bt6IesnM.js +0 -1
  197. package/client/dist/assets/dashboard-C_NQZle_.js +0 -1
  198. package/client/dist/assets/dashboard-CyZKoGoI.js +0 -1
  199. package/client/dist/assets/dashboard-HIUdUBQ0.js +0 -1
  200. package/client/dist/assets/dashboard-pm4Mr229.js +0 -1
  201. package/client/dist/assets/index-Bz0TeGRs.css +0 -2
  202. package/client/dist/assets/index-kCUcnT8G.js +0 -77
  203. package/client/dist/assets/jira-CmKWERE0.js +0 -1
  204. package/client/dist/assets/nav-BHDiSIVu.js +0 -1
  205. package/client/dist/assets/nav-CMiYAq4i.js +0 -1
  206. package/client/dist/assets/nav-CqS7NrDW.js +0 -1
  207. package/client/dist/assets/nav-D-0M7xfv.js +0 -1
  208. package/client/dist/assets/nav-D65O6u9I.js +0 -1
  209. package/client/dist/assets/nav-D_LKYvBr.js +0 -1
  210. package/client/dist/assets/nav-FDTJmU79.js +0 -1
  211. package/client/dist/assets/nav-VaB-C4k5.js +0 -1
  212. package/client/dist/assets/setup-BBiHEO7h.js +0 -1
  213. package/client/dist/assets/setup-BlTWhNIQ.js +0 -1
  214. package/client/dist/assets/setup-Bp2L_oiP.js +0 -1
  215. package/client/dist/assets/setup-CInYXp1-.js +0 -1
  216. package/client/dist/assets/setup-CYH3bP6K.js +0 -1
  217. package/client/dist/assets/setup-DwcQ921P.js +0 -1
  218. package/client/dist/assets/setup-PBLjuDSs.js +0 -1
  219. package/client/dist/assets/setup-bx6FtoBp.js +0 -1
  220. package/client/dist/assets/tickets-BL9r1G0e.js +0 -1
  221. package/client/dist/assets/tickets-B_NyHJ8f.js +0 -1
  222. package/client/dist/assets/tickets-BarF1wuG.js +0 -1
  223. package/client/dist/assets/tickets-CclVhpQA.js +0 -1
  224. package/client/dist/assets/tickets-CqqOHbli.js +0 -1
  225. package/client/dist/assets/tickets-DCkFSiqt.js +0 -1
  226. package/client/dist/assets/tickets-Djn3ccfT.js +0 -1
  227. package/client/dist/assets/tickets-MiHBPsy_.js +0 -1
  228. package/client/dist/assets/useDesktop-DUvS4fuP.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{a as i}from"./i18n-nJQvD5zJ.js";import{t as a}from"./Trans-CTqw6rr9.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{t as c}from"./arrow-up-right-9DoMn7fD.js";import{r as l}from"./useSharedWebSocket-DK96ctb7.js";import{t as u}from"./api-B2M7CtDw.js";import{n as d,r as f}from"./useDesktop-B6Du2N83.js";import{t as p}from"./clsx-CjueKrWZ.js";import{r as m}from"./provider-capabilities-Doej9lfa.js";import{t as h}from"./formatDistanceToNow-BOuXgebD.js";import{n as g,t as _}from"./spending-BpYPsevQ.js";import{jt as v,st as y}from"./index-C_sdsSZt.js";import{t as b}from"./ExportDropdown-BrtfWzEG.js";import{A as x,B as S,C,D as ee,E as w,F as T,G as E,H as D,I as O,J as k,K as A,L as j,M,N,O as P,P as F,Q as I,R as te,S as L,T as R,V as z,X as B,Z as V,_ as ne,_t as H,a as U,at as re,b as ie,c as ae,ct as oe,et as W,f as se,g as G,gt as ce,h as le,i as ue,j as de,k as fe,l as pe,lt as K,m as me,n as he,nt as ge,o as _e,ot as ve,p as ye,pt as q,q as be,r as xe,rt as Se,s as Ce,st as we,t as Te,tt as Ee,ut as J,v as De,x as Oe,y as ke,z as Ae}from"./BarChart-nBOMNfiy.js";var je=s(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),Y=e(t(),1),X=n();function Me(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function Ne(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function Pe(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Fe=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`chat-sidebar`,`spec-launcher`,`proposal`,`agent-studio`,`setup`,`smash`,`file-summary`,`loop`];function Ie({data:e,loading:t,period:n}){let{t:r}=o(`analytics`),[i,a]=(0,Y.useState)(0),s=(0,Y.useRef)(0),l=(0,Y.useRef)(null),u=(0,Y.useRef)(0);if((0,Y.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd,n=++u.current;if(l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),s.current===0&&t>0){let e=performance.now(),r=i=>{if(n!==u.current)return;let o=Math.min(1,(i-e)/600),s=1-(1-o)**3;a(0+(t-0)*s),o<1?l.current=requestAnimationFrame(r):l.current=null};l.current=requestAnimationFrame(r)}else a(t);return s.current=t,()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[e]),t&&!e)return(0,X.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let d=e.summary.totalCostUsd,f=e.summary.totalRuns,p=e.summary.totalTokens,m=e.summary.totalEstimatedCostUsd??0,h=typeof e.summary.pricedRuns==`number`||typeof e.summary.unpricedRuns==`number`,v=e.summary.unpricedRuns??0,y=e.summary.pricedRuns??(h?Math.max(0,f-v):f),b=h&&f>0&&y===0&&v>0,x=y>0&&v>0,S=typeof e.summary.usageReportedRuns==`number`||typeof e.summary.usageUnavailableRuns==`number`,C=e.summary.usageUnavailableRuns??0,ee=e.summary.usageReportedRuns??(S?Math.max(0,f-C):f),w=S&&f>0&&ee===0&&C>0,T=ee>0&&C>0,E=v>0?null:e.summary.deltaPct,D=e.trackingStartedAt,O=m>0,k=e.bySurface.map(e=>e.surface).filter(e=>!Fe.includes(e)),A=[...Fe,...k].map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}}),j=n?r(`windowLabels.${n}`):null;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{children:r(`hero.spending`)}),j&&(0,X.jsxs)(`span`,{"data-testid":`hero-window-label`,className:`normal-case tracking-normal text-muted-foreground/70 font-normal`,children:[`· `,j]})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,X.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,"data-testid":b?`hero-cost-unavailable`:void 0,title:b?r(`hero.costUnavailableTooltip`):void 0,children:b?`—`:Ne(i)}),E!==null&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${E>=0?`text-accent-warning`:`text-accent-success`}`,children:[E>=0?(0,X.jsx)(c,{className:`w-3 h-3`}):(0,X.jsx)(je,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(E).toFixed(0)})]})]}),(0,X.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,X.jsx)(`span`,{children:r(`hero.invocations`,{count:f})}),w?(0,X.jsx)(`span`,{"data-testid":`hero-usage-unavailable`,className:`text-muted-foreground/80 italic`,title:r(`hero.usageUnavailableTooltip`),children:r(`hero.usageUnavailable`)}):T&&p!=null?(0,X.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.usagePartiallyUnavailableTooltip`),children:r(`hero.usagePartiallyUnavailable`,{tokens:Pe(p),count:C})}):p!=null&&p>0?(0,X.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:Pe(p)})}):null,b&&(0,X.jsx)(`span`,{className:`text-muted-foreground/80 italic`,title:r(`hero.costUnavailableTooltip`),children:r(`hero.costUnavailable`)}),x&&(0,X.jsx)(`span`,{"data-testid":`hero-cost-partial`,className:`text-muted-foreground/80 italic`,title:r(`hero.costPartiallyUnavailableTooltip`),children:r(`hero.costPartiallyUnavailable`,{count:v})}),O&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:Me(m)}),children:r(`hero.includesEstimated`,{amount:Me(m)})})]})]}),f===0&&D&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:D.slice(0,10)})})]}),f===0?(0,X.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:D?r(`hero.trackingStarted`,{date:D.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):b?(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-4 text-xs text-muted-foreground/80`,children:r(`hero.costUnavailableTooltip`)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:A.map(e=>{let t=d>0?e.costUsd/d*100:0;return t===0?null:(0,X.jsx)(`div`,{className:`h-full ${_[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:g[e.surface],value:Me(e.costUsd)})},e.surface)})}),(0,X.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:A.filter(e=>e.costUsd>0).map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,X.jsx)(`span`,{className:`w-2 h-2 rounded-full ${_[e.surface].dot}`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:g[e.surface]}),(0,X.jsx)(`span`,{className:`text-foreground font-medium`,children:Me(e.costUsd)}),(0,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Le={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`},Re={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`,kimi:`bg-purple-400`};function ze(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Be(e){return Le[e]??e}function Ve(e){return Re[e]??`bg-accent-secondary`}function He({data:e,loading:t}){let{t:n}=o(`analytics`);if(t&&!e)return(0,X.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 r=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0),i=e.byProvider.some(e=>typeof e.unpricedCount==`number`?e.unpricedCount>0:e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0);return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:n(`providerCard.title`)}),(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,X.jsx)(a,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,X.jsx)(`span`,{className:`font-medium`})}})})]})}),r===0&&(0,X.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:n(i?`providerCard.costUnavailableTooltip`:`providerCard.noCost`)}),r>0&&(0,X.jsx)(X.Fragment,{children:(0,X.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,i=r>0?t/r*100:0;if(i===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${ze(t)}`;return(0,X.jsx)(`div`,{className:`h-full ${Ve(e.provider)}`,style:{width:`${i}%`},title:n(`providerCard.segmentTitle`,{label:Be(e.provider),value:a,count:e.count})},e.provider)})})}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 ${r>0?``:`mt-3`}`,children:e.byProvider.map(e=>(0,X.jsx)(Ue,{entry:e},e.provider))})]})}function Ue({entry:e}){let{t}=o(`analytics`),n=e.costUsd+e.estimatedCostUsd,r=e.costUsd===0&&e.estimatedCostUsd>0,i=e.unpricedCount??(e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0?e.count:0),a=e.pricedCount??Math.max(0,e.count-i),s=e.count>0&&i>0&&a===0,c=a>0&&i>0;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,X.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Ve(e.provider)}`}),(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:Be(e.provider)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),s?(0,X.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,X.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,title:c?t(`providerCard.costPartiallyUnavailableTooltip`):void 0,children:[r?`~`:``,ze(n),c&&(0,X.jsx)(`span`,{className:`ml-1 font-normal text-muted-foreground/80 italic`,children:t(`providerCard.costPartiallyUnavailable`,{count:i})})]})]})}var We=[`option`,`isActive`];function Z(){return Z=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},Z.apply(null,arguments)}function Ge(e,t){if(e==null)return{};var n,r,i=Ke(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 Ke(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 qe(e){var{option:t,isActive:n}=e,r=Ge(e,We);return typeof t==`string`?Y.createElement(L,Z({option:Y.createElement(we,Z({type:t},r)),isActive:n,shapeType:`symbols`},r)):Y.createElement(L,Z({option:t,isActive:n,shapeType:`symbols`},r))}var Je=W([(e,t,n,r,i,a,o)=>te(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>N(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>F(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>N(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>F(e,`yAxis`,n,o),(e,t,n,r)=>O(e,`zAxis`,r,!1),W([T,(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 ut({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ye=[`id`],Xe=[`onMouseEnter`,`onClick`,`onMouseLeave`],Ze=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Qe(e,t){if(e==null)return{};var n,r,i=$e(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 $e(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 et(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?et(Object(n),!0).forEach(function(t){tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):et(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function tt(e,t,n){return(t=nt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function nt(e){var t=rt(e,`string`);return typeof t==`symbol`?t:t+``}function rt(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 it=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:V(n,t),payload:e}]},at=Y.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:V(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return Y.createElement(De,{tooltipEntrySettings:u})});function ot(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=ce(n),s=H(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}=oe(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=Y.isValidElement(r)?Y.cloneElement(r,h):typeof r==`function`?r(h):Y.createElement(z,Q({},h,{type:a})),Y.createElement(q,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function st(e){var{showLabels:t,points:n,children:r}=e,i=E(),a=(0,Y.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 Y.createElement(R,{value:t?a:void 0},r)}function ct(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Qe(n,Ye),c=ge(de),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Qe(n,Xe),p=ie(l,a,o),m=Oe(d),h=ke(u,a,o);if(!ve(t))return null;var g=ce(s);return Y.createElement(Y.Fragment,null,Y.createElement(ot,{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,[k]:String(o)});return Y.createElement(x,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?j.activeDot:void 0},Y.createElement(q,Q({className:`recharts-scatter-symbol`},re(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),Y.createElement(qe,Q({option:s,isActive:a},l))))}))}function lt(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Ae(n,`recharts-scatter-`),[u,d]=(0,Y.useState)(!1),f=(0,Y.useCallback)(()=>{d(!1)},[]),p=(0,Y.useCallback)(()=>{d(!0)},[]),m=!u;return Y.createElement(st,{showLabels:m,points:r},n.children,Y.createElement(S,{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:K(r.cx,t.cx,e),cy:t.cy==null?void 0:K(r.cy,t.cy,e),size:K(r.size,t.size,e)}):$($({},t),{},{size:K(0,t.size,e)})});return e>0&&(t.current=i),Y.createElement(q,null,Y.createElement(ct,{points:i,allOtherScatterProps:n,showLabels:m}))}),Y.createElement(w,{label:n.label}))}function ut(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=J(n.dataKey)?a.dataKey:n.dataKey,u=J(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:M.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=I(e,l),g=I(e,u),_=!J(d)&&I(e,d)||`-`,v=[{name:J(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:J(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=B({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=B({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 dt=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:I(e,t)});function ft(e){var{hide:t,points:n,className:r,needClip:i,xAxisId:a,yAxisId:o,id:s}=e,c=(0,Y.useRef)(null);if(t)return null;var l=p(`recharts-scatter`,r),u=s;return Y.createElement(x,{zIndex:e.zIndex},Y.createElement(q,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&Y.createElement(`defs`,null,Y.createElement(_e,{clipPathId:u,xAxisId:a,yAxisId:o})),Y.createElement(ae,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:dt,errorBarOffset:0},Y.createElement(q,{key:`recharts-scatter-symbols`},Y.createElement(lt,{props:e,previousPointsRef:c})))))}var pt={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:j.scatter};function mt(e){var t=Se(e,pt),{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=Qe(t,Ze),{needClip:h}=Ce(d,f),g=(0,Y.useMemo)(()=>C(e.children,ee),[e.children]),_=be(),v=ge(t=>Je(t,d,f,p,e.id,g,_));return h==null||v==null?null:Y.createElement(Y.Fragment,null,Y.createElement(at,{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}),Y.createElement(ft,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 ht(e){var t=Se(e,pt),n=be();return Y.createElement(G,{id:t.id,type:`scatter`},e=>Y.createElement(Y.Fragment,null,Y.createElement(ne,{legendPayload:it(t)}),Y.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}),Y.createElement(mt,Q({},t,{id:e}))))}var gt=Y.memo(ht,D);gt.displayName=`Scatter`;function _t(e){var t=Ee(),n=(0,Y.useRef)(null);return(0,Y.useLayoutEffect)(()=>{n.current===null?t(se(e)):n.current!==e&&t(me({prev:n.current,next:e})),n.current=e},[e,t]),(0,Y.useLayoutEffect)(()=>()=>{n.current&&=(t(ye(n.current)),null)},[t]),null}var vt={zAxisId:0,range:M.range,scale:M.scale,type:M.type};function yt(e){var t=Se(e,vt);return Y.createElement(_t,{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:M.allowDuplicatedCategory,allowDataOverflow:M.allowDataOverflow,reversed:M.reversed,includeHidden:M.includeHidden})}yt.displayName=`ZAxis`;var bt=[`item`],xt=(0,Y.forwardRef)((e,t)=>Y.createElement(he,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:bt,tooltipPayloadSearcher:fe,categoricalChartProps:e,ref:t}));function St({data:e,loading:t}){let{t:n}=o(`analytics`);if(t&&!e)return(0,X.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r={jobs:n(`surfaces.job`),explore:n(`surfaces.exploreSpec`),quick:n(`surfaces.quickSpec`),refine:n(`surfaces.aiEdit`),fileSummaries:n(`surfaces.fileSummary`),smash:n(`surfaces.smash`),loop:n(`surfaces.loop`)},i=e.dailyTimeline.map(e=>({date:e.date.slice(5),[r.jobs]:e.jobsCostUsd,[r.explore]:e.exploreCostUsd,[r.quick]:e.quickCostUsd,[r.refine]:e.aiEditCostUsd,[r.fileSummaries]:e.fileSummaryCostUsd??0,[r.smash]:e.smashCostUsd??0,[r.loop]:e.loopCostUsd??0})),a=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0),s=e.dailyTimeline.reduce((e,t)=>e+(t.unpricedCount??0),0),c=a&&s>0,l=!a&&s>0;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`timeline.title`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:l?n(`timeline.costPartiallyUnavailable`,{count:s}):n(`timeline.subtitle`)})]}),c?(0,X.jsx)(`div`,{"data-testid":`timeline-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.costUnavailable`)}):a?(0,X.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.empty`)}):(0,X.jsx)(`div`,{className:`h-[220px]`,children:(0,X.jsx)(A,{width:`100%`,height:`100%`,children:(0,X.jsxs)(Te,{data:i,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,X.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,X.jsx)(ue,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,X.jsx)(xe,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,X.jsx)(P,{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,X.jsx)(U,{dataKey:r.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,X.jsx)(U,{dataKey:r.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,X.jsx)(U,{dataKey:r.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,X.jsx)(U,{dataKey:r.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,X.jsx)(U,{dataKey:r.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,X.jsx)(U,{dataKey:r.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,X.jsx)(U,{dataKey:r.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function Ct(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function wt(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 Tt({values:e}){let t=Math.max(1e-4,...e);return(0,X.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,X.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Et({mode:e,label:t,accentClass:n}){let{t:r}=o(`analytics`),i=e.mode===`explore`&&e.totalRuns<5,s=(e.estimatedCostUsd??0)>0,c=e.avgCostPerSpec==null&&(e.unpricedCount??0)>0;return(0,X.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,X.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),i?(0,X.jsxs)(`div`,{className:`py-3`,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:r(`quickVsExplore.sparseCta`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":s?`true`:void 0,title:c?r(`quickVsExplore.costUnavailableTooltip`):s?r(`quickVsExplore.estimatedTooltip`):void 0,children:[s&&e.avgCostPerSpec!=null?`~`:``,Ct(e.avgCostPerSpec)]}),(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:r(c?`quickVsExplore.costUnavailable`:`quickVsExplore.perSpec`)}),(0,X.jsx)(`div`,{className:`mt-3`,children:(0,X.jsx)(Tt,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,X.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,X.jsx)(`div`,{children:(0,X.jsx)(a,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,X.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,X.jsx)(`div`,{children:r(`quickVsExplore.avgDuration`,{duration:wt(e.avgDurationMs)})}),(0,X.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function Dt({data:e,loading:t}){let{t:n}=o(`analytics`);if(t&&!e)return(0,X.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r=e.byMode.find(e=>e.mode===`quick`),i=e.byMode.find(e=>e.mode===`explore`);if(!r||!i)return null;let a=r.avgCostPerSpec&&i.avgCostPerSpec&&r.avgCostPerSpec>0?i.avgCostPerSpec/r.avgCostPerSpec:null,s=a!==null&&r.totalRuns>=1&&i.totalRuns>=5,c=(r.estimatedCostUsd??0)>0||(i.estimatedCostUsd??0)>0;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,X.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`quickVsExplore.title`)})}),(0,X.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,X.jsx)(Et,{mode:r,label:n(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,X.jsx)(Et,{mode:i,label:n(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,X.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,X.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,X.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,n(`quickVsExplore.ratio`,{ratio:a.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,X.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(`quickVsExplore.estimatedFootnote`)})})]})}function Ot(e){return e<.005&&e>0?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function kt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function At({data:e,loading:t}){let{t:n}=o(`analytics`),r=e?.agentMissions;if(t||!r||r.summary.turns===0)return null;let{summary:a,topConversations:s}=r,c=a.estimatedCostUsd>0,l=a.prevTotalCostUsd>0?(a.totalCostUsd-a.prevTotalCostUsd)/a.prevTotalCostUsd*100:null;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card p-4`,"data-testid":`agent-missions-card`,children:[(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,X.jsx)(v,{className:`h-4 w-4 text-accent-highlight`}),(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:n(`agentMissions.title`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(`agentMissions.subtitle`)})]}),(0,X.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,X.jsxs)(`span`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":c?`true`:void 0,title:c?n(`agentMissions.estimatedNote`):void 0,children:[c?`~`:``,Ot(a.totalCostUsd)]}),l!==null&&(0,X.jsxs)(`span`,{className:l>0?`text-xs text-accent-warning`:`text-xs text-accent-success`,children:[l>0?`+`:``,l.toFixed(0),`% `,n(`agentMissions.vsPrev`)]})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`agentMissions.turnsAndTokens`,{turns:a.turns,tokens:kt(a.tokensIn+a.tokensOut)})}),s.length>0&&(0,X.jsx)(`ul`,{className:`mt-3 space-y-1 border-t border-border/40 pt-2`,children:s.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/85`,children:e.title?.trim()||n(`agentMissions.untitled`)}),(0,X.jsxs)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:[e.turns,` · `,e.lastAt?h(new Date(e.lastAt),{addSuffix:!0,locale:i()}):`—`]}),(0,X.jsxs)(`span`,{className:`shrink-0 tabular-nums font-medium`,children:[e.estimatedCostUsd>0?`~`:``,Ot(e.costUsd)]})]},e.conversationId??`unknown`))})]})}function jt({data:e,loading:t,onSelectModel:n,activeModel:r}){let{t:i}=o(`analytics`);if(t&&!e)return(0,X.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let a=e.summary.totalCostUsd,s=e.byModel.slice(0,5),c=s.reduce((e,t)=>e+t.costUsd,0),l=Math.max(0,a-c),u=l>=.005;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`models.title`)}),s.length===0?(0,X.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`models.empty`)}):(0,X.jsxs)(`ul`,{className:`space-y-1.5`,children:[s.map(e=>{let t=a>0?e.costUsd/a*100:0,o=r===e.model,s=(e.estimatedCostUsd??0)>0,c=e.unpricedCount??0,l=Math.max(0,e.count-c),u=e.count>0&&c>0&&l===0,d=l>0&&c>0;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${o?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,"data-testid":u?`model-cost-unavailable`:void 0,title:u?i(`models.costUnavailableTooltip`):d?i(`models.costPartiallyUnavailableTooltip`):s?i(`models.estimatedTooltip`):void 0,children:u?i(`models.costUnavailableWithRuns`,{count:e.count}):(0,X.jsxs)(X.Fragment,{children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count,d&&(0,X.jsx)(`span`,{className:`ml-1 italic`,children:i(`models.costPartiallyUnavailable`,{count:c})})]})})]}),(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full ${o?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)}),u&&(0,X.jsx)(`li`,{"data-testid":`model-others`,children:(0,X.jsxs)(`div`,{className:`w-full rounded-md px-2 py-1.5`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:i(`models.others`)}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,l.toFixed(2)]})]}),(0,X.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,X.jsx)(`div`,{className:`h-full bg-foreground/25`,style:{width:`${a>0?l/a*100:0}%`}})})]})})]})]})}var Mt={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)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`,"chat-sidebar":`var(--accent-info, #5fa8d3)`,"spec-launcher":`var(--accent-secondary, #f7768e)`,proposal:`var(--accent-highlight, #c084fc)`,"agent-studio":`var(--accent-success, #50fa7b)`,setup:`var(--accent-primary, #7aa2f7)`},Nt=Object.keys(g);function Pt({data:e,loading:t,onSelectPoint:n}){let{t:r}=o(`analytics`);if(t&&!e)return(0,X.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=Nt,a=i.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,c=e.summary.unpricedRuns??0,l=s&&c>0,u=!s&&c>0,d=e.scatterTruncated===!0,f=e.scatterTotal??e.scatter.length;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`scatter.title`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:i.map(e=>(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Mt[e]}}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:g[e]})]},e))})]}),d&&!s&&(0,X.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:r(`scatter.truncated`,{shown:e.scatter.length,total:f})}),u&&(0,X.jsx)(`div`,{"data-testid":`scatter-cost-partial-notice`,className:`mb-2 text-[10px] text-muted-foreground/80 italic`,children:r(`scatter.costPartiallyUnavailable`,{count:c})}),l?(0,X.jsx)(`div`,{"data-testid":`scatter-cost-unavailable`,className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.costUnavailable`)}):s?(0,X.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.empty`)}):(0,X.jsx)(`div`,{className:`h-[260px]`,children:(0,X.jsx)(A,{width:`100%`,height:`100%`,children:(0,X.jsxs)(xt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,X.jsx)(pe,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,X.jsx)(ue,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:r(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,X.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,X.jsx)(yt,{range:[40,80]}),(0,X.jsx)(P,{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)}`,r(`scatter.costLabel`)]:[String(e),n===`turns`?r(`scatter.turnsLabel`):n]}}),a.map(e=>(0,X.jsx)(gt,{data:e.points,fill:Mt[e.surface],onClick:e=>{let t=e;t?.raw&&n(t.raw)}},e.surface))]})})})]})}function Ft({data:e,loading:t,onSelectTicket:n}){let{t:r}=o(`analytics`);if(t&&!e)return(0,X.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.topTickets;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:r(`topTickets.title`)}),i.length===0?(0,X.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`topTickets.empty`)}):(0,X.jsx)(`ul`,{className:`divide-y divide-border/30`,children:i.map((e,t)=>{let i=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>r(`topTickets.breakdownItem`,{n:t.count,label:g[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?r(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:r(`topTickets.deletedTicket`,{id:e.ticketId}),s=!e.ticketTitle&&!a?`opacity-50`:``,c=e.unpricedCount??0,l=e.totalRuns>0&&c===e.totalRuns,u=c>0&&!l;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>n(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 ${s}`,disabled:a,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:i||`—`})]}),(0,X.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium`,title:l?r(`topTickets.costUnavailableTooltip`):u?r(`topTickets.costPartiallyUnavailableTooltip`):void 0,children:l?r(`topTickets.costUnavailable`):`$${e.totalCostUsd.toFixed(2)}`}),u&&(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground italic`,children:r(`topTickets.costPartiallyUnavailable`,{count:c})}),(0,X.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var It={claude:`Claude`,codex:`Codex`,gemini:`Gemini`,kimi:`Kimi`};function Lt(e){return It[e]??e}function Rt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function zt(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Bt(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 Vt(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 Ht(e,t){if(e.model)return e.model;if(!Bt(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 Ut({rows:e,loading:t,truncated:n,totalAvailable:r,tableFilters:i,onTableFiltersChange:a}){let{t:s}=o(`analytics`),[c,l]=(0,Y.useState)(null),u=Vt(e),d=new Set(e.map(e=>e.provider??`claude`)).size>1,f=n||r>e.length;return(0,X.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,X.jsxs)(`select`,{value:i.status??``,onChange:e=>a({...i,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,X.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,X.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,X.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,X.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,X.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:i.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);a({...i,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,X.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,X.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,X.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,X.jsxs)(`tr`,{className:`text-left`,children:[(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),d&&(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colProvider`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,X.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,X.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=_[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Bt(e),a=i?s(`table.contractLayer`):g[t],o=Ht(e,u);return(0,X.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,X.jsx)(`td`,{className:`px-2 py-2`,children:(0,X.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,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,X.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,X.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,X.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,X.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,X.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,X.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,X.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,X.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,Rt(e.total_cost_usd)]}):Rt(e.total_cost_usd)}),(0,X.jsx)(`td`,{className:`px-2 py-2 text-right`,children:zt(e.num_turns)}),(0,X.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?zt(r):`—`}),(0,X.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,X.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),d&&(0,X.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:Lt(e.provider??`claude`)}),(0,X.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,X.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,X.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,X.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,X.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),f&&e.length>0&&(0,X.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:r.toLocaleString()})})]})}var Wt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],Gt=[{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`},{value:`loop`,labelKey:`surfaces.loop`}];function Kt(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.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).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)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function qt(){let{t:e}=o(`analytics`),{activeProjectId:t,projects:n}=f(),[i,a]=r(),s=n.find(e=>e.id===t),c=s?d(s):[`claude`],p=c.length>1,h=i.get(`period`)??`30d`,g=(i.get(`surface`)??``).split(`,`).filter(Boolean),_=(i.get(`provider`)??``).split(`,`).filter(Boolean),v=i.get(`ticketId`),x=(i.get(`model`)??``).split(`,`).filter(Boolean),S=(i.get(`modelProvider`)??``).split(`,`).filter(Boolean),C=x.length>0&&x.length===S.length?x.map((e,t)=>({provider:S[t],model:e})):void 0,ee=(0,Y.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[w,T]=(0,Y.useState)({period:h,surface:g.length>0?g:void 0,provider:_.length>0?_:void 0,ticketId:v?Number(v):void 0,model:x.length>0?x:void 0,modelKeys:C,tzOffsetMinutes:ee}),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(!0),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)({}),[P,F]=(0,Y.useState)(null),[I,te]=(0,Y.useState)(`recency`),L=(0,Y.useRef)(new Map),R=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,w.period),w.surface&&w.surface.length>0&&e.set(`surface`,w.surface.join(`,`)),w.provider&&w.provider.length>0&&e.set(`provider`,w.provider.join(`,`)),w.ticketId&&e.set(`ticketId`,String(w.ticketId)),w.model&&w.model.length>0&&(e.set(`model`,w.model.join(`,`)),w.modelKeys&&w.modelKeys.length===w.model.length&&e.set(`modelProvider`,w.modelKeys.map(e=>e.provider).join(`,`))),a(e,{replace:!0})},[w.period,w.surface,w.provider,w.ticketId,w.model,w.modelKeys,a]);let z=(0,Y.useCallback)(async()=>{if(!t)return;let e=++R.current;j(null);let n=`${t}:${Kt(w)}`,r=L.current.get(n);r?(D(r),k(!1)):k(!0);try{let t=await fetch(`${u()}/spending?${Kt(w)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==R.current)return;let r=await t.json();L.current.set(n,r),D(r),k(!1)}catch(t){if(e!==R.current)return;j(t.message),k(!1)}},[t,w]),B=(0,Y.useRef)(0),V=(0,Y.useCallback)(async()=>{if(!t)return;let e=++B.current,n={...w};M.model&&(n.model=[M.model],n.modelKeys=void 0),M.status&&(n.status=M.status),typeof M.minCostUsd==`number`&&(n.minCostUsd=M.minCostUsd),n.sortBy=I;try{let t=await fetch(`${u()}/invocations?${Kt(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==B.current)return;F(r)}catch{if(e!==B.current)return;F(null)}},[t,w,M,I]),ne=(0,Y.useRef)(t);(0,Y.useEffect)(()=>{ne.current!==t&&(ne.current=t,D(null),F(null),k(!0))},[t]),(0,Y.useEffect)(()=>{z()},[z]),(0,Y.useEffect)(()=>{V()},[V]);let H=(0,Y.useRef)(null),U=l();(0,Y.useEffect)(()=>{let e=`analytics-spending`;return U.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{L.current.clear(),z(),V()},500))}),()=>{U.unregisterHandler(e),H.current&&clearTimeout(H.current)}},[U,t,z,V]);function re(e){if(e===`all`){T(e=>({...e,surface:void 0}));return}T(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}})}let ie=(0,Y.useCallback)((e,t)=>{T(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(E?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[E]);function ae(){T(e=>({...e,model:void 0,modelKeys:void 0}))}function oe(e){if(e===`all`){T(e=>({...e,provider:void 0}));return}T(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 W=w.surface,se=!W||W.length===0,G=w.provider,ce=!G||G.length===0,le=(0,Y.useMemo)(()=>{let e={period:w.period};return w.surface&&w.surface.length>0&&(e.surface=w.surface.join(`,`)),w.provider&&w.provider.length>0&&(e.provider=w.provider.join(`,`)),w.ticketId&&(e.ticketId=String(w.ticketId)),e},[w]),ue=E?E.summary.totalRuns===0:!1;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),w.ticketId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>T(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:w.ticketId})}),w.model&&w.model.length>0&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:ae,title:e(`page.clearModelFilter`),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.modelChip`,{model:w.model[0]}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Wt.map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>T(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${w.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,X.jsx)(b,{baseUrl:`${u()}/analytics/export`,params:le,disabled:ue}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{L.current.clear(),z(),V()},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,X.jsx)(y,{className:`w-3 h-3`})})]})]}),(0,X.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:Gt.map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>re(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?se:W?.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,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${ce?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),c.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>oe(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${G?.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))]})]}),A&&(0,X.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,X.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:A})}),(0,X.jsxs)(`button`,{onClick:()=>z(),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,X.jsx)(y,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,X.jsx)(Ie,{data:E,loading:O,period:w.period}),(0,X.jsx)(He,{data:E,loading:O}),(0,X.jsx)(St,{data:E,loading:O}),(0,X.jsx)(At,{data:E,loading:O}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,X.jsx)(Dt,{data:E,loading:O}),(0,X.jsx)(jt,{data:E,loading:O,onSelectModel:ie,activeModel:w.model?.[0]})]}),(0,X.jsx)(Pt,{data:E,loading:O,onSelectPoint:e=>{N(e=>({...e})),T(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,X.jsx)(Ft,{data:E,loading:O,onSelectTicket:e=>T(t=>({...t,ticketId:e??void 0}))}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,X.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,X.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":I===t,onClick:()=>te(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${I===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,X.jsx)(Ut,{rows:P?.rows??[],loading:O&&!P,truncated:(P?.truncated??!1)||(P?.totalAvailable??0)>(P?.rows.length??0),totalAvailable:P?.totalAvailable??0,tableFilters:M,onTableFiltersChange:N})]})]})}export{qt as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-DxrmGfoq.js","assets/rolldown-runtime-CNC7AqOf.js","assets/preload-helper-Czpn1I53.js","assets/editor.api2-4ndOupAA.js","assets/editor-Br_kD0ds.css","assets/monaco.contribution-Bt92R3Vw.js","assets/workers-uOo7WLaa.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{d as a,l as o}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{n as l}from"./dist-bVqfYmby.js";import{m as u}from"./useBrowserCaptureSession-BBXBN0Na.js";import{c as d,l as f}from"./MinimizedChatsContext-CHsu3NCX.js";import{t as p}from"./external-link-BcU5EWZp.js";import{t as m}from"./chevron-right-CViMxucY.js";import{L as h,R as g,o as _,z as v}from"./TicketDetailModal-MhJzrqbi.js";import{t as y}from"./file-text-CFT-xXKN.js";import{t as b}from"./sparkles-DrY8hb0X.js";import{t as x}from"./x-CBMI9ejn.js";import{r as S}from"./useSharedWebSocket-DK96ctb7.js";import{t as C}from"./api-B2M7CtDw.js";import{i as w,r as T}from"./useDesktop-B6Du2N83.js";import{t as E}from"./utils-BC4DHlz2.js";import{c as ee,s as D}from"./dialog-CzIekCw0.js";import{c as O}from"./provider-capabilities-Doej9lfa.js";import{n as k,t as A}from"./lib-CGdyxIWg.js";import{St as j,bt as M,y as N,yt as P}from"./index-C_sdsSZt.js";var F=c(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),I=e(t(),1),L=e(r(),1);function R(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function z(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function B(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var te=(e,t)=>Math.abs(e-t)<1.01,ne=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},V,re=()=>{if(V!==void 0)return V;if(typeof navigator>`u`)return V=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return V=!0;let e=navigator.maxTouchPoints;return V=navigator.platform===`MacIntel`&&e!==void 0&&e>0},ie=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ae=e=>e,oe=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},se=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(ie(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(ie(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},H={passive:!0},U=typeof window>`u`||`onscrollend`in window,W=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&U,o=0,s=a?null:ne(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,H),a&&r.addEventListener(`scrollend`,u,H),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},ce=(e,t)=>W(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),le=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},G=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},K=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ae,rangeExtractor:oe,onChange:()=>{},measureElement:le,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=z(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!re()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,H),e.addEventListener(`touchend`,n,H),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=z(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=z(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=R(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=z(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?J({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=z(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(re()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=z(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return B(t[q(0,t.length-1,r?e=>n[e*2]:e=>B(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&te(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},q=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function J({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=q(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var Y=typeof document<`u`?I.useLayoutEffect:I.useEffect;function ue({useFlushSync:e=!0,...t}){let n=I.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,L.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=I.useState(()=>new K(r));return i.setOptions(r),Y(()=>i._didMount(),[]),Y(()=>i._willUpdate()),i}function X(e){return ue({observeElementRect:se,observeElementOffset:ce,scrollToFn:G,...e})}var Z=n(),de=e=>`specrails-desktop:code-tree-filter:${e}`,fe=e=>`specrails-desktop:code-tree-collapsed:${e}`;function pe(e){return e.split(`/`).length-1}function me(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function he(e){return e?e.length>10?e.slice(0,10):e:null}function ge(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function _e(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function ve({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:i}=s(`code`),{activeProjectId:a}=T(),{openTicketDetail:o}=_(),{registerHandler:c,unregisterHandler:l}=S(),[u,d]=(0,I.useState)(()=>{if(!a)return`touched-by-ai`;try{let e=localStorage.getItem(de(a));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,I.useEffect)(()=>{if(a)try{localStorage.setItem(de(a),u)}catch{}},[u,a]);let[p,g]=(0,I.useState)(()=>{if(!a)return new Set;try{let e=localStorage.getItem(fe(a));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,I.useEffect)(()=>{if(a)try{localStorage.setItem(fe(a),JSON.stringify([...p]))}catch{}},[p,a]);let v=(0,I.useCallback)(e=>{g(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),y=(0,I.useCallback)(()=>{g(new Set)},[]),{data:b,refresh:x,isFirstLoad:ee}=w({namespace:`code-tree:${u}:${u===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`}`,projectId:a,initialValue:[],fetcher:(0,I.useCallback)(async()=>{let e=[],t=null;for(let i=0;i<100;i+=1){let i=new URLSearchParams({withProvenance:`1`,filter:u});u===`touched-by-ai`&&n&&i.set(`jobId`,n),u===`touched-by-ai`&&typeof r==`number`&&i.set(`ticketId`,String(r)),t&&i.set(`cursor`,t);let a=await fetch(`${C()}/code/tree?${i.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[u,n,r])}),D=(0,I.useRef)(a);(0,I.useEffect)(()=>{D.current=a},[a]),(0,I.useEffect)(()=>{if(!a)return;let e=`code-tree-${a}`;return c(e,e=>{let t=e;t.projectId===D.current&&t.type===`file.provenance_updated`&&x()}),()=>l(e)},[a,c,l,x]);let O=(0,I.useRef)(null),k=(0,I.useMemo)(()=>(b??[]).filter(e=>!_e(e.path,p)),[b,p]),A=(0,I.useCallback)(()=>{g(new Set((b??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[b]),N=X({count:k.length,getScrollElement:()=>O.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),F=k.length===0,L=(0,I.useMemo)(()=>(b??[]).filter(e=>e.kind===`file`).length,[b]);return(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Z.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>d(`touched-by-ai`),className:E(`px-2 py-1 rounded-md transition-colors`,u===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`touched-by-ai`,children:i(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>d(`all`),className:E(`px-2 py-1 rounded-md transition-colors`,u===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":u===`all`,children:i(`tree.allFiles`)}),(0,Z.jsx)(`div`,{className:`flex-1`}),(0,Z.jsx)(`button`,{type:`button`,onClick:A,title:i(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.collapseAll`),children:(0,Z.jsx)(m,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:y,title:i(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.expandAll`),children:(0,Z.jsx)(f,{className:`w-3.5 h-3.5`})})]}),u===`touched-by-ai`&&L>0&&(0,Z.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Z.jsx)(`span`,{children:i(`tree.touchedCount`,{count:L})})})]}),F&&ee?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:i(`tree.loadingFiles`)})}):F&&u===`touched-by-ai`?(0,Z.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`tree.emptyTouched`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>d(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:i(`tree.showAllFiles`)})]}):F?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:i(`tree.noFiles`)}):(0,Z.jsx)(`div`,{ref:O,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,Z.jsx)(`div`,{style:{height:N.getTotalSize(),position:`relative`,width:`100%`},children:N.getVirtualItems().map(n=>{let r=k[n.index],a=pe(r.path)*12,s=r.kind===`file`&&r.path===t,c=r.provenance?.createdByTicketId,l=r.provenance?.modifiedByTicketIds??[],u=r.provenance?.latest??null,d=he(u?.jobId),g=ge(u?.kind),_=r.kind===`dir`,y=_&&p.has(r.path),b=r.provenance?.touchedFileCount??0;return(0,Z.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:E(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{_?v(r.path):e(r.path)},onKeyDown:t=>{t.target===t.currentTarget&&(t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),_?v(r.path):e(r.path)))},role:`button`,tabIndex:0,"aria-expanded":_?!y:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,Z.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[_?(0,Z.jsxs)(Z.Fragment,{children:[y?(0,Z.jsx)(m,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Z.jsx)(f,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),y?(0,Z.jsx)(P,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Z.jsx)(M,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Z.jsx)(j,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Z.jsx)(`span`,{className:`truncate ml-0.5`,children:me(r.path)})]}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[_&&b>0&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:i(`tree.folderTouched`,{count:b}),children:b}),!_&&g&&(0,Z.jsx)(`span`,{className:E(`text-[10px] px-1.5 py-0.5 rounded`,u?.kind===`created`&&`bg-accent-success/15 text-accent-success`,u?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,u?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:u?.kind===`created`?i(`tree.latestTitleCreated`):u?.kind===`deleted`?i(`tree.latestTitleDeleted`):i(`tree.latestTitleModified`),children:i(`action.${g}`)}),!_&&d&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:i(`tree.jobTitle`,{jobId:u?.jobId??``}),children:[(0,Z.jsx)(h,{className:`h-3 w-3`}),d]}),!_&&typeof c==`number`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o(c)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${c}`,title:i(`tree.createdBySpec`,{id:c}),children:[`#`,c]}),!_&&l.slice(0,2).map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),o(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:i(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function ye(e){return new Worker(`/assets/editor.worker-tytyn86m.js`,{name:e?.name})}function be(e){return new Worker(`/assets/json.worker-Oa9UrkKE.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/css.worker-yKcq13f2.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/html.worker-DSJ9zmd7.js`,{name:e?.name})}function Ce(e){return new Worker(`/assets/ts.worker-BtjBFNHX.js`,{name:e?.name})}var we=!1;function Te(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=Te(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Ee(e){return`specrails-${e}`}function De(e,t){let n=Ee(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function Oe(){we||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new be;case`css`:case`scss`:case`less`:return new xe;case`html`:case`handlebars`:case`razor`:return new Se;case`typescript`:case`javascript`:return new Ce;default:return new ye}}},!0)}function ke({content:e,language:t,readOnly:n,onChange:r}){let{t:a}=s(`code`),o=N(),c=(0,I.useRef)(null),l=(0,I.useRef)(null),u=(0,I.useRef)(null),[d,f]=(0,I.useState)(!1),p=(0,I.useRef)(e),m=(0,I.useRef)(t),h=(0,I.useRef)(o),g=(0,I.useRef)(n),_=(0,I.useRef)(r);return(0,I.useEffect)(()=>{p.current=e},[e]),(0,I.useEffect)(()=>{m.current=t},[t]),(0,I.useEffect)(()=>{h.current=o},[o]),(0,I.useEffect)(()=>{g.current=n},[n]),(0,I.useEffect)(()=>{_.current=r},[r]),(0,I.useEffect)(()=>{let e=!1;return Oe(),i(()=>import(`./editor.main-DxrmGfoq.js`).then(t=>{if(e||!c.current)return;u.current=t;let n=De(t,h.current),r=t.editor.create(c.current,{value:p.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{_.current?.(r.getValue())}),l.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||f(!0)}),()=>{e=!0,l.current?.dispose?.(),l.current=null}},[]),(0,I.useEffect)(()=>{let t=l.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,I.useEffect)(()=>{l.current?.updateOptions?.({readOnly:n})},[n]),(0,I.useEffect)(()=>{let e=u.current,n=l.current;if(!e||!n)return;let r=n.getModel?.();r&&e.editor.setModelLanguage(r,t)},[t]),(0,I.useEffect)(()=>{let e=u.current;if(!e)return;let t=De(e,o);e.editor.setTheme(t)},[o]),d?(0,Z.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,Z.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,Z.jsx)(`div`,{ref:c,className:`w-full h-full`,"data-testid":`monaco-host`})}var Ae=(0,I.lazy)(async()=>({default:ke}));function je({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=s(`code`);return(0,Z.jsx)(I.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,Z.jsx)(Ae,{content:e,language:t,readOnly:n,onChange:r})})}function Me(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Ne({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:c}=s(`code`),{openTicketDetail:l}=_();if(!t)return(0,Z.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(d,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let u=Me(t.generatedAt,c.language),f=t.triggeredBy?.ticketId,p=t.triggeredBy?.modifiedTicketIds??[];return(0,Z.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Z.jsx)(`span`,{className:E(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,Z.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Z.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof f==`number`&&(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(f),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,f]}),p.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),u&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),a&&(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(d,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function Pe({content:e}){return(0,Z.jsx)(k,{remarkPlugins:[A],children:e})}var Fe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Ie(e){return e===`created`?g:e===`deleted`?v:y}function Le({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=s(`code`),{activeProjectId:a,projects:o}=T(),c=o.find(e=>e.id===a)?.provider,u=O(c),{registerHandler:d,unregisterHandler:f}=S(),[p,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(!1),[_,v]=(0,I.useState)({}),y=(0,I.useRef)(a);(0,I.useEffect)(()=>{y.current=a},[a]);let b=(0,I.useRef)(e);(0,I.useEffect)(()=>{b.current=e},[e]);let x=(0,I.useRef)(0),w=(0,I.useCallback)(async()=>{let t=++x.current;try{let n=await fetch(`${C()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==x.current)return;if(!n.ok){m([]),g(!0);return}let r=await n.json();if(t!==x.current)return;m(Array.isArray(r.story)?r.story:[]),g(!1)}catch{t===x.current&&(m([]),g(!0))}},[e,a]);(0,I.useEffect)(()=>{m(null),v({}),w()},[w]),(0,I.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return d(e,e=>{let t=e;t.projectId===y.current&&t.path===b.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&w()}),()=>f(e)},[a,d,f,w]);let E=(0,I.useCallback)(async(t,n)=>{if(u){v(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${C()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),a=await r.json().catch(()=>({}));if(a.skipped===`budget`){v(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){l.error(i(`story.explainFailed`)),v(e=>{let n={...e};return delete n[t.provenanceId],n});return}await w(),v(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{l.error(i(`story.explainFailed`)),v(e=>{let n={...e};return delete n[t.provenanceId],n})}}},[u,w,e,i]);return(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,Z.jsx)(`div`,{className:`h-full overflow-auto`,children:p===null?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):h?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):p.length===0?(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,Z.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:p.map(e=>(0,Z.jsx)(Re,{entry:e,state:_[e.provenanceId],canExplain:u,onOpenTicket:n,onFilterJob:r,onExplain:t=>{E(e,t)}},e.provenanceId))})})})}function Re({entry:e,state:t,canExplain:n,onOpenTicket:r,onFilterJob:i,onExplain:a}){let{t:o}=s(`code`),c=Ie(e.kind),l=e.ticket?.status??null,u=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:o(`story.spec`,{ticketId:e.ticketId}),d=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,Z.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,Z.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,Z.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Z.jsx)(c,{className:`h-3.5 w-3.5 shrink-0`}),o(`story.kindLabel.${e.kind}`)]}),u!=null&&e.ticketId!=null&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:o(`story.openSpec`,{ticketId:e.ticketId}),children:u}),u==null&&(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`story.unknownSpec`)}),l&&(0,Z.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Fe[l]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:l}),(0,Z.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:o(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,Z.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:o(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,Z.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,Z.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,Z.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:o(`story.explainedBy`,{model:e.summaryModel})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:o(`story.fallback.${d}`)}),n?t===`budget`?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:o(`story.budgetReached`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>a(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:o(`story.generateAnyway`)})]}):(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,Z.jsx)(b,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),o(t===`busy`?`story.explaining`:`story.explain`)]}):(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`story-explain-unavailable`,children:o(`story.explainUnavailable`)})]})}),e.jobId&&i&&(0,Z.jsx)(`footer`,{className:`mt-1.5`,children:(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:o(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function ze(e,t){return t===`markdown`||t===`md`||/\.(md|mdx|markdown)$/i.test(e)}var Be=180,Ve=120,He=240;function Ue(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function We(e){return e?`specrails-desktop:code-history-height:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ke(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function qe(e){let t=Ke(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function Je(e,t){let n=Ke(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Ye(e){let t=We(e);if(!t)return Be;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Be}catch{return Be}}function Xe(e,t){let n=We(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Ze(e){let t=Ue(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Qe(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function $e(e){let t=Ge(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function et(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function tt(e,t){let n=Math.max(Ve,t-He);return Math.min(Math.max(e,Ve),n)}function nt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:i}=s(`code`),{activeProjectId:a,projects:o}=T(),c=o.find(e=>e.id===a)?.provider,u=O(c),{openTicketDetail:p}=_(),{registerHandler:m,unregisterHandler:h}=S(),g=ee({allowMove:!1}),v=(0,I.useRef)(null),[y,b]=(0,I.useState)(null),[x,w]=(0,I.useState)(!0),[E,k]=(0,I.useState)(!1),[A,j]=(0,I.useState)(!1),[M,N]=(0,I.useState)(()=>Ze(a)),[P,F]=(0,I.useState)(()=>Ye(a)),[R,z]=(0,I.useState)(()=>$e(a)),[B,te]=(0,I.useState)(()=>qe(a)),ne=(0,I.useRef)(a);(0,I.useEffect)(()=>{ne.current=a},[a]);let V=(0,I.useRef)(e);(0,I.useEffect)(()=>{V.current=e},[e]),(0,I.useEffect)(()=>{let e=v.current?.clientHeight||window.innerHeight;N(Ze(a)),F(tt(Ye(a),e)),z($e(a)),te(qe(a))},[a]);let re=(0,I.useCallback)(e=>{let t=e.clientY,n=P,r=v.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function o(e){F(tt(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),F(e=>{let t=tt(e,r);return Xe(a,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[a,P]),ie=(0,I.useCallback)(()=>{let e=tt(Be,v.current?.clientHeight||window.innerHeight);F(e),Xe(a,e)},[a]),ae=(0,I.useCallback)(()=>{N(e=>{let t=!e;return Qe(a,t),t})},[a]),oe=(0,I.useCallback)(()=>{z(e=>{let t=!e;return et(a,t),t})},[a]),se=(0,I.useCallback)(e=>{te(e),Je(a,e)},[a]);(0,I.useEffect)(()=>{k(!1),j(!1),K(`preview`),J(!1)},[e]);let H=(0,I.useRef)(0),U=(0,I.useCallback)(async()=>{let t=++H.current;w(!0);try{let n=await fetch(`${C()}/code/file?path=${encodeURIComponent(e)}`);if(t!==H.current)return;if(!n.ok){b(null);return}let r=await n.json();if(t!==H.current)return;b(r)}catch{t===H.current&&b(null)}finally{t===H.current&&w(!1)}},[e,a]);(0,I.useEffect)(()=>{U()},[U]),(0,I.useEffect)(()=>{if(!a)return;let e=`code-file-${a}`;return m(e,e=>{let t=e;t.projectId===ne.current&&(t.type===`file.summary_updated`&&t.path===V.current?(k(!1),U()):t.type===`file.summary_failed`&&t.path===V.current?(l.error(t.reason??i(`summary.generationFailed`)),k(!1)):t.type===`file.summary_skipped`&&t.path===V.current&&(t.reason&&l(i(`summary.skipped`,{reason:t.reason})),k(!1)))}),()=>h(e)},[a,m,h,U,i]);let W=(0,I.useCallback)(async t=>{if(u){k(!0);try{let n=await fetch(`${C()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){k(!1);let e=typeof r.skipped==`string`?r.skipped:null;l.error(e?i(`summary.skipped`,{reason:e}):i(`summary.generationFailed`));return}if(r.skipped===`budget`){k(!1),j(!0);return}if(r.skipped){k(!1),l(i(`summary.skipped`,{reason:r.skipped}));return}await U(),k(!1)}catch{k(!1),l.error(i(`summary.generationFailed`))}}},[u,U,e,i]),ce=(0,I.useCallback)(async()=>{let t=y?.absolutePath??e;try{await navigator.clipboard?.writeText(t),l.success(i(`viewer.pathCopied`))}catch{l.error(i(`viewer.copyPathFailed`))}},[y,e,i]),le=(0,I.useMemo)(()=>ze(e,y?.language),[e,y?.language]),[G,K]=(0,I.useState)(`preview`),[q,J]=(0,I.useState)(!1),[Y,ue]=(0,I.useState)(``),[X,de]=(0,I.useState)(!1),fe=y?.content!==void 0&&!y.binary&&!y.tooLarge&&y.reason!==`not-found`,pe=(0,I.useCallback)(()=>{ue(y?.content??``),K(`raw`),J(!0)},[y]),me=(0,I.useCallback)(async()=>{de(!0);try{let t=await fetch(`${C()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:Y})});if(!t.ok){let e=await t.json().catch(()=>({}));l.error(e.error??i(`viewer.saveFailed`));return}l.success(i(`viewer.saved`)),J(!1),U()}catch{l.error(i(`viewer.saveFailed`))}finally{de(!1)}},[e,Y,i,U]),he=y?.summary??null,ge=!!y?.summaryStale,_e=y?.provenance??[],ve=y?.reason===`not-found`,ye=u?ve?i(`summary.reason.missing`):y?.binary?i(`summary.reason.binary`):y?.tooLarge?i(`summary.reason.tooLarge`):null:i(`summary.reason.providerNoPureOutput`);return(0,I.useEffect)(()=>{if(n){if(x&&!y){n(null);return}return n({hasSummary:!!he,regenerating:E,disabledReason:ye,onClick:()=>W(!1)}),()=>n(null)}},[y,W,x,n,E,he,ye]),(0,I.useEffect)(()=>{if(r){if(x&&!y){r(null);return}return r({onClick:ce}),()=>r(null)}},[ce,y,x,r]),x&&!y?(0,Z.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`viewer.loadingFile`)}):(0,Z.jsxs)(`div`,{ref:v,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[M?(0,Z.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,Z.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,Z.jsxs)(`button`,{type:`button`,onClick:ae,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(f,{className:`h-3.5 w-3.5`}),i(`viewer.showSummary`)]})]}):(0,Z.jsx)(Ne,{path:e,summary:he,stale:ge,regenerating:E,generateDisabledReason:ye,onCollapse:ae}),(0,Z.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:le&&y?.content!==void 0&&!y.binary&&!y.tooLarge&&(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":i(`viewer.markdownViewMode`),children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>K(`preview`),"aria-pressed":G===`preview`,className:G===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.preview`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>K(`raw`),"aria-pressed":G===`raw`,className:G===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.raw`)})]})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[fe&&!q&&(0,Z.jsx)(`button`,{type:`button`,onClick:pe,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:i(`viewer.edit`)}),q&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:X,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:i(`actions.cancel`,{ns:`common`})}),(0,Z.jsx)(`button`,{type:`button`,onClick:me,disabled:X,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:i(X?`viewer.saving`:`viewer.save`)})]})]})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:ve?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:i(`viewer.missingFile`)}):y?.binary?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:i(`viewer.binaryFile`)}):y?.tooLarge?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:i(`viewer.tooLarge`,{size:Math.round((y.sizeBytes??0)/1024/1024)})}):y?.content===void 0?(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:i(`viewer.noContent`)}):q?(0,Z.jsx)(je,{content:Y,language:y.language??`plaintext`,readOnly:!1,onChange:ue}):le&&G===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,Z.jsx)(Pe,{content:y.content})}):(0,Z.jsx)(je,{content:y.content,language:y.language??`plaintext`})}),_e.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":i(`history.resize`),onPointerDown:R?void 0:re,onDoubleClick:R?void 0:ie,className:R?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:R?void 0:i(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:i(B===`story`?`story.title`:`history.title`,{count:_e.length})}),(0,Z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!R&&(0,Z.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":i(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>se(`story`),"aria-pressed":B===`story`,className:B===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeStory`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>se(`log`),"aria-pressed":B===`log`,className:B===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:i(`story.modeLog`)})]}),(0,Z.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:oe,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[R?(0,Z.jsx)(d,{className:`h-3.5 w-3.5`}):(0,Z.jsx)(f,{className:`h-3.5 w-3.5`}),i(R?`history.show`:`history.hide`)]})]})]}),!R&&(B===`story`?(0,Z.jsx)(Le,{relPath:e,height:P,onOpenTicket:p,onFilterJob:t}):(0,Z.jsx)(rt,{rows:_e,onOpenTicket:p,onFilterJob:t,height:P}))]}),A&&(0,L.createPortal)((0,Z.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:g.guardBackdrop(()=>j(!1)),children:[(0,Z.jsxs)(`div`,{ref:g.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:g.panelStyle,children:[(0,Z.jsx)(`p`,{className:`text-sm text-foreground`,children:i(`viewer.budgetPrompt`)}),(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>j(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:i(`common:actions.cancel`)}),(0,Z.jsx)(`button`,{type:`button`,onClick:()=>{j(!1),W(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:i(`common:actions.confirm`)})]})]}),(0,Z.jsx)(D,{handles:g.resizeHandles})]}),document.body)]})}function rt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=s(`code`),[a,o]=(0,I.useState)(null),[c,l]=(0,I.useState)({});if(e.length===0)return null;async function u(e,t){if(a===t){o(null);return}if(o(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${C()}/code/diff?${n.toString()}`);if(r.status===404){l(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();l(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{l(e=>({...e,[t]:`missing`}))}}}return(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,Z.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?g:e.kind===`deleted`?v:y,s=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),l=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,d=c[l];return(0,Z.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Z.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,Z.jsx)(h,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,Z.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:s}):(0,Z.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:s}),e.jobId&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>u(e,l),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:i(`history.diff`)}),typeof e.ticketId==`number`&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`history.specChip`,{ticketId:e.ticketId})})]}),(0,Z.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===l&&(0,Z.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,Z.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):d===`missing`||!d?(0,Z.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,Z.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[d.patch,d.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},l)})})})}var it=320,at=240,ot=520;function st(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function ct(e){let t=st(e);if(!t)return it;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:it}catch{return it}}function lt(e,t){let n=st(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(at,t-ot);return Math.min(Math.max(e,at),n)}function ut({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=s(`code`),{activeProjectId:i}=T(),[c]=a(),l=o(),u=(0,I.useRef)(null),[d,f]=(0,I.useState)(e?t:c.get(`path`)),p=(0,I.useCallback)(e=>{f(e),n?.(e)},[n]),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(()=>ct(i)),[b,x]=(0,I.useState)(null),[S,C]=(0,I.useState)(null),w=e?b:c.get(`jobId`),E=(0,I.useMemo)(()=>{if(e)return S;let t=c.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,c]),[ee,D]=(0,I.useState)(E==null?``:String(E));(0,I.useEffect)(()=>{if(e)return;let t=c.get(`path`);t!==d&&f(t)},[c,e]),(0,I.useEffect)(()=>{D(E==null?``:String(E))},[E]),(0,I.useEffect)(()=>{let e=u.current?.clientWidth||window.innerWidth;y($(ct(i),e))},[i]),(0,I.useEffect)(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&y(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,I.useCallback)(e=>{let t=e.clientX,n=v,r=u.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){y($(n+(e.clientX-t),r))}function s(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),y(e=>{let t=$(e,r);return lt(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[i,v]),k=(0,I.useCallback)(()=>{let e=$(it,u.current?.clientWidth||window.innerWidth);y(e),lt(i,e)},[i]),A=(0,I.useCallback)(t=>{if(p(t),e)return;let n=new URLSearchParams(c);n.set(`path`,t),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,c,p]),j=(0,I.useCallback)(t=>{if(e){x(t),C(null);return}let n=new URLSearchParams(c);n.set(`jobId`,t),n.delete(`ticketId`),l({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,l,c]),M=(0,I.useCallback)(()=>{if(e){x(null),C(null);return}let t=new URLSearchParams(c);t.delete(`jobId`),t.delete(`ticketId`),l({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,l,c]),N=(0,I.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){M();return}if(e){C(n),x(null);return}let r=new URLSearchParams(c);r.set(`ticketId`,String(n)),r.delete(`jobId`),l({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[M,e,l,c]);return(0,Z.jsxs)(`div`,{ref:u,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,Z.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,Z.jsx)(ve,{onOpenFile:A,selectedPath:d,filterJobId:w,filterTicketId:E},i??`no-project`)}),(0,Z.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,Z.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,Z.jsx)(dt,{jobId:w,ticketId:E,ticketInput:ee,onTicketInputChange:D,onApplyTicket:N,onClear:M,summaryAction:m,copyPathAction:g}),(w||E)&&(0,Z.jsx)(ft,{jobId:w,ticketId:E,onOpenFile:A}),d?(0,Z.jsx)(nt,{relPath:d,onFilterJob:j,onSummaryActionChange:h,onCopyPathActionChange:_}):(0,Z.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function dt({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:c}){let{t:l}=s(`code`),d=t?`spec`:e?`job-context`:`all`;return(0,Z.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Z.jsx)(F,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,Z.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":d===`all`,className:d===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.allAi`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":d===`spec`,className:d===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.spec`)}),(0,Z.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:l(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,Z.jsx)(`div`,{className:`flex-1`}),c&&(0,Z.jsx)(`button`,{type:`button`,onClick:c.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.copyFilePath`)}),o&&(0,Z.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?l(`toolbar.regenerateSummary`):l(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:o.disabledReason?l(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,Z.jsx)(u,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?l(`toolbar.regenerating`):l(`toolbar.regenerateSummary`):o.regenerating?l(`toolbar.generating`):l(`toolbar.generateSummary`)]}),d===`job-context`&&(0,Z.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:l(`toolbar.jobContext`)}),(e||t)&&(0,Z.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(x,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function ft({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=s(`code`),[i,a]=(0,I.useState)(null);(0,I.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${C()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,I.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),c=i?.length??0;return(0,Z.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:c})})]}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsx)(pt,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,Z.jsx)(pt,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,Z.jsx)(pt,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,Z.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,Z.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Z.jsx)(p,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function pt({label:e,rows:t,icon:n,onOpenFile:r}){return(0,Z.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,Z.jsx)(n===`created`?g:n===`deleted`?v:y,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,Z.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,Z.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{ut as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{a as r}from"./i18n-Ch-Db_x2.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o}from"./useSharedWebSocket-DaPh7QBL.js";import{t as s}from"./clsx-CjueKrWZ.js";import{t as c}from"./utils-BC4DHlz2.js";import{b as l,lt as u,x as d}from"./index-kCUcnT8G.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-nBOMNfiy.js";var Se=a(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(t());function W(){return W=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},W.apply(null,arguments)}var G=e=>{var{cx:t,cy:n,r,className:i}=e,a=s(`recharts-dot`,i);return j(t)&&j(n)&&j(r)?U.createElement(`circle`,W({},ce(e),N(e),{className:a,cx:t,cy:n,r})):null},Ce=[`points`];function K(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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)}function J(){return J=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},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(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 Oe(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 ke(e){var{option:t,dotProps:n,className:r}=e;if((0,U.isValidElement)(t))return(0,U.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=s(r,typeof t==`boolean`?``:t.className),a=n??{},{points:o}=a,c=De(a,Ce);return U.createElement(G,J({},c,{className:i}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(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 Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(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 Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];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 Xe(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(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)}function Q(e,t){if(e==null)return{};var n,r,i=et(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 et(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}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=s(`recharts-line`,r),g=d,{r:_,strokeWidth:v}=Ke(t),y=H(t),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:i,yAxisId:a}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:o-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:a}=i(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function l(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:c(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:a(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":a(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":a(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=i(`analytics`),r=e.estimatedCostUsd??0,a=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=a>0,l=typeof e.pricedRuns==`number`||typeof e.unpricedRuns==`number`,u=e.unpricedRuns??0,d=e.pricedRuns??(l?Math.max(0,e.totalJobs-u):e.totalJobs),f=l&&e.totalCostUsd===0&&u>0&&d===0,p=u>0&&(d>0||e.totalCostUsd>0),m=e.unpricedTodayRuns??0,h=e.pricedTodayRuns??(l?Math.max(0,e.jobsToday-m):e.jobsToday),g=l&&e.costToday===0&&m>0&&h===0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:f?`—`:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:g?n(`desktop.costTodayUnavailable`):n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0&&u===0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(u>0?`desktop.averageUnavailable`:`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})}),(f||p)&&(0,$.jsx)(`p`,{"data-testid":`kpi-cost-coverage-note`,className:`text-[10px] text-muted-foreground/70 italic`,children:f?n(`desktop.costUnavailable`):n(`desktop.costPartiallyUnavailable`,{count:u})})]})}function wt({data:e}){let{t}=i(`analytics`),n=l(),a=e.length>0&&e.some(e=>e.costUsd>0),o=e.reduce((e,t)=>e+(t.unpricedCount??0),0),s=!a&&o>0,c=a&&o>0,u=Math.max(1,Math.floor(e.length/7)),f=e.filter((e,t)=>t%u===0).map(e=>e.date),p=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),m=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),m&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)}),c&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,children:t(`desktop.costPartiallyUnavailable`,{count:o})})]}),s?(0,$.jsx)(`div`,{"data-testid":`desktop-timeline-cost-unavailable`,className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):a?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:f,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:r()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(p.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=i(`analytics`),n=l();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0,s=e.unpricedRuns??0,c=e.pricedRuns??Math.max(0,e.totalJobs-s),l=s>0&&c===0,u=s>0&&c>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,title:u?t(`desktop.costPartiallyUnavailable`,{count:s}):void 0,children:l?t(`desktop.costUnavailableShort`):`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=i(`analytics`),n=l();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd})),a=e.some(e=>e.totalCostUsd>0),o=e.some(e=>(e.unpricedRuns??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),!a&&o?(0,$.jsx)(`div`,{"data-testid":`desktop-project-cost-unavailable`,className:`h-[180px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=i(`analytics`),[t,n]=(0,U.useState)(`7d`),[r,a]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[l,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=o(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();d(a)}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&a(t),r!==void 0&&c(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),l&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(u,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!l&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),l&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:l.kpi,windowLabel:t===`custom`?l.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:l.costTimeline}),(0,$.jsx)(Et,{projects:l.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:l.projectBreakdown})]})]})})}export{Dt as default};
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{a as r}from"./i18n-nJQvD5zJ.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{r as o}from"./useSharedWebSocket-DK96ctb7.js";import{t as s}from"./clsx-CjueKrWZ.js";import{t as c}from"./utils-BC4DHlz2.js";import{b as l,st as u,y as d}from"./index-C_sdsSZt.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-nBOMNfiy.js";var Se=a(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(t());function W(){return W=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},W.apply(null,arguments)}var G=e=>{var{cx:t,cy:n,r,className:i}=e,a=s(`recharts-dot`,i);return j(t)&&j(n)&&j(r)?U.createElement(`circle`,W({},ce(e),N(e),{className:a,cx:t,cy:n,r})):null},Ce=[`points`];function K(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(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)}function J(){return J=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},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(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 Oe(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 ke(e){var{option:t,dotProps:n,className:r}=e;if((0,U.isValidElement)(t))return(0,U.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=s(r,typeof t==`boolean`?``:t.className),a=n??{},{points:o}=a,c=De(a,Ce);return U.createElement(G,J({},c,{className:i}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(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 Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(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 Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];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 Xe(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 Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(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)}function Q(e,t){if(e==null)return{};var n,r,i=et(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 et(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}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=s(`recharts-line`,r),g=d,{r:_,strokeWidth:v}=Ke(t),y=H(t),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:i,yAxisId:a}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:o-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=n(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:a}=i(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function l(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:c(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:a(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":a(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":a(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=i(`analytics`),r=e.estimatedCostUsd??0,a=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=a>0,l=typeof e.pricedRuns==`number`||typeof e.unpricedRuns==`number`,u=e.unpricedRuns??0,d=e.pricedRuns??(l?Math.max(0,e.totalJobs-u):e.totalJobs),f=l&&e.totalCostUsd===0&&u>0&&d===0,p=u>0&&(d>0||e.totalCostUsd>0),m=e.unpricedTodayRuns??0,h=e.pricedTodayRuns??(l?Math.max(0,e.jobsToday-m):e.jobsToday),g=l&&e.costToday===0&&m>0&&h===0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:f?`—`:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:g?n(`desktop.costTodayUnavailable`):n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0&&u===0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(u>0?`desktop.averageUnavailable`:`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})}),(f||p)&&(0,$.jsx)(`p`,{"data-testid":`kpi-cost-coverage-note`,className:`text-[10px] text-muted-foreground/70 italic`,children:f?n(`desktop.costUnavailable`):n(`desktop.costPartiallyUnavailable`,{count:u})})]})}function wt({data:e}){let{t}=i(`analytics`),n=d(),a=e.length>0&&e.some(e=>e.costUsd>0),o=e.reduce((e,t)=>e+(t.unpricedCount??0),0),s=!a&&o>0,c=a&&o>0,u=Math.max(1,Math.floor(e.length/7)),f=e.filter((e,t)=>t%u===0).map(e=>e.date),p=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),m=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),m&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)}),c&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,children:t(`desktop.costPartiallyUnavailable`,{count:o})})]}),s?(0,$.jsx)(`div`,{"data-testid":`desktop-timeline-cost-unavailable`,className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):a?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:f,tickFormatter:e=>{try{return l(new Date(e),`MMM d`,{locale:r()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(p.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=i(`analytics`),n=d();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0,s=e.unpricedRuns??0,c=e.pricedRuns??Math.max(0,e.totalJobs-s),l=s>0&&c===0,u=s>0&&c>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,title:u?t(`desktop.costPartiallyUnavailable`,{count:s}):void 0,children:l?t(`desktop.costUnavailableShort`):`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=i(`analytics`),n=d();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd})),a=e.some(e=>e.totalCostUsd>0),o=e.some(e=>(e.unpricedRuns??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),!a&&o?(0,$.jsx)(`div`,{"data-testid":`desktop-project-cost-unavailable`,className:`h-[180px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=i(`analytics`),[t,n]=(0,U.useState)(`7d`),[r,a]=(0,U.useState)(``),[s,c]=(0,U.useState)(``),[l,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=o(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();d(a)}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&a(t),r!==void 0&&c(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),l&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:l.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(u,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!l&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),l&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:l.kpi,windowLabel:t===`custom`?l.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:l.costTimeline}),(0,$.jsx)(Et,{projects:l.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:l.projectBreakdown})]})]})})}export{Dt as default};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r}from"./createLucideIcon-Bjbbp_KS.js";import{t as i}from"./chevron-right-CViMxucY.js";import{t as a}from"./file-text-CFT-xXKN.js";import{t as o}from"./loader-circle-DcygOQpC.js";import{t as s}from"./utils-BC4DHlz2.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{n as p,t as m}from"./lib-CGdyxIWg.js";import{Nt as h}from"./index-kCUcnT8G.js";import{t as g}from"./lib-C7Mhm-gT.js";import{t as _}from"./atom-one-dark-qiGhVQxg.js";var v=e(t(),1),y=n();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:i,onHome:o}){let{t:c}=r(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:o,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:c(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:c(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let o=t===e.slug&&n===r.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,r.slug),title:r.title,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=r(`integrations`),o=e.reduce((e,t)=>e+t.docs.length,0),s=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:o}),categories:n(`docs.categoryCount`,{count:s})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(i,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(p,{remarkPlugins:[m],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:i,onNavigate:a,scrollContainerRef:s}){let{t:c}=r(`integrations`),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let r=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r===p.current&&e&&(u(e),s.current&&(s.current.scrollTop=0))}).catch(e=>{r===p.current&&f(e instanceof Error?e.message:c(`docs.loadError`))})},[e,t,n,i,s]),!l&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(o,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!l?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):l?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r}from"./createLucideIcon-Bjbbp_KS.js";import{t as i}from"./chevron-right-CViMxucY.js";import{t as a}from"./file-text-CFT-xXKN.js";import{t as o}from"./loader-circle-DcygOQpC.js";import{t as s}from"./utils-BC4DHlz2.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{n as p,t as m}from"./lib-CGdyxIWg.js";import{Mt as h}from"./index-C_sdsSZt.js";import{t as g}from"./lib-C7Mhm-gT.js";import{t as _}from"./atom-one-dark-qiGhVQxg.js";var v=e(t(),1),y=n();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:i,onHome:o}){let{t:c}=r(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:o,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:c(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:c(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let o=t===e.slug&&n===r.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,r.slug),title:r.title,className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=r(`integrations`),o=e.reduce((e,t)=>e+t.docs.length,0),s=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:o}),categories:n(`docs.categoryCount`,{count:s})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(i,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(p,{remarkPlugins:[m],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:i,onNavigate:a,scrollContainerRef:s}){let{t:c}=r(`integrations`),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let r=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r===p.current&&e&&(u(e),s.current&&(s.current.scrollTop=0))}).catch(e=>{r===p.current&&f(e instanceof Error?e.message:c(`docs.loadError`))})},[e,t,n,i,s]),!l&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(o,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!l?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):l?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./chevron-right-CViMxucY.js";import{t as c}from"./file-text-CFT-xXKN.js";import{t as l}from"./loader-circle-DcygOQpC.js";import{t as u}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-CGdyxIWg.js";import{Nt as p}from"./index-kCUcnT8G.js";import{t as m}from"./lib-C7Mhm-gT.js";import{t as h}from"./atom-one-dark-qiGhVQxg.js";var g=e(t(),1),_=n();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:r}=o(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(i,{to:`/docs`,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:r(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let a=t===e.slug&&n===r.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${r.slug}`,title:r.title,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=o(`integrations`),n=e.reduce((e,t)=>e+t.docs.length,0),r=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(p,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:n}),categories:t(`docs.categoryCount`,{count:r})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(s,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,_.jsx)(d,{remarkPlugins:[f],rehypePlugins:[m],components:{a({href:e,children:r,...i}){return(0,_.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=h(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:i}){let{t:a}=o(`integrations`),[s,c]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=r();return(0,g.useEffect)(()=>{let r=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r===f.current&&e&&(c(e),i.current&&(i.current.scrollTop=0))}).catch(e=>{r===f.current&&d(e instanceof Error?e.message:a(`docs.loadError`))})},[e,t,n,p,i]),!s&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):s?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,n as i,u as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./chevron-right-CViMxucY.js";import{t as c}from"./file-text-CFT-xXKN.js";import{t as l}from"./loader-circle-DcygOQpC.js";import{t as u}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-CGdyxIWg.js";import{Mt as p}from"./index-C_sdsSZt.js";import{t as m}from"./lib-C7Mhm-gT.js";import{t as h}from"./atom-one-dark-qiGhVQxg.js";var g=e(t(),1),_=n();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:r}=o(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(i,{to:`/docs`,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:r(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let a=t===e.slug&&n===r.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${r.slug}`,title:r.title,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=o(`integrations`),n=e.reduce((e,t)=>e+t.docs.length,0),r=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(p,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:n}),categories:t(`docs.categoryCount`,{count:r})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(s,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,_.jsx)(d,{remarkPlugins:[f],rehypePlugins:[m],components:{a({href:e,children:r,...i}){return(0,_.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=h(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:i}){let{t:a}=o(`integrations`),[s,c]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=r();return(0,g.useEffect)(()=>{let r=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r===f.current&&e&&(c(e),i.current&&(i.current.scrollTop=0))}).catch(e=>{r===f.current&&d(e instanceof Error?e.message:a(`docs.loadError`))})},[e,t,n,p,i]),!s&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):s?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline