specrails-desktop 2.19.0 → 2.20.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 (252) hide show
  1. package/client/dist/assets/ActivityFeedPage-BgLjSsDn.js +1 -0
  2. package/client/dist/assets/AgentBrowserCapture-R87DoreG.js +1 -0
  3. package/client/dist/assets/AgentModeCodePane-CO8F0ttc.js +2 -0
  4. package/client/dist/assets/AgentModeJobsPane-BecN3lwS.js +1 -0
  5. package/client/dist/assets/AgentsPage-_-Q9plMs.js +86 -0
  6. package/client/dist/assets/AnalyticsPage-Cqh5IGaF.js +1 -0
  7. package/client/dist/assets/{BarChart-HPiao--v.js → BarChart-DZlxRF5i.js} +1 -1
  8. package/client/dist/assets/CodePage-4eiDoOBX.js +2 -0
  9. package/client/dist/assets/{DesktopAnalyticsPage-B2RBxIvj.js → DesktopAnalyticsPage-DyiCeq0h.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-BJDvUEGj.js → DocsDialog-CDZv0FMK.js} +2 -2
  11. package/client/dist/assets/DocsPage-BmwaXyUf.js +11 -0
  12. package/client/dist/assets/{ExportDropdown-CYMcbLTD.js → ExportDropdown-CWafyruY.js} +1 -1
  13. package/client/dist/assets/IntegrationsPage-CY2jfpeW.js +3 -0
  14. package/client/dist/assets/JobDetailPage-p0lsbXRg.js +1 -0
  15. package/client/dist/assets/JobsPage-GeKC3ckC.js +1 -0
  16. package/client/dist/assets/LogViewer-Cz7jzyU2.js +16 -0
  17. package/client/dist/assets/LoopBuilderPage-C_vv7AW2.js +7 -0
  18. package/client/dist/assets/LoopsPage-CettzySP.js +1 -0
  19. package/client/dist/assets/ProjectSettingsDialog-Xw30FTul.js +1 -0
  20. package/client/dist/assets/agent-B7GdHP3Z.js +1 -0
  21. package/client/dist/assets/agent-BHmcgoJf.js +1 -0
  22. package/client/dist/assets/agent-BdY_fii4.js +1 -0
  23. package/client/dist/assets/agent-C32FOi9v.js +1 -0
  24. package/client/dist/assets/agent-CiFQxoaZ2.js +1 -0
  25. package/client/dist/assets/agent-CtAag7V6.js +1 -0
  26. package/client/dist/assets/agent-DE4Mp1fY2.js +1 -0
  27. package/client/dist/assets/agent-DK8qovyG2.js +1 -0
  28. package/client/dist/assets/{dist-js-ClEfL6Bo.js → dist-js-DoZ1SVEs.js} +1 -1
  29. package/client/dist/assets/{dist-js-b2_z7zAi.js → dist-js-zlcAXgob.js} +1 -1
  30. package/client/dist/assets/index-5mbwBNQ-.css +2 -0
  31. package/client/dist/assets/index-CG4z4_Mq.js +152 -0
  32. package/client/dist/assets/{lib-CfphudAm.js → lib-zJbG81CY.js} +2 -2
  33. package/client/dist/assets/nav-BAsYcqdw2.js +1 -0
  34. package/client/dist/assets/nav-BRrNlZkr.js +1 -0
  35. package/client/dist/assets/nav-Bqhyfbcj2.js +1 -0
  36. package/client/dist/assets/nav-CQb9y1km.js +1 -0
  37. package/client/dist/assets/nav-Cibp2KWF.js +1 -0
  38. package/client/dist/assets/nav-CzKzuwH8.js +1 -0
  39. package/client/dist/assets/nav-Danf5sRf2.js +1 -0
  40. package/client/dist/assets/nav-DtTnF9xd.js +1 -0
  41. package/client/dist/assets/{settings-DmyDpuzu.js → settings-BPq9nCJm.js} +1 -1
  42. package/client/dist/assets/{settings-DaXhxNug2.js → settings-BWHGtmU12.js} +1 -1
  43. package/client/dist/assets/{settings-MjYVJvDE.js → settings-C-m3yEZ2.js} +1 -1
  44. package/client/dist/assets/settings-CY8udi0e.js +1 -0
  45. package/client/dist/assets/{settings-CfOWHPzc2.js → settings-DZj7Uqy32.js} +1 -1
  46. package/client/dist/assets/{settings-CX29QcQW.js → settings-VgCsjaYf.js} +1 -1
  47. package/client/dist/assets/{settings-DwPRLcxr2.js → settings-r8Qq2Gzp2.js} +1 -1
  48. package/client/dist/assets/{settings-BOZBX-Vq.js → settings-zZr7NzuB.js} +1 -1
  49. package/client/dist/assets/{upload-Ox9jUq1X.js → upload-Cm4KWhcE.js} +1 -1
  50. package/client/dist/assets/{value-BeQVX5gN.js → value-m3Q84dDF.js} +1 -1
  51. package/client/dist/index.html +5 -5
  52. package/package.json +1 -1
  53. package/server/dist/agent-chat-manager.js +117 -13
  54. package/server/dist/agent-chat-router.js +7 -2
  55. package/server/dist/agent-operator-prompt.js +4 -2
  56. package/server/dist/file-provenance.js +9 -6
  57. package/server/dist/project-git.js +147 -0
  58. package/server/dist/project-router-git.js +43 -0
  59. package/server/dist/project-router.js +2 -0
  60. package/client/dist/assets/ActivityFeedPage-C0_k6n5T.js +0 -1
  61. package/client/dist/assets/AgentBrowserCapture-NHUCEnTh.js +0 -1
  62. package/client/dist/assets/AgentModeCodePane-jddXrhPY.js +0 -2
  63. package/client/dist/assets/AgentsPage-BPjf6bId.js +0 -86
  64. package/client/dist/assets/AnalyticsPage-BaJjj5mO.js +0 -1
  65. package/client/dist/assets/CodePage-CAD4KfkC.js +0 -2
  66. package/client/dist/assets/DocsPage-B6H-DBs8.js +0 -11
  67. package/client/dist/assets/IntegrationsPage-Dx_UpQVk.js +0 -3
  68. package/client/dist/assets/JobDetailPage-BlTnsRAN.js +0 -16
  69. package/client/dist/assets/JobsPage-EB0PbXOk.js +0 -1
  70. package/client/dist/assets/LoopBuilderPage-DfWfhhJY.js +0 -7
  71. package/client/dist/assets/LoopsPage-DCVATTv5.js +0 -1
  72. package/client/dist/assets/agent-B5Ycau5M.js +0 -1
  73. package/client/dist/assets/agent-BEz08l4_2.js +0 -1
  74. package/client/dist/assets/agent-BIX51CEA.js +0 -1
  75. package/client/dist/assets/agent-Bc9Kwf65.js +0 -1
  76. package/client/dist/assets/agent-BiM7puyn.js +0 -1
  77. package/client/dist/assets/agent-C0kYSv3m2.js +0 -1
  78. package/client/dist/assets/agent-CCzWlfqs.js +0 -1
  79. package/client/dist/assets/agent-DiCSo31C.js +0 -1
  80. package/client/dist/assets/index-9yNUBwEi.css +0 -2
  81. package/client/dist/assets/index-BeujshsU.js +0 -152
  82. package/client/dist/assets/nav--1ErXZrS.js +0 -1
  83. package/client/dist/assets/nav-18nqSJ8h.js +0 -1
  84. package/client/dist/assets/nav-BuonHb17.js +0 -1
  85. package/client/dist/assets/nav-C-sCoOLY2.js +0 -1
  86. package/client/dist/assets/nav-ClXz_3Ic2.js +0 -1
  87. package/client/dist/assets/nav-CtqgSQeE2.js +0 -1
  88. package/client/dist/assets/nav-S3YvCaVv.js +0 -1
  89. package/client/dist/assets/nav-czg8NkN-.js +0 -1
  90. package/client/dist/assets/settings-zJFdTzKE.js +0 -1
  91. /package/client/dist/assets/{activity-C5SeKbom.js → activity-B_71BWg3.js} +0 -0
  92. /package/client/dist/assets/{activity-DLdwUYv7.js → activity-BpTTj_PH.js} +0 -0
  93. /package/client/dist/assets/{activity-BlvN5rhP.js → activity-Ch-wbr0C2.js} +0 -0
  94. /package/client/dist/assets/{activity-DVuiy8TI2.js → activity-D0rfjQzT2.js} +0 -0
  95. /package/client/dist/assets/{activity-DIJexk6v2.js → activity-D2e62vbV2.js} +0 -0
  96. /package/client/dist/assets/{activity-Dsf3J7iW.js → activity-DHv2V5Oi.js} +0 -0
  97. /package/client/dist/assets/{activity-DOKV_Wyf.js → activity-DemHQS7l.js} +0 -0
  98. /package/client/dist/assets/{addspec-CXfEOrD42.js → addspec-B6Ns8KU02.js} +0 -0
  99. /package/client/dist/assets/{addspec-D28kw9ow2.js → addspec-CrEm6Fzr2.js} +0 -0
  100. /package/client/dist/assets/{addspec-BXV6sx5l.js → addspec-D6L4ZteP.js} +0 -0
  101. /package/client/dist/assets/{addspec-DC1tgsFG.js → addspec-Dio-H5z0.js} +0 -0
  102. /package/client/dist/assets/{addspec-DcHALPEp.js → addspec-l_zU5gla.js} +0 -0
  103. /package/client/dist/assets/{addspec-CS895X6A.js → addspec-qGyH7MHy2.js} +0 -0
  104. /package/client/dist/assets/{addspec-D39EEg02.js → addspec-xwRX_Pnf.js} +0 -0
  105. /package/client/dist/assets/{agents-CsDEv4Fj.js → agents-CHgCudUV.js} +0 -0
  106. /package/client/dist/assets/{agents-z0kA-y0Q.js → agents-CnaPeSyw.js} +0 -0
  107. /package/client/dist/assets/{agents-BXDCFJQa.js → agents-DuhLEaQ_.js} +0 -0
  108. /package/client/dist/assets/{agents-BFrHy5d-2.js → agents-Dumx4JiM2.js} +0 -0
  109. /package/client/dist/assets/{agents-BFy2Kq_k2.js → agents-OzxCLVW1.js} +0 -0
  110. /package/client/dist/assets/{agents-CTdwacTO.js → agents-Xh-zYHUx2.js} +0 -0
  111. /package/client/dist/assets/{agents-BySH0Gvw.js → agents-hv3sqmPm2.js} +0 -0
  112. /package/client/dist/assets/{agentstudio-CSZo7p8K.js → agentstudio-BIxikDf_.js} +0 -0
  113. /package/client/dist/assets/{agentstudio-B8H2H4Db2.js → agentstudio-Bo91kfUd2.js} +0 -0
  114. /package/client/dist/assets/{agentstudio-B9zthaTJ.js → agentstudio-Bz8cP8_c.js} +0 -0
  115. /package/client/dist/assets/{agentstudio-BDMpU01s.js → agentstudio-CCthUdzR.js} +0 -0
  116. /package/client/dist/assets/{agentstudio-CdD6J23W.js → agentstudio-CcH8Ckql2.js} +0 -0
  117. /package/client/dist/assets/{agentstudio-D80fZu_M2.js → agentstudio-DARgYg5Z2.js} +0 -0
  118. /package/client/dist/assets/{agentstudio-EuKglkaF2.js → agentstudio-VJOa_NVO.js} +0 -0
  119. /package/client/dist/assets/{aiedit-B_VOTUo42.js → aiedit-5ZXN4cep2.js} +0 -0
  120. /package/client/dist/assets/{aiedit-DX3BBpXF.js → aiedit-7B2dvCv-.js} +0 -0
  121. /package/client/dist/assets/{aiedit-TON-4N9S.js → aiedit-B7gAJZVC.js} +0 -0
  122. /package/client/dist/assets/{aiedit-ybQmdsST.js → aiedit-D92V-kUW.js} +0 -0
  123. /package/client/dist/assets/{aiedit-D59sPapq2.js → aiedit-D9ualLVJ.js} +0 -0
  124. /package/client/dist/assets/{aiedit-Cxoe_0wv.js → aiedit-h48tJU0V2.js} +0 -0
  125. /package/client/dist/assets/{aiedit-GYOYWCHJ2.js → aiedit-xkA_mR2a2.js} +0 -0
  126. /package/client/dist/assets/{analytics-DGOoMkaZ.js → analytics-BBAfeB1o.js} +0 -0
  127. /package/client/dist/assets/{analytics-B2jjXLCP2.js → analytics-BM1R5CEp2.js} +0 -0
  128. /package/client/dist/assets/{analytics-BotqRU_R.js → analytics-BjLruoYS.js} +0 -0
  129. /package/client/dist/assets/{analytics-CqMJQb7N.js → analytics-CKwh2zUr.js} +0 -0
  130. /package/client/dist/assets/{analytics-DL7uwNAI2.js → analytics-CpcjUkV72.js} +0 -0
  131. /package/client/dist/assets/{analytics-Ck3vl2Qo2.js → analytics-DbXHdSlk2.js} +0 -0
  132. /package/client/dist/assets/{analytics-BTkXLTfa.js → analytics-Djzr1xUQ.js} +0 -0
  133. /package/client/dist/assets/{attachments-7w-BR2V2.js → attachments-Bnbyj2PN.js} +0 -0
  134. /package/client/dist/assets/{attachments-D0fGlFve.js → attachments-C-gyrCOb.js} +0 -0
  135. /package/client/dist/assets/{attachments-Cbh4AwjP.js → attachments-C11tOKZ_.js} +0 -0
  136. /package/client/dist/assets/{attachments-BcE7kZG-2.js → attachments-CIeLa8l12.js} +0 -0
  137. /package/client/dist/assets/{attachments-B5QX1Xfa2.js → attachments-Cxrs0pyL2.js} +0 -0
  138. /package/client/dist/assets/{attachments-BsJJXFzT.js → attachments-DslHfa-L.js} +0 -0
  139. /package/client/dist/assets/{attachments-D3DJpd3e2.js → attachments-TTPsc0a52.js} +0 -0
  140. /package/client/dist/assets/{browser-CmWGMRGf2.js → browser-BKP6hqQC2.js} +0 -0
  141. /package/client/dist/assets/{browser-CaV3BJNY2.js → browser-BTivfZKE2.js} +0 -0
  142. /package/client/dist/assets/{browser-BOxg0p3n.js → browser-DEEO-OSi.js} +0 -0
  143. /package/client/dist/assets/{browser-D6wbpBOL2.js → browser-DlKLfT612.js} +0 -0
  144. /package/client/dist/assets/{browser-dsgDU1HB.js → browser-DlSXtfu5.js} +0 -0
  145. /package/client/dist/assets/{browser-BSh8xUWV.js → browser-INCUyduh.js} +0 -0
  146. /package/client/dist/assets/{browser-9GR11iTi.js → browser-bpO3onlS.js} +0 -0
  147. /package/client/dist/assets/{chat-CYHUUW0p2.js → chat-5mdg_YIc2.js} +0 -0
  148. /package/client/dist/assets/{chat-CAo0jCnj2.js → chat-BGax2nV62.js} +0 -0
  149. /package/client/dist/assets/{chat-DhpcWjOf.js → chat-BpYxnkr4.js} +0 -0
  150. /package/client/dist/assets/{chat-cFG-UfRA2.js → chat-BvHrebKC2.js} +0 -0
  151. /package/client/dist/assets/{chat-B90iLDI4.js → chat-CZyiLJvQ.js} +0 -0
  152. /package/client/dist/assets/{chat-CW54IP3u.js → chat-DKYP7NnC.js} +0 -0
  153. /package/client/dist/assets/{chat-D1PXX_p2.js → chat-wkTIy9rX.js} +0 -0
  154. /package/client/dist/assets/{code-B5UrmjaE2.js → code-BFxE1Yt62.js} +0 -0
  155. /package/client/dist/assets/{code-B1aOMCVV.js → code-BefYOm5Q.js} +0 -0
  156. /package/client/dist/assets/{code-DZKjfzBN.js → code-BkXpJt99.js} +0 -0
  157. /package/client/dist/assets/{code-CjBHU0nw.js → code-C6Sq7_t8.js} +0 -0
  158. /package/client/dist/assets/{code--qUk_yn-.js → code-CGj3w-2N.js} +0 -0
  159. /package/client/dist/assets/{code-D7GLAjrz2.js → code-Dfsxc9o82.js} +0 -0
  160. /package/client/dist/assets/{code-Cjv4_HkK2.js → code-Y5urks5s2.js} +0 -0
  161. /package/client/dist/assets/{commands-oB9q2vy_2.js → commands-Bb7MnPqn2.js} +0 -0
  162. /package/client/dist/assets/{commands-MqNuGGO4.js → commands-CQkdthjF.js} +0 -0
  163. /package/client/dist/assets/{commands-BCx1uDIE.js → commands-C_7zZwJf.js} +0 -0
  164. /package/client/dist/assets/{commands-Bhw9Hqsa2.js → commands-DBc5llLi2.js} +0 -0
  165. /package/client/dist/assets/{commands-B9XaopQC.js → commands-D_6B8lfU.js} +0 -0
  166. /package/client/dist/assets/{commands-DuaQT-it.js → commands-DhZNhSbl.js} +0 -0
  167. /package/client/dist/assets/{commands-D0RnooQF2.js → commands-uz_uKT242.js} +0 -0
  168. /package/client/dist/assets/{common-wEB9RBdf.js → common-Bb64s3Bm.js} +0 -0
  169. /package/client/dist/assets/{common-BXzqeuiC2.js → common-C8ZD5upH2.js} +0 -0
  170. /package/client/dist/assets/{common-C-jaOdxz2.js → common-CeQUwuHt2.js} +0 -0
  171. /package/client/dist/assets/{common-BaJ6MF7T.js → common-DPxotRK9.js} +0 -0
  172. /package/client/dist/assets/{common-DPGR3Tfo.js → common-KbQuTSGg.js} +0 -0
  173. /package/client/dist/assets/{common-CRd-Ge5u2.js → common-QjVnq9XP2.js} +0 -0
  174. /package/client/dist/assets/{common-CKjy-R8-.js → common-k5MTOHpn.js} +0 -0
  175. /package/client/dist/assets/{dashboard-CcEpALV_.js → dashboard-B8032psZ.js} +0 -0
  176. /package/client/dist/assets/{dashboard-DxEPkALo2.js → dashboard-BHGKtxty2.js} +0 -0
  177. /package/client/dist/assets/{dashboard-MgDVmaYS2.js → dashboard-CXnoUgN22.js} +0 -0
  178. /package/client/dist/assets/{dashboard-CfltY66K.js → dashboard-Ccyxqy7d.js} +0 -0
  179. /package/client/dist/assets/{dashboard-DLeC5ziO.js → dashboard-Dc5ZAgMN.js} +0 -0
  180. /package/client/dist/assets/{dashboard-Bl2_Yjs6.js → dashboard-JMY8ueD3.js} +0 -0
  181. /package/client/dist/assets/{dashboard-C_vS9RaM2.js → dashboard-tkWr1aHD2.js} +0 -0
  182. /package/client/dist/assets/{explore-OZhWV0Eb2.js → explore-BHEhNekP2.js} +0 -0
  183. /package/client/dist/assets/{explore-D-htKul_.js → explore-CWlAXx0f2.js} +0 -0
  184. /package/client/dist/assets/{explore-Dvp-5qOw2.js → explore-DAsroA482.js} +0 -0
  185. /package/client/dist/assets/{explore-IS8VyaSZ.js → explore-DG1CtYqT.js} +0 -0
  186. /package/client/dist/assets/{explore-FaKfWCr72.js → explore-DMSGAnhK.js} +0 -0
  187. /package/client/dist/assets/{explore-B_79NLR5.js → explore-DaXiW9-6.js} +0 -0
  188. /package/client/dist/assets/{explore-D5b2jgvR.js → explore-UwHHj2ux.js} +0 -0
  189. /package/client/dist/assets/{format-command-CHImQv6W.js → format-command-BHymDa4r.js} +0 -0
  190. /package/client/dist/assets/{integrations-B97cGWfo2.js → integrations-B-JVE1_D.js} +0 -0
  191. /package/client/dist/assets/{integrations-C3Ma3GdM.js → integrations-BAujIDoE.js} +0 -0
  192. /package/client/dist/assets/{integrations-Bp3leAh3.js → integrations-CAF21FbQ.js} +0 -0
  193. /package/client/dist/assets/{integrations-Du_0rDfi2.js → integrations-CHCgning2.js} +0 -0
  194. /package/client/dist/assets/{integrations-C5MUA-0-.js → integrations-CtsOpq2D2.js} +0 -0
  195. /package/client/dist/assets/{integrations-CiQbCn_W.js → integrations-DS5FFMes.js} +0 -0
  196. /package/client/dist/assets/{integrations-t4X5UVcx2.js → integrations-axZN4--n2.js} +0 -0
  197. /package/client/dist/assets/{jira-D6IDTIsc2.js → jira-BcZzX9122.js} +0 -0
  198. /package/client/dist/assets/{jira-DdEKW9Pu.js → jira-CTYs7LA12.js} +0 -0
  199. /package/client/dist/assets/{jira-BzFvFn7t2.js → jira-D2nN39e92.js} +0 -0
  200. /package/client/dist/assets/{jira-BCHx9zUF.js → jira-DJxmIkyr.js} +0 -0
  201. /package/client/dist/assets/{jira-DSZ5xFRl.js → jira-IhC1ROIc.js} +0 -0
  202. /package/client/dist/assets/{jira-BqXyykbt2.js → jira-Iw575fN8.js} +0 -0
  203. /package/client/dist/assets/{jira-B1XaR6fj.js → jira-kbWZY7jH.js} +0 -0
  204. /package/client/dist/assets/{jobs-CeOcGHd_2.js → jobs-Bvh_HiRo2.js} +0 -0
  205. /package/client/dist/assets/{jobs-BgHEgCWk2.js → jobs-BzYX5VLd.js} +0 -0
  206. /package/client/dist/assets/{jobs-CU-khJTt.js → jobs-DTfaTfzQ2.js} +0 -0
  207. /package/client/dist/assets/{jobs-Ct5v2p6T.js → jobs-DrPyq5J2.js} +0 -0
  208. /package/client/dist/assets/{jobs-m7L0K9uC2.js → jobs-Dty7cCdI2.js} +0 -0
  209. /package/client/dist/assets/{jobs-Ce0SE81t.js → jobs-Dv8MP-eE.js} +0 -0
  210. /package/client/dist/assets/{jobs-BX9dP3Qn.js → jobs-DvkAoA8D.js} +0 -0
  211. /package/client/dist/assets/{loops-BlrQiK122.js → loops-BR4FmOv12.js} +0 -0
  212. /package/client/dist/assets/{loops-DuuWQWTI.js → loops-BgX_uudn.js} +0 -0
  213. /package/client/dist/assets/{loops-KOTryzk5.js → loops-Bpl2j2LP.js} +0 -0
  214. /package/client/dist/assets/{loops-Bs0ectZ32.js → loops-DW8hSMdS2.js} +0 -0
  215. /package/client/dist/assets/{loops-CLZV8HHY2.js → loops-Q2muu8hW2.js} +0 -0
  216. /package/client/dist/assets/{loops-t1mUZtf0.js → loops-Y3FQsUCh.js} +0 -0
  217. /package/client/dist/assets/{loops-BEUiCzEI.js → loops-q7CNDvfK.js} +0 -0
  218. /package/client/dist/assets/{mcp-CXy61khH.js → mcp-B8omp_Cd.js} +0 -0
  219. /package/client/dist/assets/{mcp-_DUUXTHB2.js → mcp-B_nWlxZa2.js} +0 -0
  220. /package/client/dist/assets/{mcp-dlOyUQQy2.js → mcp-Cb2jtHP72.js} +0 -0
  221. /package/client/dist/assets/{mcp-4QbfLPa4.js → mcp-DPqm2C8-.js} +0 -0
  222. /package/client/dist/assets/{mcp-NlLc9T8u2.js → mcp-DTCCrYHz2.js} +0 -0
  223. /package/client/dist/assets/{mcp-zqSVP7nA.js → mcp-D_oPS6Zc.js} +0 -0
  224. /package/client/dist/assets/{mcp-CmOBPDjE.js → mcp-DytBbASZ.js} +0 -0
  225. /package/client/dist/assets/{setup-BxVydxbl2.js → setup-CNMdCHHt2.js} +0 -0
  226. /package/client/dist/assets/{setup-BmXfxlzA2.js → setup-Cag4XrbL2.js} +0 -0
  227. /package/client/dist/assets/{setup-DIRZ1Lf-.js → setup-D9IHGoWU.js} +0 -0
  228. /package/client/dist/assets/{setup-Dx13pESZ.js → setup-Dg6Ba3JT.js} +0 -0
  229. /package/client/dist/assets/{setup-Z01j3st4.js → setup-DyK36RIW.js} +0 -0
  230. /package/client/dist/assets/{setup-SLAi4xxQ2.js → setup-aTlGxuwi2.js} +0 -0
  231. /package/client/dist/assets/{setup-DwbKSnKQ.js → setup-kWsoAeHQ.js} +0 -0
  232. /package/client/dist/assets/{specs-BYSOlQRw2.js → specs-BFSUPa122.js} +0 -0
  233. /package/client/dist/assets/{specs-BWQ-0EXt2.js → specs-BMzip1WY2.js} +0 -0
  234. /package/client/dist/assets/{specs-d-zU7_3Q.js → specs-C-mtLcXw.js} +0 -0
  235. /package/client/dist/assets/{specs-CkP0B28v2.js → specs-CAzpvADd2.js} +0 -0
  236. /package/client/dist/assets/{specs-57pue7UQ.js → specs-CyRIw_IR.js} +0 -0
  237. /package/client/dist/assets/{specs-nM5Cpcqe.js → specs-DMm7gB_l.js} +0 -0
  238. /package/client/dist/assets/{specs-RSYuLgF4.js → specs-DuottM0Z.js} +0 -0
  239. /package/client/dist/assets/{terminal-D3RTuBwy.js → terminal-58ReNaya.js} +0 -0
  240. /package/client/dist/assets/{terminal-Adi3W-GZ2.js → terminal-CDiOAmBd2.js} +0 -0
  241. /package/client/dist/assets/{terminal-DOuNm2BI.js → terminal-CJN-mQMc.js} +0 -0
  242. /package/client/dist/assets/{terminal-C8KlD61D.js → terminal-CYB4TiAd.js} +0 -0
  243. /package/client/dist/assets/{terminal-BA6FCZna2.js → terminal-DTQ_dPqi2.js} +0 -0
  244. /package/client/dist/assets/{terminal-BCIUSkrg.js → terminal-DawP8xNL.js} +0 -0
  245. /package/client/dist/assets/{terminal-DCkOEjSj2.js → terminal-DsaDTq5N2.js} +0 -0
  246. /package/client/dist/assets/{tickets-Bsyv_znj.js → tickets-CNvIilmP.js} +0 -0
  247. /package/client/dist/assets/{tickets-C_UPra_1.js → tickets-CujsZvkf.js} +0 -0
  248. /package/client/dist/assets/{tickets-B2q36GlQ2.js → tickets-DBfFePwk2.js} +0 -0
  249. /package/client/dist/assets/{tickets-DiUA3rXq.js → tickets-Da15iaRw.js} +0 -0
  250. /package/client/dist/assets/{tickets-DDjU7UfE2.js → tickets-Df6pee-O2.js} +0 -0
  251. /package/client/dist/assets/{tickets-DR4ZrPMf.js → tickets-DoRTUYRT.js} +0 -0
  252. /package/client/dist/assets/{tickets-D72LbUtU2.js → tickets-DvohTziT2.js} +0 -0
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-G3Sl9C67.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-T7u8kQWG.js","assets/editor-Br_kD0ds.css","assets/workers-CXcXtO3b.js","assets/monaco.contribution-PUeaZk8T.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{$ as n,$t as r,Bt as i,Cn as a,D as o,E as s,Ft as c,Gn as l,Hn as u,Ht as d,It as f,J as p,Kn as m,Ln as h,Nt as g,Qt as _,Rn as v,Rt as y,Sn as b,Wn as x,Zt as S,cn as C,dn as w,gt as T,h as E,q as D,s as O,tt as k,un as ee,wn as A,zt as j}from"./index-CG4z4_Mq.js";var M=C(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),N=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`}]]),P=e(m(),1),F=e(l(),1);function I(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 L(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 te(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ne=(e,t)=>Math.abs(e-t)<1.01,re=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},R,z=()=>{if(R!==void 0)return R;if(typeof navigator>`u`)return R=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return R=!0;let e=navigator.maxTouchPoints;return R=navigator.platform===`MacIntel`&&e!==void 0&&e>0},B=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ie=e=>e,ae=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},V=(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(B(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(B(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},H={passive:!0},U=typeof window>`u`?!0:`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:re(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)}},G=(e,t)=>W(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),oe=(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`]},K=(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})},se=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:ie,rangeExtractor:ae,onChange:()=>{},measureElement:oe,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=L(()=>(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,!(!z()||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=L(()=>[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=L(()=>[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=I(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=L(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?le({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=L(()=>{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))&&(z()&&(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=L(()=>[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 te(t[ce(0,t.length-1,r?e=>n[e*2]:e=>te(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&&ne(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()}},ce=(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 le({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=ce(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 ue=typeof document<`u`?P.useLayoutEffect:P.useEffect;function q({useFlushSync:e=!0,...t}){let n=P.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,F.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=P.useState(()=>new se(r));return i.setOptions(r),ue(()=>i._didMount(),[]),ue(()=>i._willUpdate()),i}function de(e){return q({observeElementRect:V,observeElementOffset:G,scrollToFn:K,...e})}var J=a(),Y=e=>`specrails-desktop:code-tree-filter:${e}`,X=e=>`specrails-desktop:code-tree-collapsed:${e}`;function Z(e){return e.split(`/`).length-1}function fe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function pe(e){return e?e.length>10?e.slice(0,10):e:null}function me(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function he(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 ge({onOpenFile:e,selectedPath:t,filterJobId:i,filterTicketId:a}){let{t:o}=v(`code`),{activeProjectId:s}=ee(),{openTicketDetail:l}=E(),{registerHandler:u,unregisterHandler:d}=b(),[p,m]=(0,P.useState)(()=>{if(!s)return`touched-by-ai`;try{let e=localStorage.getItem(Y(s));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,P.useEffect)(()=>{if(s)try{localStorage.setItem(Y(s),p)}catch{}},[p,s]);let[h,y]=(0,P.useState)(()=>{if(!s)return new Set;try{let e=localStorage.getItem(X(s));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,P.useEffect)(()=>{if(s)try{localStorage.setItem(X(s),JSON.stringify([...h]))}catch{}},[h,s]);let x=(0,P.useCallback)(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),S=(0,P.useCallback)(()=>{y(new Set)},[]),{data:C,refresh:T,isFirstLoad:D}=w({namespace:`code-tree:${p}:${p===`touched-by-ai`?`${i??`all-jobs`}:${a??`all-specs`}`:`all`}`,projectId:s,initialValue:[],fetcher:(0,P.useCallback)(async()=>{let e=[],t=null;for(let n=0;n<100;n+=1){let n=new URLSearchParams({withProvenance:`1`,filter:p});p===`touched-by-ai`&&i&&n.set(`jobId`,i),p===`touched-by-ai`&&typeof a==`number`&&n.set(`ticketId`,String(a)),t&&n.set(`cursor`,t);let r=await fetch(`${A()}/code/tree?${n.toString()}`);if(!r.ok)break;let o=await r.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[p,i,a])}),O=(0,P.useRef)(s);(0,P.useEffect)(()=>{O.current=s},[s]),(0,P.useEffect)(()=>{if(!s)return;let e=`code-tree-${s}`;return u(e,e=>{let t=e;t.projectId===O.current&&t.type===`file.provenance_updated`&&T()}),()=>d(e)},[s,u,d,T]);let k=(0,P.useRef)(null),j=(0,P.useMemo)(()=>(C??[]).filter(e=>!he(e.path,h)),[C,h]),N=(0,P.useCallback)(()=>{y(new Set((C??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[C]),F=de({count:j.length,getScrollElement:()=>k.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()=>{}}}),I=j.length===0,L=(0,P.useMemo)(()=>(C??[]).filter(e=>e.kind===`file`).length,[C]);return(0,J.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,J.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(`touched-by-ai`),className:n(`px-2 py-1 rounded-md transition-colors`,p===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":p===`touched-by-ai`,children:o(i?`tree.jobFiles`:a?`tree.specFiles`:`tree.touchedByAi`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(`all`),className:n(`px-2 py-1 rounded-md transition-colors`,p===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":p===`all`,children:o(`tree.allFiles`)}),(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsx)(`button`,{type:`button`,onClick:N,title:o(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.collapseAll`),children:(0,J.jsx)(_,{className:`w-3.5 h-3.5`})}),(0,J.jsx)(`button`,{type:`button`,onClick:S,title:o(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.expandAll`),children:(0,J.jsx)(r,{className:`w-3.5 h-3.5`})})]}),p===`touched-by-ai`&&L>0&&(0,J.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,J.jsx)(`span`,{children:o(`tree.touchedCount`,{count:L})})})]}),I&&D?(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:o(`tree.loadingFiles`)})}):I&&p===`touched-by-ai`?(0,J.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`tree.emptyTouched`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>m(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:o(`tree.showAllFiles`)})]}):I?(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:o(`tree.noFiles`)}):(0,J.jsx)(`div`,{ref:k,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,J.jsx)(`div`,{style:{height:F.getTotalSize(),position:`relative`,width:`100%`},children:F.getVirtualItems().map(i=>{let a=j[i.index],s=Z(a.path)*12,u=a.kind===`file`&&a.path===t,d=a.provenance?.createdByTicketId,p=a.provenance?.modifiedByTicketIds??[],m=a.provenance?.latest??null,v=pe(m?.jobId),y=me(m?.kind),b=a.kind===`dir`,S=b&&h.has(a.path),C=a.provenance?.touchedFileCount??0;return(0,J.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${i.start}px)`,height:i.size,width:`100%`},className:n(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,u&&`bg-muted text-foreground`),onClick:()=>{b?x(a.path):e(a.path)},role:`button`,tabIndex:0,"aria-expanded":b?!S:void 0,"data-testid":`file-tree-row-${a.path}`,children:[(0,J.jsxs)(`span`,{style:{paddingLeft:s},className:`flex items-center gap-1 min-w-0 flex-1`,children:[b?(0,J.jsxs)(J.Fragment,{children:[S?(0,J.jsx)(_,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,J.jsx)(r,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),S?(0,J.jsx)(c,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,J.jsx)(f,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,J.jsx)(M,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,J.jsx)(`span`,{className:`truncate ml-0.5`,children:fe(a.path)})]}),(0,J.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[b&&C>0&&(0,J.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:o(`tree.folderTouched`,{count:C}),children:C}),!b&&y&&(0,J.jsx)(`span`,{className:n(`text-[10px] px-1.5 py-0.5 rounded`,m?.kind===`created`&&`bg-accent-success/15 text-accent-success`,m?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,m?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:m?.kind===`created`?o(`tree.latestTitleCreated`):m?.kind===`deleted`?o(`tree.latestTitleDeleted`):o(`tree.latestTitleModified`),children:o(`action.${y}`)}),!b&&v&&(0,J.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:o(`tree.jobTitle`,{jobId:m?.jobId??``}),children:[(0,J.jsx)(g,{className:`h-3 w-3`}),v]}),!b&&typeof d==`number`&&(0,J.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l(d)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${d}`,title:o(`tree.createdBySpec`,{id:d}),children:[`#`,d]}),!b&&p.slice(0,2).map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(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:o(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},a.path)})})})]})}function _e(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ve(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function be(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Se=!1;function Ce(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=Ce(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 we(e){return`specrails-${e}`}function Te(e,t){let n=we(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 Ee(){Se||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ve;case`css`:case`scss`:case`less`:return new ye;case`html`:case`handlebars`:case`razor`:return new be;case`typescript`:case`javascript`:return new xe;default:return new _e}}},!0)}function De({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=v(`code`),o=O(),s=(0,P.useRef)(null),c=(0,P.useRef)(null),l=(0,P.useRef)(null),[u,d]=(0,P.useState)(!1),f=(0,P.useRef)(e),p=(0,P.useRef)(n),m=(0,P.useRef)(o),h=(0,P.useRef)(r),g=(0,P.useRef)(i);return(0,P.useEffect)(()=>{f.current=e},[e]),(0,P.useEffect)(()=>{p.current=n},[n]),(0,P.useEffect)(()=>{m.current=o},[o]),(0,P.useEffect)(()=>{h.current=r},[r]),(0,P.useEffect)(()=>{g.current=i},[i]),(0,P.useEffect)(()=>{let e=!1;return Ee(),t(()=>import(`./editor.main-G3Sl9C67.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=Te(t,m.current),r=t.editor.create(s.current,{value:f.current,language:p.current,readOnly:h.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{g.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,P.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,P.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,P.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,P.useEffect)(()=>{let e=l.current;if(!e)return;let t=Te(e,o);e.editor.setTheme(t)},[o]),u?(0,J.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,J.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,J.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,J.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var Oe=(0,P.lazy)(async()=>({default:De}));function ke({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=v(`code`);return(0,J.jsx)(P.Suspense,{fallback:(0,J.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,J.jsx)(Oe,{content:e,language:t,readOnly:n,onChange:r})})}function Ae(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 je({path:e,summary:t,stale:r,regenerating:i,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=v(`code`),{openTicketDetail:l}=E();if(!t)return(0,J.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,J.jsxs)(`button`,{type:`button`,onClick:o,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,J.jsx)(S,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let u=Ae(t.generatedAt,c.language),d=t.triggeredBy?.ticketId,f=t.triggeredBy?.modifiedTicketIds??[];return(0,J.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,J.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),r&&(0,J.jsx)(`span`,{className:n(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:s(`summary.stale`)}),i&&(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,J.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof d==`number`&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>l(d),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,d]}),f.map(e=>(0,J.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,J.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),o&&(0,J.jsxs)(`button`,{type:`button`,onClick:o,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,J.jsx)(S,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Me({content:e}){return(0,J.jsx)(o,{remarkPlugins:[s],children:e})}function Ne(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var Pe=180,Fe=120,Ie=240;function Le(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Re(e){return e?`specrails-desktop:code-history-height:${e}`:null}function ze(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Be(e){let t=Re(e);if(!t)return Pe;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Pe}catch{return Pe}}function Ve(e,t){let n=Re(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function He(e){let t=Le(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ue(e,t){let n=Le(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function We(e){let t=ze(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ge(e,t){let n=ze(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Ke(e,t){let n=Math.max(Fe,t-Ie);return Math.min(Math.max(e,Fe),n)}function qe({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:i}){let{t:a}=v(`code`),{activeProjectId:o}=ee(),{openTicketDetail:s}=E(),{registerHandler:c,unregisterHandler:l}=b(),u=p({allowMove:!1}),d=(0,P.useRef)(null),[f,m]=(0,P.useState)(null),[g,_]=(0,P.useState)(!0),[y,x]=(0,P.useState)(!1),[C,w]=(0,P.useState)(!1),[T,O]=(0,P.useState)(()=>He(o)),[k,j]=(0,P.useState)(()=>Be(o)),[M,N]=(0,P.useState)(()=>We(o)),F=(0,P.useRef)(o);(0,P.useEffect)(()=>{F.current=o},[o]);let I=(0,P.useRef)(e);(0,P.useEffect)(()=>{I.current=e},[e]),(0,P.useEffect)(()=>{let e=d.current?.clientHeight||window.innerHeight;O(He(o)),j(Ke(Be(o),e)),N(We(o))},[o]);let L=(0,P.useCallback)(e=>{let t=e.clientY,n=k,r=d.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){j(Ke(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),j(e=>{let t=Ke(e,r);return Ve(o,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[o,k]),te=(0,P.useCallback)(()=>{let e=Ke(Pe,d.current?.clientHeight||window.innerHeight);j(e),Ve(o,e)},[o]),ne=(0,P.useCallback)(()=>{O(e=>{let t=!e;return Ue(o,t),t})},[o]),re=(0,P.useCallback)(()=>{N(e=>{let t=!e;return Ge(o,t),t})},[o]);(0,P.useEffect)(()=>{x(!1),w(!1),H(`preview`),W(!1)},[e]);let R=(0,P.useRef)(0),z=(0,P.useCallback)(async()=>{let t=++R.current;_(!0);try{let n=await fetch(`${A()}/code/file?path=${encodeURIComponent(e)}`);if(t!==R.current)return;if(!n.ok){m(null);return}let r=await n.json();if(t!==R.current)return;m(r)}catch{t===R.current&&m(null)}finally{t===R.current&&_(!1)}},[e,o]);(0,P.useEffect)(()=>{z()},[z]),(0,P.useEffect)(()=>{if(!o)return;let e=`code-file-${o}`;return c(e,e=>{let t=e;t.projectId===F.current&&(t.type===`file.summary_updated`&&t.path===I.current?(x(!1),z()):t.type===`file.summary_failed`&&t.path===I.current?(h.error(t.reason??a(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===I.current&&(t.reason&&h(a(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>l(e)},[o,c,l,z,a]);let B=(0,P.useCallback)(async t=>{x(!0);try{let n=await fetch(`${A()}/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){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;h.error(e?a(`summary.skipped`,{reason:e}):a(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),w(!0);return}if(r.skipped){x(!1),h(a(`summary.skipped`,{reason:r.skipped}));return}await z(),x(!1)}catch{x(!1),h.error(a(`summary.generationFailed`))}},[z,e,a]),ie=(0,P.useCallback)(async()=>{let t=f?.absolutePath??e;try{await navigator.clipboard?.writeText(t),h.success(a(`viewer.pathCopied`))}catch{h.error(a(`viewer.copyPathFailed`))}},[f,e,a]),ae=(0,P.useMemo)(()=>Ne(e,f?.language),[e,f?.language]),[V,H]=(0,P.useState)(`preview`),[U,W]=(0,P.useState)(!1),[G,oe]=(0,P.useState)(``),[K,se]=(0,P.useState)(!1),ce=f?.content!==void 0&&!f.binary&&!f.tooLarge&&f.reason!==`not-found`,le=(0,P.useCallback)(()=>{oe(f?.content??``),H(`raw`),W(!0)},[f]),ue=(0,P.useCallback)(async()=>{se(!0);try{let t=await fetch(`${A()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:G})});if(!t.ok){let e=await t.json().catch(()=>({}));h.error(e.error??a(`viewer.saveFailed`));return}h.success(a(`viewer.saved`)),W(!1),z()}catch{h.error(a(`viewer.saveFailed`))}finally{se(!1)}},[e,G,a,z]),q=f?.summary??null,de=!!f?.summaryStale,Y=f?.provenance??[],X=f?.reason===`not-found`,Z=X?a(`summary.reason.missing`):f?.binary?a(`summary.reason.binary`):f?.tooLarge?a(`summary.reason.tooLarge`):null;return(0,P.useEffect)(()=>{if(n){if(g&&!f){n(null);return}return n({hasSummary:!!q,regenerating:y,disabledReason:Z,onClick:()=>B(!1)}),()=>n(null)}},[f,B,g,n,y,q,Z]),(0,P.useEffect)(()=>{if(i){if(g&&!f){i(null);return}return i({onClick:ie}),()=>i(null)}},[ie,f,g,i]),g&&!f?(0,J.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`viewer.loadingFile`)}):(0,J.jsxs)(`div`,{ref:d,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[T?(0,J.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,J.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,J.jsxs)(`button`,{type:`button`,onClick:ne,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,J.jsx)(r,{className:`h-3.5 w-3.5`}),a(`viewer.showSummary`)]})]}):(0,J.jsx)(je,{path:e,summary:q,stale:de,regenerating:y,generateDisabledReason:Z,onCollapse:ne}),(0,J.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:ae&&f?.content!==void 0&&!f.binary&&!f.tooLarge&&(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":a(`viewer.markdownViewMode`),children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>H(`preview`),"aria-pressed":V===`preview`,className:V===`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:a(`viewer.preview`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>H(`raw`),"aria-pressed":V===`raw`,className:V===`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:a(`viewer.raw`)})]})}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!U&&(0,J.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:a(`viewer.edit`)}),U&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>W(!1),disabled:K,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:a(`actions.cancel`,{ns:`common`})}),(0,J.jsx)(`button`,{type:`button`,onClick:ue,disabled:K,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:a(K?`viewer.saving`:`viewer.save`)})]})]})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:X?(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:a(`viewer.missingFile`)}):f?.binary?(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:a(`viewer.binaryFile`)}):f?.tooLarge?(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:a(`viewer.tooLarge`,{size:Math.round((f.sizeBytes??0)/1024/1024)})}):f?.content===void 0?(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:a(`viewer.noContent`)}):U?(0,J.jsx)(ke,{content:G,language:f.language??`plaintext`,readOnly:!1,onChange:oe}):ae&&V===`preview`?(0,J.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,J.jsx)(Me,{content:f.content})}):(0,J.jsx)(ke,{content:f.content,language:f.language??`plaintext`})}),Y.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`history.resize`),onPointerDown:M?void 0:L,onDoubleClick:M?void 0:te,className:M?`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:M?void 0:a(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,J.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:a(`history.title`,{count:Y.length})}),(0,J.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:re,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:[M?(0,J.jsx)(S,{className:`h-3.5 w-3.5`}):(0,J.jsx)(r,{className:`h-3.5 w-3.5`}),a(M?`history.show`:`history.hide`)]})]}),!M&&(0,J.jsx)(Je,{rows:Y,onOpenTicket:s,onFilterJob:t,height:k})]}),C&&(0,J.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:u.guardBackdrop(()=>w(!1)),children:[(0,J.jsxs)(`div`,{ref:u.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:u.panelStyle,children:[(0,J.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`viewer.budgetPrompt`)}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>w(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:a(`common:actions.cancel`)}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{w(!1),B(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:a(`common:actions.confirm`)})]})]}),(0,J.jsx)(D,{handles:u.resizeHandles})]})]})}function Je({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:a}=v(`code`),[o,s]=(0,P.useState)(null),[c,l]=(0,P.useState)({});if(e.length===0)return null;async function u(e,t){if(o===t){s(null);return}if(s(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${A()}/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,J.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,J.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let s=e.kind===`created`?j:e.kind===`deleted`?i:y,l=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:a(`history.unknownJob`),d=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,f=c[d];return(0,J.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,J.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,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,J.jsx)(s,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,J.jsx)(`span`,{className:`capitalize`,children:a(`kind.${e.kind}`)})]}),(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,J.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,J.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:l}):(0,J.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:l}),e.jobId&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>u(e,d),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:a(`history.diff`)}),typeof e.ticketId==`number`&&(0,J.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:a(`history.openSpec`,{ticketId:e.ticketId}),children:a(`history.specChip`,{ticketId:e.ticketId})})]}),(0,J.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),o===d&&(0,J.jsx)(`div`,{className:`px-2 pb-2`,children:f===`loading`?(0,J.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.loadingDiff`)}):f===`missing`||!f?(0,J.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:a(`history.diffUnavailable`)}):(0,J.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:[f.patch,f.truncated?`\n${a(`history.diffTruncated`)}`:``]})})]},d)})})})}var Ye=320,Xe=240,Ze=520;function Qe(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function $e(e){let t=Qe(e);if(!t)return Ye;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Ye}catch{return Ye}}function et(e,t){let n=Qe(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(Xe,t-Ze);return Math.min(Math.max(e,Xe),n)}function tt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=v(`code`),{activeProjectId:i}=ee(),[a]=x(),o=u(),s=(0,P.useRef)(null),[c,l]=(0,P.useState)(e?t:a.get(`path`)),d=(0,P.useCallback)(e=>{l(e),n?.(e)},[n]),[f,p]=(0,P.useState)(null),[m,h]=(0,P.useState)(null),[g,_]=(0,P.useState)(()=>$e(i)),[y,b]=(0,P.useState)(null),[S,C]=(0,P.useState)(null),w=e?y:a.get(`jobId`),T=(0,P.useMemo)(()=>{if(e)return S;let t=a.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,S,a]),[E,D]=(0,P.useState)(T==null?``:String(T));(0,P.useEffect)(()=>{if(e)return;let t=a.get(`path`);t!==c&&l(t)},[a,e]),(0,P.useEffect)(()=>{D(T==null?``:String(T))},[T]),(0,P.useEffect)(()=>{let e=s.current?.clientWidth||window.innerWidth;_($($e(i),e))},[i]),(0,P.useEffect)(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&_(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,P.useCallback)(e=>{let t=e.clientX,n=g,r=s.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){_($(n+(e.clientX-t),r))}function c(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),_(e=>{let t=$(e,r);return et(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[i,g]),k=(0,P.useCallback)(()=>{let e=$(Ye,s.current?.clientWidth||window.innerWidth);_(e),et(i,e)},[i]),A=(0,P.useCallback)(t=>{if(d(t),e)return;let n=new URLSearchParams(a);n.set(`path`,t),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a,d]),j=(0,P.useCallback)(t=>{if(e){b(t),C(null);return}let n=new URLSearchParams(a);n.set(`jobId`,t),n.delete(`ticketId`),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a]),M=(0,P.useCallback)(()=>{if(e){b(null),C(null);return}let t=new URLSearchParams(a);t.delete(`jobId`),t.delete(`ticketId`),o({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,o,a]),N=(0,P.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){M();return}if(e){C(n),b(null);return}let r=new URLSearchParams(a);r.set(`ticketId`,String(n)),r.delete(`jobId`),o({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[M,e,o,a]);return(0,J.jsxs)(`div`,{ref:s,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,J.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:g},children:(0,J.jsx)(ge,{onOpenFile:A,selectedPath:c,filterJobId:w,filterTicketId:T},i??`no-project`)}),(0,J.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,J.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,J.jsx)(nt,{jobId:w,ticketId:T,ticketInput:E,onTicketInputChange:D,onApplyTicket:N,onClear:M,summaryAction:f,copyPathAction:m}),(w||T)&&(0,J.jsx)(rt,{jobId:w,ticketId:T,onOpenFile:A}),c?(0,J.jsx)(qe,{relPath:c,onFilterJob:j,onSummaryActionChange:p,onCopyPathActionChange:h}):(0,J.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function nt({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:c}=v(`code`),l=t?`spec`:e?`job-context`:`all`;return(0,J.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,J.jsx)(N,{className:`h-3.5 w-3.5`}),c(`toolbar.scope`)]}),(0,J.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":l===`all`,className:l===`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:c(`toolbar.allAi`)}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":l===`spec`,className:l===`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:c(`toolbar.spec`)}),(0,J.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:c(`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,J.jsx)(`div`,{className:`flex-1`}),s&&(0,J.jsx)(`button`,{type:`button`,onClick:s.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:c(`toolbar.copyFilePath`)}),o&&(0,J.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?c(`toolbar.regenerateSummary`):c(`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?c(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,J.jsx)(T,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?c(`toolbar.regenerating`):c(`toolbar.regenerateSummary`):o.regenerating?c(`toolbar.generating`):c(`toolbar.generateSummary`)]}),l===`job-context`&&(0,J.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:c(`toolbar.jobContext`)}),(e||t)&&(0,J.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,J.jsx)(k,{className:`h-3.5 w-3.5`}),c(`toolbar.clear`)]})]})})}function rt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=v(`code`),[i,a]=(0,P.useState)(null);(0,P.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${A()}/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,P.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]),s=i?.length??0;return(0,J.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,J.jsx)(it,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,J.jsx)(it,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,J.jsx)(it,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,J.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,J.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,J.jsx)(d,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function it({label:e,rows:t,icon:n,onOpenFile:r}){return(0,J.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,J.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,J.jsx)(n===`created`?j:n===`deleted`?i:y,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,J.jsx)(`span`,{children:e}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,J.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,J.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{tt as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-1dnHRn8W.js";import{In as n,J as r,On as i,Qt as a,an as o,cn as s,dn as c,fn as l,in as u,ln as d,nn as f,on as p,p as m,pn as h,s as g,sn as _,un as v,ut as y}from"./index-BeujshsU.js";import{$ as b,A as x,B as S,E as ee,F as C,H as w,K as T,L as E,N as D,O,P as te,Q as ne,R as re,S as ie,T as ae,U as oe,W as se,X as ce,Y as le,Z as ue,_ as de,_t as fe,a as pe,c as me,d as he,dt as k,et as A,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as j,it as xe,j as Se,k as Ce,l as we,lt as M,mt as Te,n as Ee,nt as De,o as Oe,pt as N,q as ke,r as Ae,rt as je,s as Me,t as Ne,u as Pe,ut as P,v as Fe,w as F,z as Ie}from"./BarChart-HPiao--v.js";var Le=a(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);function I(e,t){return o(e,{...t,weekStartsOn:1})}function L(e,t){let n=p(e,t?.in),r=n.getFullYear(),i=d(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=I(i),o=d(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=I(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function R(e,t){let n=p(e,t?.in);return n.setHours(0,0,0,0),n}function Re(e,t,n){let[r,i]=s(n?.in,e,t),a=R(r),o=R(i),c=+a-m(a),l=+o-m(o);return Math.round((c-l)/v)}function ze(e,t){let n=L(e,t),r=d(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),I(r)}function Be(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ve(e){return!(!Be(e)&&typeof e!=`number`||isNaN(+p(e)))}function He(e,t){let n=p(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ue(e,t){let n=p(e,t?.in);return Re(n,He(n))+1}function We(e,t){let n=p(e,t?.in),r=I(n)-+ze(n);return Math.round(r/c)+1}function z(e,t){let n=p(e,t?.in),r=n.getFullYear(),i=_(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,s=d(t?.in||e,0);s.setFullYear(r+1,0,a),s.setHours(0,0,0,0);let c=o(s,t),l=d(t?.in||e,0);l.setFullYear(r,0,a),l.setHours(0,0,0,0);let u=o(l,t);return+n>=+c?r+1:+n>=+u?r:r-1}function Ge(e,t){let n=_(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=z(e,t),a=d(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),o(a,t)}function Ke(e,t){let n=p(e,t?.in),r=o(n,t)-+Ge(n,t);return Math.round(r/c)+1}function B(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var V={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return B(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):B(n+1,2)},d(e,t){return B(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return B(e.getHours()%12||12,t.length)},H(e,t){return B(e.getHours(),t.length)},m(e,t){return B(e.getMinutes(),t.length)},s(e,t){return B(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return B(Math.trunc(r*10**(n-3)),t.length)}},H={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qe={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return V.y(e,t)},Y:function(e,t,n,r){let i=z(e,r),a=i>0?i:1-i;return t===`YY`?B(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):B(a,t.length)},R:function(e,t){return B(L(e),t.length)},u:function(e,t){return B(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return B(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return B(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return V.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return B(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Ke(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):B(i,t.length)},I:function(e,t,n){let r=We(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):B(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):V.d(e,t)},D:function(e,t,n){let r=Ue(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):B(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return B(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return B(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return B(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?H.noon:r===0?H.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?H.evening:r>=12?H.afternoon:r>=4?H.morning:H.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return V.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):V.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):V.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):V.s(e,t)},S:function(e,t){return V.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ye(r);case`XXXX`:case`XX`:return U(r);default:return U(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ye(r);case`xxxx`:case`xx`:return U(r);default:return U(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},t:function(e,t,n){return B(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return B(+e,t.length)}};function Je(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+B(a,2)}function Ye(e,t){return e%60==0?(e>0?`-`:`+`)+B(Math.abs(e)/60,2):U(e,t)}function U(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=B(Math.trunc(r/60),2),a=B(r%60,2);return n+i+t+a}var Xe=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Ze=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Qe={p:Ze,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Xe(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Xe(r,t)).replace(`{{time}}`,Ze(i,t))}},$e=/^D+$/,et=/^Y+$/,tt=[`D`,`DD`,`YY`,`YYYY`];function nt(e){return $e.test(e)}function rt(e){return et.test(e)}function it(e,t,n){let r=at(e,t,n);if(console.warn(r),tt.includes(e))throw RangeError(r)}function at(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var ot=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,st=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ct=/^'([^]*?)'?$/,lt=/''/g,ut=/[a-zA-Z]/;function dt(e,t,n){let r=_(),i=n?.locale??r.locale??u,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=p(e,n?.in);if(!Ve(s))throw RangeError(`Invalid time value`);let c=t.match(st).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qe[t];return n(e,i.formatLong)}return e}).join(``).match(ot).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ft(e)};if(qe[t])return{isToken:!0,value:e};if(t.match(ut))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&rt(a)||!n?.useAdditionalDayOfYearTokens&&nt(a))&&it(a,t,String(e));let o=qe[a[0]];return o(s,a,i.localize,l)}).join(``)}function ft(e){let t=e.match(ct);return t?t[1].replace(lt,`'`):e}var W=e(n());function G(){return G=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},G.apply(null,arguments)}var pt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return k(n)&&k(r)&&k(i)?W.createElement(`circle`,G({},ve(e),xe(e),{className:o,cx:n,cy:r,r:i})):null},mt=[`points`];function ht(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ht(Object(n),!0).forEach(function(t){gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gt(e,t,n){return(t=_t(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _t(e){var t=vt(e,`string`);return typeof t==`symbol`?t:t+``}function vt(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(){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 yt(e,t){if(e==null)return{};var n,r,i=bt(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 bt(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 xt(e){var{option:n,dotProps:r,className:i}=e;if((0,W.isValidElement)(n))return(0,W.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=yt(o,mt);return W.createElement(pt,q({},c,{className:a}))}function St(e,t){return e==null?!1:t?!0:e.length===1}function Ct(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=E.scatter}=e;if(!St(t,n))return null;var u=F(n),d=be(n),f=t.map((e,r)=>{var s=K(K(K({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 W.createElement(xt,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),W.createElement(x,{zIndex:l},W.createElement(N,q({className:r},p),f))}function wt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wt(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(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 Ot=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=J(J(J({},{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}),fe(i)),xe(i)),c=(0,W.isValidElement)(i)?(0,W.cloneElement)(i,s):typeof i==`function`?i(s):W.createElement(pt,s);return W.createElement(N,{className:`recharts-active-dot`,clipPath:o},c)};function kt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=E.activeDot}=e,s=De(Se),c=Pe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return P(l)?null:W.createElement(x,{zIndex:o},W.createElement(Ot,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var At=(e,t,n,r)=>D(e,`xAxis`,t,r),jt=(e,t,n,r)=>te(e,`xAxis`,t,r),Mt=(e,t,n,r)=>D(e,`yAxis`,n,r),Nt=(e,t,n,r)=>te(e,`yAxis`,n,r),Pt=A([oe,At,Mt,jt,Nt],(e,t,n,r,i)=>b(e,`xAxis`)?le(t,r,!1):le(n,i,!1)),Ft=(e,t,n,r,i)=>i;function It(e){return e.type===`line`}var Lt=A([oe,At,Mt,jt,Nt,A([C,Ft],(e,t)=>e.filter(It).find(e=>e.id===t)),Pt,re],(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 cn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rt(e){var t=fe(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 zt=[`id`],Bt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Vt=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=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},Y.apply(null,arguments)}function Ht(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 X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ht(Object(n),!0).forEach(function(t){Ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ut(e,t,n){return(t=Wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wt(e){var t=Gt(e,`string`);return typeof t==`symbol`?t:t+``}function Gt(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 Z(e,t){if(e==null)return{};var n,r,i=Kt(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 Kt(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 qt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:ue(n,t),payload:e}]},Jt=W.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:ge,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ue(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return W.createElement(Fe,{tooltipEntrySettings:d})}),Q=(e,t)=>`${t}px ${e}px`;function Yt(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Xt=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Q(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[...Yt(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Zt(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ve(Z(r,zt));return W.createElement(Ct,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qt(e){var{showLabels:t,children:n,points:r}=e,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ae,{value:t?i:void 0},n)}function $t(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=X(X({},Te(Z(a,Bt))),{},{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 W.createElement(W.Fragment,null,r?.length>1&&W.createElement(ie,Y({shapeType:`curve`,option:u},d,{pathRef:n})),W.createElement(Zt,{points:r,clipPathId:t,props:a}))}function en(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function tn(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:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,W.useRef)(v),[b,x]=(0,W.useState)(!1),C=!b,w=(0,W.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),T=(0,W.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),E=en(r.current),D=(0,W.useRef)(0);y.current!==v&&(D.current=a.current,y.current=v);var O=D.current;return W.createElement(Qt,{points:o,showLabels:C},n.children,W.createElement(S,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=M(O,E+O,e),u=Math.min(l,E),d=c?s?Xt(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Q(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return X(X({},t),{},{x:M(i.x,t.x,e),y:M(i.y,t.y,e)})}return f?X(X({},t),{},{x:M(p*2,t.x,e),y:M(m/2,t.y,e)}):X(X({},t),{},{x:t.x,y:t.y})});return i.current=g,W.createElement($t,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return W.createElement($t,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),W.createElement(ee,{label:n.label}))}function nn(e){var{clipPathId:t,props:n}=e,r=(0,W.useRef)(null),i=(0,W.useRef)(0),a=(0,W.useRef)(null);return W.createElement(tn,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var rn=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:ne(e.payload,t)}),an=class extends W.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:p}=this.props;if(e)return null;var m=t(`recharts-line`,i),h=d,{r:g,strokeWidth:_}=Rt(n),v=F(n),y=g*2+_,b=f?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return W.createElement(x,{zIndex:p},W.createElement(N,{className:m},f&&W.createElement(`defs`,null,W.createElement(Oe,{clipPathId:h,xAxisId:a,yAxisId:o}),!v&&W.createElement(`clipPath`,{id:`clipPath-dots-${h}`},W.createElement(`rect`,{x:c-y/2,y:s-y/2,width:l+y,height:u+y}))),W.createElement(me,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:rn,errorBarOffset:0},W.createElement(nn,{props:this.props,clipPathId:h}))),W.createElement(kt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},on={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:E.line,type:`linear`};function sn(e){var t=je(e,on),{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=Z(t,Vt),{needClip:_}=Me(p,m),v=he(),y=se(),b=ke(),x=De(e=>Lt(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:ee,x:C,y:w}=v;return W.createElement(an,Y({},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:ee,left:C,top:w,needClip:_}))}function cn(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=ne(e,o);if(t===`horizontal`)return{x:ce({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(P(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=P(l)?null:n.scale.map(l),d=ce({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 ln(e){var t=je(e,on),n=ke();return W.createElement(_e,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(de,{legendPayload:qt(t)}),W.createElement(Jt,{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}),W.createElement(ye,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(sn,Y({},t,{id:e}))))}var un=W.memo(ln,w);un.displayName=`Line`;var dn=[`axis`],fn=(0,W.forwardRef)((e,t)=>W.createElement(Ee,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dn,tooltipPayloadSearcher:Ce,categoricalChartProps:e,ref:t})),$=h(),pn=[{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 mn({period:e,from:t,to:n,onChange:a}){let{t:o}=i(`analytics`);function s(e){e===`custom`?a(`custom`,t,n):a(e)}function c(e){a(`custom`,e,n)}function l(e){a(`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:pn.map(t=>(0,$.jsx)(`button`,{onClick:()=>s(t.value),className:r(`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:o(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=>c(e.target.value),"aria-label":o(`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:o(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":o(`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 hn({kpi:e}){let{t}=i(`analytics`),n=e.estimatedCostUsd??0,r=e.estimatedCostToday??0,a=e.includesEstimated??n>0,o=n>0,s=r>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:t(`desktop.totalCost`),value:`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:t(`desktop.costToday`,{value:`${s?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:o},{key:`totalJobs`,label:t(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:t(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:t(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:t(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:t(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${o?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:t(`desktop.periodAverage`),estimated:o&&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,$.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(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))}),a&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.includesEstimatedTooltip`,{amount:`$${n.toFixed(4)}`}),children:t(`desktop.includesEstimated`,{amount:`$${n.toFixed(4)}`})})]})}function gn({data:e}){let{t}=i(`analytics`),n=g(),r=e.length>0&&e.some(e=>e.costUsd>0),a=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%a===0).map(e=>e.date),s=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),c=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`)}),c&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(T,{width:`100%`,height:200,children:(0,$.jsxs)(fn,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return dt(new Date(e),`MMM d`,{locale:f()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(s.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)(un,{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 _n({projects:e}){let{t}=i(`analytics`),n=g();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;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,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[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 vn({projects:e}){let{t}=i(`analytics`),n=g();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));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`)}),(0,$.jsx)(T,{width:`100%`,height:180,children:(0,$.jsxs)(Ne,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(pe,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function yn(){let{t:e}=i(`analytics`),[t,n]=(0,W.useState)(`7d`),[r,a]=(0,W.useState)(``),[o,s]=(0,W.useState)(``),[c,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(null),{registerHandler:h,unregisterHandler:g}=l(),_=(0,W.useCallback)(e=>{let n=e;n.type===`log`&&n.event_type===`job_done`&&v(t,r,o)},[t,r,o]);(0,W.useEffect)(()=>(h(`desktop-analytics`,_),()=>g(`desktop-analytics`)),[_,h,g]);async function v(e,t,n){f(!0),m(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}`);u(await i.json())}catch(e){m(e.message)}finally{f(!1)}}(0,W.useEffect)(()=>{v(t,r,o)},[t,r,o]);function b(e,t,r){n(e),t!==void 0&&a(t),r!==void 0&&s(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)(Le,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),c&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:c.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(mn,{period:t,from:r,to:o,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>v(t,r,o),disabled:d,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)(y,{className:`w-3 h-3 ${d?`animate-spin`:``}`})})]})]}),p&&(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:p})}),d&&!c&&(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))})]}),c&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(hn,{kpi:c.kpi}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(gn,{data:c.costTimeline}),(0,$.jsx)(vn,{projects:c.projectBreakdown})]}),(0,$.jsx)(_n,{projects:c.projectBreakdown})]})]})})}export{yn as default};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-1dnHRn8W.js";import{$ as n,Cn as r,Kn as i,Rn as a,Sn as o,_ as s,_n as c,bn as l,cn as u,fn as d,gn as f,hn as p,mn as m,s as h,vn as g,vt as _,xn as v,yn as y}from"./index-CG4z4_Mq.js";import{$ as b,A as x,B as S,E as ee,F as C,H as w,K as T,L as E,N as D,O,P as te,Q as ne,R as re,S as ie,T as ae,U as oe,W as se,X as ce,Y as le,Z as ue,_ as de,_t as fe,a as pe,c as me,d as he,dt as k,et as A,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as j,it as xe,j as Se,k as Ce,l as we,lt as M,mt as Te,n as Ee,nt as De,o as Oe,pt as N,q as ke,r as Ae,rt as je,s as Me,t as Ne,u as Pe,ut as P,v as Fe,w as F,z as Ie}from"./BarChart-DZlxRF5i.js";var Le=u(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);function I(e,t){return p(e,{...t,weekStartsOn:1})}function L(e,t){let n=f(e,t?.in),r=n.getFullYear(),i=y(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=I(i),o=y(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=I(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function R(e,t){let n=f(e,t?.in);return n.setHours(0,0,0,0),n}function Re(e,t,n){let[r,i]=g(n?.in,e,t),a=R(r),o=R(i),c=+a-s(a),u=+o-s(o);return Math.round((c-u)/l)}function ze(e,t){let n=L(e,t),r=y(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),I(r)}function Be(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ve(e){return!(!Be(e)&&typeof e!=`number`||isNaN(+f(e)))}function He(e,t){let n=f(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ue(e,t){let n=f(e,t?.in);return Re(n,He(n))+1}function We(e,t){let n=f(e,t?.in),r=I(n)-+ze(n);return Math.round(r/v)+1}function z(e,t){let n=f(e,t?.in),r=n.getFullYear(),i=c(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=y(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=p(o,t),l=y(t?.in||e,0);l.setFullYear(r,0,a),l.setHours(0,0,0,0);let u=p(l,t);return+n>=+s?r+1:+n>=+u?r:r-1}function Ge(e,t){let n=c(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=z(e,t),a=y(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),p(a,t)}function Ke(e,t){let n=f(e,t?.in),r=p(n,t)-+Ge(n,t);return Math.round(r/v)+1}function B(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var V={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return B(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):B(n+1,2)},d(e,t){return B(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return B(e.getHours()%12||12,t.length)},H(e,t){return B(e.getHours(),t.length)},m(e,t){return B(e.getMinutes(),t.length)},s(e,t){return B(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return B(Math.trunc(r*10**(n-3)),t.length)}},H={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qe={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return V.y(e,t)},Y:function(e,t,n,r){let i=z(e,r),a=i>0?i:1-i;return t===`YY`?B(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):B(a,t.length)},R:function(e,t){return B(L(e),t.length)},u:function(e,t){return B(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return B(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return B(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return V.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return B(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Ke(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):B(i,t.length)},I:function(e,t,n){let r=We(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):B(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):V.d(e,t)},D:function(e,t,n){let r=Ue(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):B(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return B(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return B(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return B(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?H.noon:r===0?H.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?H.evening:r>=12?H.afternoon:r>=4?H.morning:H.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return V.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):V.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):V.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):V.s(e,t)},S:function(e,t){return V.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ye(r);case`XXXX`:case`XX`:return U(r);default:return U(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ye(r);case`xxxx`:case`xx`:return U(r);default:return U(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},t:function(e,t,n){return B(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return B(+e,t.length)}};function Je(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+B(a,2)}function Ye(e,t){return e%60==0?(e>0?`-`:`+`)+B(Math.abs(e)/60,2):U(e,t)}function U(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=B(Math.trunc(r/60),2),a=B(r%60,2);return n+i+t+a}var Xe=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Ze=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Qe={p:Ze,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Xe(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Xe(r,t)).replace(`{{time}}`,Ze(i,t))}},$e=/^D+$/,et=/^Y+$/,tt=[`D`,`DD`,`YY`,`YYYY`];function nt(e){return $e.test(e)}function rt(e){return et.test(e)}function it(e,t,n){let r=at(e,t,n);if(console.warn(r),tt.includes(e))throw RangeError(r)}function at(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var ot=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,st=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ct=/^'([^]*?)'?$/,lt=/''/g,ut=/[a-zA-Z]/;function dt(e,t,n){let r=c(),i=n?.locale??r.locale??m,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=f(e,n?.in);if(!Ve(s))throw RangeError(`Invalid time value`);let l=t.match(st).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qe[t];return n(e,i.formatLong)}return e}).join(``).match(ot).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ft(e)};if(qe[t])return{isToken:!0,value:e};if(t.match(ut))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(l=i.localize.preprocessor(s,l));let u={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return l.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&rt(a)||!n?.useAdditionalDayOfYearTokens&&nt(a))&&it(a,t,String(e));let o=qe[a[0]];return o(s,a,i.localize,u)}).join(``)}function ft(e){let t=e.match(ct);return t?t[1].replace(lt,`'`):e}var W=e(i());function G(){return G=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},G.apply(null,arguments)}var pt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return k(n)&&k(r)&&k(i)?W.createElement(`circle`,G({},ve(e),xe(e),{className:o,cx:n,cy:r,r:i})):null},mt=[`points`];function ht(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ht(Object(n),!0).forEach(function(t){gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gt(e,t,n){return(t=_t(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _t(e){var t=vt(e,`string`);return typeof t==`symbol`?t:t+``}function vt(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(){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 yt(e,t){if(e==null)return{};var n,r,i=bt(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 bt(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 xt(e){var{option:n,dotProps:r,className:i}=e;if((0,W.isValidElement)(n))return(0,W.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=yt(o,mt);return W.createElement(pt,q({},c,{className:a}))}function St(e,t){return e==null?!1:t?!0:e.length===1}function Ct(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=E.scatter}=e;if(!St(t,n))return null;var u=F(n),d=be(n),f=t.map((e,r)=>{var s=K(K(K({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 W.createElement(xt,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),W.createElement(x,{zIndex:l},W.createElement(N,q({className:r},p),f))}function wt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wt(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(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 Ot=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=J(J(J({},{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}),fe(i)),xe(i)),c=(0,W.isValidElement)(i)?(0,W.cloneElement)(i,s):typeof i==`function`?i(s):W.createElement(pt,s);return W.createElement(N,{className:`recharts-active-dot`,clipPath:o},c)};function kt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=E.activeDot}=e,s=De(Se),c=Pe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return P(l)?null:W.createElement(x,{zIndex:o},W.createElement(Ot,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var At=(e,t,n,r)=>D(e,`xAxis`,t,r),jt=(e,t,n,r)=>te(e,`xAxis`,t,r),Mt=(e,t,n,r)=>D(e,`yAxis`,n,r),Nt=(e,t,n,r)=>te(e,`yAxis`,n,r),Pt=A([oe,At,Mt,jt,Nt],(e,t,n,r,i)=>b(e,`xAxis`)?le(t,r,!1):le(n,i,!1)),Ft=(e,t,n,r,i)=>i;function It(e){return e.type===`line`}var Lt=A([oe,At,Mt,jt,Nt,A([C,Ft],(e,t)=>e.filter(It).find(e=>e.id===t)),Pt,re],(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 cn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rt(e){var t=fe(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 zt=[`id`],Bt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Vt=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=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},Y.apply(null,arguments)}function Ht(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 X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ht(Object(n),!0).forEach(function(t){Ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ut(e,t,n){return(t=Wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wt(e){var t=Gt(e,`string`);return typeof t==`symbol`?t:t+``}function Gt(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 Z(e,t){if(e==null)return{};var n,r,i=Kt(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 Kt(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 qt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:ue(n,t),payload:e}]},Jt=W.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:ge,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ue(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return W.createElement(Fe,{tooltipEntrySettings:d})}),Q=(e,t)=>`${t}px ${e}px`;function Yt(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Xt=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Q(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[...Yt(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Zt(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ve(Z(r,zt));return W.createElement(Ct,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qt(e){var{showLabels:t,children:n,points:r}=e,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ae,{value:t?i:void 0},n)}function $t(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=X(X({},Te(Z(a,Bt))),{},{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 W.createElement(W.Fragment,null,r?.length>1&&W.createElement(ie,Y({shapeType:`curve`,option:u},d,{pathRef:n})),W.createElement(Zt,{points:r,clipPathId:t,props:a}))}function en(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function tn(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:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,W.useRef)(v),[b,x]=(0,W.useState)(!1),C=!b,w=(0,W.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),T=(0,W.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),E=en(r.current),D=(0,W.useRef)(0);y.current!==v&&(D.current=a.current,y.current=v);var O=D.current;return W.createElement(Qt,{points:o,showLabels:C},n.children,W.createElement(S,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=M(O,E+O,e),u=Math.min(l,E),d=c?s?Xt(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Q(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return X(X({},t),{},{x:M(i.x,t.x,e),y:M(i.y,t.y,e)})}return f?X(X({},t),{},{x:M(p*2,t.x,e),y:M(m/2,t.y,e)}):X(X({},t),{},{x:t.x,y:t.y})});return i.current=g,W.createElement($t,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return W.createElement($t,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),W.createElement(ee,{label:n.label}))}function nn(e){var{clipPathId:t,props:n}=e,r=(0,W.useRef)(null),i=(0,W.useRef)(0),a=(0,W.useRef)(null);return W.createElement(tn,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var rn=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:ne(e.payload,t)}),an=class extends W.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:p}=this.props;if(e)return null;var m=t(`recharts-line`,i),h=d,{r:g,strokeWidth:_}=Rt(n),v=F(n),y=g*2+_,b=f?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return W.createElement(x,{zIndex:p},W.createElement(N,{className:m},f&&W.createElement(`defs`,null,W.createElement(Oe,{clipPathId:h,xAxisId:a,yAxisId:o}),!v&&W.createElement(`clipPath`,{id:`clipPath-dots-${h}`},W.createElement(`rect`,{x:c-y/2,y:s-y/2,width:l+y,height:u+y}))),W.createElement(me,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:rn,errorBarOffset:0},W.createElement(nn,{props:this.props,clipPathId:h}))),W.createElement(kt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},on={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:E.line,type:`linear`};function sn(e){var t=je(e,on),{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=Z(t,Vt),{needClip:_}=Me(p,m),v=he(),y=se(),b=ke(),x=De(e=>Lt(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:ee,x:C,y:w}=v;return W.createElement(an,Y({},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:ee,left:C,top:w,needClip:_}))}function cn(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=ne(e,o);if(t===`horizontal`)return{x:ce({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(P(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=P(l)?null:n.scale.map(l),d=ce({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 ln(e){var t=je(e,on),n=ke();return W.createElement(_e,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(de,{legendPayload:qt(t)}),W.createElement(Jt,{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}),W.createElement(ye,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(sn,Y({},t,{id:e}))))}var un=W.memo(ln,w);un.displayName=`Line`;var dn=[`axis`],fn=(0,W.forwardRef)((e,t)=>W.createElement(Ee,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dn,tooltipPayloadSearcher:Ce,categoricalChartProps:e,ref:t})),$=r(),pn=[{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 mn({period:e,from:t,to:r,onChange:i}){let{t:o}=a(`analytics`);function s(e){e===`custom`?i(`custom`,t,r):i(e)}function c(e){i(`custom`,e,r)}function l(e){i(`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:pn.map(t=>(0,$.jsx)(`button`,{onClick:()=>s(t.value),className:n(`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:o(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=>c(e.target.value),"aria-label":o(`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:o(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:r,onChange:e=>l(e.target.value),"aria-label":o(`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 hn({kpi:e}){let{t}=a(`analytics`),n=e.estimatedCostUsd??0,r=e.estimatedCostToday??0,i=e.includesEstimated??n>0,o=n>0,s=r>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:t(`desktop.totalCost`),value:`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:t(`desktop.costToday`,{value:`${s?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:o},{key:`totalJobs`,label:t(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:t(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:t(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:t(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:t(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${o?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:t(`desktop.periodAverage`),estimated:o&&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,$.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(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))}),i&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.includesEstimatedTooltip`,{amount:`$${n.toFixed(4)}`}),children:t(`desktop.includesEstimated`,{amount:`$${n.toFixed(4)}`})})]})}function gn({data:e}){let{t}=a(`analytics`),n=h(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%i===0).map(e=>e.date),s=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),c=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`)}),c&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(T,{width:`100%`,height:200,children:(0,$.jsxs)(fn,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return dt(new Date(e),`MMM d`,{locale:d()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(s.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)(un,{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 _n({projects:e}){let{t}=a(`analytics`),n=h();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;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,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[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 vn({projects:e}){let{t}=a(`analytics`),n=h();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));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`)}),(0,$.jsx)(T,{width:`100%`,height:180,children:(0,$.jsxs)(Ne,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(pe,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function yn(){let{t:e}=a(`analytics`),[t,n]=(0,W.useState)(`7d`),[r,i]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(null),[d,f]=(0,W.useState)(!0),[p,m]=(0,W.useState)(null),{registerHandler:h,unregisterHandler:g}=o(),v=(0,W.useCallback)(e=>{let n=e;n.type===`log`&&n.event_type===`job_done`&&y(t,r,s)},[t,r,s]);(0,W.useEffect)(()=>(h(`desktop-analytics`,v),()=>g(`desktop-analytics`)),[v,h,g]);async function y(e,t,n){f(!0),m(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}`);u(await i.json())}catch(e){m(e.message)}finally{f(!1)}}(0,W.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&i(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)(Le,{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`,children:[(0,$.jsx)(mn,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:d,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)(_,{className:`w-3 h-3 ${d?`animate-spin`:``}`})})]})]}),p&&(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:p})}),d&&!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)(hn,{kpi:l.kpi}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(gn,{data:l.costTimeline}),(0,$.jsx)(vn,{projects:l.projectBreakdown})]}),(0,$.jsx)(_n,{projects:l.projectBreakdown})]})]})})}export{yn as default};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{At as t,B as n,C as r,I as i,In as a,J as o,Kt as s,L as c,On as l,R as u,S as d,Ut as f,V as p,pn as m,yt as h}from"./index-BeujshsU.js";import{t as g}from"./lib-CfphudAm.js";import{t as _}from"./atom-one-dark-BrRN8wBy.js";var v=e(a(),1),y=m();function b({categories:e,activeCategory:n,activeSlug:r,onSelect:i,onHome:a}){let{t:c}=l(`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:a,className:o(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(s,{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(a=>{let s=n===e.slug&&r===a.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,a.slug),title:a.title,className:o(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,s?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function x({categories:e,onSelect:n}){let{t:r}=l(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=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:i===0?r(`docs.indexEmpty`):r(`docs.summary`,{documents:r(`docs.documentCount`,{count:i}),categories:r(`docs.categoryCount`,{count:a})})}),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:r(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(r=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>n(e.slug,r.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)(t,{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:r.title}),(0,y.jsx)(f,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},r.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(r,{remarkPlugins:[d],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:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=l(`integrations`),[s,c]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let i=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===f.current&&e&&(c(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!s&&!u?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(h,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):s?(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"./chunk-BNv3lrIs.js";import{$ as t,Cn as n,D as r,Dt as i,E as a,G as o,H as s,K as c,Kn as l,Qt as u,Rn as d,Rt as f,U as p,V as m,nn as h}from"./index-CG4z4_Mq.js";import{t as g}from"./lib-zJbG81CY.js";import{t as _}from"./atom-one-dark-BrRN8wBy.js";var v=e(l(),1),y=n();function b({categories:e,activeCategory:n,activeSlug:r,onSelect:i,onHome:a}){let{t:o}=d(`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:a,className:t(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`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:o(`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:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=n===e.slug&&r===a.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,a.slug),title:a.title,className:t(`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)(f,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:a.title})]})},a.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=d(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),i=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:r===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:r}),categories:n(`docs.categoryCount`,{count:i})})}),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)(f,{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)(u,{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)(r,{remarkPlugins:[a],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:r,onNavigate:a,scrollContainerRef:o}){let{t:s}=d(`integrations`),[c,l]=(0,v.useState)(null),[u,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let i=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===p.current&&e&&(l(e),o.current&&(o.current.scrollTop=0))}).catch(e=>{i===p.current&&f(e instanceof Error?e.message:s(`docs.loadError`))})},[e,t,n,r,o]),!c&&!u?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):c?(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
@@ -8,4 +8,4 @@ import{a as e}from"./chunk-BNv3lrIs.js";import{At as t,B as n,C as r,I as i,In a
8
8
  prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
9
  prose-hr:border-border
10
10
  prose-th:text-foreground prose-td:text-foreground/90
11
- prose-li:text-foreground/90`,children:(0,y.jsx)(S,{content:s.content,currentCategory:s.category,onNavigateDoc:i})})}):null}function w({open:e,onClose:t}){let{t:r,i18n:a}=l(`integrations`),o=a.language||`en`,[d,f]=(0,v.useState)(null),[m,g]=(0,v.useState)(!0),[_,S]=(0,v.useState)(),[w,T]=(0,v.useState)(),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(g(!0),fetch(`/api/docs?lang=${encodeURIComponent(o)}`).then(e=>e.json()).then(e=>f(e)).catch(()=>f({categories:[]})).finally(()=>g(!1)))},[e,o]);let D=(0,v.useCallback)((e,t)=>{S(e),T(t)},[]),O=(0,v.useCallback)(()=>{S(void 0),T(void 0)},[]),k=!!(_&&w);return(0,y.jsx)(i,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(c,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(n,{children:[(0,y.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{className:`w-4 h-4`}),r(`docs.title`)]}),(0,y.jsx)(u,{children:r(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[m?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(h,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:d?.categories??[],activeCategory:_,activeSlug:w,onSelect:D,onHome:O}),(0,y.jsx)(`main`,{ref:E,className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:k&&_&&w?(0,y.jsx)(C,{category:_,slug:w,lang:o,onNotFound:O,onNavigate:D,scrollContainerRef:E}):d&&(0,y.jsx)(x,{categories:d.categories,onSelect:D})})]})]})})}var T=(0,v.memo)(w);export{T as default};
11
+ prose-li:text-foreground/90`,children:(0,y.jsx)(S,{content:c.content,currentCategory:c.category,onNavigateDoc:a})})}):null}function w({open:e,onClose:t}){let{t:n,i18n:r}=d(`integrations`),a=r.language||`en`,[l,u]=(0,v.useState)(null),[f,g]=(0,v.useState)(!0),[_,S]=(0,v.useState)(),[w,T]=(0,v.useState)(),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(g(!0),fetch(`/api/docs?lang=${encodeURIComponent(a)}`).then(e=>e.json()).then(e=>u(e)).catch(()=>u({categories:[]})).finally(()=>g(!1)))},[e,a]);let D=(0,v.useCallback)((e,t)=>{S(e),T(t)},[]),O=(0,v.useCallback)(()=>{S(void 0),T(void 0)},[]),k=!!(_&&w);return(0,y.jsx)(m,{open:e,onOpenChange:e=>{e||t()},children:(0,y.jsxs)(s,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(o,{children:[(0,y.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,y.jsx)(h,{className:`w-4 h-4`}),n(`docs.title`)]}),(0,y.jsx)(p,{children:n(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[f?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:l?.categories??[],activeCategory:_,activeSlug:w,onSelect:D,onHome:O}),(0,y.jsx)(`main`,{ref:E,className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:k&&_&&w?(0,y.jsx)(C,{category:_,slug:w,lang:a,onNotFound:O,onNavigate:D,scrollContainerRef:E}):l&&(0,y.jsx)(x,{categories:l.categories,onSelect:D})})]})]})})}var T=(0,v.memo)(w);export{T as default};
@@ -0,0 +1,11 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,Cn as n,D as r,Dt as i,E as a,Hn as o,Kn as s,Qt as c,Rn as l,Rt as u,Un as d,Vn as f,nn as p}from"./index-CG4z4_Mq.js";import{t as m}from"./lib-zJbG81CY.js";import{t as h}from"./atom-one-dark-BrRN8wBy.js";var g=e(s(),1),_=n();function v({categories:e,activeCategory:n,activeSlug:r}){let{t:i}=l(`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)(f,{to:`/docs`,className:t(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`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:i(`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:i(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=n===e.slug&&r===i.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(f,{to:`/docs/${e.slug}/${i.slug}`,title:i.title,className:t(`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)(u,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:i.title})]})},i.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=l(`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)(f,{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)(u,{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)(c,{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)(r,{remarkPlugins:[a],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:r}){let{t:a}=l(`integrations`),[s,c]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=o();return(0,g.useEffect)(()=>{let i=++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=>{i===f.current&&e&&(c(e),r.current&&(r.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:a(`docs.loadError`))})},[e,t,n,p,r]),!s&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(i,{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
+ prose-headings:text-foreground prose-headings:font-bold
3
+ prose-p:text-foreground/90
4
+ prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
5
+ prose-strong:text-foreground
6
+ prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
7
+ prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
8
+ prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
+ prose-hr:border-border
10
+ prose-th:text-foreground prose-td:text-foreground/90
11
+ prose-li:text-foreground/90`,children:(0,_.jsx)(b,{content:s.content,currentCategory:s.category,onNavigateDoc:(e,t)=>p(`/docs/${e}/${t}`)})})}):null}function S(){let{category:e,slug:t}=d(),{i18n:n}=l(`integrations`),r=n.language||`en`,[a,o]=(0,g.useState)(null),[s,c]=(0,g.useState)(!0),u=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(r)}`).then(e=>e.json()).then(e=>o(e)).catch(()=>o({categories:[]})).finally(()=>c(!1))},[r]);let f=!!(e&&t);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[s?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(i,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,_.jsx)(v,{categories:a?.categories??[],activeCategory:e,activeSlug:t}),(0,_.jsx)(`main`,{ref:u,className:`flex-1 overflow-y-auto`,children:f&&e&&t?(0,_.jsx)(x,{category:e,slug:t,lang:r,scrollContainerRef:u}):a&&(0,_.jsx)(y,{categories:a.categories})})]})}export{S as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{Dn as t,Ft as n,In as r,On as i,pn as a}from"./index-BeujshsU.js";var o=e(r(),1),s=a(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:r,label:a,disabled:u}){let{t:d}=i(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(t=>`${e}?${new URLSearchParams({format:t.format,mode:t.mode,...r}).toString()}`,[e,r]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),t.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(n,{className:`w-3 h-3`}),m?d(`export.downloading`):a??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(n,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{Cn as t,Kn as n,Ln as r,Rn as i,Ut as a}from"./index-CG4z4_Mq.js";var o=e(n(),1),s=t(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:n,disabled:u}){let{t:d}=i(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),r.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):n??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
@@ -0,0 +1,3 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{B as t,Bn as n,Cn as r,Dt as i,G as a,H as o,J as s,Jt as c,K as l,Kn as u,Ln as d,Q as f,Rn as p,Sn as m,Ut as h,V as g,Yt as _,at as v,dn as y,i as b,it as x,ln as S,q as C,un as w,wn as T,xt as E,yt as D,z as O}from"./index-CG4z4_Mq.js";var k=e(u(),1),A=r(),j=[`todo`,`in_progress`,`done`,`cancelled`],M={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function N({state:e,onChanged:t}){let{t:n}=p(`jira`),r=e.connection,[i,a]=(0,k.useState)(r.enabled),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(!1),[u,m]=(0,k.useState)([]),[h,g]=(0,k.useState)([]),[_,v]=(0,k.useState)(r.discardStatus??``),[y,b]=(0,k.useState)(r.statusMap??{}),x=e.outbox??{pending:0,inflight:0,done:0,dead:0},S=(0,k.useCallback)(async()=>{try{let{ops:e}=await O.listOutbox(`dead`);m(e)}catch{m([])}},[]);(0,k.useEffect)(()=>{S()},[S]),(0,k.useEffect)(()=>{let e=!1;return O.listStatuses().then(({statuses:t})=>{e||g(t)}).catch(()=>{e||g([])}),()=>{e=!0}},[]);async function C(e){let r=_;v(e);try{await O.patchConnection({discardStatus:e||null}),t()}catch(e){v(r),d.error(F(e,n))}}async function w(e,r){let i=y,a={...y,[e]:r||void 0};b(a);let o=Object.fromEntries(Object.entries(a).filter(([,e])=>e));try{await O.patchConnection({statusMap:Object.keys(o).length?o:null}),t()}catch(e){b(i),d.error(F(e,n))}}async function T(){let e=!i;a(e),l(!0);try{await O.setEnabled(e)}catch(t){a(!e),d.error(F(t,n))}finally{l(!1)}}async function E(){s(!0);try{let e=await O.syncNow();d.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){d.error(F(e,n))}finally{s(!1)}}async function D(){if(window.confirm(n(`status.disconnectConfirm`))){l(!0);try{await O.disconnect(),d.success(n(`status.disconnectedToast`)),t()}catch(e){d.error(F(e,n))}finally{l(!1)}}}async function N(e){try{await O.retryOutbox(e),await S()}catch(e){d.error(F(e,n))}}let I=x.pending+x.inflight;return(0,A.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:r.jiraProjectKey})}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r.baseUrl,` · `,r.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,A.jsx)(`a`,{href:`${r.baseUrl}/browse/${r.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,A.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(i?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,A.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":i,"aria-label":n(`status.enabledLabel`),disabled:c,onClick:T,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${i?`bg-accent-success`:`bg-input`}`,children:(0,A.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${i?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,A.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,A.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${M[e]}`)}),(0,A.jsxs)(`select`,{value:y[e]??``,onChange:t=>void w(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,A.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!h.some(t=>t.name===y[e])&&(0,A.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,A.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,A.jsxs)(`select`,{value:_,onChange:e=>void C(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,A.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),h.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.id)),_&&!h.some(e=>e.name===_)&&(0,A.jsx)(`option`,{value:_,children:_})]})]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:E,disabled:o,children:n(o?`status.syncing`:`status.syncNow`)}),(0,A.jsx)(f,{variant:`ghost`,size:`sm`,onClick:D,disabled:c,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,A.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,A.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),x.dead>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:x.dead})}):I>0?(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,A.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),u.length>0&&(0,A.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),u.map(e=>(0,A.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,A.jsxs)(`span`,{className:`truncate text-xs`,children:[P(e,n),` · `,e.deadReason??e.lastError??``]}),(0,A.jsx)(f,{variant:`outline`,size:`sm`,onClick:()=>N(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function P(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function F(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function I({activeProjectId:e}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(null),[s,c]=(0,k.useState)(!0),[u,d]=(0,k.useState)(!1),[f,m]=(0,k.useState)(!1),h=(0,k.useCallback)(async()=>{try{i(await O.getConnection())}catch{i({connected:!1})}finally{c(!1)}},[]);if((0,k.useEffect)(()=>{!t||!e||(c(!0),h())},[e,h]),!t)return null;let v=!!(r?.connected&&r.connection);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,A.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,A.jsx)(E,{className:`w-4 h-4`})}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`jiraCard.title`)}),v&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,A.jsx)(_,{className:`w-3 h-3`}),` `,n(`jiraCard.connected`)]})]}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`jiraCard.category`)})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:v&&r?.connection?n(`jiraCard.connectedDescription`,{key:r.connection.jiraProjectKey}):n(`jiraCard.description`)}),(0,A.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,A.jsx)(`li`,{children:n(`jiraCard.bullet1`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet2`)}),(0,A.jsx)(`li`,{children:n(`jiraCard.bullet3`)})]}),(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:n(`jiraCard.requires`)}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:s?(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):v?(0,A.jsx)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:n(`jiraCard.manage`)}):(0,A.jsxs)(`button`,{type:`button`,onClick:()=>d(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,A.jsx)(E,{className:`w-3.5 h-3.5`}),n(`jiraCard.connect`)]})}),(0,A.jsx)(g,{open:u,onOpenChange:d,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.modalTitle`)})}),(0,A.jsx)(b,{onConnected:()=>{d(!1),h()},onSkip:()=>d(!1)})]})}),(0,A.jsx)(g,{open:f,onOpenChange:m,children:(0,A.jsxs)(o,{className:`max-w-lg`,children:[(0,A.jsx)(a,{children:(0,A.jsx)(l,{children:n(`jiraCard.manageTitle`)})}),r?.connected&&r.connection&&(0,A.jsx)(N,{state:r,onChanged:()=>{h().then(()=>m(!1))}})]})})]})}function L(){let{t:e}=p(`integrations`),{activeProjectId:n,projects:r}=w(),i=r.find(e=>e.id===n),a=i?S(i).includes(`claude`):!0,{registerHandler:o,unregisterHandler:s}=m(),c=(0,k.useRef)(n);(0,k.useEffect)(()=>{c.current=n},[n]);let[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)(null),{data:h,isLoading:g,isFirstLoad:_,refresh:v}=y({namespace:`plugins`,projectId:n,initialValue:[],fetcher:(0,k.useCallback)(async()=>{let e=await fetch(`${T()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,k.useEffect)(()=>(o(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==c.current||t.type.startsWith(`plugin.`)&&v())}),()=>s(`integrations-page`)),[o,s,v]),(0,k.useEffect)(()=>{u(!g&&!h?`Failed to load plugins`:null)},[g,h]);let b=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status!==`orphan`),[h]),C=(0,k.useMemo)(()=>(h??[]).filter(e=>e.status===`orphan`),[h]);return n?(0,A.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,A.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,A.jsx)(D,{className:`w-4 h-4 text-accent-primary`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,A.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:_&&g?(0,A.jsx)(q,{}):l&&a?(0,A.jsx)(J,{onRetry:v}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,A.jsx)(I,{activeProjectId:n}),a&&b.map(e=>(0,A.jsx)(R,{plugin:e,isInstalling:d===e.name,onInstall:()=>f(e.name),onCloseInstall:()=>{f(null),v()}},e.name))]}),a&&C.length>0&&(0,A.jsxs)(`div`,{className:`mt-10`,children:[(0,A.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:C.map(e=>(0,A.jsx)(U,{plugin:e,onRemoved:v},e.name))})]}),!t&&(!a||b.length===0)&&(0,A.jsx)(Y,{})]})})]}):(0,A.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function R({plugin:e,isInstalling:t,onInstall:r,onCloseInstall:i}){let{t:a}=p(`integrations`),[o,s]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,A.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,A.jsx)(_,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,A.jsx)(c,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,A.jsx)(x,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,A.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,A.jsx)(h,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,A.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,A.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,A.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,A.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,A.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,A.jsx)(n,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,A.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,A.jsx)(H,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,A.jsx)(B,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,A.jsx)(V,{pluginName:e.name}),(0,A.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,A.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(z,{pluginName:e.name,active:e.status===`installed`}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(v,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,A.jsx)(W,{pluginName:e.name,onClose:i}),o&&(0,A.jsx)(G,{pluginName:e.name,onClose:()=>s(!1),onUninstalled:()=>{s(!1)}})]})}function z({pluginName:e,active:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1),[a,o]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${T()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){o(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,A.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,A.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,A.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function B({keys:e}){let{t}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,A.jsx)(`strong`,{}),code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,A.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,A.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function V({pluginName:e}){let{t}=p(`integrations`),[r,a]=(0,k.useState)(!1),[o,s]=(0,k.useState)(null);return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(h,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t,i18nKey:`update.body`,components:{code:(0,A.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{a(!0),s(null);try{let t=await fetch(`${T()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[r&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t,i18nKey:`update.button`,components:{code:(0,A.jsx)(`code`,{})}})]}),o&&(0,A.jsx)(`div`,{className:`text-destructive text-[10px]`,children:o})]})}function H({pluginName:e,conflicts:t}){let{t:r}=p(`integrations`),[a,o]=(0,k.useState)(null),[s,c]=(0,k.useState)(null),l=async e=>{o(e),c(null);try{let t=await fetch(`${T()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){c(e.message)}finally{o(null)}};return(0,A.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,A.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,A.jsx)(x,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:(0,A.jsx)(n,{t:r,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,A.jsx)(`strong`,{})}})})]}),(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,A.jsxs)(`button`,{type:`button`,disabled:a===e,onClick:()=>l(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[a===e&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),(0,A.jsx)(n,{t:r,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,A.jsx)(`code`,{})}})]},e))}),s&&(0,A.jsx)(`div`,{className:`text-destructive`,children:s})]})}function U({plugin:e,onRemoved:t}){let{t:n}=p(`integrations`),[r,i]=(0,k.useState)(!1);return(0,A.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,A.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,A.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,A.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${T()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,A.jsx)(v,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function W({pluginName:e,onClose:t}){let{t:n}=p(`integrations`),[r,a]=(0,k.useState)(null),[o,s]=(0,k.useState)(null),[l,u]=(0,k.useState)(!1),[d,f]=(0,k.useState)(null),[g,v]=(0,k.useState)([]),[y,b]=(0,k.useState)(null),[S,C]=(0,k.useState)([]),{registerHandler:w,unregisterHandler:E}=m(),D=(0,k.useCallback)(()=>{a(null),s(null),fetch(`${T()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>a(e)).catch(e=>s(e.message))},[e]);(0,k.useEffect)(()=>{D()},[D]),(0,k.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&v(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&C(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&C(t=>[...t,`► ${e}`]),n.ok&&D()}}),()=>E(`install-${e}`)),[e,w,E,D]);let O=async e=>{b(e),C([n(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${T()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){C(t=>[...t,n(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(r?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,A.jsxs)(K,{onClose:t,title:n(`installDialog.title`,{name:e}),children:[o&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),!r&&!o&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),` `,n(`installDialog.computingChanges`)]}),r&&(0,A.jsxs)(A.Fragment,{children:[r.platformNote&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,A.jsx)(x,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,A.jsx)(`span`,{children:r.platformNote})]}),(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.filesHeading`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:r.files.map((e,t)=>(0,A.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),r.requirements.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.prerequisites`)}),(0,A.jsx)(`ul`,{className:`text-xs space-y-1`,children:r.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,r=e.name===`uv`;return(0,A.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,A.jsx)(_,{className:`w-3 h-3 text-accent-success`}):(0,A.jsx)(c,{className:`w-3 h-3 text-accent-warning`}),(0,A.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,A.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&r&&(0,A.jsxs)(`button`,{type:`button`,disabled:y===e.name,onClick:()=>O(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[y===e.name&&(0,A.jsx)(i,{className:`w-2.5 h-2.5 animate-spin`}),n(`installDialog.autoInstall`)]})]},e.name)})}),S.length>0&&(0,A.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:S.join(`
2
+ `)})]}),g.length>0&&(0,A.jsxs)(`section`,{children:[(0,A.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:n(`installDialog.progress`)}),(0,A.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:g.join(`
3
+ `)})]}),d&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:d})]}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:n(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:!r||!j||l,onClick:async()=>{u(!0),f(null);try{let n=await fetch(`${T()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){f(e.message)}finally{u(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[l?(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}):(0,A.jsx)(h,{className:`w-3 h-3`}),n(`card.install`)]})]})]})}function G({pluginName:e,onClose:t,onUninstalled:r}){let{t:a}=p(`integrations`),[o,s]=(0,k.useState)(!1),[c,l]=(0,k.useState)(null);return(0,A.jsxs)(K,{onClose:t,title:a(`uninstallDialog.title`,{name:e}),children:[(0,A.jsx)(`p`,{className:`text-xs`,children:(0,A.jsx)(n,{t:a,i18nKey:`uninstallDialog.body`,components:{code:(0,A.jsx)(`code`,{})}})}),c&&(0,A.jsx)(`div`,{className:`text-xs text-destructive`,children:c}),(0,A.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,A.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:a(`common:actions.cancel`)}),(0,A.jsxs)(`button`,{type:`button`,disabled:o,onClick:async()=>{s(!0);try{let t=await fetch(`${T()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);r()}catch(e){l(e.message)}finally{s(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[o&&(0,A.jsx)(i,{className:`w-3 h-3 animate-spin`}),a(`card.uninstall`)]})]})]})}function K({title:e,onClose:t,children:n}){let{panelRef:r,panelStyle:i,headerHandleProps:a,resizeHandles:o,isFloating:c,guardBackdrop:l}=s();return(0,A.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:l(t),children:[(0,A.jsxs)(`div`,{ref:r,className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),style:i,children:[(0,A.jsx)(`h3`,{className:`text-sm font-semibold ${c?`cursor-grab active:cursor-grabbing`:``}`,...a,children:e}),n]}),(0,A.jsx)(C,{handles:o})]})}function q(){return(0,A.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,A.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function J({onRetry:e}){let{t}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,A.jsx)(x,{className:`w-5 h-5 text-destructive`}),(0,A.jsx)(`p`,{children:t(`page.loadError`)}),(0,A.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function Y(){let{t:e}=p(`integrations`);return(0,A.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,A.jsx)(D,{className:`w-6 h-6`}),(0,A.jsx)(`p`,{children:e(`page.empty`)})]})}export{L as default};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$t as n,At as r,Cn as i,Dt as a,F as o,Gt as s,Hn as c,I as l,Jt as ee,Kn as u,Ln as d,Q as f,Qt as p,R as m,Rn as h,Sn as te,Un as ne,Ut as g,Vn as _,Yt as re,Z as v,Zt as y,_t as b,fn as x,g as ie,h as S,pt as ae,un as C,v as w,wn as T,y as E}from"./index-CG4z4_Mq.js";import{t as D}from"./format-command-BHymDa4r.js";import{n as O,t as k}from"./LogViewer-Cz7jzyU2.js";var A=e(u(),1),j=i();function M(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function N(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var P={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function F(e,t){if(t.type===`reset`)return P;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=E(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function oe({job:e,events:r,defaultOpen:i=!0,pipelineTotals:o,phases:s,phaseDefinitions:c}){let{t:l}=h(`jobs`),[u,d]=(0,A.useState)(i),f=(0,A.useMemo)(()=>N(r),[r]),p=e.status===`running`,m=e.status===`completed`,[te,ne]=(0,A.useState)(()=>Date.now());(0,A.useEffect)(()=>{if(!p)return;let e=window.setInterval(()=>ne(Date.now()),1e3);return()=>window.clearInterval(e)},[p]);let[g,_]=(0,A.useReducer)(F,P),v=(0,A.useRef)(e.id);(0,A.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:r})},[e.id,r]);let[y,b]=(0,A.useState)(!0);(0,A.useEffect)(()=>{if(!p)return;b(!0);let e=window.setTimeout(()=>b(!1),8e3);return()=>window.clearTimeout(e)},[p,e.id]);let x=e.finished_at?M(e.started_at,e.finished_at):p?M(e.started_at,te):`—`,ie=!!e.total_cost_usd_estimated,S=e.total_cost_usd==null?null:`${ie?`~`:``}$${e.total_cost_usd.toFixed(4)}`,ae=e.num_turns==null?null:String(e.num_turns),C=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),T=C==null?null:`${(C/1e3).toFixed(1)}k`,E=(0,A.useMemo)(()=>!s||!c?null:c.find(e=>s[e.key]===`running`)?.label??null,[s,c]),D=p&&g.steps===0?`connecting`:g.actionKey||`thinking`,O=w.has(D)&&g.actionArg!==``,k=w.has(D)&&!O?`working`:D,oe=O?l(`statusPanel.activity.${k}`,{arg:g.actionArg}):l(`statusPanel.activity.${k}`),z=E??(p&&g.steps===0?l(`statusPanel.activity.starting`):null),B=g.steps>0?l(`statusPanel.steps`,{count:g.steps}):null,V=l(p?`statusPanel.inProgress`:m?`statusPanel.completed`:`statusPanel.failed`),H=p?`border-accent-info/20 bg-accent-info/5`:m?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,U=p?a:m?re:ee,se=p?`w-4 h-4 text-accent-info shrink-0 animate-spin`:m?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,j.jsxs)(`div`,{className:t(`mx-4 my-2 rounded-xl border transition-colors duration-500`,H),children:[(0,j.jsxs)(`button`,{type:`button`,onClick:()=>d(!u),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,j.jsx)(U,{className:se,"aria-hidden":`true`}),(0,j.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:V}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`tabular-nums`,children:x}),p?B&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:B}):(0,j.jsxs)(j.Fragment,{children:[S&&(0,j.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:S}),f.length>0&&(0,j.jsx)(`span`,{children:l(`statusPanel.filesCount`,{count:f.length})})]})]}),(0,j.jsx)(n,{className:t(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,u&&`rotate-180`)})]}),u&&(0,j.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:p?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneInProgress`)}),(0,j.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[l(`statusPanel.duration`),(0,j.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:l(`statusPanel.liveTooltip`),"aria-label":l(`statusPanel.liveTooltip`)})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:x})]}),(0,j.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,j.jsx)(a,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),z&&(0,j.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:z}),(0,j.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:oe}),B&&(0,j.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,B]})]})]}),y&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:l(`statusPanel.explainer`)}),(0,j.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:l(`statusPanel.zoneFinalPending`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,j.jsx)(R,{label:l(`statusPanel.cost`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.costTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.turns`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)}),(0,j.jsx)(R,{label:l(`statusPanel.tokens`),caption:l(`statusPanel.pendingCaption`),tooltip:l(`statusPanel.pendingTooltip`)})]})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:l(`statusPanel.zoneFinal`)}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.duration`),value:x}),(0,j.jsx)(L,{label:l(`statusPanel.cost`),value:S,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.turns`),value:ae,naCaption:l(`statusPanel.notAvailable`)}),(0,j.jsx)(L,{label:l(`statusPanel.tokens`),value:T,naCaption:l(`statusPanel.notAvailable`)})]}),o&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.pipelineTotal`,{count:o.jobCount})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,j.jsx)(I,{label:l(`statusPanel.totalCost`),value:`$${o.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,j.jsx)(I,{label:l(`statusPanel.totalTokens`),value:`${((o.totalTokensIn+o.totalTokensOut+o.totalTokensCacheRead+o.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]})]}),f.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:l(`statusPanel.filesModified`)}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,j.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function I({label:e,value:n,valueClass:r}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,r),children:n})]})}function L({label:e,value:n,valueClass:r,naCaption:i}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,j.jsx)(`p`,{className:t(`text-sm font-semibold tabular-nums mt-0.5`,n==null?`text-muted-foreground`:r),children:n??`—`}),n==null&&(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:i})]})}function R({label:e,caption:t,tooltip:n}){return(0,j.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,j.jsx)(s,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var z=4;function B({tickets:e,onTicketClick:t}){let{t:r}=h(`jobs`),[i,a]=(0,A.useState)(!1);if(e.length===0)return null;let o=e.length>=z&&!i?e.slice(0,1):e,s=e.length-o.length;return(0,j.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[o.map(e=>(0,j.jsx)(V,{ticket:e,onClick:()=>t(e.id)},e.id)),s>0&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showMore`,{count:s}),(0,j.jsx)(n,{className:`w-3 h-3`})]}),i&&e.length>=z&&(0,j.jsxs)(`button`,{type:`button`,onClick:()=>a(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[r(`ticketHeader.showLess`),(0,j.jsx)(y,{className:`w-3 h-3`})]})]})}function V({ticket:e,onClick:n}){let{t:r}=h(`jobs`),i=e.title==null,a=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return i?(0,j.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,j.jsx)(`span`,{className:t(a,`text-muted-foreground bg-muted/20 select-none`),title:r(`ticketHeader.deletedTooltip`),children:r(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,j.jsxs)(`button`,{type:`button`,onClick:n,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,j.jsxs)(`span`,{className:t(a,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,j.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var H={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function U(){let{t:e}=h(`jobs`),{id:n}=ne(),{activeProjectId:i,projects:s}=C(),ee=s.find(e=>e.id===i)?.provider,u=c(),{openTicketDetail:y}=S(),[w,E]=(0,A.useState)(null),[M,N]=(0,A.useState)([]),[P,F]=(0,A.useState)([]),[I,L]=(0,A.useState)({}),[R,z]=(0,A.useState)([]),[V,U]=(0,A.useState)(!0),[se,W]=(0,A.useState)(!1),[G,ce]=(0,A.useState)(null),[le,K]=(0,A.useState)(!1),[q,ue]=(0,A.useState)(``),[J,Y]=(0,A.useState)(!1),[de,fe]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(!n)return;let e=new AbortController;E(null),N([]),F([]),L({}),U(!0),W(!1);async function t(){try{let t=await fetch(`${T()}/jobs/${n}`,{signal:e.signal});if(t.status===404){W(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();E(r.job),N(r.events)}catch(e){if(e.name===`AbortError`)return;W(!0)}finally{e.signal.aborted||U(!1)}}return t(),()=>e.abort()},[n,i]),(0,A.useEffect)(()=>{if(!w?.pipeline_id){z([]);return}let e=w.pipeline_id;fetch(`${T()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&z(e.jobs)}).catch(()=>{})},[w?.pipeline_id,w?.status]);let X=(0,A.useRef)(i);X.current=i;let Z=(0,A.useRef)([]),Q=(0,A.useRef)(null),pe=(0,A.useCallback)(()=>{Q.current=null;let e=Z.current;e.length!==0&&(Z.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),me=(0,A.useCallback)(e=>{let t=Z.current;t.push(e),t.length>1e4&&(Z.current=t.slice(-8e3)),Q.current||=requestAnimationFrame(pe)},[pe]);(0,A.useEffect)(()=>()=>{Q.current&&cancelAnimationFrame(Q.current)},[]);let he=(0,A.useCallback)(e=>{let t=e;if(!(X.current&&t.projectId&&t.projectId!==X.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];F(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;L(n)}else if(t.type===`event`&&t.jobId===n)me({id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===n)me({id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.turn_user`&&t.jobId===n)K(!0);else if(t.type===`job.turn_done`&&t.jobId===n)ce(t.totals),K(!1);else if(t.type===`job.finalized`&&t.jobId===n){K(!1),Y(!1);let e=t.totals;e&&ce(e),fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}else if(t.type===`phase`){let e=t.phase,n=t.state;L(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status;E(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`)&&fetch(`${T()}/jobs/${n}`).then(e=>e.json()).then(e=>E(e.job)).catch(()=>{})}}}},[n,me]),{registerHandler:ge,unregisterHandler:_e}=te();(0,A.useEffect)(()=>(ge(`job-detail-${n}`,he),()=>_e(`job-detail-${n}`)),[n,he,ge,_e]),(0,A.useEffect)(()=>{if(!n||!w||w.status!==`running`||w.hasTelemetry)return;let e=setInterval(()=>{fetch(`${T()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&E(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,w?.status,w?.hasTelemetry]);async function ve(){if(n)try{let t=await fetch(`${T()}/jobs/${n}`,{method:`DELETE`});if(t.ok)(await t.json()).status===`deleted`?(d.success(e(`detail.toast.jobDeleted`)),u(`/jobs`)):d.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)});else{let n=await t.json();d.error(e(`detail.toast.failed`),{description:n.error})}}catch{d.error(e(`detail.toast.networkError`))}}async function ye(){if(!(!n||J)){Y(!0);try{let t=await fetch(`${T()}/jobs/${n}/finalize`,{method:`POST`});if(t.ok)d.success(e(`detail.toast.finalizeScheduled`));else{let n=await t.json().catch(()=>({}));d.error(e(`detail.toast.finalizeFailed`),{description:n.error}),Y(!1)}}catch{d.error(e(`detail.toast.networkError`)),Y(!1)}}}async function be(){let t=q.trim();if(!(!n||!t||de)){fe(!0);try{let r=await fetch(`${T()}/jobs/${n}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(r.ok)ue(``);else{let t=await r.json().catch(()=>({}));d.error(e(`detail.toast.sendFailed`),{description:t.error})}}catch{d.error(e(`detail.toast.networkError`))}finally{fe(!1)}}}async function xe(){if(w)try{let t=await fetch(`${T()}/jobs/${w.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${w.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){d.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Se(){if(w)try{let t=await fetch(`${T()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:w.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));d.success(e(`detail.toast.jobRequeued`)),u(`/jobs/${n.jobId}`)}catch(e){d.error(e.message)}}if(V)return(0,j.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,j.jsxs)(`div`,{className:`space-y-3`,children:[(0,j.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,j.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,j.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(se||!w)return(0,j.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,j.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,j.jsx)(f,{asChild:!0,variant:`outline`,size:`sm`,children:(0,j.jsxs)(_,{to:`/`,children:[(0,j.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=H[w.status]??H.queued,Ce=w.status===`running`,we=w.status===`completed`||w.status===`failed`,Te=!!w.interactive,Ee=Te&&Ce,De=(w.tickets?.length??0)>0,Oe=R.length>1?{totalCostUsd:R.reduce((e,t)=>e+(t.total_cost_usd??0),0),totalTokensIn:R.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:R.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:R.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:R.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:R.length}:null;return(0,j.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,j.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,j.jsxs)(_,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,j.jsx)(r,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,j.jsx)(p,{className:`w-3 h-3`}),(0,j.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),De&&(0,j.jsx)(B,{tickets:w.tickets??[],onTicketClick:y}),(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(`div`,{children:(0,j.jsx)(v,{variant:$.variant,children:e($.labelKey)})})}),(0,j.jsx)(l,{children:e($.tooltipKey)})]}),(0,j.jsx)(`code`,{className:t(`font-mono text-foreground/90 truncate`,De?`text-xs text-muted-foreground`:`text-sm`),children:D(w.command,ee)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,j.jsx)(`span`,{children:w.started_at?e(`detail.startedAgo`,{timeAgo:ie(new Date(w.started_at),{addSuffix:!0,locale:x()})}):e(`detail.queuedWaiting`)}),w.model&&(0,j.jsx)(`span`,{className:`text-muted-foreground/40`,children:w.model})]})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[w.hasTelemetry&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,className:`h-7`,onClick:xe,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,j.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,j.jsx)(l,{children:e(`detail.exportDiagnosticTooltip`)})]}),we&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:Se,className:`h-7`,children:[(0,j.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,j.jsx)(l,{children:e(`detail.reExecuteTooltip`)})]}),Ee&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsxs)(f,{variant:`outline`,size:`sm`,onClick:ye,disabled:J,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,j.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(J?`detail.finalizing`:`detail.finalizeJob`)]})}),(0,j.jsx)(l,{children:e(`detail.finalizeJobTooltip`)})]}),Ce&&(0,j.jsxs)(o,{children:[(0,j.jsx)(m,{asChild:!0,children:(0,j.jsx)(f,{variant:`outline`,size:`sm`,onClick:ve,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Te?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,j.jsx)(l,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,j.jsx)(O,{phases:I,phaseDefinitions:P})]}),(w.status===`running`||w.status===`completed`||w.status===`failed`)&&(0,j.jsx)(oe,{job:w,events:M,defaultOpen:w.status===`completed`||w.status===`running`,pipelineTotals:Oe??void 0,phases:I,phaseDefinitions:P}),(0,j.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,j.jsx)(k,{events:M})}),Ee&&(0,j.jsxs)(`div`,{className:`shrink-0 border-t border-border/40 bg-surface/40 px-3 py-2 space-y-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[le&&(0,j.jsx)(a,{className:`w-3 h-3 animate-spin`}),e(le?`detail.interactive.working`:`detail.interactive.ready`)]}),G&&(0,j.jsx)(`span`,{className:`tabular-nums`,children:e(`detail.interactive.liveTotals`,{turns:G.num_turns,cost:G.total_cost_usd.toFixed(4)})})]}),(0,j.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,j.jsx)(`textarea`,{value:q,onChange:e=>ue(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),be())},rows:2,placeholder:e(`detail.interactive.placeholder`),"aria-label":e(`detail.interactive.placeholder`),className:`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-ring`}),(0,j.jsxs)(f,{size:`sm`,onClick:()=>void be(),disabled:de||!q.trim(),className:`h-9 shrink-0`,children:[(0,j.jsx)(ae,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.interactive.send`)]})]})]})]})}export{U as default};